PatchRequest/BusyWork: Sleep replacement that executes real, varied work to break behavioral pattern matching by EDR and anti-cheat systems · GitHub

PatchRequest/BusyWork: Sleep replacement that executes real, varied work to break behavioral pattern matching by EDR and anti-cheat systems · GitHub

A Rust library that replaces sleep() with real, varied work to evade behavioral pattern matching by EDR, anti-cheat, and dynamic analysis systems.

Every call executes a completely different code path — random category, random task, random iteration counts. No two calls produce the same syscall sequence, instruction trace, or API call pattern.

sleep() is one of the most commonly hooked and monitored functions. EDR and anti-cheat systems flag predictable idle-then-act patterns as suspicious. Even if sleep() itself isn’t hooked, the behavioral signature of “do X, idle N ms, do X again” is trivial to fingerprint.

BusyWork fills those gaps with genuine, varied activity — real syscalls, real computations, real I/O — that looks like normal application behavior under dynamic analysis. The execution profile changes on every call, defeating both signature-based and heuristic-based detection.

Zero time objects in the library binary. No Duration, no Instant, no SystemTime. Nothing for static analysis to latch onto as a timing mechanism.

Add to your Cargo.toml:

[dependencies]
busywork = "0.1"

Or with only specific categories (faster compile, smaller binary):

[dependencies]
busywork = { version = "0.1", default-features = false, features = ["cat-compute", "cat-memory", "cat-winapi"] }
use busywork::{busywork, busywork_with, BusyWork, Categories, Intensity};

// Simple — random tasks across all categories
busywork(Intensity::Medium);

// Pick specific categories
busywork_with(Intensity::High, Categories::COMPUTE | Categories::WINAPI);

// Builder for full control
BusyWork::new(Intensity::Ultra)
    .allow(Categories::COMPUTE | Categories::FILESYSTEM)
    .deny(Categories::NETWORK)
    .jitter(true)
    .run();

Busywork blocks can blend into surrounding code by processing your variables. Feed any data from the current scope — tasks will weave it into their control flow (hashing it, sorting it, using it as loop bounds), making the block indistinguishable from real data processing to static or dynamic analysis.

All data is cloned on feed — originals are never modified.

let session_id: u64 = 0xDEADBEEF;
let payload = vec![0x41u8; 1024];
let user_name = "admin";
let packet_count: u32 = 147;

BusyWork::new(Intensity::Medium)
    .allow(Categories::COMPUTE | Categories::MEMORY)
    .feed(&session_id)      // integers, floats, bools
    .feed(&payload)          // Vec<u8>, &[u8], [u8; N]
    .feed(user_name)         // &str, String
    .feed(&packet_count)     // unlimited parameters
    .run();

Without .feed(), tasks generate random input data — detectable as isolated noise blocks with no data dependency on the surrounding program. With .feed(), the busywork reads and processes the same variables as your real code. A data-flow analyzer cannot determine which computations are “real” and which are busywork.

Works with custom types — implement FeedWork for your own structs:

use busywork::FeedWork;

struct GameState { x: f32, y: f32, hp: u32 }

impl FeedWork for GameState {
    fn write_work_bytes(&self, out: &mut Vec<u8>) {
        self.x.write_work_bytes(out);
        self.y.write_work_bytes(out);
        self.hp.write_work_bytes(out);
    }
}

BusyWork::new(Intensity::Low)
    .feed(&game_state)
    .run();

Every run() call maintains a 256-byte scratch buffer that flows through all tasks sequentially. Each task reads from the scratch buffer (blending it into its computation) and writes its results back. Task N’s SHA-256 output becomes part of task N+1’s sort input, which feeds task N+2’s compression.

This creates a data-dependency chain across the entire execution — an analyzer cannot isolate individual tasks as independent noise blocks, because each task’s behavior genuinely depends on what came before it.

loop {
    do_real_work();
    busywork(Intensity::Medium); // different execution path every time
}

No timers — just work volume:

LevelTasks/callIterationsBuffer sizeCall depth
Low2501 KB2
Medium550016 KB4
High105,000256 KB8
Ultra2050,0001 MB16

Jitter (on by default) randomizes all parameters by ±30%, so two consecutive calls at the same intensity produce different instruction traces.

