mirror of
https://bitbucket.org/Mattrixwv/pytutorial.git
synced 2025-12-06 10:13:58 -05:00
Added port scanner
This commit is contained in:
22
portScanner.py
Normal file
22
portScanner.py
Normal file
@@ -0,0 +1,22 @@
|
||||
import socket
|
||||
|
||||
|
||||
print("Please enter an IP Address to scan.")
|
||||
target = input("> ")
|
||||
|
||||
print("*" * 40)
|
||||
print("* Scanning: " + target + " *")
|
||||
print("*" * 40)
|
||||
|
||||
openPorts = []
|
||||
|
||||
for port in range(1, 1025):
|
||||
print("Port: " + str(port))
|
||||
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
result = s.connect_ex((target, port))
|
||||
if result == 0:
|
||||
openPorts.append(result)
|
||||
s.close()
|
||||
|
||||
for port in openPorts:
|
||||
print("Port: " + str(port) + " Open")
|
||||
Reference in New Issue
Block a user