20 lines
715 B
Python
20 lines
715 B
Python
import psutil
|
|||
|
|
import time
|
||
|
|
|
||
|
|
print("Monitoring TCP connections for traffic from 202.114.4.114 for 15 seconds...")
|
||
|
|
monitor_ip = "202.114.4.114"
|
||
|
|
start = time.time()
|
||
|
|
found_any = False
|
||
|
|
|
||
|
|
while time.time() - start < 15:
|
||
|
|
connections = psutil.net_connections(kind='tcp')
|
||
|
|
for conn in connections:
|
||
|
|
# Check if remote address matches the monitor IP
|
||
|
|
if conn.raddr and conn.raddr.ip == monitor_ip:
|
||
|
|
print(f"Connection detected: Local={conn.laddr.ip}:{conn.laddr.port}, Remote={conn.raddr.ip}:{conn.raddr.port}, Status={conn.status}")
|
||
|
|
found_any = True
|
||
|
|
time.sleep(0.5)
|
||
|
|
|
||
|
|
if not found_any:
|
||
|
|
print("No TCP connections from 202.114.4.114 were detected during the 15-second window.")
|