CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
Path: blob/master/lib/metasploit/framework/login_scanner/ftp.rb
Views: 1904
require 'metasploit/framework/ftp/client'1require 'metasploit/framework/login_scanner/base'2require 'metasploit/framework/login_scanner/rex_socket'34module Metasploit5module Framework6module LoginScanner78# This is the LoginScanner class for dealing with FTP.9# It is responsible for taking a single target, and a list of credentials10# and attempting them. It then saves the results.11class FTP12include Metasploit::Framework::LoginScanner::Base13include Metasploit::Framework::LoginScanner::RexSocket14include Metasploit::Framework::Ftp::Client1516DEFAULT_PORT = 2117LIKELY_PORTS = [ DEFAULT_PORT, 2121 ]18LIKELY_SERVICE_NAMES = [ 'ftp' ]19PRIVATE_TYPES = [ :password ]20REALM_KEY = nil2122# @!attribute ftp_timeout23# @return [Integer] The timeout in seconds to wait for a response to an FTP command24attr_accessor :ftp_timeout2526validates :ftp_timeout,27presence: true,28numericality: {29only_integer: true,30greater_than_or_equal_to: 131}32333435# (see Base#attempt_login)36def attempt_login(credential)37result_options = {38credential: credential39}4041begin42success = connect_login(credential.public, credential.private)43rescue ::EOFError, Errno::ECONNRESET, Rex::ConnectionError, Rex::ConnectionTimeout, ::Timeout::Error44result_options[:status] = Metasploit::Model::Login::Status::UNABLE_TO_CONNECT45success = false46ensure47disconnect48end4950if success51result_options[:status] = Metasploit::Model::Login::Status::SUCCESSFUL52elsif !(result_options.has_key? :status)53result_options[:status] = Metasploit::Model::Login::Status::INCORRECT54end5556result = ::Metasploit::Framework::LoginScanner::Result.new(result_options)57result.host = host58result.port = port59result.protocol = 'tcp'60result.service_name = 'ftp'61result62end6364private6566# This method sets the sane defaults for things67# like timeouts and TCP evasion options68def set_sane_defaults69self.connection_timeout ||= 3070self.port ||= DEFAULT_PORT71self.max_send_size ||= 072self.send_delay ||= 073self.ftp_timeout ||= 1674end7576end7778end79end80end818283