Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/modules/auxiliary/scanner/ftp/anonymous.rb
Views: 11784
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Auxiliary6include Msf::Exploit::Remote::Ftp7include Msf::Auxiliary::Scanner8include Msf::Auxiliary::Report910def initialize11super(12'Name' => 'Anonymous FTP Access Detection',13'Description' => 'Detect anonymous (read/write) FTP server access.',14'References' =>15[16['URL', 'https://en.wikipedia.org/wiki/File_Transfer_Protocol#Anonymous_FTP'],17],18'Author' => 'Matteo Cantoni <goony[at]nothink.org>',19'License' => MSF_LICENSE20)2122register_options(23[24Opt::RPORT(21),25])26end2728def run_host(target_host)2930begin3132res = connect_login(true, false)3334banner.strip! if banner3536dir = Rex::Text.rand_text_alpha(8)37if res38write_check = send_cmd(['MKD', dir] , true)3940if write_check && write_check =~ /^2/41send_cmd( ['RMD', dir] , true)4243print_good("#{target_host}:#{rport} - Anonymous READ/WRITE (#{banner})")44access_type = 'Read/Write'45else46print_good("#{target_host}:#{rport} - Anonymous READ (#{banner})")47access_type = 'Read-only'48end49register_creds(target_host, access_type)50end5152disconnect5354rescue ::Interrupt55raise $ERROR_INFO56rescue ::Rex::ConnectionError, ::IOError57end58end5960def register_creds(target_host, access_type)61# Build service information62service_data = {63address: target_host,64port: datastore['RPORT'],65service_name: 'ftp',66protocol: 'tcp',67workspace_id: myworkspace_id68}6970# Build credential information71credential_data = {72origin_type: :service,73module_fullname: self.fullname,74private_data: datastore['FTPPASS'],75private_type: :password,76username: datastore['FTPUSER'],77workspace_id: myworkspace_id78}7980credential_data.merge!(service_data)81credential_core = create_credential(credential_data)8283# Assemble the options hash for creating the Metasploit::Credential::Login object84login_data = {85access_level: access_type,86core: credential_core,87last_attempted_at: DateTime.now,88status: Metasploit::Model::Login::Status::SUCCESSFUL,89workspace_id: myworkspace_id90}9192login_data.merge!(service_data)93create_credential_login(login_data)94end95end969798