Join us at IRC!
Things are more like they are now than they have ever been before. - Dwight D. Eisenhower
Thursday, May 24, 2012
Navigation
Members Online
Total Online: 30
Web Spiders: 14
Guests Online: 28
Members Online: 2

Registered Members: 70201
Newest Member: subnick
Latest Articles
View Thread

HellBound Hackers | Computer General | Programming

Author

Metasploit portscanner module

n3w7yp3
Member

Posts: 358
Location: USA
Joined: 19.03.05
Rank:
Mad User
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:


##
# 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'],
},
'Descblockedription' => 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:


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

wolfmankurd
Member



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


BY READING MY POST, YOU ACCEPT IT AS IS AND AGREE TO MY DISCLAIMER OF ALL WARRANTIES, EXPRESS OR IMPLIED, AS WELL AS DISCLAIMERS OF ALL LIABILITY, DIRECT, INDIRECT, CONSEQUENTIAL OR INCIDENTAL, THAT MAY ARISE FROM THE USE OF THIS (MIS)INFORMATION.


Widowmakr@hotmail.com http://LetsHackStuff.com
Guest
Username

Password

Remember Me


Bookmark This Page
Affiliates
Adverts

 

 

Links
By using, viewing or obtaining any information contained on this site, you agree to the disclaimer.

© HellBound Hackers 2008- 2009. Since 3rd December 2004.