0

From https://github.com/rapid7/metasploit-framework/blob/master/modules/auxiliary/scanner/smtp/smtp_version.rb#L26:

class MetasploitModule < Msf::Auxiliary
  include Msf::Exploit::Remote::Smtp
  include Msf::Auxiliary::Scanner
  include Msf::Auxiliary::Report

  def initialize
    super(
      'Name'        => 'SMTP Banner Grabber',
      'Description' => 'SMTP Banner Grabber',
      'References'  =>
        [
          ['URL', 'http://www.ietf.org/rfc/rfc2821.txt'],
        ],
      'Author'      => 'CG',
      'License'     => MSF_LICENSE
    )
    deregister_options('MAILFROM', 'MAILTO')
  end

  def run_host(ip)
    res = connect
    banner_sanitized = Rex::Text.to_hex_ascii(banner.to_s)
    print_good("#{ip}:#{rport} SMTP #{banner_sanitized}")
    report_service(:host => rhost, :port => rport, :name => "smtp", :info => banner)
  end
end

I see connect is called above. Is connect a member function? How to know the member function of which super class is called? Thanks.

Todd A. Jacobs
  • 81,402
  • 15
  • 141
  • 199
user1424739
  • 11,937
  • 17
  • 63
  • 152
  • Ruby doesn't have "member functions." It's either a method or a variable, and since the #run_host method doesn't define the variable, it has to be a method of some sort unless you're seeing errors. – Todd A. Jacobs Feb 16 '21 at 15:18

1 Answers1

0

Most Likely an Inherited or Included Method

You didn't post all the relevant code, so you'd have to go spelunking in the rest of the source to be sure. I'm only going to address the section you specifically addressed.

In the small example you linked to, #connect is probably inherited from Msf::Auxiliary, or one of the included modules. From the name, it's most likely from Msf::Exploit::Remote::Smtp, but I didn't research it for you.

The reason it's most likely a method is that your current class isn't taking a connect argument anywhere. Since Ruby expressions essentially allow you to use method calls like right-hand side assignment values, this is a common idiom.

If you want to know for sure, grep your source for def connect to find where it's defined (assuming it's not done through something more meta like Module#define_method), or /\bconnect\b/ to find all the locations in your source tree where you might want to look more closely for its use or definition.

Todd A. Jacobs
  • 81,402
  • 15
  • 141
  • 199