4.任務096:SQLMAP自動注入-INHECTION、DETECTION、TECHNIQUES、FINGERPRINT

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"要掃描的變量"
    
  2. 排除指定的掃描參數
    參數--skip

     --level=5 --skip="要指定的頭"     應爲要>5才能掃描其他的參數
    
  3. 指定數據庫類型
    參數--dbms

    --dbms="要指定的數據庫名" 
    下面是數據庫名<裏面可以添加數據庫版本的>
    • MySQL <5.0>
    • Oracle <11i>
    • Microsoft SQL Server <2005>
    • PostgreSQL
    • Microsoft Access
    • SQLite
    • Firebird
    • Sybase
    • SAP MaxDB
    • DB2
    
  4. 指定系統
    參數--os

    --os="linux或者是windows"
    
  5. 設置取值失效
    sqlmap默認通常 sqlmap 使用負值使參數取值失效。 id=13,使其失效: id=-13

    1. 使用大數使參數值失效
      --invalid-bignum 使用大數使參數值失效。id=13,使其失效:id= 999999999

      	--invalid-bignum 
      
    2. 使用布爾判斷取值使其失效
      --invalid-logical 使用布爾判斷取值使其失效id=13。id=13,使其失效:AND 18=19

      --invalid-logical
      
  6. –no-cast
    榨取數據時,sqlmap 將所有結果轉換爲字符串,並用空格替換 NULL 結果
    老版本 mysql 數據庫需要開啓此開關

  7. 關閉逃避
    默認出於混淆和避免出錯的目的,在 payload 中用單引號界定字符串時,sqlmap 默認使用 char() 編碼逃逸的方法替換字符串,躲避檢查

    正常發送SELECT 'foo' 編碼後發送SELECT CHAR(102)+CHAR(111)+CHAR(111)
    

    要是這樣的目標可能無法識別所以可以關閉這個參數--no-escape

    --no-escape
    
  8. 插入前綴和後綴
    正常情況下發送$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";

    參數

    --prefix "要插入前綴的內容"  --suffix"要插入後綴的內容"
    
  9. 繞過安全機制想 WAF , IPS 等等等
    sqlmap是沒有混淆來繞過安全防護的 所以目標網站就會吧sqlmap掃描過濾掉
    sqlmap作者就單獨開發了一個參數編寫了許多腳本來繞過過濾
    參數

    --tamper="繞過的腳步"
    

    參看腳本命令dpkg -L sqlmap | grep tamper
    在這裏插入圖片描述

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目錄下

  2. 設置掃描風險級別
    掃描目標網站是有風險的應爲可能會叫目標網站掃描掛掉

    --risk="要掃描的等級1-4"
    

    Risk升高可造成數據被篡改等風險(update)

  3. 參數--string, --not-string, --regexp, --code, --text-only, --titles

    頁面比較,基於布爾的注入檢測,依據返回頁面內容的變化判斷真假邏輯但有些頁面隨時間閾值變化,此時需要人爲指定標識真假的字符串

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
  1. 基於時間的注入檢測
    基於時間的注入檢測相應延遲時間(默認5秒)

    --time-sec
    
  2. 聯合查詢
    2.1默認聯合查詢1-10列,隨 –level 增加最多支持50列
    也可以指定查詢第幾列

    –union-cols 6-9			這個是隻查詢69

    2.2聯合查詢默認使用 NULL
    聯合查詢默認使用 NULL, 極端情況下 NULL 可能失敗,此時可以手動指定數值

    --union-char 123			就不是NULL了就是123
  3. 攻擊者控制了某DNS服務器情況下
    攻擊者控制了某DNS服務器,使用此功能可以提高數據榨取的速度

    --dns-domain "DNS服務器" 
    
  4. 另外頁面出現結果
    有特殊的注入一個頁面,結果在另外一個頁面出現來sqlmap進行判斷可以用下面這個參數 --second-order

    -u "要注入的地址"   --second-order "結果出現的地址"
    

作者QQ2737977997

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章