From c0bcd0637e2896ae9e847868878090019d5e8669 Mon Sep 17 00:00:00 2001 From: n1nj4sec Date: Sat, 16 Jan 2016 13:24:29 +0100 Subject: [PATCH] port_scan module using scapy ! --- pupy/modules/port_scan.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 pupy/modules/port_scan.py diff --git a/pupy/modules/port_scan.py b/pupy/modules/port_scan.py new file mode 100644 index 00000000..2f50a47c --- /dev/null +++ b/pupy/modules/port_scan.py @@ -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 !") +