api1 演示密文{"decoded":"https://www.52pojie.cn/"}
api1 第1种,上传api.php到网站的根目录,之后分页或多页运用插件后https://你的网址/api.php?url=Base64加密
api1 第2种,使用本地服务http://localhost/api.php?url=eyJkZWNvZGVkIjoiaHR0cHM6Ly93d3cuNTJwb2ppZS5jbi8ifQ==
api2 要修改api代码,把正则表达式放到源码中,使用http://localhost/api.php?url=Base64加密的网址
<?php
//研究人员:呱呱生
//编程:AI
?>
<?php
// 检查是否通过 GET 请求传递了 'url' 参数
if (isset($_GET['url'])) {
// 获取编码后的字符串
$url = $_GET['url'];
// 对 Base64 编码的字符串进行解码
$decoded = base64_decode($url);
if ($decoded === false) {
// 若解码失败,返回错误信息
http_response_code(400);
echo json_encode(['error' => 'Invalid Base64 encoding']);
} else {
// 若解码成功,返回解码后的字符串
echo json_encode(['decoded' => $decoded]);
}
} else {
// 若未传递 'url' 参数,返回错误信息
http_response_code(400);
echo json_encode(['error' => 'Missing "url" parameter']);
}
?>
<?php
//研究人员:呱呱生
//编程:AI
//注意:要修改
//通过正则表达式获取源码中的加密Base64,查看源码,获取
?>
<?php
// 检查是否通过 GET 请求传递了 'url' 参数
if (isset($_GET['url'])) {
$url = $_GET['url'];
// 初始化 cURL 会话
$ch = curl_init();
// 设置 cURL 选项
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // 不验证 SSL 证书,生产环境需调整
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); // 不验证 SSL 主机,生产环境需调整
// 执行 cURL 请求
$response = curl_exec($ch);
// 检查 cURL 请求是否有错误
if (curl_errno($ch)) {
http_response_code(500);
header('Content-Type: application/json');
echo json_encode([
'status' => 'error',
'message' => 'Failed to fetch the URL: '. curl_error($ch)
]);
curl_close($ch);
exit;
}
// 关闭 cURL 会话
curl_close($ch);
// 查找 'hls': ' 的起始位置
$startPos = strpos($response, '通过正则表达式获取源码中的加密Base64');
if ($startPos === false) {
http_response_code(400);
header('Content-Type: application/json');
echo json_encode([
'status' => 'error',
'message' => 'Could not find 通过正则表达式获取源码中的加密Base64 in the fetched content.'
]);
exit;
}
$startPos += strlen('通过正则表达式获取源码中的加密Base64');
// 查找下一个 ' 的位置
$endPos = strpos($response, '\'', $startPos);
if ($endPos === false) {
http_response_code(400);
header('Content-Type: application/json');
echo json_encode([
'status' => 'error',
'message' => 'Could not find the end quote for the \'hls\' value.'
]);
exit;
}
// 提取从 'hls': ' 到下一个 ' 之间的内容
$encodedContent = substr($response, $startPos, $endPos - $startPos);
// 对提取的内容进行 Base64 解码
$decoded = base64_decode($encodedContent, true);
// 检查解码是否成功
if ($decoded === false) {
http_response_code(400);
header('Content-Type: application/json');
echo json_encode([
'status' => 'error',
'message' => 'The extracted content is not a valid Base64 string.'
]);
} else {
http_response_code(200);
header('Content-Type: application/json');
echo json_encode([
'status' => 'success',
'decoded_content' => $decoded
]);
}
} else {
http_response_code(400);
header('Content-Type: application/json');
echo json_encode([
'status' => 'error',
'message' => 'Missing "url" parameter in the request.'
]);
}
?>