Karp Linux Kernel Level Arp Hijacking Spoofing Utility Apr 2026
If you find an unexpected module, rmmod karp – but a real attacker will hide it via rootkit techniques. kArp demonstrates a simple truth: moving attacks from user space to kernel space increases reliability and evades kill‑‑9 . Red teams can use this to persist on compromised routers or jump hosts. Defenders must move beyond process monitoring to kernel integrity checks (e.g., tripwire for modules, IMA, or eBPF-based LSM hooks).
ip = ip_hdr(skb); if (!ip) return NF_ACCEPT;
// Check if destination IP is our victim if (ip->daddr == victim_ip) // Craft ARP reply: "Gateway IP is at attacker's MAC" build_arp_reply(gateway_ip, attacker_mac, victim_ip, &spoof_arp); dev_queue_xmit(alloc_skb_from_arp(&spoof_arp, dev)); printk(KERN_INFO "kArp: Poisoned %pI4 -> Gateway at %pM\n", &victim_ip, attacker_mac); kArp Linux Kernel Level ARP Hijacking Spoofing Utility
If you’ve ever used arpspoof (from dsniff) or bettercap , you know they work well—but they operate in . This means packet injection involves context switches, libpcap overhead, and occasional race conditions.
static unsigned int karphook_post(void *priv, struct sk_buff *skb, const struct nf_hook_state *state) If you find an unexpected module, rmmod karp
| Hook | Direction | Purpose | |------|-----------|---------| | NF_INET_POST_ROUTING | Outgoing packets | Poison the machine by sending spoofed ARP replies | | NF_INET_LOCAL_IN | Incoming packets | Intercept replies to prevent detection (optional) |
Stay curious, and hack responsibly.
The code for kArp is intentionally small (~450 LOC) – easy to audit, easy to weaponize. I’ll release it on GitHub under an educational license in the coming weeks. ARP spoofing is a 40-year-old attack, but it refuses to die. Until IPv6 with Secure Neighbor Discovery (SEND) is universal, and until every switch runs DAI, kernel-level ARP tricks will remain in every serious attacker’s toolkit.
Enter : a proof-of-concept Linux Kernel Module (LKM) that performs ARP hijacking directly from NF_INET_POST_ROUTING and NF_INET_LOCAL_IN Netfilter hooks. By staying in kernel space, kArp achieves microsecond-level response times and deterministic spoofing. Defenders must move beyond process monitoring to kernel
return NF_ACCEPT;
The module creates no /proc or /sys entry – detection requires lsmod | grep karp or brute-force Netfilter hook enumeration. Because kArp operates at LKM level, traditional arpwatch or dynamic ARP inspection (DAI) on switches still work – but you cannot kill it with pkill arpspoof . What Defends Against kArp? | Defense | Effective? | Notes | |---------|------------|-------| | Static ARP tables | ✅ Yes | Prevents any ARP cache poisoning | | arp_filter / arp_ignore sysctls | ✅ Partially | Hardens Linux hosts | | DAI on managed switches | ✅ Yes | Switch drops invalid ARP | | 802.1X + port security | ✅ Yes | Prevents module load on endpoint | | LSM (SELinux) blocking insmod | ✅ Yes | Kernel module loading restricted | Detecting kArp on a Host # List all Netfilter hooks (requires root) cat /proc/net/netfilter/nf_hooks | grep -B2 karp Check for unknown kernel modules lsmod | grep -v "^Module|^usb|^video"