第五課:工具介紹-Sqlmap
專注APT攻擊與防御
https://micropoor.blogspot.com/

由于Sqlmap 是常用工具之一,所以本篇的篇幅較長,詳解一次所有參數(shù)。
sqlmap參數(shù)詳解:
Usage: python sqlmap.py [options]

Options(選項):

-h, --help Show basic help message and exit 展示幫助文檔 參數(shù)
-hh Show advanced help message and exit 展示詳細幫助文檔 參數(shù)
--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 指定具體數(shù)據(jù)庫
-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的結(jié)果作為目標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發(fā)送的數(shù)據(jù)字符串
--param-del=PARA.. Character used for splitting parameter values 用于拆分參數(shù)值的字符
--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 從響應(yīng)中忽略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: frnETag: 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 使用代理連
接到目標網(wǎng)址
--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 忽略系統(tǒng)默認代理設(shè)置
--tor Use Tor anonymity network 使用Tor匿名網(wǎng)絡(luò)
--tor-port=TORPORT Set Tor proxy port other than default 設(shè)置Tor代
理端口而不是默認值
--tor-type=TORTYPE Set Tor proxy type (HTTP (default), SOCKS4 or SOCKS5) 設(shè)置
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) 隨機更改給定參數(shù)的值(s)
--safe-url=SAFEURL URL address to visit frequently during testing 在測試期間頻繁訪問的URL地址
--safe-post=SAFE.. POST data to send to a safe URL POST數(shù)據(jù)發(fā)送到安全URL
--safe-req=SAFER.. Load safe HTTP request from a file 從文件加載安全HTTP請求

--safe-freq=SAFE.. Test requests between two visits to a given safe URL 在兩次訪問給定安全網(wǎng)址之間測試請求
--skip-urlencode Skip URL encoding of payload data 跳過有效載荷數(shù)據(jù)的URL編碼
--csrf-token=CSR.. Parameter used to hold anti-CSRF token 參數(shù)用于保存anti-CSRF令牌

--csrf-url=CSRFURL URL address to visit to extract anti-CSRF token 提取anti-CSRF URL地址訪問令牌

--force-ssl Force usage of SSL/HTTPS 強制使用SSL /HTTPS
--hpp Use HTTP parameter pollution method 使用HTTP參數(shù)pollution的方法
--eval=EVALCODE Evaluate provided Python code before the request (e.g. 評估請求之前提供Python代碼

"import hashlib;id2=hashlib.md5(id).hexdigest()")

Optimization(優(yōu)化):

These options can be used to optimize the performance of sqlmap 這些選項可用于優(yōu)化sqlmap的性能

-o Turn on all optimization switches 開啟所有優(yōu)化開關(guān)
--predict-output Predict common queries output 預(yù)測常見的查詢輸出
--keep-alive Use persistent HTTP(s) connections 使用持久的HTTP(S)連接
--null-connection Retrieve page length without actual HTTP response body 從
沒有實際的HTTP響應(yīng)體中檢索頁面長度
--threads=THREADS Max number of concurrent HTTP(s) requests (default 1)
最大的HTTP(S)請求并發(fā)量(默認為1)

Injection(注入):

These options can be used to specify which parameters to test for,
provide custom injection payloads and optional tampering scripts

這些選項可以用來指定測試哪些參數(shù), 提供自定義的注入payloads和可選篡改腳本。

-p TESTPARAMETER Testable parameter(s) 可測試的參數(shù)
(S)
--skip=SKIP Skip testing for given parameter(s) 跳過對給定參數(shù)的測試
--skip-static Skip testing parameters that not appear to be dynamic 跳過測試不顯示為動態(tài)的參數(shù)
--param-exclude=.. Regexp to exclude parameters from testing (e.g. "ses") 使用正則表達式排除參數(shù)進行測試(e.g. "ses")
--dbms=DBMS Force back-end DBMS to this value 強制后端的DBMS為此值
--dbms-cred=DBMS.. DBMS authentication credentials (user:password)
DBMS認證憑證(user:password)
--os=OS Force back-end DBMS operating system to this value 強制
后端的DBMS操作系統(tǒng)為這個值
--invalid-bignum Use big numbers for invalidating values 使用大數(shù)字使值無效
--invalid-logical Use logical operations for invalidating values 使用邏輯操作使值無效
--invalid-string Use random strings for invalidating values 使用隨機字符串使值無效
--no-cast Turn off payload casting mechanism 關(guān)閉有效載荷鑄造機制
--no-escape Turn off string escaping mechanism 關(guān)閉字符串轉(zhuǎn)義機制
--prefix=PREFIX Injection payload prefix string 注入payload字符串前綴
--suffix=SUFFIX Injection payload suffix string 注入payload字符串后綴
--tamper=TAMPER Use given script(s) for tampering injection data 使用給定的腳本(S)篡改注入數(shù)據(jù)

