Skip to content

Linux LKM rootkit

Reptile LKM Rootkit: Traces and Offline Checks

Reptile is an open-source Linux kernel rootkit with a userland loader and port-knocking shell, used in espionage intrusions. Its traces, checks and recovery.

Kind
Linux LKM rootkit · Kernel layer
Platforms
Linux
First seen
2017
Status
In the wild
Also known as
REPTILE
Checked by
Linux kernel

Overview

Reptile is a public, open-source LKM rootkit for Linux. Its repository dates from October 2017 and still carries a "security research" disclaimer. The README lists kernels it was tested on, from 2.6.32 (CentOS 6) to 4.19 (Debian 10).

Reptile is more than a hiding module. It ships with:

  • a userland loader that carries the kernel module encrypted;
  • a reverse shell started by a "magic packet";
  • a command tool, and an option to hide lines inside files.

Reported uses:

  • Korean organisations, 2022–2023. AhnLab ASEC described several campaigns against Korean organisations since 2022. In one, the operator renamed every component after the keyword intel_audio and paired the rootkit with an ICMP shell.
  • Mélofée, 2023. ExaTrack found that the Mélofée implant installs a rootkit "based on a modified version" of Reptile. ExaTrack links Mélofée "with high confidence" to Chinese state-sponsored groups, naming Winnti.
  • UNC3886, 2024. Mandiant reported REPTILE as the preferred rootkit of UNC3886, which it calls "a suspected China-nexus cyber espionage actor". The actor deployed it on Linux guest virtual machines right after gaining access.

Because the source is public, finding Reptile on a host does not identify an actor on its own.

How it loads and hides

Loading. The default build installs four programs in a hidden directory named after the build keyword, by default /reptile/:

  • reptile, the loader;
  • reptile_cmd, the command tool;
  • reptile_shell, the reverse shell;
  • reptile_start, a start script.

The loader decrypts the module it carries and passes it to the kernel with init_module(). In the default install there is no standalone .ko on disk. The packing comes from the open-source kmatryoshka loader. Elastic notes that, because of this, insmod never runs; only syscall auditing of init_module sees the load (Elastic, 2026).

Persistence varies:

  • The public installer writes a udev rule named <random>-<keyword>.rules into /lib/udev/rules.d/ (or /etc/udev/rules.d/).
  • Mandiant notes that older versions used modprobe configuration.
  • UNC3886 mostly used RC scripts or systemd units instead, and only a few samples used udev.
  • In ASEC's Korean case, an rc.local entry started the loader, wrapped in tags that the rootkit hides.

Hiding. Reptile hooks kernel functions with the KHOOK engine. The public source hooks:

HookedWhat it hides
filldir, filldir64, fillonedir, __d_lookup, vfs_statxFiles and directories whose path contains the keyword
next_tgid, find_task_by_vpid, sys_killHidden processes, from /proc and from signals
tcp4_seq_show, udp4_seq_showConnections to chosen IP addresses
vfs_readText between #<keyword> and #</keyword> tags, in any file read
ip_rcvWatches TCP, UDP and ICMP packets for the port-knocking trigger

The module unlinks itself from the kernel's module list, so lsmod misses it. The public source does not remove its /sys/module entry.

The magic packet carries the command-and-control address. When it arrives, the rootkit starts the reverse shell towards that address (ASEC). UNC3886's customised listener spoke TLS, using the victim's own certificate and key taken from compromised FortiGate devices (Mandiant).

Traces on disk

LocationWhatSource
/reptile/reptile, /reptile/reptile_cmd, /reptile/reptile_shell, /reptile/reptile_startDefault install; the keyword replaces reptile in renamed buildsASEC, repository
/lib/udev/rules.d/<random>-<keyword>.rules (or /etc/udev/rules.d/)Public installer's persistenceRepository, Elastic
/etc/intel_audio/intel_audio.ko, intel_audio_start, intel_audio_reverse, gvfs-gdb-volume-monitorASEC's Korean case: module, start script, shell, ICMP shellASEC
rc.local lines between #<intel_audio> and #</intel_audio>Hidden autostart in the same caseASEC
/etc/rc.modulesMélofée's module persistenceExaTrack
/var/lib/fwupdd/<keyword>_cmd, _reverse, _startUNC3886 componentsMandiant
/lib/modules/<release>/kernel/drivers/<keyword>/<keyword>, /usr/bin/<keyword>UNC3886 encrypted kernel component and its launcherMandiant
RC scripts or systemd units running the launcherUNC3886 persistenceMandiant
Text after #</Centos_Selinux_Config_And_Module>UNC3886's file-tampering markerMandiant
Kernel log taint lines naming an unknown moduleLoad of an unsigned, out-of-tree moduleLinux kernel

Mandiant's report lists hashes, component names such as bubba and authdd, and YARA rules for the launcher. Use those from the report itself.

How to check a host

Live, with caution. The rootkit filters listings, /proc, connections and even file contents for every program, static tools included. Look for disagreement between views rather than for the files.

