Created
October 3, 2024 17:46
-
-
Save rajkrrsingh/b0354f8450fef593a42ebedf8b081991 to your computer and use it in GitHub Desktop.
Python script using the Scapy library to monitor network traffic for given IP and Port
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from scapy.all import * | |
def monitor_xpanse_requests(ip_address, port): | |
"""Monitors network traffic for client requests. | |
""" | |
# Filter for TCP packets from the specified IP address and port | |
filter_str = f"tcp and host {ip_address} and port {port}" | |
# Start sniffing packets | |
sniff(filter=filter_str, prn=lambda pkt: print(pkt.summary())) | |
if __name__ == "__main__": | |
# Replace with the actual IP address and port of your IP and Port | |
xpanse_ip = "<IP-Address>" | |
xpanse_port = "<Port>" | |
monitor_xpanse_requests(xpanse_ip, xpanse_port) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment