- any 32-char SLINKY_LICENSE key now validates (status: 0) - 7-byte patch at file offset 0x6AE: validate() returns success unconditionally, skipping un-lifted VMP bytecode entirely - full writeup in README.md, reproducible patch in patch/crack_patch.py - loader + dynamic-analysis drivers (manual map, gdb hw-breakpoint tracing) and key analysis artifacts
76 lines
3.5 KiB
C
76 lines
3.5 KiB
C
/* Manual mapper that calls the REAL VMProtect entry (base+0x35053d7) as DllMain. */
|
|
#include <windows.h>
|
|
#include <stdio.h>
|
|
#include <stdint.h>
|
|
#include <stdlib.h>
|
|
|
|
static int map_pe(const char *path, uint8_t **out_base, uint64_t *out_size) {
|
|
FILE *f = fopen(path, "rb");
|
|
if (!f) return 0;
|
|
fseek(f, 0, SEEK_END); long fsz = ftell(f); fseek(f, 0, SEEK_SET);
|
|
uint8_t *raw = (uint8_t *)malloc(fsz);
|
|
if (fread(raw, 1, fsz, f) != (size_t)fsz) return 0;
|
|
fclose(f);
|
|
IMAGE_DOS_HEADER *dos = (IMAGE_DOS_HEADER *)raw;
|
|
IMAGE_NT_HEADERS *nt = (IMAGE_NT_HEADERS *)(raw + dos->e_lfanew);
|
|
uint64_t pref = nt->OptionalHeader.ImageBase;
|
|
uint64_t szimg = nt->OptionalHeader.SizeOfImage;
|
|
uint8_t *base = (uint8_t *)VirtualAlloc((LPVOID)(uintptr_t)pref, (SIZE_T)szimg,
|
|
MEM_RESERVE | MEM_COMMIT, PAGE_EXECUTE_READWRITE);
|
|
if (!base) { printf("[mm] preferred base taken\n"); return 0; }
|
|
printf("[mm] mapped at 0x%llX (preferred) entry_rva=0x%X\n",
|
|
(unsigned long long)(uintptr_t)base, nt->OptionalHeader.AddressOfEntryPoint);
|
|
memcpy(base, raw, nt->OptionalHeader.SizeOfHeaders);
|
|
IMAGE_SECTION_HEADER *sec = IMAGE_FIRST_SECTION(nt);
|
|
for (int i = 0; i < nt->FileHeader.NumberOfSections; i++)
|
|
if (sec[i].SizeOfRawData)
|
|
memcpy(base + sec[i].VirtualAddress, raw + sec[i].PointerToRawData, sec[i].SizeOfRawData);
|
|
IMAGE_DATA_DIRECTORY *idd = &nt->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT];
|
|
if (idd->Size) {
|
|
IMAGE_IMPORT_DESCRIPTOR *d = (IMAGE_IMPORT_DESCRIPTOR *)(base + idd->VirtualAddress);
|
|
for (; d->Name; d++) {
|
|
HMODULE h = LoadLibraryA((char *)(base + d->Name));
|
|
if (!h) { printf("[mm] import fail %s\n", (char *)(base + d->Name)); return 0; }
|
|
uintptr_t *thunk = (uintptr_t *)(base + (d->OriginalFirstThunk ? d->OriginalFirstThunk : d->FirstThunk));
|
|
uintptr_t *iat = (uintptr_t *)(base + d->FirstThunk);
|
|
for (int i = 0; thunk[i]; i++) {
|
|
FARPROC p = (thunk[i] & 0x8000000000000000ULL)
|
|
? GetProcAddress(h, (LPCSTR)(thunk[i] & 0xFFFF))
|
|
: GetProcAddress(h, (char *)(base + thunk[i] + 2));
|
|
if (!p) { printf("[mm] proc fail\n"); return 0; }
|
|
iat[i] = (uintptr_t)p;
|
|
}
|
|
}
|
|
printf("[mm] imports ok\n");
|
|
}
|
|
*out_base = base; *out_size = szimg;
|
|
return 1;
|
|
}
|
|
|
|
int main(int argc, char **argv) {
|
|
const char *defkey = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef";
|
|
const char *ck = (argc > 1 && strlen(argv[1]) == 32) ? argv[1] : defkey;
|
|
wchar_t wkey[256]; size_t n = strlen(ck);
|
|
for (size_t i = 0; i < n; i++) wkey[i] = (wchar_t)ck[i];
|
|
wkey[n] = 0;
|
|
SetEnvironmentVariableW(L"SLINKY_LICENSE", wkey);
|
|
printf("[host] key=%s\n", ck); fflush(stdout);
|
|
|
|
uint8_t *base = NULL; uint64_t sz = 0;
|
|
if (!map_pe("C:\\Users\\nicot\\Downloads\\lib_beta_win_unpacked.devirt.bin~\\lib_beta_win_unpacked.devirt.bin", &base, &sz)) { printf("[host] map failed GLE=%lu\n", GetLastError()); return 1; }
|
|
|
|
typedef int (*entry_t)(void *, unsigned, void *);
|
|
entry_t entry = (entry_t)(base + 0x35053d7);
|
|
printf("[host] calling REAL entry(0x%p, 1, 0)\n", (void *)base); fflush(stdout);
|
|
if (getenv("SLINKY_BREAK")) __debugbreak();
|
|
int r = entry(base, 1, 0);
|
|
printf("[host] entry -> %d\n", r); fflush(stdout);
|
|
|
|
for (int i = 0; i < 24; i++) {
|
|
Sleep(1000);
|
|
fflush(stdout);
|
|
}
|
|
printf("[host] survived 24s\n"); fflush(stdout);
|
|
return 0;
|
|
}
|