Skip to content

Backdoors and covert channels

Magic-Packet Backdoors in Kernel Rootkits: Traces, Checks

How kernel rootkits on Linux and Windows wait for a crafted packet instead of opening a port, the hooks they use to see it, and how to detect them on a host.

Goal
Backdoors and covert channels
Layer
Kernel
Platforms
Linux, Windows
Also known as
Port knocking, Traffic signaling
Checked by
Linux kernel

Overview

A magic-packet backdoor opens no port of its own. It watches incoming traffic for a crafted packet: a source port, a flag pattern, a key in the payload. Only then does it act: a reverse shell to an address the packet carries, a hidden payload, or a hijacked connection. Between triggers a port scan finds nothing new.

MITRE ATT&CK calls this Traffic Signaling (T1205), with port knocking (T1205.001) and socket filters (T1205.002) as sub-techniques. Its detection notes describe the chain: trigger packets, then a firewall change or a process that starts listening or sniffing, then a successful connection.

Kernel rootkits see packets before any service does and can hide what follows. Most wait for a packet nothing else expects. Snake, on Windows, works in-band: it reads the first packet of ordinary connections to services already listening.

How it works

The trigger needs a place to watch packets. Rootkits use six:

Trigger pointWhat it seesWho uses it
Netfilter hook registered by a module (Linux)Packets at a hook point (for example pre-routing), in priority order with the firewall's own chainsSyslogk, KoviD, Diamorphine variant
Hook on a kernel receive function (Linux)Every IPv4 packet entering ip_rcvReptile
XDP program (eBPF, Linux)Packets in the driver, before the network stackTripleCross, LinkPro
TC program (eBPF, Linux)Packets entering or leaving an interfaceTripleCross and LinkPro, for replies and port rewriting
Packet socket with a classic BPF filter (userland, Linux)A copy of matching packets on the interfaceBPFDoor, outside the catalogue
Kernel driver inspecting TCP sessions (Windows)The first client-to-server packet after the handshake of every TCP session, on ports where another program listensSnake

The last row is an in-band trigger: the operator connects to a real service, such as a web server, and the first packet carries the authentication. CISA does not name the Windows networking interface the driver uses.

Netfilter runs hooks "sorted, the lowest number is run first" (nft(8)), so a rootkit hook ahead of the filter chains acts before firewall rules or their logs see the packet. KoviD's README says its outgoing packets "bypass iptables rules". Drovorub hooks the registration function so that its own hook stays first (NSA and FBI).

After the trigger, the backdoor usually connects out, which inbound-only firewalls allow (Elastic, 2022). The trigger is often dropped once read: Reptile's public source drops a matched packet.

Not every netfilter hook is a trigger: every firewall module registers some. Drovorub's drop traffic it hides; Skidmap's 2023 kmeminfo.ko uses them to "analyze, modify, or drop network packets" (Trustwave).

How families use it

FamilyTrigger pointTrigger and actionSource
ReptileKHOOK inline hook on ip_rcvTCP, UDP or ICMP packets with chosen fields and a key; starts a reverse shell to the address the packet carries. UNC3886's listener spoke TLS with keys taken from FortiGate devicesRepository, ASEC, Mandiant
SyslogkNetfilter hookTCP source port 59318 starts the hidden Rekoobe payload; source ports 63400–63411, reserved field 0x08 and the key D9sd87JMaij stop itAvast
KoviDNetfilter hooks (pre-routing and local-out in the source)Port knocking with custom packets; reverse shells through netcat, OpenSSL or socatRepository
TripleCrossXDP, with a TC egress program for repliesPackets with the backdoor's patterns and commandsRepository
DiamorphineNetfilter hooks, IPv4 and IPv6Gen Digital's 2024 variant only: packets carrying XOR-encoded strings run an operating system command. The public source has no network triggerGen Digital
Snake (Windows)Kernel module, on TCP sessions to listening programs"Intercepts the first client-to-server packet following the 3-way handshake in every TCP session"; a valid ustart authentication value sends the session to Snake, anything else to the real listener. It "will only communicate over TCP ports on which another application is actively listening". MITRE lists this as T1205 for UroburosCISA

Outside the catalogue: BPFDoor looks "for a so-called magic packet in every TCP, UDP and ICMP packet received" through a socket filter (Elastic, 2022); PwC attributes it to a group it calls Red Menshen. LinkPro's XDP program waits for a TCP SYN with window size 54321, then redirects that source's traffic to an internal listener on port 2233 (Synacktiv).

In the catalogue but not listed here, Azazel's preloaded accept() hook is a userland, in-band backdoor rather than a kernel trigger: it hands a shell to connections from source ports 61040–61060.

Traces it leaves

WhereTraceNotes
Network, outside the hostA lone inbound packet with odd fields, followed by an outbound connection from the host to the same or a related addressThe most reliable view; the host may hide both
Network, outside the hostFor Snake, sessions to an ordinary service whose first packet or HTTP headers carry the ustart patternCISA publishes Suricata rules for its HTTP, HTTP/2 and raw TCP forms
Kernel, liveNetfilter hooks from an unknown module; XDP or TC programs; packet sockets with filtersSee the commands below
ProcessesShells or network connections whose parent is a kernel threadElastic: Reptile "generates unusual network events through kworker"
Module fileImports of nf_register_net_hook; strings holding the key or portsWhen the .ko is on disk
DiskeBPF objects and loaders; persistence for the payloadFor XDP and TC triggers

