From 664e774a330d459c4297b0d7e8f3761e2b4bdacb Mon Sep 17 00:00:00 2001 From: Jon Hart Date: Fri, 20 Oct 2017 09:44:07 -0700 Subject: [PATCH] style/rubocop cleanup --- .../scanner/gopher/gopher_gophermap.rb | 106 +++++++++--------- 1 file changed, 55 insertions(+), 51 deletions(-) diff --git a/modules/auxiliary/scanner/gopher/gopher_gophermap.rb b/modules/auxiliary/scanner/gopher/gopher_gophermap.rb index 0911f3067b..b5e4fdd950 100644 --- a/modules/auxiliary/scanner/gopher/gopher_gophermap.rb +++ b/modules/auxiliary/scanner/gopher/gopher_gophermap.rb @@ -11,45 +11,50 @@ class MetasploitModule < Msf::Auxiliary def initialize super( 'Name' => 'Gopher gophermap Scanner', - 'Description' => %q{ + 'Description' => %q( This module identifies Gopher servers, and processes the gophermap file which lists all the files on the server. - }, + ), 'References' => [ - ['URL', 'https://sdfeu.org/w/tutorials:gopher'], + ['URL', 'https://sdfeu.org/w/tutorials:gopher'] ], 'Author' => 'h00die', 'License' => MSF_LICENSE ) - register_options([ - Opt::RPORT(70), - OptString.new('PATH',[false,'Path to enumerate','']) - ]) - + register_options( + [ + Opt::RPORT(70), + OptString.new('PATH', [false, 'Path to enumerate', '']) + ] + ) end + TYPE_MAP = { + '0' => 'Text file', + '1' => 'Directory', + '2' => 'CSO name server', + '3' => 'Error', + '4' => 'Mac HQX filer', + '5' => 'PC binary', + '6' => 'UNIX uuencoded file', + '7' => 'Search server', + '8' => 'Telnet Session', + '9' => 'Binary File', + 'c' => 'Calendar', + 'e' => 'Event', + 'g' => 'GIF image', + 'h' => 'HTML', + 'i' => 'inline text', + 's' => 'Sound', + 'I' => 'Image', + 'M' => 'MIME multipart/mixed message', + 'T' => 'TN3270 Session' + }.freeze + def get_type(char) - return {'0' => 'Text file', - '1' => 'Directory', - '2' => 'CSO name server', - '3' => 'Error', - '4' => 'Mac HQX filer', - '5' => 'PC binary', - '6' => 'UNIX uuencoded file', - '7' => 'Search server', - '8' => 'Telnet Session', - '9' => 'Binary File', - 'c' => 'Calendar', - 'e' => 'Event', - 'g' => 'GIF image', - 'h' => 'HTML', - 'i' => 'inline text', - 's' => 'Sound', - 'I' => 'Image', - 'M' => 'MIME multipart/mixed message', - 'T' => 'TN3270 Session'}.fetch(char.chomp) + TYPE_MAP.fetch(char.chomp) end def run_host(ip) @@ -59,32 +64,32 @@ class MetasploitModule < Msf::Auxiliary gophermap = sock.get_once if gophermap gophermap.split("\r\n").each do |line| - if line.split("\t").length >= 2 - # syntax: [type_character]description[tab]path[tab, after this is optional]server[tab]port - line = line.split("\t") - desc = line[0] - type_char = desc.slice!(0) #remove first character which is the file type - file_type = get_type(type_char) - if file_type && file_type == 'inline text' - print_good(desc) - next - end - if file_type - print_good(" #{file_type}: #{desc}") - else - print_good(" Invalid File Type (#{type_char}): #{desc}") - end - if line.length >= 3 - print_good(" Path: #{line[2]}:#{line[3]}#{line[1]}") - elsif line.length >= 2 - print_good(" Path: #{line[2]}#{line[1]}") - else - print_good(" Path: #{line[1]}") + line_parts = line.split("\t") + next unless line_parts.length >= 2 + # syntax: [type_character]description[tab]path[tab, after this is optional]server[tab]port + line_parts = line.split("\t") + desc = line_parts[0] + type_char = desc.slice!(0) # remove first character which is the file type + file_type = get_type(type_char) + if file_type && file_type == 'inline text' + print_good(desc) + next + end + if file_type + print_good(" #{file_type}: #{desc}") + else + print_good(" Invalid File Type (#{type_char}): #{desc}") + end + if line_parts.length >= 3 + print_good(" Path: #{line_parts[2]}:#{line_parts[3]}#{line_parts[1]}") + elsif line.length >= 2 + print_good(" Path: #{line_parts[2]}#{line_parts[1]}") + else + print_good(" Path: #{line_parts[1]}") - end end end - report_service(:host => ip, :port => rport, :name => 'gopher', :info => gophermap) + report_service(host: ip, port: rport, service: 'gopher', info: gophermap) else print_error('No gophermap') end @@ -95,5 +100,4 @@ class MetasploitModule < Msf::Auxiliary disconnect end end - end