port_scan module using scapy !

This commit is contained in:
n1nj4sec 2016-01-16 13:24:29 +01:00
parent 8ee7aa53a3
commit c0bcd0637e
1 changed files with 24 additions and 0 deletions

24
pupy/modules/port_scan.py Normal file
View File

@ -0,0 +1,24 @@
# -*- coding: UTF8 -*-
from pupylib.PupyModule import *
import logging
logging.getLogger("scapy.runtime").setLevel(logging.ERROR)
from scapy.all import *
__class_name__="PortScan"
class PortScan(PupyModule):
""" run a TCP port scan """
dependencies=['portscan', 'scapy']
def init_argparse(self):
self.arg_parser = PupyArgumentParser(prog="port_scan", description=self.__doc__)
self.arg_parser.add_argument('--ports','-p', default="21,22,23,80,139,443,445,3389,8000,8080", help='ports to scan ex: 22,80,443')
self.arg_parser.add_argument('address', metavar="ip/range", help='IP/range to scan')
def run(self, args):
ps=self.client.conn.modules['portscan'].PortScanner()
ports=[int(x) for x in args.ports.split(',')]
res=ps.scan(args.address, ports)
self.rawlog(res)
self.success("Scan finished !")