[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M71FSBKW9XMM8G01BC89W11D":3,"skill-same:01M71FSBKW9XMM8G01BC89W11D":93},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":39,"linkOnly":40,"markdownContent":41,"markdownBody":42,"frontMatter":43,"refName":66,"commitSha":67,"skillDirectory":68,"forksCount":14,"repositoryHtmlUrl":69,"repositoryHomepageUrl":6,"ownerHtmlUrl":70,"ownerBlogUrl":6,"ownerDescription":71,"updatedAt":72,"install":73,"resources":86},"01M71FSBKW9XMM8G01BC89W11D","traffic-arppoisoning-detect",null,"Detect and prevent ARP spoofing attacks using ARPWatch, Dynamic ARP Inspection, Wireshark analysis, and custom monitoring scripts to protect against man-in-the-middle interception.","DCx7C5\u002Fai-marketplace","DCx7C5","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F42419559?v=4","01M71C01G2AZV3NTNGWAWSHJPP","DC","01M71C01GQW6G50S2BYMS7PP3E",0,"MIT","https:\u002F\u002Fgithub.com\u002FDCx7C5\u002Fai-marketplace\u002Fblob\u002Fmain\u002Fskills\u002Fnetwork\u002Ftraffic\u002Farppoisoning\u002Fdetect\u002FSKILL.md",[],[19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38],"traffic arppoisoning detect","detect","traffic","sonnet","arp","security","layer","network","read","scripts","de","monitoring","analysis","Bash","man","cybersecurity","inspection","cm","layer-2-security","man-in-the-middle","2026-11-10 10:12:30",false,"---\nname: traffic-arppoisoning-detect\ndescription: Detect and prevent ARP spoofing attacks using ARPWatch, Dynamic ARP Inspection, Wireshark analysis, and custom monitoring scripts to protect against man-in-the-middle interception.\ndomain: cybersecurity\nsubdomain: network-security\ntags:\n- arp-poisoning\n- arp-spoofing\n- mitm\n- dynamic-arp-inspection\n- arpwatch\n- network-security\n- man-in-the-middle\n- layer-2-security\nnist_csf:\n- PR.IR-01\n- DE.CM-01\n- ID.AM-03\n- PR.DS-02\nmodel: sonnet\nmaxTurns: 20\ntools: [Read, Bash, Glob, Grep]\nmitre_attack:\n- T1059\n- T1557\n- T1557.002\ncapec: []\n---\n\n# Detecting ARP Poisoning in Network Traffic\n\n## Overview\n\nARP poisoning (ARP spoofing) is a Layer 2 attack where an adversary sends falsified ARP messages to associate their MAC address with the IP address of a legitimate host, enabling man-in-the-middle (MitM) interception, session hijacking, or denial of service. Since ARP has no built-in authentication mechanism, any device on a broadcast domain can forge ARP replies. Detection requires monitoring ARP traffic for anomalies such as gratuitous ARP floods, IP-to-MAC mapping changes, and duplicate IP addresses. This skill covers deploying multiple detection layers including ARPWatch, Dynamic ARP Inspection (DAI), Wireshark-based analysis, and custom Python monitoring tools.\n\n\n## When to Use\n\n- When investigating security incidents that require detecting arp poisoning in network traffic\n- When building detection rules or threat hunting queries for this domain\n- When SOC analysts need structured procedures for this analysis type\n- When validating security monitoring coverage for related attack techniques\n\n## Prerequisites\n\n- Access to the target network segment (broadcast domain)\n- Linux host for ARPWatch and custom monitoring tools\n- Managed switches supporting Dynamic ARP Inspection (Cisco Catalyst, Aruba, Juniper EX)\n- Wireshark or tcpdump for packet capture\n- DHCP snooping configured (prerequisite for DAI)\n- Network monitoring infrastructure (SIEM, syslog server)\n\n## Core Concepts\n\n### ARP Protocol Fundamentals\n\nARP maps IP addresses to MAC addresses on a local network segment. The protocol operates statelessly with no authentication:\n\n```\nNormal ARP Process:\n1. Host A broadcasts: \"Who has 10.0.1.1? Tell 10.0.1.100\"\n2. Router replies: \"10.0.1.1 is at AA:BB:CC:DD:EE:01\"\n3. Host A caches the mapping\n\nARP Poisoning Attack:\n1. Attacker sends unsolicited ARP reply to Host A:\n   \"10.0.1.1 is at EV:IL:MA:CA:DD:RR\" (attacker's MAC)\n2. Host A updates cache, sends traffic to attacker\n3. Attacker forwards to real gateway (MitM position)\n```\n\n### Attack Indicators\n\n| Indicator | Description | Severity |\n|-----------|-------------|----------|\n| MAC flip-flopping | Same IP mapped to different MACs rapidly | High |\n| Gratuitous ARP flood | Unsolicited ARP replies targeting multiple hosts | High |\n| Duplicate IP address | Two different MACs claiming same IP | Critical |\n| Unusual ARP volume | Spike in ARP packets per second | Medium |\n| ARP from non-DHCP source | Static IP claims from unknown devices | Medium |\n| Gateway MAC change | Default gateway MAC address changed | Critical |\n\n## Workflow\n\n### Step 1: Deploy ARPWatch for Continuous Monitoring\n\n```bash\n# Install ARPWatch\nsudo apt-get install -y arpwatch\n\n# Configure ARPWatch\nsudo vi \u002Fetc\u002Fdefault\u002Farpwatch\n# INTERFACES=\"eth0\"\n# ARGS=\"-N -p -i eth0 -f \u002Fvar\u002Flibs\u002Farpwatch\u002Farp.dat\"\n\n# Start monitoring\nsudo systemctl enable arpwatch\nsudo systemctl start arpwatch\n\n# View current ARP database\ncat \u002Fvar\u002Flibs\u002Farpwatch\u002Farp.dat\n\n# Monitor logs for changes\ntail -f \u002Fvar\u002Flog\u002Fsyslog | grep arpwatch\n```\n\nARPWatch alert types:\n- **new station** - Previously unseen MAC address\n- **changed ethernet address** - IP mapped to different MAC (potential poisoning)\n- **flip flop** - MAC alternating between two addresses (active attack)\n- **reused old ethernet address** - Previously seen mapping returned\n\n### Step 2: Configure Dynamic ARP Inspection (DAI) on Switches\n\n**Cisco Catalyst configuration:**\n\n```\n! Enable DHCP snooping (prerequisite for DAI)\nip dhcp snooping\nip dhcp snooping vlan 10,20,30\n\n! Configure trusted ports (uplinks, DHCP servers)\ninterface GigabitEthernet1\u002F0\u002F1\n description Uplink to Distribution\n ip dhcp snooping trust\n\ninterface GigabitEthernet1\u002F0\u002F48\n description DHCP Server\n ip dhcp snooping trust\n\n! Enable Dynamic ARP Inspection\nip arp inspection vlan 10,20,30\n\n! Configure trusted ports for DAI\ninterface GigabitEthernet1\u002F0\u002F1\n ip arp inspection trust\n\n! Set rate limits to prevent ARP flood DoS\ninterface range GigabitEthernet1\u002F0\u002F2-47\n ip arp inspection limit rate 15\n\n! Enable additional validation checks\nip arp inspection validate src-mac dst-mac ip\n\n! Configure ARP ACL for static IP devices (servers, printers)\narp access-list STATIC-ARP-ENTRIES\n permit ip host 10.0.10.100 mac host 0011.2233.4455\n permit ip host 10.0.10.101 mac host 0011.2233.4456\n\nip arp inspection filter STATIC-ARP-ENTRIES vlan 10\n\n! Verify DAI status\nshow ip arp inspection vlan 10\nshow ip arp inspection statistics\nshow ip dhcp snooping binding\n```\n\n### Step 3: Wireshark Detection Filters\n\n```\n# Detect gratuitous ARP (sender and target IP are the same)\narp.src.proto_ipv4 == arp.dst.proto_ipv4\n\n# Detect ARP replies (focus on unsolicited)\narp.opcode == 2\n\n# Detect duplicate IP address claims\narp.duplicate-address-detected\n\n# Detect ARP packets from specific attacker MAC\neth.src == ev:il:ma:ca:dd:rr\n\n# Detect ARP storms (high volume)\n# Use Statistics > I\u002FO Graphs > Display filter: arp\n\n# Detect gateway impersonation\narp.src.proto_ipv4 == 10.0.1.1 && arp.src.hw_mac != aa:bb:cc:dd:ee:01\n```\n\n### Step 4: Custom Python ARP Monitor\n\n```python\n#!\u002Fusr\u002Fbin\u002Fenv python3\n\"\"\"\nReal-time ARP poisoning detection using packet capture.\nMonitors ARP traffic for spoofing indicators and alerts on anomalies.\n\"\"\"\n\nimport subprocess\nimport sys\nimport json\nimport time\nfrom collections import defaultdict\nfrom datetime import datetime\n\ntry:\n    from scapy.all import sniff, ARP, Ether, get_if_hwaddr, conf\n    SCAPY_AVAILABLE = True\nexcept ImportError:\n    SCAPY_AVAILABLE = False\n\n\nclass ARPPoisonDetector:\n    def __init__(self, interface: str, gateway_ip: str, gateway_mac: str):\n        self.interface = interface\n        self.gateway_ip = gateway_ip\n        self.gateway_mac = gateway_mac.lower()\n        self.arp_table = {}  # IP -> MAC mapping\n        self.arp_history = defaultdict(list)  # IP -> list of (MAC, timestamp)\n        self.alerts = []\n        self.arp_count = defaultdict(int)  # Source MAC -> count per interval\n        self.last_reset = time.time()\n        self.arp_rate_threshold = 50  # ARP packets per 10 seconds\n\n    def alert(self, severity: str, message: str, details: dict):\n        \"\"\"Generate alert for detected anomaly.\"\"\"\n        alert_data = {\n            'timestamp': datetime.now().isoformat(),\n            'severity': severity,\n            'message': message,\n            'details': details,\n        }\n        self.alerts.append(alert_data)\n        print(f\"\\n[{severity}] {datetime.now().strftime('%H:%M:%S')} - {message}\")\n        for key, value in details.items():\n            print(f\"  {key}: {value}\")\n\n    def check_gateway_spoofing(self, src_ip: str, src_mac: str):\n        \"\"\"Check if someone is spoofing the gateway.\"\"\"\n        if src_ip == self.gateway_ip and src_mac != self.gateway_mac:\n            self.alert('CRITICAL', 'Gateway ARP Spoofing Detected', {\n                'gateway_ip': self.gateway_ip,\n                'expected_mac': self.gateway_mac,\n                'spoofed_mac': src_mac,\n                'action': 'Potential MitM attack on default gateway',\n            })\n            return True\n        return False\n\n    def check_mac_change(self, src_ip: str, src_mac: str):\n        \"\"\"Check if IP-to-MAC mapping has changed.\"\"\"\n        if src_ip in self.arp_table:\n            known_mac = self.arp_table[src_ip]\n            if known_mac != src_mac:\n                self.alert('HIGH', 'ARP Cache Poisoning Attempt', {\n                    'ip_address': src_ip,\n                    'previous_mac': known_mac,\n                    'new_mac': src_mac,\n                    'action': 'IP-to-MAC mapping changed unexpectedly',\n                })\n                return True\n        return False\n\n    def check_flip_flop(self, src_ip: str, src_mac: str):\n        \"\"\"Check for MAC address flip-flopping (active attack indicator).\"\"\"\n        self.arp_history[src_ip].append((src_mac, time.time()))\n\n        # Keep only last 60 seconds of history\n        cutoff = time.time() - 60\n        self.arp_history[src_ip] = [\n            (mac, ts) for mac, ts in self.arp_history[src_ip]\n            if ts > cutoff\n        ]\n\n        unique_macs = set(mac for mac, ts in self.arp_history[src_ip])\n        if len(unique_macs) > 2:\n            self.alert('CRITICAL', 'ARP Flip-Flop Detected (Active Attack)', {\n                'ip_address': src_ip,\n                'mac_addresses': list(unique_macs),\n                'changes_in_60s': len(self.arp_history[src_ip]),\n            })\n            return True\n        return False\n\n    def check_arp_rate(self, src_mac: str):\n        \"\"\"Check for ARP flood (DoS or scanning).\"\"\"\n        self.arp_count[src_mac] += 1\n\n        # Reset counters every 10 seconds\n        if time.time() - self.last_reset > 10:\n            for mac, count in self.arp_count.items():\n                if count > self.arp_rate_threshold:\n                    self.alert('MEDIUM', 'ARP Flood Detected', {\n                        'source_mac': mac,\n                        'arp_packets_10s': count,\n                        'threshold': self.arp_rate_threshold,\n                    })\n            self.arp_count.clear()\n            self.last_reset = time.time()\n\n    def process_packet(self, packet):\n        \"\"\"Process captured ARP packet.\"\"\"\n        if not packet.haslayer(ARP):\n            return\n\n        arp = packet[ARP]\n\n        # Only process ARP replies (opcode 2) and requests (opcode 1)\n        if arp.op not in (1, 2):\n            return\n\n        src_ip = arp.psrc\n        src_mac = arp.hwsrc.lower()\n\n        # Run detection checks\n        self.check_gateway_spoofing(src_ip, src_mac)\n        self.check_mac_change(src_ip, src_mac)\n        self.check_flip_flop(src_ip, src_mac)\n        self.check_arp_rate(src_mac)\n\n        # Update ARP table\n        self.arp_table[src_ip] = src_mac\n\n    def start_monitoring(self):\n        \"\"\"Start real-time ARP monitoring.\"\"\"\n        print(f\"[*] Starting ARP Poison Detection on {self.interface}\")\n        print(f\"[*] Gateway: {self.gateway_ip} ({self.gateway_mac})\")\n        print(f\"[*] Monitoring... (Ctrl+C to stop)\\n\")\n\n        if SCAPY_AVAILABLE:\n            sniff(\n                iface=self.interface,\n                filter=\"arp\",\n                prn=self.process_packet,\n                store=False,\n            )\n        else:\n            print(\"[-] Scapy not available. Install with: pip install scapy\")\n            print(\"[*] Falling back to tcpdump-based monitoring...\")\n            self._monitor_with_tcpdump()\n\n    def _monitor_with_tcpdump(self):\n        \"\"\"Fallback monitoring using tcpdump.\"\"\"\n        cmd = ['tcpdump', '-i', self.interface, '-l', '-n', 'arp']\n        proc = subprocess.Popen(cmd, stdout=subprocess.PIPE,\n                                stderr=subprocess.DEVNULL, text=True)\n        try:\n            for line in proc.stdout:\n                parts = line.strip().split()\n                if 'is-at' in parts:\n                    try:\n                        ip_idx = parts.index('is-at') - 1\n                        mac_idx = parts.index('is-at') + 1\n                        src_ip = parts[ip_idx]\n                        src_mac = parts[mac_idx].lower()\n                        self.check_gateway_spoofing(src_ip, src_mac)\n                        self.check_mac_change(src_ip, src_mac)\n                        self.arp_table[src_ip] = src_mac\n                    except (IndexError, ValueError):\n                        continue\n        except KeyboardInterrupt:\n            proc.terminate()\n\n    def generate_report(self) -> dict:\n        \"\"\"Generate summary report of detected anomalies.\"\"\"\n        return {\n            'monitoring_interface': self.interface,\n            'gateway': {'ip': self.gateway_ip, 'mac': self.gateway_mac},\n            'total_alerts': len(self.alerts),\n            'arp_table_size': len(self.arp_table),\n            'alerts': self.alerts,\n        }\n\n\nif __name__ == '__main__':\n    if len(sys.argv) \u003C 4:\n        print(\"Usage: python process.py \u003Cinterface> \u003Cgateway_ip> \u003Cgateway_mac>\")\n        print(\"Example: python process.py eth0 10.0.1.1 aa:bb:cc:dd:ee:01\")\n        sys.exit(1)\n\n    detector = ARPPoisonDetector(\n        interface=sys.argv[1],\n        gateway_ip=sys.argv[2],\n        gateway_mac=sys.argv[3],\n    )\n\n    try:\n        detector.start_monitoring()\n    except KeyboardInterrupt:\n        print(\"\\n\\n[*] Monitoring stopped.\")\n        report = detector.generate_report()\n        print(f\"[*] Total alerts generated: {report['total_alerts']}\")\n        print(f\"[*] ARP table entries: {report['arp_table_size']}\")\n```\n\n## Prevention Measures\n\n### Layer 2 Controls\n\n1. **Dynamic ARP Inspection (DAI)** - Validates ARP packets against DHCP snooping binding table\n2. **DHCP Snooping** - Builds trusted IP-MAC-port binding database\n3. **Port Security** - Limits MAC addresses per port\n4. **Private VLANs** - Restricts communication between hosts in the same VLAN\n\n### Network Controls\n\n1. **Static ARP Entries** - For critical infrastructure (gateways, DNS, DHCP)\n2. **Network Segmentation** - Reduce broadcast domain size with VLANs\n3. **802.1X Authentication** - Authenticate devices before network access\n4. **Encrypted Protocols** - Use SSH, HTTPS, TLS to protect data even if intercepted\n\n## Best Practices\n\n- **Defense in Depth** - Combine DAI, ARPWatch, and custom monitoring for comprehensive coverage\n- **DHCP Snooping First** - Always enable DHCP snooping before DAI (DAI depends on snooping database)\n- **Static ARP for Gateways** - Configure static ARP entries on critical servers for the default gateway\n- **Monitor Gratuitous ARP** - Pay special attention to unsolicited ARP replies\n- **Small Broadcast Domains** - Use VLANs to limit the scope of ARP-based attacks\n- **Regular Audits** - Periodically compare ARP tables across devices to identify anomalies\n\n## References\n\n- [NIST SP 800-54 - Border Gateway Protocol Security](https:\u002F\u002Fcsrc.nist.gov\u002Fpublications\u002Fdetail\u002Fsp\u002F800-54\u002Ffinal)\n- [Cisco DAI Configuration Guide](https:\u002F\u002Fwww.cisco.com\u002Fc\u002Fen\u002Fus\u002Ftd\u002Fdocs\u002Fswitches\u002Flan\u002Fcatalyst9300\u002Fsoftware\u002Frelease\u002F16-12\u002Fconfiguration_guide\u002Fsec\u002Fb_1612_sec_9300_cg\u002Fconfiguring_dynamic_arp_inspection.html)\n- [Comparitech ARP Poisoning Guide](https:\u002F\u002Fwww.comparitech.com\u002Fblog\u002Finformation-security\u002Farp-poisoning-spoofing-detect-prevent\u002F)\n- [Okta ARP Poisoning Techniques](https:\u002F\u002Fwww.okta.com\u002Fidentity-101\u002Farp-poisoning\u002F)\n","# Detecting ARP Poisoning in Network Traffic\n\n## Overview\n\nARP poisoning (ARP spoofing) is a Layer 2 attack where an adversary sends falsified ARP messages to associate their MAC address with the IP address of a legitimate host, enabling man-in-the-middle (MitM) interception, session hijacking, or denial of service. Since ARP has no built-in authentication mechanism, any device on a broadcast domain can forge ARP replies. Detection requires monitoring ARP traffic for anomalies such as gratuitous ARP floods, IP-to-MAC mapping changes, and duplicate IP addresses. This skill covers deploying multiple detection layers including ARPWatch, Dynamic ARP Inspection (DAI), Wireshark-based analysis, and custom Python monitoring tools.\n\n\n## When to Use\n\n- When investigating security incidents that require detecting arp poisoning in network traffic\n- When building detection rules or threat hunting queries for this domain\n- When SOC analysts need structured procedures for this analysis type\n- When validating security monitoring coverage for related attack techniques\n\n## Prerequisites\n\n- Access to the target network segment (broadcast domain)\n- Linux host for ARPWatch and custom monitoring tools\n- Managed switches supporting Dynamic ARP Inspection (Cisco Catalyst, Aruba, Juniper EX)\n- Wireshark or tcpdump for packet capture\n- DHCP snooping configured (prerequisite for DAI)\n- Network monitoring infrastructure (SIEM, syslog server)\n\n## Core Concepts\n\n### ARP Protocol Fundamentals\n\nARP maps IP addresses to MAC addresses on a local network segment. The protocol operates statelessly with no authentication:\n\n```\nNormal ARP Process:\n1. Host A broadcasts: \"Who has 10.0.1.1? Tell 10.0.1.100\"\n2. Router replies: \"10.0.1.1 is at AA:BB:CC:DD:EE:01\"\n3. Host A caches the mapping\n\nARP Poisoning Attack:\n1. Attacker sends unsolicited ARP reply to Host A:\n   \"10.0.1.1 is at EV:IL:MA:CA:DD:RR\" (attacker's MAC)\n2. Host A updates cache, sends traffic to attacker\n3. Attacker forwards to real gateway (MitM position)\n```\n\n### Attack Indicators\n\n| Indicator | Description | Severity |\n|-----------|-------------|----------|\n| MAC flip-flopping | Same IP mapped to different MACs rapidly | High |\n| Gratuitous ARP flood | Unsolicited ARP replies targeting multiple hosts | High |\n| Duplicate IP address | Two different MACs claiming same IP | Critical |\n| Unusual ARP volume | Spike in ARP packets per second | Medium |\n| ARP from non-DHCP source | Static IP claims from unknown devices | Medium |\n| Gateway MAC change | Default gateway MAC address changed | Critical |\n\n## Workflow\n\n### Step 1: Deploy ARPWatch for Continuous Monitoring\n\n```bash\n# Install ARPWatch\nsudo apt-get install -y arpwatch\n\n# Configure ARPWatch\nsudo vi \u002Fetc\u002Fdefault\u002Farpwatch\n# INTERFACES=\"eth0\"\n# ARGS=\"-N -p -i eth0 -f \u002Fvar\u002Flibs\u002Farpwatch\u002Farp.dat\"\n\n# Start monitoring\nsudo systemctl enable arpwatch\nsudo systemctl start arpwatch\n\n# View current ARP database\ncat \u002Fvar\u002Flibs\u002Farpwatch\u002Farp.dat\n\n# Monitor logs for changes\ntail -f \u002Fvar\u002Flog\u002Fsyslog | grep arpwatch\n```\n\nARPWatch alert types:\n- **new station** - Previously unseen MAC address\n- **changed ethernet address** - IP mapped to different MAC (potential poisoning)\n- **flip flop** - MAC alternating between two addresses (active attack)\n- **reused old ethernet address** - Previously seen mapping returned\n\n### Step 2: Configure Dynamic ARP Inspection (DAI) on Switches\n\n**Cisco Catalyst configuration:**\n\n```\n! Enable DHCP snooping (prerequisite for DAI)\nip dhcp snooping\nip dhcp snooping vlan 10,20,30\n\n! Configure trusted ports (uplinks, DHCP servers)\ninterface GigabitEthernet1\u002F0\u002F1\n description Uplink to Distribution\n ip dhcp snooping trust\n\ninterface GigabitEthernet1\u002F0\u002F48\n description DHCP Server\n ip dhcp snooping trust\n\n! Enable Dynamic ARP Inspection\nip arp inspection vlan 10,20,30\n\n! Configure trusted ports for DAI\ninterface GigabitEthernet1\u002F0\u002F1\n ip arp inspection trust\n\n! Set rate limits to prevent ARP flood DoS\ninterface range GigabitEthernet1\u002F0\u002F2-47\n ip arp inspection limit rate 15\n\n! Enable additional validation checks\nip arp inspection validate src-mac dst-mac ip\n\n! Configure ARP ACL for static IP devices (servers, printers)\narp access-list STATIC-ARP-ENTRIES\n permit ip host 10.0.10.100 mac host 0011.2233.4455\n permit ip host 10.0.10.101 mac host 0011.2233.4456\n\nip arp inspection filter STATIC-ARP-ENTRIES vlan 10\n\n! Verify DAI status\nshow ip arp inspection vlan 10\nshow ip arp inspection statistics\nshow ip dhcp snooping binding\n```\n\n### Step 3: Wireshark Detection Filters\n\n```\n# Detect gratuitous ARP (sender and target IP are the same)\narp.src.proto_ipv4 == arp.dst.proto_ipv4\n\n# Detect ARP replies (focus on unsolicited)\narp.opcode == 2\n\n# Detect duplicate IP address claims\narp.duplicate-address-detected\n\n# Detect ARP packets from specific attacker MAC\neth.src == ev:il:ma:ca:dd:rr\n\n# Detect ARP storms (high volume)\n# Use Statistics > I\u002FO Graphs > Display filter: arp\n\n# Detect gateway impersonation\narp.src.proto_ipv4 == 10.0.1.1 && arp.src.hw_mac != aa:bb:cc:dd:ee:01\n```\n\n### Step 4: Custom Python ARP Monitor\n\n```python\n#!\u002Fusr\u002Fbin\u002Fenv python3\n\"\"\"\nReal-time ARP poisoning detection using packet capture.\nMonitors ARP traffic for spoofing indicators and alerts on anomalies.\n\"\"\"\n\nimport subprocess\nimport sys\nimport json\nimport time\nfrom collections import defaultdict\nfrom datetime import datetime\n\ntry:\n    from scapy.all import sniff, ARP, Ether, get_if_hwaddr, conf\n    SCAPY_AVAILABLE = True\nexcept ImportError:\n    SCAPY_AVAILABLE = False\n\n\nclass ARPPoisonDetector:\n    def __init__(self, interface: str, gateway_ip: str, gateway_mac: str):\n        self.interface = interface\n        self.gateway_ip = gateway_ip\n        self.gateway_mac = gateway_mac.lower()\n        self.arp_table = {}  # IP -> MAC mapping\n        self.arp_history = defaultdict(list)  # IP -> list of (MAC, timestamp)\n        self.alerts = []\n        self.arp_count = defaultdict(int)  # Source MAC -> count per interval\n        self.last_reset = time.time()\n        self.arp_rate_threshold = 50  # ARP packets per 10 seconds\n\n    def alert(self, severity: str, message: str, details: dict):\n        \"\"\"Generate alert for detected anomaly.\"\"\"\n        alert_data = {\n            'timestamp': datetime.now().isoformat(),\n            'severity': severity,\n            'message': message,\n            'details': details,\n        }\n        self.alerts.append(alert_data)\n        print(f\"\\n[{severity}] {datetime.now().strftime('%H:%M:%S')} - {message}\")\n        for key, value in details.items():\n            print(f\"  {key}: {value}\")\n\n    def check_gateway_spoofing(self, src_ip: str, src_mac: str):\n        \"\"\"Check if someone is spoofing the gateway.\"\"\"\n        if src_ip == self.gateway_ip and src_mac != self.gateway_mac:\n            self.alert('CRITICAL', 'Gateway ARP Spoofing Detected', {\n                'gateway_ip': self.gateway_ip,\n                'expected_mac': self.gateway_mac,\n                'spoofed_mac': src_mac,\n                'action': 'Potential MitM attack on default gateway',\n            })\n            return True\n        return False\n\n    def check_mac_change(self, src_ip: str, src_mac: str):\n        \"\"\"Check if IP-to-MAC mapping has changed.\"\"\"\n        if src_ip in self.arp_table:\n            known_mac = self.arp_table[src_ip]\n            if known_mac != src_mac:\n                self.alert('HIGH', 'ARP Cache Poisoning Attempt', {\n                    'ip_address': src_ip,\n                    'previous_mac': known_mac,\n                    'new_mac': src_mac,\n                    'action': 'IP-to-MAC mapping changed unexpectedly',\n                })\n                return True\n        return False\n\n    def check_flip_flop(self, src_ip: str, src_mac: str):\n        \"\"\"Check for MAC address flip-flopping (active attack indicator).\"\"\"\n        self.arp_history[src_ip].append((src_mac, time.time()))\n\n        # Keep only last 60 seconds of history\n        cutoff = time.time() - 60\n        self.arp_history[src_ip] = [\n            (mac, ts) for mac, ts in self.arp_history[src_ip]\n            if ts > cutoff\n        ]\n\n        unique_macs = set(mac for mac, ts in self.arp_history[src_ip])\n        if len(unique_macs) > 2:\n            self.alert('CRITICAL', 'ARP Flip-Flop Detected (Active Attack)', {\n                'ip_address': src_ip,\n                'mac_addresses': list(unique_macs),\n                'changes_in_60s': len(self.arp_history[src_ip]),\n            })\n            return True\n        return False\n\n    def check_arp_rate(self, src_mac: str):\n        \"\"\"Check for ARP flood (DoS or scanning).\"\"\"\n        self.arp_count[src_mac] += 1\n\n        # Reset counters every 10 seconds\n        if time.time() - self.last_reset > 10:\n            for mac, count in self.arp_count.items():\n                if count > self.arp_rate_threshold:\n                    self.alert('MEDIUM', 'ARP Flood Detected', {\n                        'source_mac': mac,\n                        'arp_packets_10s': count,\n                        'threshold': self.arp_rate_threshold,\n                    })\n            self.arp_count.clear()\n            self.last_reset = time.time()\n\n    def process_packet(self, packet):\n        \"\"\"Process captured ARP packet.\"\"\"\n        if not packet.haslayer(ARP):\n            return\n\n        arp = packet[ARP]\n\n        # Only process ARP replies (opcode 2) and requests (opcode 1)\n        if arp.op not in (1, 2):\n            return\n\n        src_ip = arp.psrc\n        src_mac = arp.hwsrc.lower()\n\n        # Run detection checks\n        self.check_gateway_spoofing(src_ip, src_mac)\n        self.check_mac_change(src_ip, src_mac)\n        self.check_flip_flop(src_ip, src_mac)\n        self.check_arp_rate(src_mac)\n\n        # Update ARP table\n        self.arp_table[src_ip] = src_mac\n\n    def start_monitoring(self):\n        \"\"\"Start real-time ARP monitoring.\"\"\"\n        print(f\"[*] Starting ARP Poison Detection on {self.interface}\")\n        print(f\"[*] Gateway: {self.gateway_ip} ({self.gateway_mac})\")\n        print(f\"[*] Monitoring... (Ctrl+C to stop)\\n\")\n\n        if SCAPY_AVAILABLE:\n            sniff(\n                iface=self.interface,\n                filter=\"arp\",\n                prn=self.process_packet,\n                store=False,\n            )\n        else:\n            print(\"[-] Scapy not available. Install with: pip install scapy\")\n            print(\"[*] Falling back to tcpdump-based monitoring...\")\n            self._monitor_with_tcpdump()\n\n    def _monitor_with_tcpdump(self):\n        \"\"\"Fallback monitoring using tcpdump.\"\"\"\n        cmd = ['tcpdump', '-i', self.interface, '-l', '-n', 'arp']\n        proc = subprocess.Popen(cmd, stdout=subprocess.PIPE,\n                                stderr=subprocess.DEVNULL, text=True)\n        try:\n            for line in proc.stdout:\n                parts = line.strip().split()\n                if 'is-at' in parts:\n                    try:\n                        ip_idx = parts.index('is-at') - 1\n                        mac_idx = parts.index('is-at') + 1\n                        src_ip = parts[ip_idx]\n                        src_mac = parts[mac_idx].lower()\n                        self.check_gateway_spoofing(src_ip, src_mac)\n                        self.check_mac_change(src_ip, src_mac)\n                        self.arp_table[src_ip] = src_mac\n                    except (IndexError, ValueError):\n                        continue\n        except KeyboardInterrupt:\n            proc.terminate()\n\n    def generate_report(self) -> dict:\n        \"\"\"Generate summary report of detected anomalies.\"\"\"\n        return {\n            'monitoring_interface': self.interface,\n            'gateway': {'ip': self.gateway_ip, 'mac': self.gateway_mac},\n            'total_alerts': len(self.alerts),\n            'arp_table_size': len(self.arp_table),\n            'alerts': self.alerts,\n        }\n\n\nif __name__ == '__main__':\n    if len(sys.argv) \u003C 4:\n        print(\"Usage: python process.py \u003Cinterface> \u003Cgateway_ip> \u003Cgateway_mac>\")\n        print(\"Example: python process.py eth0 10.0.1.1 aa:bb:cc:dd:ee:01\")\n        sys.exit(1)\n\n    detector = ARPPoisonDetector(\n        interface=sys.argv[1],\n        gateway_ip=sys.argv[2],\n        gateway_mac=sys.argv[3],\n    )\n\n    try:\n        detector.start_monitoring()\n    except KeyboardInterrupt:\n        print(\"\\n\\n[*] Monitoring stopped.\")\n        report = detector.generate_report()\n        print(f\"[*] Total alerts generated: {report['total_alerts']}\")\n        print(f\"[*] ARP table entries: {report['arp_table_size']}\")\n```\n\n## Prevention Measures\n\n### Layer 2 Controls\n\n1. **Dynamic ARP Inspection (DAI)** - Validates ARP packets against DHCP snooping binding table\n2. **DHCP Snooping** - Builds trusted IP-MAC-port binding database\n3. **Port Security** - Limits MAC addresses per port\n4. **Private VLANs** - Restricts communication between hosts in the same VLAN\n\n### Network Controls\n\n1. **Static ARP Entries** - For critical infrastructure (gateways, DNS, DHCP)\n2. **Network Segmentation** - Reduce broadcast domain size with VLANs\n3. **802.1X Authentication** - Authenticate devices before network access\n4. **Encrypted Protocols** - Use SSH, HTTPS, TLS to protect data even if intercepted\n\n## Best Practices\n\n- **Defense in Depth** - Combine DAI, ARPWatch, and custom monitoring for comprehensive coverage\n- **DHCP Snooping First** - Always enable DHCP snooping before DAI (DAI depends on snooping database)\n- **Static ARP for Gateways** - Configure static ARP entries on critical servers for the default gateway\n- **Monitor Gratuitous ARP** - Pay special attention to unsolicited ARP replies\n- **Small Broadcast Domains** - Use VLANs to limit the scope of ARP-based attacks\n- **Regular Audits** - Periodically compare ARP tables across devices to identify anomalies\n\n## References\n\n- [NIST SP 800-54 - Border Gateway Protocol Security](https:\u002F\u002Fcsrc.nist.gov\u002Fpublications\u002Fdetail\u002Fsp\u002F800-54\u002Ffinal)\n- [Cisco DAI Configuration Guide](https:\u002F\u002Fwww.cisco.com\u002Fc\u002Fen\u002Fus\u002Ftd\u002Fdocs\u002Fswitches\u002Flan\u002Fcatalyst9300\u002Fsoftware\u002Frelease\u002F16-12\u002Fconfiguration_guide\u002Fsec\u002Fb_1612_sec_9300_cg\u002Fconfiguring_dynamic_arp_inspection.html)\n- [Comparitech ARP Poisoning Guide](https:\u002F\u002Fwww.comparitech.com\u002Fblog\u002Finformation-security\u002Farp-poisoning-spoofing-detect-prevent\u002F)\n- [Okta ARP Poisoning Techniques](https:\u002F\u002Fwww.okta.com\u002Fidentity-101\u002Farp-poisoning\u002F)\n",{"name":5,"tags":44,"capec":51,"model":22,"tools":52,"domain":34,"maxTurns":56,"nist_csf":57,"subdomain":50,"description":7,"mitre_attack":62},[45,46,47,48,49,50,38,37],"arp-poisoning","arp-spoofing","mitm","dynamic-arp-inspection","arpwatch","network-security",[],[53,32,54,55],"Read","Glob","Grep",20,[58,59,60,61],"PR.IR-01","DE.CM-01","ID.AM-03","PR.DS-02",[63,64,65],"T1059","T1557","T1557.002","main","a91f1293287ffa9f4f1b8f486cd6e835a1568c84","skills\u002Fnetwork\u002Ftraffic\u002Farppoisoning\u002Fdetect","https:\u002F\u002Fgithub.com\u002FDCx7C5\u002Fai-marketplace","https:\u002F\u002Fgithub.com\u002FDCx7C5","#Python","2026-09-01 11:21:00",{"source":8,"skillName":5,"commands":74,"prompt":84,"zipAvailable":85},[75,78,81],{"tool":76,"command":77},"npx","npx skills add DCx7C5\u002Fai-marketplace --skill traffic-arppoisoning-detect",{"tool":79,"command":80},"bunx","bunx skills add DCx7C5\u002Fai-marketplace --skill traffic-arppoisoning-detect",{"tool":82,"command":83},"pnpm","pnpm dlx skills add DCx7C5\u002Fai-marketplace --skill traffic-arppoisoning-detect","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FDCx7C5\u002Fai-marketplace\u002Fblob\u002Fmain\u002Fskills\u002Fnetwork\u002Ftraffic\u002Farppoisoning\u002Fdetect\u002FSKILL.md",true,[87],{"path":88,"resourceType":89,"resourceTypeDesc":90,"sizeBytes":91,"sourceHtmlUrl":92},"index.json","REFERENCE","参考文档",676,"https:\u002F\u002Fgithub.com\u002FDCx7C5\u002Fai-marketplace\u002Fblob\u002Fmain\u002Fskills\u002Fnetwork\u002Ftraffic\u002Farppoisoning\u002Fdetect\u002Findex.json",[94,116,135,156,178,194],{"skillNo":95,"name":96,"nameZh":6,"description":97,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":98,"categories":99,"keywords":100,"publishedAt":39},"01M71HAPZ01KQ30RKTB0FFSQ05","services-wmi-persistence-detect","Detect WMI event subscription persistence by enumerating ActiveScriptEventConsumer, CommandLineEventConsumer, and permanent subscriptions in the WMI repository.","https:\u002F\u002Fgithub.com\u002FDCx7C5\u002Fai-marketplace\u002Fblob\u002Fmain\u002Fskills\u002Fwindows\u002Fservices\u002Fwmi\u002Fpersistence\u002Fdetect\u002FSKILL.md",[],[101,20,102,103,104,29,36,105,106,107,108,109,110,111,112,113,114,34,115],"services","services wmi persistence detect","wmi","persistence","process","activescript","event","subscriptions","commandline-consumer","repository","subscription","event-subscription","t1546.003","forensics","process-forensics",{"skillNo":117,"name":118,"nameZh":6,"description":119,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":120,"categories":121,"keywords":122,"publishedAt":39},"01M71HAK6JTTTS229T17WJMMCG","services-wmi-exec-exploit","Perform lateral movement across Windows networks using WMI-based remote execution techniques including Impacket wmiexec.py, CrackMapExec, and native WMI commands for stealthy post-exploitation during red team engagements.","https:\u002F\u002Fgithub.com\u002FDCx7C5\u002Fai-marketplace\u002Fblob\u002Fmain\u002Fskills\u002Fwindows\u002Fservices\u002Fwmi\u002Fexec\u002Fexploit\u002FSKILL.md",[],[123,101,124,103,125,126,21,34,32,31,127,128,129,130,29,131,132,27,133,134],"exploit","services wmi exec exploit","exec","remote","team","across","crackmapexec","native","command","lateral movement","lateral-movement","Impacket",{"skillNo":136,"name":137,"nameZh":6,"description":138,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":139,"categories":140,"keywords":141,"publishedAt":39},"01M71HAG6MHKNQV8KDZKMT4886","registry-artifact-extract","Extract and analyze Windows Registry hives to uncover user activity, installed software, autostart entries, and evidence of system compromise.","https:\u002F\u002Fgithub.com\u002FDCx7C5\u002Fai-marketplace\u002Fblob\u002Fmain\u002Fskills\u002Fwindows\u002Fregistry\u002Fartifact\u002Fextract\u002FSKILL.md",[],[142,143,144,145,146,147,34,32,148,31,149,150,29,27,151,152,153,154,155,22],"artifact","registry","registry artifact extract","extract","evidence-collection","artifact-analysis","collection","analyze","uncover","software","activity","digital-forensics","windows-registry","regripper",{"skillNo":157,"name":158,"nameZh":6,"description":159,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":160,"categories":161,"keywords":162,"publishedAt":39},"01M71HACR4A8XTWTTSXK4124AA","processes-token-impersonate-detect","Detect Windows token impersonation and privilege abuse including SeImpersonatePrivilege exploitation via Potato attacks and token stealing techniques.","https:\u002F\u002Fgithub.com\u002FDCx7C5\u002Fai-marketplace\u002Fblob\u002Fmain\u002Fskills\u002Fwindows\u002Fprocesses\u002Ftoken\u002Fimpersonate\u002Fdetect\u002FSKILL.md",[],[20,163,164,165,166,167,168,36,169,34,115,170,171,172,173,174,175,176,177,29],"processes token impersonate detect","token","processes","attacks","windows","escalation","techniques","privilege-escalation","seimpersonate","token-impersonation","printspoofer","exploitation","potato","impersonation","via",{"skillNo":179,"name":180,"nameZh":6,"description":181,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":182,"categories":183,"keywords":184,"publishedAt":39},"01M71HAABSB4Z6QFSXEG00R4RK","processes-thread-injection-detect","Detect Windows thread injection techniques including CreateRemoteThread, QueueUserAPC, NtCreateThreadEx, and thread hijacking via process memory analysis.","https:\u002F\u002Fgithub.com\u002FDCx7C5\u002Fai-marketplace\u002Fblob\u002Fmain\u002Fskills\u002Fwindows\u002Fprocesses\u002Fthread\u002Finjection\u002Fdetect\u002FSKILL.md",[],[185,186,20,187,165,167,188,36,189,169,34,115,31,190,191,192,193,177,29,105],"thread","processes thread injection detect","injection","memory","process-injection","api","apc-injection","thread-injection","nt-api",{"skillNo":195,"name":196,"nameZh":6,"description":197,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":198,"categories":199,"keywords":200,"publishedAt":39},"01M71HA7H311V5G14WMX58HQSS","processes-hollow-technique-detect","Detect process hollowing (RunPE) by identifying processes with mismatched image paths between PEB and VAD tree, or unmapped PE headers in memory.","https:\u002F\u002Fgithub.com\u002FDCx7C5\u002Fai-marketplace\u002Fblob\u002Fmain\u002Fskills\u002Fwindows\u002Fprocesses\u002Fhollow\u002Ftechnique\u002Fdetect\u002FSKILL.md",[],[201,20,165,202,188,36,203,204,34,115,205,206,207,208,209,210,29,105,211,212],"processes hollow technique detect","tree","memory-forensics","process-hollow","peb","runpe","image","pe-header","in memory","with","mismatched","headers"]