Skip to content

Instantly share code, notes, and snippets.

@rajkrrsingh
Created October 3, 2024 17:46
Show Gist options
  • Save rajkrrsingh/b0354f8450fef593a42ebedf8b081991 to your computer and use it in GitHub Desktop.
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
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