sqlmap使用教程 一

244 阅读4分钟

本文已参与「新人创作礼」活动,一起开启掘金创作之路。 参考:www.freebuf.com/sectool/164…

一、参数

1. Options(选项)

-h --help -hh 显示帮助信息

--version 显示版本

-v +int (0-6 default 1)

0”只显示python错误以及严重的信息;
"1"同时显示基本信息和警告信息(默认);
“2”同时显示debug信息;
“3”同时显示注入的payload;
“4”同时显示HTTP请求;
“5”同时显示HTTP响应头;
“6”同时显示HTTP响应页面;
如果想看到sqlmap发送的测试payload最好的等级就是3。
eg:sqlmap -v 3 

2. Target(目标)

-u URL , --url=URL  目标url eg:http://www.site.com/vuln.php?id=1
-d DIRECT           直接连接数据库的连接字符串
-l LOGFILE          从Burp或者WebScarab代理日志文件中分析目标
-m BULKFILE         将目标地址保存在文件中,一行为一个URL地址进行批量检测。
-r REQUESTFILE      从文件加载HTTP请求,sqlmap可以从一个文本文件中获取HTTP请求,这样就可以跳过设置一些其他参数(比如cookie,POST数据,等等),请求是HTTPS的时需要配合这个--force-ssl参数来使用,或者可以在Host头后门加上:443
-g GOOGLEDORK       从谷歌中加载结果目标URL(只获取前100个结果,需要挂代理)
-c CONFIGFILE       从配置ini文件中加载选项

3. Request(请求)

-A AGENT, --user..  自定义User-Agent
--user-agent=AGENT  默认情况下sqlmap的HTTP请求头中User-Agent值是:sqlmap/1.0-dev-xxxxxxx(http://sqlmap.org)可以使用--user-agent参数来修改,同时也可以使用--random-agent参数来随机的从./txt/user-agents.txt中获取。当--level参数设定为3或者3以上的时候,会尝试对User-Angent进行注入-H HEADER, --hea..  Extra header (e.g. "X-Forwarded-For: 127.0.0.1")
--headers=HEADERS   Extra headers (e.g. "Accept-Language: fr\nETag: 123")--method=METHOD     强制使用给定的HTTP方法(例如put)
--data=DATA         通过POST发送数据参数 e.g. "id=1"
--param-del=PARA..  当GET或POST的数据需要用其他字符分割测试参数的时候需要用到此参数。(e.g. &)
--cookie=COOKIE     HTTP Cookie header value (e.g. "PHPSESSID=a8d127e..")
--cookie-del=COO..  用来分隔cookie的字符串值 (e.g. ;)
--live-cookies=L..  用于加载最新值的实时 cookie 文件
--load-cookies=L.   加载包含 Netscape/wget 格式的 cookie 的文件
--drop-set-cookie   Ignore Set-Cookie header from response
--mobile            Imitate smartphone through HTTP User-Agent header
--random-agent      Use randomly selected HTTP User-Agent header value
--host=HOST         HTTP Host header value
--referer=REFERER   HTTP Referer header value 当--level参数设定为3或者3以上的时候会尝试对referer注入
​
​
--auth-type=AUTH..  HTTP authentication type (Basic, Digest, Bearer, ...)
--auth-cred=AUTH..  HTTP authentication credentials (name:password)
--auth-file=AUTH..  HTTP authentication PEM cert/private key file
--ignore-code=IG..  Ignore (problematic) HTTP error code (e.g. 401)
--ignore-proxy      Ignore system default proxy settings
--ignore-redirects  Ignore redirection attempts 忽略重定向的尝试
--ignore-timeouts   Ignore connection timeouts
--proxy=PROXY       Use a proxy to connect to the target URL
--proxy-cred=PRO..  Proxy authentication credentials (name:password)
--proxy-file=PRO..  Load proxy list from a file
--proxy-freq=PRO..  Requests between change of proxy from a given list
--tor               Use Tor anonymity network
--tor-port=TORPORT  Set Tor proxy port other than default
--tor-type=TORTYPE  Set Tor proxy type (HTTP, SOCKS4 or SOCKS5 (default))
--check-tor         Check to see if Tor is used properly
--delay=DELAY       Delay in seconds between each HTTP request
--timeout=TIMEOUT   Seconds to wait before timeout connection (default 30)
--retries=RETRIES   Retries when the connection timeouts (default 3) 当HTTP(S)超时时,可以设定重新尝试连接次数,默认是3次。
--retry-on=RETRYON  Retry request on regexp matching content (e.g. "drop") 对正则表达式匹配内容的重试请求
--randomize=RPARAM  Randomly change value for given parameter(s) 可以设定某一个参数值在每一次请求中随机的变化,长度和类型会与提供的初始值一样
--safe-url=SAFEURL  URL address to visit frequently during testing
--safe-post=SAFE..  POST data to send to a safe URL
--safe-req=SAFER..  Load safe HTTP request from a file
--safe-freq=SAFE..  Regular requests between visits to a safe URL
--skip-urlencode    Skip URL encoding of payload data
--csrf-token=CSR..  Parameter used to hold anti-CSRF token
--csrf-url=CSRFURL  URL address to visit for extraction of anti-CSRF token
--csrf-method=CS..  HTTP method to use during anti-CSRF token page visit
--csrf-retries=C..  Retries for anti-CSRF token retrieval (default 0)
--force-ssl         Force usage of SSL/HTTPS
--chunked           Use HTTP chunked transfer encoded (POST) requests 使用 HTTP 分块传输编码 (POST) 请求
--hpp               Use HTTP parameter pollution method 使用 HTTP 参数污染方法
--eval=EVALCODE     Evaluate provided Python code before the request (e.g."import hashlib;id2=hashlib.md5(id).hexdigest()") 在有些时候,需要根据某个参数的变化,而修改另个一参数,才能形成正常的请求,这时可以用--eval参数在每次请求时根据所写python代码做完修改后请求。eg: sqlmap.py -u"http://www.target.com/vuln.php?id=1&hash=c4ca4238a0b923820dcc509a6f75849b"--eval="import hashlib;hash=hashlib.md5(id).hexdigest()"