@@ -44,47 +44,19 @@ def initialize(info = {})
4444 ] )
4545 end
4646
47- def sanitize_ftp_response ( str )
48- Rex ::Text . to_hex_ascii ( str . to_s . gsub ( /^\d {3}[\s -]/ , '' ) . strip . gsub ( /\A \( |\) \z / , '' ) )
49- end
50-
5147 def check
5248 # attempt to connect
5349 begin
54- if !connect_login
55- print_error ( 'Connection refused' )
56- return Exploit ::CheckCode ::Unknown ( 'Failed to connect or authenticate via FTP' )
57- end
58-
59- if banner
60- vprint_status ( "FTP banner: #{ sanitize_ftp_response ( banner ) } " )
61-
62- # Cleaned up FTP banner
63- report_service (
64- host : rhost ,
65- port : rport ,
66- proto : 'tcp' ,
67- name : 'ftp' ,
68- info : sanitize_ftp_response ( banner )
69- )
70-
71- # Raw FTP banner
72- report_note (
73- host : rhost ,
74- port : rport ,
75- proto : 'tcp' ,
76- type : 'ftp.banner' ,
77- data : { banner : banner . strip }
78- )
79- end
50+ return Exploit ::CheckCode ::Unknown ( 'Failed to connect or authenticate via FTP' ) unless connect_login
8051 rescue Rex ::ConnectionRefused
81- print_error ( 'Connection refused' )
52+ report_host ( host : rhost )
8253 return Exploit ::CheckCode ::Unknown ( 'Connection refused by the target' )
8354 rescue Rex ::ConnectionTimeout
84- print_error ( 'Connection timed out' )
55+ report_host ( host : rhost )
8556 return Exploit ::CheckCode ::Unknown ( 'Connection timed out' )
8657 end
8758
59+
8860 s = ''
8961 attempts = 0
9062 max = datastore [ 'MAX_ATTEMPTS' ] . to_i
@@ -101,6 +73,7 @@ def check
10173 end
10274 end
10375 disconnect
76+
10477 # check if version was found
10578 if s !~ /vsFTPd \d +\. \d +\. \d +/
10679 print_error ( 'Did not find FTP version in FTP session' )
@@ -126,7 +99,6 @@ def run
12699
127100 attempts = 0
128101 max = datastore [ 'MAX_ATTEMPTS' ] . to_i
129-
130102 loop do
131103 attempts += 1
132104 if max > 0 && attempts > max
0 commit comments