Skip to content

Commit af26d56

Browse files
authored
Create network_scanner.py
1 parent f920f74 commit af26d56

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

network_scanner.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import socket
2+
print(r"""
3+
____
4+
| _ \ _ _ _
5+
| |_) ( )_ __ | | __ _ ___| |
6+
| _ - | _ \| | _ / _` |/ __| |___
7+
| |_) | | | | | (_) | (_) |\__ \ _ \
8+
|____/|_|_| |_|_,___ |\__,_|_ __/ | |_|
9+
""")
10+
print(r""" ***** Network scanning tool ***** """)
11+
def scan_ports(target, start_port, end_port):
12+
print(f"Scanning ports on {target}...\n")
13+
for port in range(start_port, end_port + 1):
14+
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
15+
sock.settimeout(1)
16+
result = sock.connect_ex((target, port))
17+
if result == 0:
18+
print(f"Port {port} is open")
19+
sock.close()
20+
21+
# Collect input from the user
22+
target_ip = input("Enter the target IP address: ")
23+
start_port = int(input("Enter the starting port: "))
24+
end_port = int(input("Enter the ending port: "))
25+
26+
# Perform the port scanning
27+
scan_ports(target_ip, start_port, end_port)

0 commit comments

Comments
 (0)