From 7ede7f0775adb37ed9e62142818054edf22d2ede Mon Sep 17 00:00:00 2001 From: aobreroes Date: Mon, 24 Mar 2025 14:58:57 +0100 Subject: [PATCH] 24032025 --- main.py | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 main.py diff --git a/main.py b/main.py new file mode 100644 index 0000000..e4f1043 --- /dev/null +++ b/main.py @@ -0,0 +1,40 @@ +# Here we import two modules, socket and time + +import socket +import time + +s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + +# here we asking for the target website +# or host +target = input('What you want to scan?: ') + +# next line gives us the ip address +# of the target +target_ip = socket.gethostbyname(target) +print('Starting scan on host:', target_ip) + +# function for scanning ports + + +def port_scan(port): + try: + s.connect((target_ip, port)) + return True + except: + return False + + +start = time.time() + + +ports= [22,80,33] +# here we are scanning port 0 to 4 +for port in ports: + if port_scan(port): + print(f'port {port} is open') + else: + print(f'port {port} is closed') + +end = time.time() +print(f'Time taken {end-start:.2f} seconds') \ No newline at end of file