Creating my first metasploit module

Following the tutorial from Metasploit Unleashed website, which is very good btw, I got to the part where we needed to write a custom tcp scanner.

The process of extending the metasploit framework is really simple and to create a new scanner only one class was needed:

The scanner is called simple_tcp and this is its code:

require 'msf/core'
class Metasploit3 < Msf::Auxiliary
        include Msf::Exploit::Remote::Tcp
        include Msf::Auxiliary::Scanner
        def initialize
                        'Name'           => 'My custom TCP scan',
                        'Version'        => '$Revision: 1 $',
                        'Description'    => 'My quick scanner',
                        'Author'         => 'Your name here',
                        'License'        => MSF_LICENSE
                        ], self.class)

        def run_host(ip)
		greeting = "HELLO SERVER" 
                data = sock.recv(1024)
                print_status("Received: #{data} from #{ip}")

Looking back at the intro to metasploit we quickly identify a few familiar pieces.
First we see that the Metasploit3 class is inheriting the functionality from the Msf::Auxiliary module. However, to enable multiple inheritance the use of mixins it put in place and both the modules Msf::Exploit::Remote::Tcp and Msf::Auxiliary::Scanner are included in the class.

Here are the results:
Screen Shot 2014-01-30 at 10.59.59 PM

The example provided by the Metasploit Unleashed tutorial shows how trivial it is to extend the metapsloit framework and customize to fit your specific needs.
The code is widely available on github and you can dig in and find implementation of the core objects the framework provides.

Next step is to keep hammering the tutorial and dig a bit deeper on the framework implementation.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s