[ ترجمه آنلاین ] دسته گل

ورود به بخش مترجم آنلاین

پیشنهاد کاربران

Winpcap !new!: Jumpstart

""" Jumpstart WinPcap Feature: Live Packet Monitor & Logger Captures packets, filters by protocol, saves summary to file. """ from scapy.all import sniff, get_windows_if_list from datetime import datetime import sys

--- Starting capture --- Filter: tcp or udp or arp Max packets: 30 | Timeout: 15s jumpstart winpcap

# Save to log file with open("packet_log.txt", "a") as log: log.write(log_line) def start_capture(interface=None, packet_count=20, timeout_sec=10, filter_str="tcp or udp or arp"): """ Capture packets with optional filter. """ Jumpstart WinPcap Feature: Live Packet Monitor &

def packet_callback(packet): """Process each captured packet.""" timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S.%f")[:-3] summary = packet.summary() log_line = f"[timestamp] summary\n" filters by protocol

def list_adapters(): """Show all network adapters available for capture.""" ifaces = get_windows_if_list() print("\n=== Available Network Adapters (WinPcap/Npcap) ===\n") for iface in ifaces: name = iface.get('name', 'Unknown') desc = iface.get('description', 'No description') ips = iface.get('ips', []) ip_str = ', '.join([ip['addr'] for ip in ips if ip.get('addr')]) if ips else 'No IP' print(f"Name: name") print(f"Description: desc") print(f"IPs: ip_str\n") return ifaces

Enter adapter NAME from above (or press Enter for default): >

try: sniff( iface=interface, count=packet_count, timeout=timeout_sec, filter=filter_str, prn=packet_callback, store=False ) except KeyboardInterrupt: print("\nCapture stopped by user.") except PermissionError: print("\nERROR: Run as Administrator to capture packets.") sys.exit(1) except Exception as e: print(f"\nERROR: e") if "No device exists" in str(e): print("Hint: Check adapter name or install Npcap/WinPcap.") sys.exit(1)