Skip to content

Commit 3fdad4d

Browse files
TomSellersTod Beardsley
authored andcommitted
Update auxillary/scanner/ftp with Credential Gem
1 parent dc95b01 commit 3fdad4d

File tree

1 file changed

+51
-24
lines changed

1 file changed

+51
-24
lines changed

modules/auxiliary/scanner/ftp/anonymous.rb

Lines changed: 51 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -35,40 +35,67 @@ def run_host(target_host)
3535

3636
begin
3737

38-
res = connect_login(true, false)
38+
res = connect_login(true, false)
3939

40-
banner.strip! if banner
40+
banner.strip! if banner
4141

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)
4545

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)
4848

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)
5456
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
6557

66-
disconnect
58+
disconnect
6759

6860
rescue ::Interrupt
69-
raise $!
61+
raise $ERROR_INFO
7062
rescue ::Rex::ConnectionError, ::IOError
7163
end
64+
end
7265

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)
73100
end
74101
end

0 commit comments

Comments
 (0)