Follow us on Twitter!
Hacking isn't just Computers & Exploits. It's a Philosophy. - Mr_Cheese
Sunday, April 20, 2014
Navigation
Home
HellBoundHackers Main:
HellBoundHackers Find:
HellBoundHackers Information:
Learn
Communicate
Submit
Shop
Challenges
HellBoundHackers Exploit:
HellBoundHackers Programming:
HellBoundHackers Think:
HellBoundHackers Track:
HellBoundHackers Patch:
HellBoundHackers Other:
HellBoundHackers Need Help?
Other
Members Online
Total Online: 29
Guests Online: 25
Members Online: 4

Registered Members: 82844
Newest Member: Jimmy Zhang
Latest Articles
View Thread

HellBound Hackers | Computer General | Programming

Author

Metasploit portscanner module

n3w7yp3
Member

Your avatar

Posts: 358
Location: USA
Joined: 19.03.05
Rank:
Moderate
Posted on 16-12-05 22:42
Hey all, with the release of Metasploit 3.0 release 1 alpha, I noticed that it included a port scanner. So, I decided to code one for the 2.x branch. Simply put the following code in the exploits dir on the framework root:

Code

##
# This file is part of a series of add-ons for the Metasploit framework 2.x branch.
# It was coded by n3w7yp3 of Newage Hackers Labs.
# It can be distributed under the Newage Hackers Labs License agreement.
# Metasploit is avalible for free download at http://www.metasploit.com
# Enjoy, and use responsibly
##

# DISCLIAMER: The author hereby takes no responsibility for what you use this software for.
# Note: This is not actually part of Metasploit, its part of a series of expansions being coded by NHL.

package Msf::Exploit::msf_scan;
#use strict;
use base "Msf::Exploit";
use Pex::DCERPC;
use Pex::NDR;
use Pex::Text;
use Pex::x86;
use IO::Socket::INET;
# use IO::Socket::SSL;

our $info =
{
   'Name' => 'Metasploit Portscanner',
   'Version' => 'Revision: 1.0.0 $',
   'Authors' => [ 'n3w7yp3 <n3w7yp3 [at] gmail.com>' ],

   'UserOpts' =>
   {
      'RHOST' => [ 1, 'ADDR', 'The host to scan' ],
      'SPORT' => [ 1, 'PORT', 'Start port' ],
      'STPORT' => [ 1, 'PORT1', 'Stop port' ],
      'PROTO' => [ 1, 'PROTO', 'Ptotocol to use', 'tcp'],
   },
   'Description' => Pex::Text::Freeform(
   qq{
      This is a recon module that is capable of doing a TCP or UDP portscan against a host. SPORT is the start port, STPORT is the stop port.
}
   ),
   'Keys' => ['scan'],
   'Release date' => '2005-12-16',
};
sub new
{
   my $class = shift;
   my $self = $class -> SUPER::new({'Info' => $info}, @_);
   return ($self);
}
sub Exploit
{
   my $self = shift;
   my $host = $self -> GetVar('RHOST');
   my $port1 = $self -> GetVar('SPORT');
   my $port2 = $self -> GetVar('STPORT');
   my $proto = $self -> GetVar('PROTO');
   my $port = 0;
   $self -> PrintLine ("[*] Starting Metasploit Port scanner by n3w7yp3...");
   $self -> PrintLine ("[*] Scanning ports $port1 through $port2 on $host...");
   $self -> PrintLine ("[*] Results of scan follow:");
   for($port = $port1 ; $port <= $port2 ; $port++)
   {
      my $socket = IO::Socket::INET -> new (Proto => $proto, PeerAddr => $host, PeerPort => $port, Timeout => 1);
      if($socket)
      {
         $self -> PrintLine ("\t$port\/$proto\tOPEN");
      }
   }
   $self -> PrintLine ("[*] Scan complete");
   return;
}







It is run like so:

Code

msf > use msf_scan
msf msf_scan > set RHOST 127.0.0.1
RHOST -> 127.0.0.1
msf msf_scan > set SPORT 20
SPORT -> 20
msf msf_scan > set STPORT 30
STPORT -> 30
msf msf_scan > exploit
[*] Starting Metasploit Port scanner by n3w7yp3...
[*] Scanning ports 20 through 30 on 127.0.0.1...
[*] Results of scan follow:
        22/tcp  OPEN
        25/tcp  OPEN
[*] Scan complete





Enjoy!


"Root is a state of mind" -- K0resh

Edited by n3w7yp3 on 16-12-05 22:42
Author

RE: Metasploit portscanner module


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 17-12-05 11:03
sweet if i used metasploit im sur eits be awesome.