Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/modules/auxiliary/scanner/gopher/gopher_gophermap.rb
Views: 11784
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Auxiliary6include Msf::Exploit::Remote::Tcp7include Msf::Auxiliary::Report8include Msf::Auxiliary::Scanner910def initialize11super(12'Name' => 'Gopher gophermap Scanner',13'Description' => %q(14This module identifies Gopher servers, and processes the gophermap15file which lists all the files on the server.16),17'References' =>18[19['URL', 'https://sdfeu.org/w/tutorials:gopher']20],21'Author' => 'h00die',22'License' => MSF_LICENSE23)2425register_options(26[27Opt::RPORT(70),28OptString.new('PATH', [false, 'Path to enumerate', ''])29]30)31end3233TYPE_MAP = {34'0' => 'Text file',35'1' => 'Directory',36'2' => 'CSO name server',37'3' => 'Error',38'4' => 'Mac HQX filer',39'5' => 'PC binary',40'6' => 'UNIX uuencoded file',41'7' => 'Search server',42'8' => 'Telnet Session',43'9' => 'Binary File',44'c' => 'Calendar',45'e' => 'Event',46'g' => 'GIF image',47'h' => 'HTML',48'i' => 'inline text',49's' => 'Sound',50'I' => 'Image',51'M' => 'MIME multipart/mixed message',52'T' => 'TN3270 Session'53}.freeze5455def get_type(char)56TYPE_MAP.fetch(char.chomp)57end5859def run_host(ip)60begin61connect62sock.put("#{datastore['path']}\r\n")63gophermap = sock.get_once64if gophermap65gophermap.split("\r\n").each do |line|66line_parts = line.split("\t")67next unless line_parts.length >= 268# syntax: [type_character]description[tab]path[tab, after this is optional]server[tab]port69line_parts = line.split("\t")70desc = line_parts[0]71type_char = desc.slice!(0) # remove first character which is the file type72file_type = get_type(type_char)73if file_type && file_type == 'inline text'74print_good(desc)75next76end77if file_type78print_good(" #{file_type}: #{desc}")79else80print_good(" Invalid File Type (#{type_char}): #{desc}")81end82if line_parts.length >= 383print_good(" Path: #{line_parts[2]}:#{line_parts[3]}#{line_parts[1]}")84elsif line.length >= 285print_good(" Path: #{line_parts[2]}#{line_parts[1]}")86else87print_good(" Path: #{line_parts[1]}")8889end90end91report_service(host: ip, port: rport, service: 'gopher', info: gophermap)92else93print_error('No gophermap')94end95rescue ::Rex::ConnectionError, ::IOError, ::Errno::ECONNRESET96rescue ::Exception => e97print_error("#{ip}: #{e} #{e.backtrace}")98ensure99disconnect100end101end102end103104105