@@ -11,45 +11,50 @@ class MetasploitModule < Msf::Auxiliary
11
11
def initialize
12
12
super (
13
13
'Name' => 'Gopher gophermap Scanner' ,
14
- 'Description' => %q{
14
+ 'Description' => %q(
15
15
This module identifies Gopher servers, and processes the gophermap
16
16
file which lists all the files on the server.
17
- } ,
17
+ ) ,
18
18
'References' =>
19
19
[
20
- [ 'URL' , 'https://sdfeu.org/w/tutorials:gopher' ] ,
20
+ [ 'URL' , 'https://sdfeu.org/w/tutorials:gopher' ]
21
21
] ,
22
22
'Author' => 'h00die' ,
23
23
'License' => MSF_LICENSE
24
24
)
25
25
26
- register_options ( [
27
- Opt ::RPORT ( 70 ) ,
28
- OptString . new ( 'PATH' , [ false , 'Path to enumerate' , '' ] )
29
- ] )
30
-
26
+ register_options (
27
+ [
28
+ Opt ::RPORT ( 70 ) ,
29
+ OptString . new ( 'PATH' , [ false , 'Path to enumerate' , '' ] )
30
+ ]
31
+ )
31
32
end
32
33
34
+ TYPE_MAP = {
35
+ '0' => 'Text file' ,
36
+ '1' => 'Directory' ,
37
+ '2' => 'CSO name server' ,
38
+ '3' => 'Error' ,
39
+ '4' => 'Mac HQX filer' ,
40
+ '5' => 'PC binary' ,
41
+ '6' => 'UNIX uuencoded file' ,
42
+ '7' => 'Search server' ,
43
+ '8' => 'Telnet Session' ,
44
+ '9' => 'Binary File' ,
45
+ 'c' => 'Calendar' ,
46
+ 'e' => 'Event' ,
47
+ 'g' => 'GIF image' ,
48
+ 'h' => 'HTML' ,
49
+ 'i' => 'inline text' ,
50
+ 's' => 'Sound' ,
51
+ 'I' => 'Image' ,
52
+ 'M' => 'MIME multipart/mixed message' ,
53
+ 'T' => 'TN3270 Session'
54
+ } . freeze
55
+
33
56
def get_type ( char )
34
- return { '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' } . fetch ( char . chomp )
57
+ TYPE_MAP . fetch ( char . chomp )
53
58
end
54
59
55
60
def run_host ( ip )
@@ -59,32 +64,32 @@ def run_host(ip)
59
64
gophermap = sock . get_once
60
65
if gophermap
61
66
gophermap . split ( "\r \n " ) . each do |line |
62
- if line . split ( "\t " ) . length >= 2
63
- # syntax: [type_character]description[tab]path[tab, after this is optional]server[tab]port
64
- line = line . split ( "\t " )
65
- desc = line [ 0 ]
66
- type_char = desc . slice! ( 0 ) #remove first character which is the file type
67
- file_type = get_type ( type_char )
68
- if file_type && file_type == 'inline text'
69
- print_good ( desc )
70
- next
71
- end
72
- if file_type
73
- print_good ( " #{ file_type } : #{ desc } " )
74
- else
75
- print_good ( " Invalid File Type (#{ type_char } ): #{ desc } " )
76
- end
77
- if line . length >= 3
78
- print_good ( " Path: #{ line [ 2 ] } :#{ line [ 3 ] } #{ line [ 1 ] } " )
79
- elsif line . length >= 2
80
- print_good ( " Path: #{ line [ 2 ] } #{ line [ 1 ] } " )
81
- else
82
- print_good ( " Path: #{ line [ 1 ] } " )
67
+ line_parts = line . split ( "\t " )
68
+ next unless line_parts . length >= 2
69
+ # syntax: [type_character]description[tab]path[tab, after this is optional]server[tab]port
70
+ line_parts = line . split ( "\t " )
71
+ desc = line_parts [ 0 ]
72
+ type_char = desc . slice! ( 0 ) # remove first character which is the file type
73
+ file_type = get_type ( type_char )
74
+ if file_type && file_type == 'inline text'
75
+ print_good ( desc )
76
+ next
77
+ end
78
+ if file_type
79
+ print_good ( " #{ file_type } : #{ desc } " )
80
+ else
81
+ print_good ( " Invalid File Type (#{ type_char } ): #{ desc } " )
82
+ end
83
+ if line_parts . length >= 3
84
+ print_good ( " Path: #{ line_parts [ 2 ] } :#{ line_parts [ 3 ] } #{ line_parts [ 1 ] } " )
85
+ elsif line . length >= 2
86
+ print_good ( " Path: #{ line_parts [ 2 ] } #{ line_parts [ 1 ] } " )
87
+ else
88
+ print_good ( " Path: #{ line_parts [ 1 ] } " )
83
89
84
- end
85
90
end
86
91
end
87
- report_service ( : host => ip , : port => rport , :name => 'gopher' , : info => gophermap )
92
+ report_service ( host : ip , port : rport , service : 'gopher' , info : gophermap )
88
93
else
89
94
print_error ( 'No gophermap' )
90
95
end
@@ -95,5 +100,4 @@ def run_host(ip)
95
100
disconnect
96
101
end
97
102
end
98
-
99
103
end
0 commit comments