Files
crackme/loader2/slinky_loader.c
T
2rax f5225a7fec Port crack to the original packed binary (runtime, no client byte patches)
- original's .text is unpacked in-place at runtime; license cluster is
  byte-identical to the devirt dump (verified via runtime dumps)
- byte patches on the client are DETECTED AND REVERTED (~2.5s) by its
  integrity self-repair; re-patching hard-fails init -> don't patch bytes
- license check uses zero CryptoAPI calls (custom VM math, not forgeable)
- crack: 7-byte stub on kernel32!FreeLibraryAndExitThread -> ExitThread in
  the host process; failed license then leaves the client resident
- loader2/slinky_loader.c: full verified flow (Java 8 VM + env + stub + load)
- differential key tests, dry-run host requirements documented in README_part2.md
2026-11-08 12:07:54 -05:00

80 lines
3.8 KiB
C

/* Slinky loader for the ORIGINAL packed binary (lib_beta_win).
*
* The client's VMProtect layer actively restores its own .text (byte patches
* are detected and reverted within seconds — verified experimentally), so the
* crack does NOT touch the client. Instead it neutralizes the only observable
* effect of a failed license: the self-unload.
*
* How the license flow behaves (all verified at runtime):
* entry unpacks .text in-place -> init(+0x1220) reads SLINKY_LICENSE ->
* thread(+0x10F0) runs the VM key check (custom math, no CryptoAPI) ->
* on failure: "status: 7003" + Sleep(1000) + FreeLibraryAndExitThread
* (which is the ONLY thing that ever unmaps the client).
*
* This loader:
* 1. sets SLINKY_LICENSE (any 32-char key)
* 2. creates a Java 8 VM (the entry expects to live inside a JVM process)
* 3. installs a 7-byte stub on kernel32!FreeLibraryAndExitThread
* (mov ecx,edx; jmp ExitThread) — copy-on-write, this process only,
* client bytes stay pristine
* 4. LoadLibraryW's the client -> license fails -> unload blocked -> client
* stays resident
*
* Build: gcc -O2 -I<jdk8 include> -I<jdk8 include>\win32 -o javaw.exe slinky_loader.c
* (name the exe javaw.exe; the client checks its host)
*
* For real injection: run the same stub+env logic inside the target process
* before the client loads (inject a tiny DLL that does steps 2-3, then loads
* the client), or use any injector with these hooks pre-applied.
*/
#include <windows.h>
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <jni.h>
typedef jint (JNICALL *CreateVM_t)(JavaVM **, void **, void *);
int main(int argc, char **argv) {
const char *key = (argc > 1 && strlen(argv[1]) == 32) ? argv[1]
: "WRONGKEY-THIS-IS-NOT-A-REAL-KEY!";
wchar_t wkey[64]; size_t n = strlen(key);
for (size_t i = 0; i < n; i++) wkey[i] = (wchar_t)key[i];
wkey[n] = 0;
SetEnvironmentVariableW(L"SLINKY_LICENSE", wkey);
printf("[loader] SLINKY_LICENSE=%s\n", key); fflush(stdout);
/* 1. real Java 8 VM so the client's host checks pass */
HMODULE jvm = LoadLibraryW(L"C:\\Program Files\\Eclipse Adoptium\\jdk-8.0.502.7-hotspot\\jre\\bin\\server\\jvm.dll");
if (jvm) {
CreateVM_t cjv = (CreateVM_t)GetProcAddress(jvm, "JNI_CreateJavaVM");
JavaVM *vm = NULL; void *env = NULL;
JavaVMInitArgs va; memset(&va, 0, sizeof va);
va.version = JNI_VERSION_1_8; va.ignoreUnrecognized = JNI_TRUE;
printf("[loader] JNI_CreateJavaVM -> %d\n", cjv ? cjv(&vm, &env, &va) : -1); fflush(stdout);
}
/* 2. neutralize the self-unload: FreeLibraryAndExitThread -> ExitThread */
HMODULE k32 = GetModuleHandleW(L"kernel32.dll");
unsigned char *fle = (unsigned char *)GetProcAddress(k32, "FreeLibraryAndExitThread");
unsigned char *et = (unsigned char *)GetProcAddress(k32, "ExitThread");
unsigned char stub[7] = { 0x8B, 0xCA, 0xE9, 0, 0, 0, 0 }; /* mov ecx,edx; jmp rel32 */
intptr_t rel = (intptr_t)et - (intptr_t)(fle + 7);
memcpy(stub + 3, &rel, 4);
DWORD old;
VirtualProtect(fle, 7, PAGE_EXECUTE_READWRITE, &old);
memcpy(fle, stub, 7);
VirtualProtect(fle, 7, old, &old);
FlushInstructionCache(GetCurrentProcess(), fle, 7);
printf("[loader] self-unload blocked @ kernel32!FreeLibraryAndExitThread %p\n", (void *)fle); fflush(stdout);
/* 3. load the client */
HMODULE h = LoadLibraryW(L"C:\\Users\\nicot\\Downloads\\lib_beta_win_unpacked.devirt.bin~\\lib_beta_win.dll");
printf("[loader] client -> %p (GLE=%lu; 'init failed' is normal - it "
"delists itself from the loader on purpose)\n", (void *)h, GetLastError()); fflush(stdout);
for (int i = 0; i < 30; i++) { Sleep(1000); fflush(stdout); }
printf("[loader] client resident after 30s\n"); fflush(stdout);
return 0;
}