Skip to content

Commit

Permalink
Update crab.py
Browse files Browse the repository at this point in the history
  • Loading branch information
N0tA1dan authored Dec 31, 2021
1 parent 681bb7d commit b996488
Showing 1 changed file with 20 additions and 14 deletions.
34 changes: 20 additions & 14 deletions src/crab.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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()
Expand All @@ -92,20 +89,29 @@ 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"):
iplookup(args[1])
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")


0 comments on commit b996488

Please sign in to comment.