SHA-256 hash chains, MD5 hash chains, prime sieve (Eratosthenes), matrix multiplication, array sorting, deflate compress/decompress, Fibonacci sequence, XOR cipher rounds, Collatz conjecture, string operations, bubble sort, bitwise operations, pi approximation (Leibniz), permutation generation (Heap’s algorithm).

Alloc/touch/free pages, memcpy chains, sort random data, pattern fill & verify, heap fragmentation (many small allocs), ring buffer simulation, repeated binary search, buffer reversal, buffer interleaving, scatter/gather access patterns.

Enumerate System32, temp dir, Program Files, fonts, drivers, prefetch, logs, user profile. Stat system files & DLLs. Read hosts, services, win.ini, system.ini. All read-only — no files created or modified.

Read installed software, system info (ProductName, CurrentBuild), services, timezone, environment variables, network config (TCP/IP parameters), CPU hardware info, font list, startup programs (Run keys), file associations (HKCR). All KEY_READ — no writes.

Enumerate windows (EnumWindows + GetWindowTextW), enumerate processes (ToolHelp32 snapshot), system info (GetSystemInfo, GlobalMemoryStatusEx), clipboard read, system metrics (10 indices), foreground window, cursor position, desktop window, logical drives + drive types, volume info, disk free space, FindFirstFile/FindNextFile, module handles (12 DLLs), VirtualQuery memory walk, system/Windows directories, process/thread IDs.

DNS lookups (24 hosts), HTTP GET (11 endpoints), NTP queries (7 servers), HTTP HEAD requests, TCP connect probes (10 host:port targets), DNS with varied ports, HTTP POST/PUT to echo endpoints. Socket timeouts via raw setsockopt — no Duration type.

BCryptGenRandom (system CSPRNG), BCrypt SHA-256 hashing, BCrypt SHA-512, BCrypt MD5, BCrypt SHA-1, AES-256 symmetric encrypt, RNG algorithm providers (RNG, FIPS186DSARNG, DUALECRNG).

WMI queries via COM automation: Win32_Process (process enumeration), Win32_OperatingSystem (OS info), Win32_ComputerSystem (computer/domain info), Win32_NetworkAdapterConfiguration (network adapters), Win32_LogicalDisk (disk info), Win32_Service (services), Win32_BIOS (BIOS info), Win32_Processor (CPU info). All read-only WQL SELECT queries.

Measured on Windows 11, debug build, 5 runs each:

By Intensity (all categories)

LevelMinAvgMax
Low0.10 ms0.19 ms0.33 ms
Medium3.26 ms941 ms3,064 ms
High133 ms1,855 ms6,322 ms
Ultra4,439 ms58,450 ms176,147 ms

The wide min/max spread is intentional — each call picks different tasks with different costs.

By Category (Medium intensity)

CategoryMinAvgMax
COMPUTE14.69 ms499 ms1,256 ms
MEMORY14.93 ms123 ms242 ms
FILESYSTEM0.81 ms21.2 ms48.0 ms
REGISTRY0.93 ms4.64 ms17.8 ms
WINAPI0.28 ms5.01 ms19.1 ms
NETWORK1,188 ms3,350 ms6,318 ms
CRYPTO5.47 ms8.77 ms12.8 ms

Each category is a cargo feature, all on by default:

[dependencies]
busywork = "0.1"

# Or cherry-pick:
busywork = { version = "0.1", default-features = false, features = ["cat-compute", "cat-memory"] }

FeatureDependenciesDescription
cat-computesha2, md-5, flate2Pure CPU work
cat-memory—Allocation patterns
cat-filesystem—Read-only filesystem I/O
cat-registrywindowsWindows Registry reads
cat-winapiwindowsWin32 API calls
cat-network—DNS, HTTP, NTP
cat-cryptowindowsWindows CNG (BCrypt) crypto
cat-comwindowsCOM/WMI queries

Every design decision optimizes for evasion:

