@@ -35,40 +35,67 @@ def run_host(target_host)
35
35
36
36
begin
37
37
38
- res = connect_login ( true , false )
38
+ res = connect_login ( true , false )
39
39
40
- banner . strip! if banner
40
+ banner . strip! if banner
41
41
42
- dir = Rex ::Text . rand_text_alpha ( 8 )
43
- if res
44
- write_check = send_cmd ( [ 'MKD' , dir ] , true )
42
+ dir = Rex ::Text . rand_text_alpha ( 8 )
43
+ if res
44
+ write_check = send_cmd ( [ 'MKD' , dir ] , true )
45
45
46
- if ( write_check and write_check =~ /^2/ )
47
- send_cmd ( [ 'RMD' , dir ] , true )
46
+ if write_check && write_check =~ /^2/
47
+ send_cmd ( [ 'RMD' , dir ] , true )
48
48
49
- print_status ( "#{ target_host } :#{ rport } Anonymous READ/WRITE (#{ banner } )" )
50
- access_type = "rw"
51
- else
52
- print_status ( "#{ target_host } :#{ rport } Anonymous READ (#{ banner } )" )
53
- access_type = "ro"
49
+ print_good ( "#{ target_host } :#{ rport } - Anonymous READ/WRITE (#{ banner } )" )
50
+ access_type = 'Read/Write'
51
+ else
52
+ print_good ( "#{ target_host } :#{ rport } - Anonymous READ (#{ banner } )" )
53
+ access_type = 'Read-only'
54
+ end
55
+ register_creds ( target_host , access_type )
54
56
end
55
- report_auth_info (
56
- :host => target_host ,
57
- :port => rport ,
58
- :sname => 'ftp' ,
59
- :user => datastore [ 'FTPUSER' ] ,
60
- :pass => datastore [ 'FTPPASS' ] ,
61
- :type => "password_#{ access_type } " ,
62
- :active => true
63
- )
64
- end
65
57
66
- disconnect
58
+ disconnect
67
59
68
60
rescue ::Interrupt
69
- raise $!
61
+ raise $ERROR_INFO
70
62
rescue ::Rex ::ConnectionError , ::IOError
71
63
end
64
+ end
72
65
66
+ def register_creds ( target_host , access_type )
67
+ # Build service information
68
+ service_data = {
69
+ address : target_host ,
70
+ port : datastore [ 'RPORT' ] ,
71
+ service_name : 'ftp' ,
72
+ protocol : 'tcp' ,
73
+ workspace_id : myworkspace_id
74
+ }
75
+
76
+ # Build credential information
77
+ credential_data = {
78
+ origin_type : :service ,
79
+ module_fullname : self . fullname ,
80
+ private_data : datastore [ 'FTPPASS' ] ,
81
+ private_type : :password ,
82
+ username : datastore [ 'FTPUSER' ] ,
83
+ workspace_id : myworkspace_id
84
+ }
85
+
86
+ credential_data . merge! ( service_data )
87
+ credential_core = create_credential ( credential_data )
88
+
89
+ # Assemble the options hash for creating the Metasploit::Credential::Login object
90
+ login_data = {
91
+ access_level : access_type ,
92
+ core : credential_core ,
93
+ last_attempted_at : DateTime . now ,
94
+ status : Metasploit ::Model ::Login ::Status ::SUCCESSFUL ,
95
+ workspace_id : myworkspace_id
96
+ }
97
+
98
+ login_data . merge! ( service_data )
99
+ create_credential_login ( login_data )
73
100
end
74
101
end
0 commit comments