-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscannerlol.py
More file actions
60 lines (47 loc) · 1.66 KB
/
Copy pathscannerlol.py
File metadata and controls
60 lines (47 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/python3
#This will probably be so bad but let's try it out.
import pyfiglet
import sys
import socket
from datetime import datetime
ascii_banner = pyfiglet.figlet_format("ScannerLoL")
print(ascii_banner)
#explain/define the target. Old version
#if len(sys.argv) == 2:
# target = socket.gethostbyname(sys.argv[1]) #Translate hostname to IPv4
#explain/define the target. New Version with ability to choose
target = input("Enter a IP host to scan: ")
targetIP = socket.gethostbyname(target)
sPort = int(input("Enter a start port to scan: "))
ePort = int(input("Enter end port to scan: "))
#else:
#print("Not enough arguments. Invalid.")
#print("Syntax: python3 scannerlol.py <ip>")
#Add a banner
print("_" * 50)
print("Scanning target: "+target)
print("Time started: "+str(datetime.now()))
print("_" * 50)
try:
for port in range(50,85): #common ports in home routers with open DNS.
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
socket.setdefaulttimeout(1)
result = s.connect_ex((target,port))
if result == 0:
print(f"Port {port} is open")
s.close()
except KeyboardInterrupt:
print("\nExiting program.")
sys.exit()
except socket.gaierror:
print("Hostname could not be resolved.")
sys.exit()
except socket.error:
print("Could not connect to server.")
sys.exit()
#run the following in the terminal to scan your network for open ports:
# python3 scannerlol.py
#enter ip to scan
#enter starting port
#enter last port to scan.
# python3 scannerlol.py (your IP) This is old