TechniqueWhat it defeats
Random task selection per callBehavioral sequence matching — no two calls produce the same API call order
±30% jitter on all parametersTiming heuristics — iteration counts, buffer sizes, call depths all vary
Data flow integration via .feed()Data-flow analysis — busywork operates on the same variables as surrounding code, preventing isolation as “noise blocks”
Inter-task scratch buffer chainingBlock isolation analysis — each task’s output feeds the next task’s input, creating a connected data-dependency graph across the entire run
Task registry rebuilt per callStatic analysis — no stable global function pointer table to fingerprint
Function pointers, not trait objectsVtable signature detection — each task is a direct call to a unique address
black_box on all resultsDead-code elimination — compiler can’t optimize away the work
No time objects in binaryString/import scanning — Duration, Instant, SystemTime are absent
Real syscalls across categoriesSyscall sequence analysis — mixes NtReadFile, NtQueryKey, NtDeviceIoControl, etc.
Read-only filesystem/registry opsBehavioral red flags — no writes, no creates, no deletes
Legitimate API call targetsAPI monitoring — calls the same APIs that normal applications use
COM/WMI queriesProcess behavioral profiling — WMI queries are one of the most common Windows API patterns in legitimate software

What it looks like under analysis

A process calling busywork(Medium) in a loop produces traces like:

Call 1: RegOpenKeyEx → RegEnumKeyEx × 3 → RegCloseKey → SHA256 × 200 → ReadFile(hosts)
Call 2: EnumWindows → GetWindowText × 15 → GlobalMemoryStatusEx → sort(50KB)
Call 3: connect(httpbin.org:80) → send(GET) → recv → BCryptGenRandom × 8
Call 4: FindFirstFile(*.dll) × 40 → GetVolumeInformation → memcpy(16KB) × 300
Call 5: CoCreateInstance(WbemLocator) → ExecQuery(Win32_Process) → enumerate × 50

No repeating pattern. Each call exercises different subsystems, different buffer sizes, different iteration counts. To an EDR, it looks like a normal application doing normal things.

With .feed(), the data flowing through these operations comes from your actual program variables — hash chains process your session tokens, sorts operate on your counters, crypto operations encrypt your payloads. A taint-tracking analyzer following your variables will see them consumed by what appears to be legitimate processing. The scratch buffer chains these operations together so even cross-task data flow looks organic.

185 tests across 5 test suites, verified with full untruncated output:

SuiteTestsWhat it covers
workdata::tests52Every FeedWork type, blend_into XOR correctness, blend_seed/derive_usize determinism, clone independence, empty/zero edge cases
tasks::tests24ScratchBuffer mechanics (seed, absorb, chain accumulation). Every registered task function called directly with 14 work-data shapes × parameter extremes (zero, min, large) — 1,176 task invocations. Registry completeness (84 tasks across 8 categories, no duplicates)
tasks::compute::tests19Mirror tests proving work data changes computation: hash inputs differ, fibonacci starting values shift, sieve limits get bias, cipher keys incorporate fed data, distinct inputs produce distinct seeds
tasks::memory::tests9Mirror tests proving work data flows into memory tasks: buffers modified, patterns XOR’d, ring buffers seeded, reversibility verified
———
tests/smoke.rs10Basic API smoke tests, category filtering (including COM), jitter toggle
tests/bench.rs4Intensity/category benchmarks, jitter variance measurement
tests/feed.rs64Data isolation (15 types verified untouched after run), per-category with feed (all 8 categories), intensity levels, edge cases (NaN, Unicode, 64KB), builder combinations, type coverage
tests/robustness.rs23Stress (500 rapid calls, 10k small feeds, 1MB feed), custom FeedWork impl, regression patterns (empty→real, alternating, max values)

cargo test --lib -- --test-threads=1              # 85 unit tests
cargo test --test feed -- --test-threads=1        # 64 integration tests
cargo test --test robustness -- --test-threads=1  # 23 stress/regression tests
cargo test --test smoke -- --test-threads=1       # 10 smoke tests
cargo test --test bench -- --test-threads=1       # 4 benchmark tests
84 tasks across 8 categories
All 84 tasks actively consume fed work data and participate in scratch buffer chaining
185 tests across unit, integration, stress, mirror, and benchmark suites
0 time objects in the library binary

Source link

Share:

Leave a Reply

3 latest news
News Archives
On Key

Related Posts

5 Adtech Trends From DMEXCO 2026

DMEXCO returned to Cologne on September 23-24 under the official theme “Scaling Intelligence.” The message behind the theme was straightforward: AI has moved beyond experimentation,