-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProject12.py
More file actions
57 lines (40 loc) · 1.14 KB
/
Copy pathProject12.py
File metadata and controls
57 lines (40 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import socket
# Enter target IP address
target = input("Enter Target IP Address: ")
# Display scanning message
print("\nScanning Target:", target)
print("-" * 40)
# List of common ports
ports = [21, 22, 23, 80, 443]
# Start scanning
for port in ports:
# Create socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
# Set timeout
s.settimeout(1)
# Check port connection
result = s.connect_ex((target, port))
# If port is open
if result == 0:
print(f"Port {port} is OPEN")
# Identify service and risk
if port == 21:
print("Service : FTP")
print("Risk : HIGH")
elif port == 22:
print("Service : SSH")
print("Risk : MEDIUM")
elif port == 23:
print("Service : TELNET")
print("Risk : HIGH")
elif port == 80:
print("Service : HTTP")
print("Risk : MEDIUM")
elif port == 443:
print("Service : HTTPS")
print("Risk : LOW")
print("-" * 40)
# Close socket
s.close()
# Scan completed message
print("Scanning Completed")