How to check a host

Live, as root.

nft list hooks                               # every netfilter hook with its function and owning module
bpftool net show                             # XDP, tc and netfilter eBPF attachments
ip -d link show | grep -i xdp
tc filter show dev eth0 ingress; tc filter show dev eth0 egress   # repeat for each interface
ss -0pb                                      # packet sockets, their processes and classic BPF filters
ss -wp                                       # raw sockets
ps -eo pid,ppid,comm,args | awk '$2 == 2'    # children of kthreadd: kernel threads, and anything else
  • nft list hooks shows each hook's function and the module that registered it. It needs CONFIG_NETFILTER_NETLINK_HOOK (module nfnetlink_hook, Linux 5.14 and later) (nft(8)). A hook from a module nobody can account for is a lead.
  • ss -b shows "socket classic BPF filters" to administrators (ss(8)). DHCP clients and capture tools also open packet sockets.
  • A rootkit can hide its socket, process or module from these tools. Watch from outside: a tap, firewall or flow logs.

Memory. Volatility 3's linux.malware.netfilter "lists Netfilter hooks" with their handlers, linux.ebpf lists eBPF programs, and linux.malware.hidden_modules finds the module behind a hook.

Windows (Snake). An in-band trigger rides on traffic the host expects, so a port scan shows only the real service. CISA finds network detection of recent variants feasible, with "some potential for false positives", and calls memory analysis "the most effective approach" on the host. The Snake family page lists the disk traces.

Offline, from an image.

R=/mnt/evidence
nm -u /path/to/suspect.ko | grep -E 'nf_register_net_hook|nf_register_hook'
strings -a /path/to/suspect.ko | grep -E 'D9sd87JMaij|/bin/sh|reverse|socat|openssl'
find "$R" -xdev -type f -size -20M -exec file {} + 2>/dev/null | grep -i 'eBPF'

Then read firewall and flow logs from other devices for the trigger patterns above, and for outbound sessions that started right after a single inbound packet. Avast's IoC repository and Mandiant's report publish indicators for their samples.

What the checker looks for

The linuxkernel module sees the module that carries a trigger, when its file is under lib/modules/: "Unsigned module among signed modules", "Module unknown to the kernel build and to every package", and the taint log lines. An import of nf_register_net_hook is listed only as context next to a hooking finding, since every firewall module imports it. Names such as packet_rcv or tpacket_rcv, hooked to hide traffic from captures, raise "Names kernel functions that rootkits hook"; ip_rcv, Reptile's trigger point, is not among them.

It does not see the trigger: netfilter hooks in memory, XDP and TC programs, packet sockets and traffic are outside the collection. Reptile's default install keeps its module encrypted inside the loader, so there may be no .ko to read.

On Windows, CISA describes the trigger in the 2023 generation of Snake, whose driver sits encrypted inside comadmin.dat and is loaded by a user-mode service. The windrivers module lists driver services and .sys files, so it sees neither that driver nor the trigger; this page therefore lists no Windows check.

Mitigation and recovery

  • Filter upstream. A firewall in front of the host drops trigger packets before any hook sees them. Once started, Syslogk's Rekoobe payload is reached as a fake SMTP server (Avast), so the same filtering also blocks that connection. This does not stop an in-band trigger such as Snake's, which arrives on a port the service needs.
  • Filter egress. Reverse shells need outbound connections.
  • Stop the loaders. Enforce module signatures, use kernel lockdown, restrict eBPF (see eBPF programs as rootkits), and audit module loads and bpf() calls.
  • Keep flow logs and the IDS rules from the reports above.

Recovery. Capture memory first: hooks, trigger state and hidden payloads exist there. From network logs, list every trigger source and every destination the host connected to, and hunt for them elsewhere. Rebuild from known-good media and rotate credentials, including keys reused from network devices, as in UNC3886's case.

Sources

Primary public reports, newest first.

  1. 2026-04-02Hooked on Linux: Rootkit Detection EngineeringElastic Security Labs
  2. 2025-10-14LinkPro: eBPF rootkit analysisSynacktiv
  3. 2024-06-18Cloaked and Covert: Uncovering UNC3886 Espionage OperationsGoogle Cloud (Mandiant)
  4. 2024-06-18New Diamorphine rootkit variant seen undetected in the wildGen Digital (Avast)
  5. 2023-07-21Reptile Malware Targeting Linux SystemsAhnLab ASEC
  6. 2023-05-09Hunting Russian Intelligence "Snake" Malware (AA23-129A)CISA
  7. 2022-07-13A peek behind the BPFDoorElastic Security Labs
  8. 2022-06-13Linux Threat Hunting: 'Syslogk' a kernel rootkit found under development in the wildGen Digital (Avast)
  9. 2022-04-01KoviD source repositoryGitHub
  10. 2021-10-27TripleCross source repository and thesisGitHub
  11. 2020-08-13Russian GRU 85th GTsSS Deploys Previously Undisclosed Drovorub MalwareNSA and FBI
  12. 2017-10-22Reptile source repositoryGitHub

See also

Families that use it