cat /proc/sys/kernel/tainted
for m in /sys/module/*; do [ -e "$m/initstate" ] && ! grep -q "^${m##*/} " /proc/modules && echo "only in sysfs: ${m##*/}"; done
dmesg | grep -iE 'taint|module verification'
ausearch -m KERN_MODULE -i 2>/dev/null | tail -n 20   # if auditd watches module loads
ls -la /reptile 2>&1                                  # the default keyword: hidden from listings but reachable by name
  • A hidden directory still answers when you name it. ls -la /reptile failing proves nothing, because the keyword is usually changed.
  • Elastic suggests watching for network connections and file creation by kworker kernel threads, which Reptile's shell start produces.
  • Capture memory before going further. In a memory image, Volatility 3's linux.malware.hidden_modules and linux.malware.check_modules look for modules missing from the list (Linux Forensics: memory forensics).

Offline, from an image. On a clean machine, the keyword-hidden files and tagged lines are plain to read.

R=/mnt/evidence
ls -la "$R"/lib/udev/rules.d "$R"/etc/udev/rules.d
grep -rnE 'RUN\+?=' "$R"/etc/udev/rules.d "$R"/lib/udev/rules.d 2>/dev/null   # programs started by udev
grep -rnE '^#<[^>]+>|^#</[^>]+>' "$R"/etc 2>/dev/null           # file-tampering tags
find "$R"/lib/modules "$R"/usr/lib/modules -type f ! -name '*.ko*' ! -name 'modules.*' 2>/dev/null
cat "$R"/etc/rc.local "$R"/etc/rc.modules 2>/dev/null
zgrep -hE 'taint|module verification' "$R"/var/log/kern.log* "$R"/var/log/messages* 2>/dev/null
  • Udev rules are the persistence to review first; see udev rules on Linux Persistence.
  • Files under the module tree without a .ko extension are not modules the kernel's tools load by name. UNC3886's encrypted component sat in such a path.
  • Hunt for small ELF files that call init_module from /usr/bin or other system paths, and check whether a package owns them (dpkg -S, rpm -qf).

What the checker looks for

The linuxkernel module sees part of Reptile:

  • Kernel log taint messages: "Kernel log: out-of-tree module loaded" and "Kernel log: unsigned module loaded", naming the loaded module when it was the first such module of the boot. The name is the build's name, which operators change.
  • A module hidden from /proc/modules. With the collect script's _live/ outputs, "Loaded module missing from /proc/modules" for a module listed under /sys/module but missing from /proc/modules, matching the public source's hiding, and "Kernel tainted by an out-of-tree or unsigned module" from the saved taint value.
  • An unpacked module. When an operator stored the module as a plain .ko under lib/modules/, it raises "Unsigned module among signed modules" and "Module unknown to the kernel build and to every package". Hook-target names such as filldir and tcp4_seq_show, when the module carries them as strings, raise "Names kernel functions that rootkits hook". UNC3886's encrypted component under lib/modules/ has no .ko name, so it is not read as a module.

It does not see the default install:

  • the module travels encrypted inside the loader;
  • udev rules, rc scripts, systemd units and /etc/intel_audio-style folders outside the module tree are not read by the checker;
  • tagged lines in rc.local and /etc/rc.modules are not read either.

Check those by hand, or with Linux Persistence, which reads the persistence side.

Removal and recovery

  1. Capture memory, then image the disk. The module and its hidden list exist only in memory. A reboot also restarts the loader if persistence is in place.

  2. Map everything from the image.

    • the loader, the command tool, the shell and the start script;
    • every persistence entry: udev rule, rc script, unit, rc.modules;
    • tagged lines in configuration files;
    • companion tools such as the ICMP shell.

    Then search the network logs for the magic-packet source and the shell's destination.

  3. Rebuild. Reptile gives root to unprivileged users on request, runs a remote shell as root and edits what files appear to contain. Cleaning in place cannot prove that nothing else was changed. Rebuild the host from known-good media.

  4. Rotate credentials. Rotate everything stored on or used from the host. In UNC3886's case, also rotate the TLS certificates and keys that were reused from network devices.

  5. Harden. Enforce module signatures (Secure Boot with lockdown, or module.sig_enforce=1), and audit init_module and finit_module. Alert on new udev rules and rc scripts, and on network activity from kernel threads.

Syslogk and Adore-ng use similar magic-packet and hiding designs. Diamorphine is the simpler open-source module often seen beside it in cryptomining cases.

Sources

Primary public reports, newest first.

  1. 2026-04-02Hooked on Linux: Rootkit Detection EngineeringElastic Security Labs
  2. 2024-06-18Cloaked and Covert: Uncovering UNC3886 Espionage OperationsGoogle Cloud (Mandiant)
  3. 2023-07-21Reptile Malware Targeting Linux SystemsAhnLab ASEC
  4. 2023-03-28Mélofée: a new alien malware in the Panda's toolset targeting Linux hostsExaTrack
  5. 2017-10-22Reptile source repositoryGitHub

See also

Related families