
سنتحدث في هذا المنشور عن كيفية إنشاء سكريبت يقوم بفحص البورتات المفتوحه في الشبكه من خلال بايثون .
هناك العديد من الطرق لانشاء هذا السكربت قمت بأختيار الكود التالي الذي اثبت فعاليته على معظم أنظمه التشغيل
لقد استخدمت بعض الموديولات في بايثون مثل
import threading
from queue import Queue
import time
import socket
print_lock = threading.Lock()
target = input('Enter ip Address: ') maxport = int(input('Enter the max Number port to scan: ')) def portscan(port):
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try:
con = s.connect((target,port))
with print_lock:
print('port',port)
con.close()
except:
pass
def threader():
while True:
worker = q.get()
# Run the example job with the avail worker in queue (thread)
portscan(worker)
# completed with the job
q.task_done() q = Queue()
for x in range(100):
t = threading.Thread(target=threader)
# classifying as a daemon, so they will die when the main dies
t.daemon = True
# begins, must come after daemon definition
t.start() start = time.time()
for worker in range(1,maxport):
q.put(worker)
q.join()





