diff options
author | alexej996 <aleksej@spidermail.tk> | 2018-11-03 23:29:28 +0100 |
---|---|---|
committer | alexej996 <aleksej@spidermail.tk> | 2018-11-03 23:29:28 +0100 |
commit | 807e414def99e2c3e1f83d3ab09da132ac0e29c7 (patch) | |
tree | 97230f55be79f0a4974c118c350da97d336602d2 /tmap | |
parent | d3c624c601ed0ad863045ed3057eb2bf2e8dd1d9 (diff) |
allow for range and specific ports in the same line
Diffstat (limited to 'tmap')
-rwxr-xr-x | tmap | 34 |
1 files changed, 21 insertions, 13 deletions
@@ -42,7 +42,7 @@ def main(): parser.add_argument("--version", dest="version", help="print version info and exit", action="store_true") parser.add_argument("HOSTS", help="IP or domain to scan", default="empty_host", nargs="?") parser.add_argument("-H", "--hosts", metavar="HOSTS", dest="tgtHost", help="IP or domain to scan", default="empty_host_option") - parser.add_argument("-p", "--ports", metavar="PORTS", dest="tgtPort", help="ports to scan", default="21,22,23,25,53,80,443,8080,8333,9050,9150") + parser.add_argument("-p", "--ports", metavar="PORTS", dest="tgtPort", help="ports to scan", default="20-25,53,80-85,443-445,8080,8333,9050,9150") parser.add_argument("-t", "--timeout", metavar="TIMEOUT", dest="sockTimeout", type=int, help="seconds to wait before connection timeout for each port", default=2) parser.add_argument("--clearnet", dest="clearnet", help="don't use Tor for scanning", action="store_true") parser.add_argument("--torport", metavar="TORPORT", dest="torPort", type=int, help="port for Tor proxy", default="9050") @@ -72,19 +72,27 @@ def main(): socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5, "127.0.0.1", args.torPort) ## Load specified ports into PORTS list - if "-" not in args.tgtPort: - try: - PORTS = list(map(int, args.tgtPort.split(","))) - except: - parser.print_help() - exit() - else: - PORTS = list(map(int, args.tgtPort.split("-"))) - if len(PORTS) != 2 or PORTS[0]>PORTS[1]: - parser.print_help() - exit() + PORTS = list() + for p in args.tgtPort.split(","): + if "-" not in p: + try: + p = int(p) + PORTS.append(p) + except: + parser.print_help() + exit() else: - PORTS = range(PORTS[0],PORTS[1]+1) + try: + p = list(map(int, p.split("-"))) + except: + parser.print_help() + exit() + if len(p) != 2 or p[0]>p[1]: + parser.print_help() + exit() + else: + p = list(range(p[0],p[1]+1)) + PORTS += p ## Load other variables HOSTS = args.HOSTS.split(",") |