diff --git a/src/crab.py b/src/crab.py index b440ad2..9847c08 100644 --- a/src/crab.py +++ b/src/crab.py @@ -37,35 +37,32 @@ def pytonwhois(host): w = whois.whois(host) print(w.text) -def portscan(host, port): +def portscan(host, port, timeout): s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - s.settimeout(0.5) + s.settimeout(timeout) try: con = s.connect((host,port)) - - print('Port :',port,"is open.") - + print('Port:',port,"is open.") con.close() except: pass -def portscan2(host): +def portscan2(host, timeout): start = time.time() for x in range(1,65535): - - t = threading.Thread(target=fastportscan,kwargs={'host':host, 'port': x}) + t = threading.Thread(target=fastportscan,kwargs={'host':host, 'port': x, 'timeout': timeout}) x += 1 t.start() end = time.time() print("took: ", end - start, "seconds") -def fastportscan(host, port): +def fastportscan(host, port, timeout): s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - s.settimeout(0.5) + s.settimeout(float(timeout)) try: con = s.connect((host,port)) @@ -76,11 +73,11 @@ def fastportscan(host, port): except: pass -def fastportscan2(host): +def fastportscan2(host, timeout): start = time.time() for x in range(1,1023): - t = threading.Thread(target=fastportscan,kwargs={'host':host, 'port': x}) + t = threading.Thread(target=fastportscan,kwargs={'host':host, 'port': x, 'timeout': timeout}) x += 1 t.start() @@ -92,9 +89,17 @@ def fastportscan2(host): if (args[0] == "-h"): print('''Usage: python3 crab.py [Options] {Target} -h: Shows this menu + -p: Port Scan - Casual port scan. Scans every port. + Usage: python crab.py -fp [your target] [time out in seconds] + Example: python crab.py -p google.com 0.5 + -fp: Fast Port Scan - Fastest port scan. Only scans from a range of 1 - 1023 + Usage: python crab.py -fp [your target] [time out in seconds] + Example: python crab.py -fp google.com 0.5 + -i: Info - Get Basic information on a given Host + -w: whois - Runs a whois search on a given Host ''') if (args[0] == "-i"): @@ -102,10 +107,11 @@ def fastportscan2(host): if (args[0] == "-w"): pytonwhois(args[1]) if (args[0] == "-p"): - portscan2(args[1]) + portscan2(args[1], args[2]) if(args[0] == "-fp"): - fastportscan2(args[1]) + fastportscan2(args[1], args[2]) except IndexError: print("Invalid args. Use [-h] for help") +