Detection(檢測):

These options can be used to customize the detection phase 這些選項可以用來指定在SQL盲注時如何解析和比較HTTP響應(yīng)頁面的內(nèi)容。

--level=LEVEL Level of tests to perform (1-5, default 1) 執(zhí)行測試的等級
(1-5,默認為1)
--risk=RISK Risk of tests to perform (1-3, default 1) 執(zhí)行測試的風險
(0-3,默認為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 當查詢求值為True時匹配的HTTP代碼
--text-only Compare pages based only on the textual content 僅基于在文本內(nèi)容比較網(wǎng)頁
--titles Compare pages based only on their titles 僅根據(jù)他們的標題進行比較

Techniques(技巧):

These options can be used to tweak testing of specific SQL injection
techniques
這些選項可用于調(diào)整具體的SQL注入測試。

--technique=TECH SQL injection techniques to use (default "BEUSTQ") SQL
注入技術(shù)測試(默認BEUST)
--time-sec=TIMESEC Seconds to delay the DBMS response (default 5)
DBMS響應(yīng)的延遲時間(默認為5秒)
--union-cols=UCOLS Range of columns to test for UNION query SQL injection
定列范圍用于測試UNION查詢注入
--union-char=UCHAR Character to use for bruteforcing number of columns 用于暴力猜解列數(shù)的字符

--union-from=UFROM Table to use in FROM part of UNION query SQL injection
要在UNION查詢SQL注入的FROM部分使用的表
--dns-domain=DNS.. Domain name used for DNS exfiltration attack 域名用于DNS漏出攻擊
--second-order=S.. Resulting page URL searched for second-order response 生成頁面的URL搜索為second-order響應(yīng)

Fingerprint(指紋):

-f, --fingerprint Perform an extensive DBMS version fingerprint 執(zhí)行檢查廣
泛的DBMS版本指紋

Enumeration(枚舉):

These options can be used to enumerate the back-end database
management system information, structure and data contained in the
tables. Moreover you can run your own SQL statements
這些選項可以用來列舉后端數(shù)據(jù)庫管理系統(tǒng)的信息、表中的結(jié)構(gòu)和數(shù)據(jù)。此外,您還可以運行您自己的SQL語句。

-a, --all Retrieve everything 檢索一切
-b, --banner Retrieve DBMS banner 檢索數(shù)據(jù)庫管理系統(tǒng)的標
--current-user Retrieve DBMS current user 檢索數(shù)據(jù)庫管理系統(tǒng)的標識
--current-db Retrieve DBMS current database 檢索數(shù)據(jù)庫管理系統(tǒng)當前數(shù)據(jù)庫
--hostname Retrieve DBMS server hostname 檢索數(shù)據(jù)庫服務(wù)器的主機名
--is-dba Detect if the DBMS current user is DBA 檢測DBMS當前用戶是否DBA
--users Enumerate DBMS users 枚舉數(shù)據(jù)庫管理系統(tǒng)用戶
--passwords Enumerate DBMS users password hashes 枚舉數(shù)據(jù)庫管理
系統(tǒng)用戶密碼哈希

--privileges Enumerate DBMS users privileges 枚舉數(shù)據(jù)庫管理系統(tǒng)用戶的權(quán)限
--roles Enumerate DBMS users roles 枚舉數(shù)據(jù)庫管理系統(tǒng)用戶的角色
--dbs Enumerate DBMS databases 枚舉數(shù)據(jù)庫管理系統(tǒng)數(shù)據(jù)庫
--tables Enumerate DBMS database tables 枚舉的DBMS數(shù)據(jù)庫中的表
--columns Enumerate DBMS database table columns 枚舉DBMS數(shù)據(jù)庫表列
--schema Enumerate DBMS schema 枚舉數(shù)據(jù)庫架構(gòu)
--count Retrieve number of entries for table(s) 檢索表的條目數(shù)
--dump Dump DBMS database table entries 轉(zhuǎn)儲數(shù)據(jù)庫管理系統(tǒng)的數(shù)據(jù)庫中的表項
--dump-all Dump all DBMS databases tables entries 轉(zhuǎn)儲數(shù)據(jù)庫管理系統(tǒng)的數(shù)據(jù)庫中的表項
--search Search column(s), table(s) and/or database name(s) 搜索列(S),表(S)和/或數(shù)據(jù)庫名稱(S)
--comments Retrieve DBMS comments 檢索數(shù)據(jù)庫的comments(注釋、評論)
-D DB DBMS database to enumerate 要進行枚舉的數(shù)據(jù)庫名
-T TBL DBMS database table(s) to enumerate 要進行枚舉的數(shù)據(jù)庫表
-C COL DBMS database table column(s) to enumerate 要進行枚舉的數(shù)據(jù)庫列
-X EXCLUDECOL DBMS database table column(s) to not enumerate 要不進行枚舉的數(shù)據(jù)庫列
-U USER DBMS user to enumerate 用來進行枚舉的數(shù)據(jù)庫用戶
--exclude-sysdbs Exclude DBMS system databases when enumerating tables枚舉表時排除系統(tǒng)數(shù)據(jù)庫
--pivot-column=P.. Pivot column name 主列名稱
--where=DUMPWHERE Use WHERE condition while table dumping 使用WHERE條件進行表轉(zhuǎn)儲

--start=LIMITSTART First query output entry to retrieve 第一個查詢輸出進入檢索
--stop=LIMITSTOP Last query output entry to retrieve 最后查詢的輸出進入檢索
--first=FIRSTCHAR First query output word character to retrieve 第一個查詢輸出字的字符檢索
--last=LASTCHAR Last query output word character to retrieve 最后查詢的輸出字字符檢索
--sql-query=QUERY SQL statement to be executed 要執(zhí)行的SQL語句
--sql-shell Prompt for an interactive SQL shell 提示交互式SQL的shell
--sql-file=SQLFILE Execute SQL statements from given file(s) 從給定文件執(zhí)行SQL語句

Brute force(蠻力):

These options can be used to run brute force checks 這些選項可以被用來運行蠻力檢查。

--common-tables Check existence of common tables 檢查存在共同表
--common-columns Check existence of common columns 檢查存在共同列

User-defined function injection(用戶自定義函數(shù)注入):
These options can be used to create custom user-defined functions 這些選項可
以用來創(chuàng)建用戶自定義函數(shù)。

--udf-inject Inject custom user-defined functions 注入用戶自定義函數(shù)
--shared-lib=SHLIB Local path of the shared library 共享庫的本地路徑

File system access(訪問文件系統(tǒng)):

These options can be used to access the back-end database management
system underlying file system
這些選項可以被用來訪問后端數(shù)據(jù)庫管理系統(tǒng)的底層文件系統(tǒng)。

--file-read=RFILE Read a file from the back-end DBMS file system 從后端的數(shù)據(jù)庫管理系統(tǒng)文件系統(tǒng)讀取文件
--file-write=WFILE Write a local file on the back-end DBMS file system 編輯后端的數(shù)據(jù)庫管理系統(tǒng)文件系統(tǒng)上的本地文件
--file-dest=DFILE Back-end DBMS absolute filepath to write to 后端的數(shù)據(jù)庫管理系統(tǒng)寫入文件的絕對路徑

Operating system access(操作系統(tǒng)訪問):

These options can be used to access the back-end database management
system underlying operating system
這些選項可以用于訪問后端數(shù)據(jù)庫管理系統(tǒng)的底層操作系統(tǒng)。

--os-cmd=OSCMD Execute an operating system command 執(zhí)行操作系統(tǒng)命令
--os-shell Prompt for an interactive operating system shell 交互式的操作系統(tǒng)的shell
--os-pwn Prompt for an OOB shell, Meterpreter or VNC 獲取一個OOB shell,meterpreter或VNC
--os-smbrelay One click prompt for an OOB shell, Meterpreter or VNC 一鍵獲取一個OOB shell,meterpreter或VNC
--os-bof Stored procedure buffer overflow exploitation 存儲過程緩沖區(qū)溢出利用
--priv-esc Database process user privilege escalation 數(shù)據(jù)庫進程用戶權(quán)限提升
--msf-path=MSFPATH Local path where Metasploit Framework is installed
Metasploit Framework本地的安裝路徑
--tmp-path=TMPPATH Remote absolute path of temporary files directory 遠程臨時文件目錄的絕對路徑

Windows registry access(Windows注冊表訪問):

These options can be used to access the back-end database management
system Windows registry

這些選項可以被用來訪問后端數(shù)據(jù)庫管理系統(tǒng)Windows注冊表。

--reg-read Read a Windows registry key value 讀一個Windows注冊表項值
--reg-add Write a Windows registry key value data 寫一個Windows注冊表項值數(shù)據(jù)
--reg-del Delete a Windows registry key value 刪除Windows注冊表鍵
--reg-key=REGKEY Windows registry key Windows注冊表鍵
--reg-value=REGVAL Windows registry key value Windows注冊表項值
--reg-data=REGDATA Windows registry key value data Windows注冊表鍵值數(shù)據(jù)
--reg-type=REGTYPE Windows registry key value type Windows注冊表項值類型

General(一般):

These options can be used to set some general working parameters 這些選項可以用來設(shè)置一些一般的工作參數(shù)。

-s SESSIONFILE Load session from a stored (.sqlite) file 保存和恢復檢索會話文件的所有數(shù)據(jù)
-t TRAFFICFILE Log all HTTP traffic into a textual file 記錄所有HTTP流量到一個文本文件中
--batch Never ask for user input, use the default behaviour 從不詢問用戶輸入,使用所有默認配置。
--binary-fields=.. Result fields having binary values (e.g. "digest") 具有二進制值的結(jié)果字段
--charset=CHARSET Force character encoding used for data retrieval 強制用于數(shù)據(jù)檢索的字符編碼
--crawl=CRAWLDEPTH Crawl the website starting from the target URL
從目標網(wǎng)址開始抓取網(wǎng)站
--crawl-exclude=.. Regexp to exclude pages from crawling (e.g. "logout") 正則表達式排除網(wǎng)頁抓取

--csv-del=CSVDEL Delimiting character used in CSV output (default ",") 分隔CSV輸出中使用的字符
--dump-format=DU.. Format of dumped data (CSV (default), HTML or SQLITE)
轉(zhuǎn)儲數(shù)據(jù)的格式
--eta Display for each output the estimated time of arrival 顯示每個輸出的預(yù)計到達時間
--flush-session Flush session files for current target 刷新當前目標的會話文件
--forms Parse and test forms on target URL 在目標網(wǎng)址上解析和測試表單
--fresh-queries Ignore query results stored in session file 忽略在會話文件中存儲的查詢結(jié)果
--hex Use DBMS hex function(s) for data retrieval 使用DBMShex函數(shù)進行數(shù)據(jù)檢索
--output-dir=OUT.. Custom output directory path 自定義輸出目錄路徑
--parse-errors Parse and display DBMS error messages from responses 解析和顯示響應(yīng)中的DBMS錯誤消息
--save=SAVECONFIG Save options to a configuration INI file 保存選項到INI配置文件
--scope=SCOPE Regexp to filter targets from provided proxy log 使用正則表達式從提供的代理日志中過濾目標
--test-filter=TE.. Select tests by payloads and/or titles (e.g. ROW) 根據(jù)有效負載和/或標題(e.g. ROW)選擇測試
--test-skip=TEST.. Skip tests by payloads and/or titles (e.g. BENCHMARK) 根據(jù)有效負載和/或標題跳過測試(e.g. BENCHMARK)
--update Update sqlmap 更新SqlMap

Miscellaneous(雜項):

-z MNEMONICS Use short mnemonics (e.g. "flu,bat,ban,tec=EU") 使用簡短的助記符
--alert=ALERT Run host OS command(s) when SQL injection is found 在找到SQL注入時運行主機操作系統(tǒng)命令

--answers=ANSWERS Set question answers (e.g. "quit=N,follow=N") 設(shè)置問題答案
--beep Beep on question and/or when SQL injection is found 發(fā)現(xiàn)SQL注入時提醒
--cleanup Clean up the DBMS from sqlmap specific UDF and tablesSqlMap具體的UDF和表清理DBMS
--dependencies Check for missing (non-core) sqlmap dependencies 檢查是否缺少(非內(nèi)核)sqlmap依賴關(guān)系
--disable-coloring Disable console output coloring 禁用控制臺輸出顏色
--gpage=GOOGLEPAGE Use Google dork results from specified page number使用Google dork結(jié)果指定頁碼
--identify-waf Make a thorough testing for a WAF/IPS/IDS protection 對WAF / IPS / IDS保護進行全面測試
--skip-waf Skip heuristic detection of WAF/IPS/IDS protection 跳過啟發(fā)式檢測WAF / IPS / IDS保護
--mobile Imitate smartphone through HTTP User-Agent header 通過HTTP User-Agent標頭模仿智能手機
--offline Work in offline mode (only use session data) 在離線模式下工作(僅使用會話數(shù)據(jù))
--page-rank Display page rank (PR) for Google dork results Googledork結(jié)果顯示網(wǎng)頁排名(PR)
--purge-output Safely remove all content from output directory 安全地從輸出目錄中刪除所有內(nèi)容
--smart Conduct thorough tests only if positive heuristic(s) 只有在正啟發(fā)式時才進行徹底測試
--sqlmap-shell Prompt for an interactive sqlmap shell 提示交互式
sqlmap shell
--wizard Simple wizard interface for beginner users 給初級用戶的簡單向?qū)Ы缑?/span>

Micropoor
?