注射参数

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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")
--param-filter=P.. Select testable parameter(s) by place (e.g. "POST")
--dbms=DBMS Force back-end DBMS to provided value
--dbms-cred=DBMS.. DBMS authentication credentials (user:password)
--os=OS Force back-end DBMS operating system to provided 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"要扫描的变量"

排除指定的扫描参数

参数--skip

1
--level=5 --skip="要指定的头"     应为要>5才能扫描其他的参数

指定数据库类型

参数--dbms

1
2
3
4
5
6
7
8
9
10
11
12
--dbms="要指定的数据库名" 
下面是数据库名<里面可以添加数据库版本的>
• MySQL <5.0>
• Oracle <11i>
• Microsoft SQL Server <2005>
• PostgreSQL
• Microsoft Access
• SQLite
• Firebird
• Sybase
• SAP MaxDB
• DB2

指定系统

参数--os

1
--os="linux或者是windows"

设置取值失效

sqlmap默认通常 sqlmap 使用负值使参数取值失效。 id=13,使其失效: id=-13

  1. 使用大数使参数值失效
    --invalid-bignum 使用大数使参数值失效。id=13,使其失效:id= 999999999
1
--invalid-bignum 
  1. 使用布尔判断取值使其失效
    --invalid-logical 使用布尔判断取值使其失效id=13。id=13,使其失效:AND 18=19
    1
    --invalid-logical

    –no-cast

    榨取数据时,sqlmap 将所有结果转换为字符串,并用空格替换 NULL 结果
    老版本 mysql 数据库需要开启此开关

    关闭逃避

    默认出于混淆和避免出错的目的,在 payload 中用单引号界定字符串时,sqlmap 默认使用 char() 编码逃逸的方法替换字符串,躲避检查
1
正常发送SELECT 'foo' 编码后发送SELECT CHAR(102)+CHAR(111)+CHAR(111)

要是这样的目标可能无法识别所以可以关闭这个参数--no-escape

1
--no-escape

插入前缀和后缀

正常情况下发送$query = "SELECT * FROM users WHERE id=(’" . $_GET[’id’] . "’) LIMIT 0, 1";
终端输入扫描>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’) <PAYLOAD> AND (’abc’=’abc’) LIMIT 0, 1";

参数

1
--prefix "要插入前缀的内容"  --suffix"要插入后缀的内容"

绕过安全机制想 WAF , IPS 等等等

sqlmap是没有混淆来绕过安全防护的 所以目标网站就会吧sqlmap扫描过滤掉
sqlmap作者就单独开发了一个参数编写了许多脚本来绕过过滤
参数

1
--tamper="绕过的脚步"

参看脚本命令dpkg -L sqlmap | grep tamper
在这里插入图片描述

侦测参数

1
2
3
4
5
6
7
8
9
10
11
12
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
--smart Perform thorough tests only if positive heuristic(s)
--text-only Compare pages based only on the textual content
--titles Compare pages based only on their titles

设置扫描等级

1
--levl="要扫描的等级1-5" 

级别探测语句在/usr/share/sqlmap/data/xml/payloads目录下

设置扫描风险级别

扫描目标网站是有风险的应为可能会叫目标网站扫描挂掉

1
--risk="要扫描的等级1-4"

Risk升高可造成数据被篡改等风险(update)

参数--string, --not-string, --regexp, --code, --text-only, --titles

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

技巧参数

1
2
3
4
5
6
7
8
9
10
11
12
Techniques:
These options can be used to tweak testing of specific SQL injection
techniques

--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-url=SEC.. Resulting page URL searched for second-order response
--second-req=SEC.. Load second-order HTTP request from file

扫描技术

  • 默认sqlmap都会使用
  • B: Boolean-based blind
  • E: Error-based
  • U: Union query-based
  • s: Stacked queries (检查文件系统、操作系统、注册表必须使用的)
  • T: Time-based blind

基于时间的注入检测

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

1
--time-sec

联合查询

默认联合查询1-10列,随 –level 增加最多支持50列

也可以指定查询第几列

1
–union-cols 6-9			这个是只查询6到9列

2.2联合查询默认使用 NULL
联合查询默认使用 NULL, 极端情况下 NULL 可能失败,此时可以手动指定数值

1
--union-char 123			就不是NULL了就是123了

攻击者控制了某DNS服务器情况下

攻击者控制了某DNS服务器,使用此功能可以提高数据榨取的速度

1
--dns-domain "DNS服务器" 

另外页面出现结果

有特殊的注入一个页面,结果在另外一个页面出现来sqlmap进行判断可以用下面这个参数 --second-order

1
-u "要注入的地址"   --second-order "结果出现的地址"