Simple Python Open Port Scanner

Опубликовано: 24 Март 2026
на канале: Ralph Turchiano
322
like

Cut and Paste: (Python 2 Not 3 - You will have to indent Proprerly, be familiar with sublime and running python on Kali Linux)
import socket
from datetime import datetime

target = raw_input('Enter a target: ')
targetIP = socket.gethostbyname(target)

print 'Initiated: In Progress'

start_time = datetime.now()
print 'Scan Start', start_time


try:
for port in range(1,1000):
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
result = sock.connect_ex((targetIP, port))
if result == 0:
print(str(port) + ' is opened')
sock.close()

except socket.error:
pass

time_end = datetime.now()
print 'Scan Complete',time_end

Copied by Ralph Turchiano, Thanks to Sergii Nesterenko##
File Name == PythonScannerBasic.py ##
Thanks to the Course: Cybersecurity Attacks (Red Team Activity)

#python #portscanner #code