2008-06-06 04:29:41 +00:00
|
|
|
##
|
2010-04-30 08:40:19 +00:00
|
|
|
# $Id$
|
|
|
|
##
|
|
|
|
|
|
|
|
##
|
|
|
|
# This file is part of the Metasploit Framework and may be subject to
|
2008-06-06 04:29:41 +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-06-06 04:29:41 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
|
|
|
|
require 'msf/core'
|
|
|
|
|
|
|
|
|
2008-10-02 05:23:59 +00:00
|
|
|
class Metasploit3 < Msf::Auxiliary
|
2008-06-06 04:29:41 +00:00
|
|
|
|
2008-10-02 05:23:59 +00:00
|
|
|
include Msf::Exploit::Remote::Ftp
|
|
|
|
include Msf::Auxiliary::Scanner
|
2009-01-11 05:52:07 +00:00
|
|
|
include Msf::Auxiliary::Report
|
2008-06-06 04:29:41 +00:00
|
|
|
|
|
|
|
def initialize
|
|
|
|
super(
|
|
|
|
'Name' => 'Anonymous FTP Access Detection',
|
2008-06-06 04:39:44 +00:00
|
|
|
'Version' => '$Revision$',
|
2008-06-06 04:29:41 +00:00
|
|
|
'Description' => 'Detect anonymous (read/write) FTP server access.',
|
|
|
|
'References' =>
|
|
|
|
[
|
|
|
|
['URL', 'http://en.wikipedia.org/wiki/File_Transfer_Protocol#Anonymous_FTP'],
|
|
|
|
],
|
|
|
|
'Author' => 'Matteo Cantoni <goony[at]nothink.org>',
|
|
|
|
'License' => MSF_LICENSE
|
|
|
|
)
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2008-06-06 04:29:41 +00:00
|
|
|
register_options(
|
|
|
|
[
|
|
|
|
Opt::RPORT(21),
|
|
|
|
], self.class)
|
|
|
|
end
|
|
|
|
|
|
|
|
def run_host(target_host)
|
|
|
|
|
2008-10-04 21:42:37 +00:00
|
|
|
begin
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2008-10-04 21:42:37 +00:00
|
|
|
res = connect_login(true, false)
|
2008-06-06 04:29:41 +00:00
|
|
|
|
2008-10-04 21:42:37 +00:00
|
|
|
banner.strip! if banner
|
2008-06-06 04:29:41 +00:00
|
|
|
|
2008-10-04 21:42:37 +00:00
|
|
|
dir = Rex::Text.rand_text_alpha(8)
|
2010-04-30 08:40:19 +00:00
|
|
|
if res
|
2008-10-04 21:42:37 +00:00
|
|
|
write_check = send_cmd( ['MKD', dir] , true)
|
2008-06-06 04:29:41 +00:00
|
|
|
|
2008-10-04 21:42:37 +00:00
|
|
|
if (write_check and write_check =~ /^2/)
|
|
|
|
send_cmd( ['RMD', dir] , true)
|
2008-11-11 05:12:52 +00:00
|
|
|
|
2008-10-04 21:42:37 +00:00
|
|
|
print_status("#{target_host}:#{rport} Anonymous READ/WRITE (#{banner})")
|
2010-08-18 00:58:20 +00:00
|
|
|
access_type = "rw"
|
2008-06-06 04:29:41 +00:00
|
|
|
else
|
2008-10-04 21:42:37 +00:00
|
|
|
print_status("#{target_host}:#{rport} Anonymous READ (#{banner})")
|
2010-08-18 00:58:20 +00:00
|
|
|
access_type = "ro"
|
2008-06-06 04:29:41 +00:00
|
|
|
end
|
2009-01-11 05:52:07 +00:00
|
|
|
report_auth_info(
|
|
|
|
:host => target_host,
|
2010-08-18 00:58:20 +00:00
|
|
|
:port => rport,
|
|
|
|
:sname => 'ftp',
|
2009-01-11 05:52:07 +00:00
|
|
|
:user => datastore['FTPUSER'],
|
|
|
|
:pass => datastore['FTPPASS'],
|
2010-08-18 00:58:20 +00:00
|
|
|
:type => "password_#{access_type}",
|
|
|
|
:active => true
|
2009-01-11 05:52:07 +00:00
|
|
|
)
|
2008-06-06 04:29:41 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
disconnect
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2008-10-04 21:42:37 +00:00
|
|
|
rescue ::Interrupt
|
|
|
|
raise $!
|
2008-11-11 05:12:52 +00:00
|
|
|
rescue ::Rex::ConnectionError, ::IOError
|
2008-10-04 21:42:37 +00:00
|
|
|
end
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2008-06-06 04:29:41 +00:00
|
|
|
end
|
2008-11-11 05:12:52 +00:00
|
|
|
end
|