Web Security Lecture 4 - sqlmap Performance Optimization & sqlmap injection parameters & sqlmap injection technique parameters

A, sqlmap performance optimization

1.1 sqlmap disposed persistent HTTP connections (connecting length)

sqlmap may be provided connected to a persistent connection. HTTP packets set connection: keep-alive

Command Line:
python sqlmap.py -u "http://127.0.0.1/sqli/Less-1/?id=1" --keep-alive --banner
Here Insert Picture Description

1.2 sqlmap arranged not to receive HTTP Body

参数 --null-connection
sqlmap中设置空连接,表示不接受HTTP当中的Body。 可以直接获得HTTP响应的大小而不用获得HTTP响应体,常用在盲注过程中

Here Insert Picture Description

1.3 sqlmap set multithreading

参数 --thread
sqlmap中设置同时发送多少个HTTP请求的多线程

One-click optimization

-o add this parameter is equivalent to the same time add the following three parameters optimization

  • –keep-alive
  • –null-connection
  • –threads=3

Two, sqlmap custom detection parameters

2.1 sqlmap set detection level: --level

  • This parameter is used to specify a detection level of 1 to 5 there were five. The default is 1, do denotes a minimum detected, corresponding, class 5 represents the most do detecting
python sqlmap.py -u "http://127.0.0.1/sqli/Less-1/?id=1" --banner --level 2 -v 5

2.2 sqlmap set the level of risk: -risk

  • This parameter is used to specify the level of risk, there are 1 to 3 of 3. The default risk level 1, level harmless to test this target in most cases.
  • Risk Level 2 adds time based on the injection test, grade 3 adds OR test.

Three, sqlmap specified position injection

3.1 sqlmap settings specify implant parameters

  • Sqlmap tests all GET parameters and POST parameters By default , when the levelGreater than or equal 2 will test the cookieParameters,
    when the test will be greater than or equal level User-Agent Referer 3 and when . In fact you can also manually specify a comma-delimited,
    Referer is jump, anti-climb the
    list of parameters to be tested, the list parameter is not level restrictions. This is the "-p" role
  • If you do not want to test some parameters you can use the --skip .

3.2 Sqlmap injection position disposed URI

  • 当注入点位于URI本身内部时,会出现一些特殊情况。除非手动指向URI路径,否则sqlmap不会对URI路径

  • 执行任何自动测试。必须在命令行中添加星号(*)来指定这些注入点。

     python sqlmap.py -u "http://127.0.0.1/sqli/Less-1/?id=1*&us=1&uname=admin" --banner
    

四、sqlmap注入参数

4.1 sqlmap强制设置DBMS

默认情况下sqlmap会自动识别探测目标web应用程序的后端数据库管理系统(DBMS),sqlmap支持 的DBMS种类

  • MySQL
  • Oracle
  • PostgreSQL
  • Microsoft SQL Server
  • Microsoft Access
  • Firebird
  • SQLite
  • Sybase
  • SAP MaxDB
  • DB2

	可以指定数据库来进行探测
	参数 --dbms 数据库类型
	python sqlmap.py -u "http://127.0.0.1/sqli/Less-1/?id=1" --dbms mysql --banner

4.2 sqlmap强制设置OS系统

默认情况下sqlmap会自动探测目标web应用程序的后端操作系统,sqlmap完全支持的OS种类Linux、 Windows

参数 --os 系统类型
python sqlmap.py -u "http://127.0.0.1/sqli/Less-1/?id=1" --dbms mysql --os linux --banner

4.3 Sqlmap强制设置无效值替换

参数:–invalid-bignum

在sqlmap需要使原始参数值无效(例如id=13)时,它使用经典的否定(例如id=-13)。

有了这个参数,就可以强制使用大整数值来实现相同的目标(例如id=99999999)。

python sqlmap.py -u "http://127.0.0.1/sqli/Less-1/?id=1" --invalid-bignum --banner

参数:–invalid-logical

有了这个参数,就可以强制使用布尔操作来实现相同的目标(例如id=13 and18=19)。

参数:–invalid-string

有了这个参数,就可以强制使用随机字符串来实现相同的目标(例如id=akewmc)。

五、Sqlmap自定义注入负载位置

在某些情况下,只有当用户提供要附加到注入负载的特定后缀时,易受攻击的参数才可被利用。当用户已经知道查询语法并希望通过直接提供注入有效负载前缀和后缀来检测和利用SQL注入时,这些选项就派上用场了。

  • –prefix 设置SQL注入Payload前缀

  • –suffix 设置SQL注入Payload后缀

     $query = "SELECT * FROM users WHERE id=('.$_GET['id'].') LIMIT 0, 1";
     
     .$_GET['id'].  ==>  ')AND ('abc'='abc
     
     python sqlmap.py -u "http://ip/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";
    

六、Sqlmap设置Tamper脚本

sqlmap本身不会混淆发送的有效负载,除了单引号之间的字符串被CHAR()类似的表示形式所取代之外。sqlmap通过Tamper脚本来绕过WAF等防御措施,可以在tamper文件夹下找到所有sqlmap自带的tamper脚本。

python sqlmap.py -u "http://ip/sqlmap/mysql/get_int.php?id=1" --tamper "between.py,randomcase.py,space2comment.py" -v 3

七、Sqlmap设置DBMS认证

设置DBMS认证方式通过以下命令:

--dbms-cred = username:password

python sqlmap.py -u "http://127.0.0.1/sqli/Less-3/?id=1" --dbms-cred = "root:root" --banner

八、sqlmap注入技术参数

8.1 sqlmap设置具体SQL注入技术

参数 --technique

此参数用于指定检测注入时所用技术。默认情况下Sqlmap会使用自己支持的全部技术进行 检测。 此参数后跟表示检测技术的大写字母,其值为B、E、U、S、T或Q,含义如下:

  • B:Boolean-based blind(布尔型注入)
  • E:Error-based(报错型注入)
  • U:Union query-based(可联合查询注入)
  • S:Stacked queries(可多语句查询注入)
  • T:Time-based blind(基于时间延迟注入)
  • Q:Inline queries(嵌套查询注入)

–technique ES指定使用两种检测技术。
“–technique BEUSTQ”与默认情况等效。

8.2 sqlmap设置时间盲注延迟时间

参数:–time-sec

用此参数设置基于时间延迟注入中延时时长,默认为5秒

8.3 sqlmap设置union字段数

  • 在进行联合查询注入时,Sqlmap会自动检测列数,范围是1到10。当level值较高时列数检测范 围的上限会扩大到50。

  • 可以用此参数指定列数检测范围,如==–union-cols 12-16==就会让Sqlmap的列数检测范围变成 12到16。

     python sqlmap.py -u "http://127.0.0.1/sqli/Less-3/?id=1" --technique U --current-db -v 3 --union-cols 12-18
    

8.4 sqlmap character set union

Parameters: -union-char

Use null character (NULL) when Sqlmap be injected into the joint inquiry by default. But higher level value Sqlmap generates a random number for queries joint injection . Because sometimes injected into an empty character fails while using a random number will be successful .

python sqlmap.py -u "http://127.0.0.1/sqli/Less-3/?id=1" --technique U --current-db -v 3 --union-cols 12-18 --union-char 123

8.5 sqlmap set union lookup table

Parameters: -union-from

In some cases you must specify a valid table name and can be accessed in a union query, or query execution failed joint

8.6 sqlmap fingerprint recognition

Probe target fingerprint information: Parameters -f or -fingerprint
with -banner almost

Published 45 original articles · won praise 4 · Views 1279

Guess you like

Origin blog.csdn.net/Yauger/article/details/104303697