Crack Slinky license check (VMProtect devirt dump)
- 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
This commit is contained in:
1 parent
7b19c3ee9f
commit
593391f215
15 files changed
+668
-2
No files matched your search
@@ -0,0 +1,75 @@
|
||||
/* 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;
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
const char *defkey = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef"; /* 32 chars */
|
||||
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;
|
||||
|
||||
if (!SetEnvironmentVariableW(L"SLINKY_LICENSE", wkey)) {
|
||||
printf("SetEnvironmentVariableW failed: %lu\n", GetLastError());
|
||||
return 1;
|
||||
}
|
||||
printf("[host] SLINKY_LICENSE=%s (len %zu)\n", ck, n);
|
||||
fflush(stdout);
|
||||
|
||||
HMODULE h = LoadLibraryW(L"C:\\Users\\nicot\\Downloads\\lib_beta_win_unpacked.devirt.bin~\\lib_beta_win_unpacked.devirt.bin");
|
||||
printf("[host] LoadLibraryW -> %p (GLE=%lu)\n", (void *)h, GetLastError());
|
||||
fflush(stdout);
|
||||
|
||||
Sleep(12000);
|
||||
printf("[host] still alive after 12s; DLL %s\n", h ? "(check if unloaded via GetModuleHandle)" : "");
|
||||
HMODULE h2 = GetModuleHandleW(L"C:\\Users\\nicot\\Downloads\\lib_beta_win_unpacked.devirt.bin~\\lib_beta_win_unpacked.devirt.bin");
|
||||
printf("[host] GetModuleHandle now -> %p\n", (void *)h2);
|
||||
fflush(stdout);
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
/* Manual mapper for the devirtualized Slinky DLL.
|
||||
* Maps the PE at its preferred base 0x180000000, resolves imports,
|
||||
* then calls the clean license init (base+0x1220) which spawns the
|
||||
* SLINKY_LICENSE validation thread. Skips the VMProtect entry point.
|
||||
*/
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
|
||||
typedef struct { uint32_t virt, sz; } _IMG_RELOC;
|
||||
|
||||
static int map_pe(const char *path, uint8_t **out_base, uint64_t *out_size) {
|
||||
FILE *f = fopen(path, "rb");
|
||||
if (!f) { printf("[mm] open failed\n"); 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) { printf("[mm] read failed\n"); 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;
|
||||
printf("[mm] preferred base 0x%llX size 0x%llX entry 0x%llX\n",
|
||||
(unsigned long long)pref, (unsigned long long)szimg,
|
||||
(unsigned long long)pref + nt->OptionalHeader.AddressOfEntryPoint);
|
||||
|
||||
uint8_t *base = (uint8_t *)VirtualAlloc((LPVOID)(uintptr_t)pref, (SIZE_T)szimg,
|
||||
MEM_RESERVE | MEM_COMMIT, PAGE_EXECUTE_READWRITE);
|
||||
uint64_t delta = 0;
|
||||
if (!base) {
|
||||
base = (uint8_t *)VirtualAlloc(NULL, (SIZE_T)szimg, MEM_RESERVE | MEM_COMMIT, PAGE_EXECUTE_READWRITE);
|
||||
if (!base) { printf("[mm] VirtualAlloc failed\n"); return 0; }
|
||||
delta = (uint64_t)(uintptr_t)base - pref;
|
||||
printf("[mm] preferred base taken; mapped at 0x%llX delta 0x%llX\n",
|
||||
(unsigned long long)(uintptr_t)base, (unsigned long long)delta);
|
||||
} else {
|
||||
printf("[mm] mapped at preferred base 0x%llX (no relocs needed)\n", (unsigned long long)(uintptr_t)base);
|
||||
}
|
||||
|
||||
/* headers + sections */
|
||||
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 == 0) continue;
|
||||
memcpy(base + sec[i].VirtualAddress, raw + sec[i].PointerToRawData, sec[i].SizeOfRawData);
|
||||
}
|
||||
|
||||
/* relocations */
|
||||
if (delta != 0 && nt->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_BASERELOC].Size) {
|
||||
uint8_t *r = base + nt->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_BASERELOC].VirtualAddress;
|
||||
uint8_t *rend = r + nt->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_BASERELOC].Size;
|
||||
while (r < rend) {
|
||||
uint32_t page = *(uint32_t *)r; uint32_t bs = *(uint32_t *)(r + 4);
|
||||
if (bs == 0) break;
|
||||
int n = (bs - 8) / 2;
|
||||
for (int i = 0; i < n; i++) {
|
||||
uint16_t e = *(uint16_t *)(r + 8 + i * 2);
|
||||
uint32_t off = e & 0xFFF, type = e >> 12;
|
||||
uint8_t *t = base + page + off;
|
||||
if (type == 10) *(uint64_t *)t += delta;
|
||||
else if (type == 3) *(uint32_t *)t += (uint32_t)delta;
|
||||
else if (type == 0) continue;
|
||||
else printf("[mm] reloc type %u at 0x%X\n", type, page + off);
|
||||
}
|
||||
r += bs;
|
||||
}
|
||||
}
|
||||
|
||||
/* imports */
|
||||
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++) {
|
||||
char *dll = (char *)(base + d->Name);
|
||||
HMODULE h = LoadLibraryA(dll);
|
||||
if (!h) { printf("[mm] import dll fail: %s\n", dll); 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;
|
||||
if (thunk[i] & 0x8000000000000000ULL) p = GetProcAddress(h, (LPCSTR)(thunk[i] & 0xFFFF));
|
||||
else p = GetProcAddress(h, (char *)(base + thunk[i] + 2));
|
||||
if (!p) { printf("[mm] import %s ord/hint fail\n", dll); return 0; }
|
||||
iat[i] = (uintptr_t)p;
|
||||
}
|
||||
}
|
||||
printf("[mm] imports resolved\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)) return 1;
|
||||
|
||||
/* init(hInst, DLL_PROCESS_ATTACH) -> spawns SLINKY_LICENSE validation thread */
|
||||
typedef int (*init_t)(void *, unsigned);
|
||||
init_t init = (init_t)(base + 0x1220);
|
||||
printf("[host] calling init(0x%p, 1)\n", (void *)base); fflush(stdout);
|
||||
if (getenv("SLINKY_BREAK")) __debugbreak();
|
||||
int r = init(base, 1);
|
||||
printf("[host] init -> %d ; waiting for validation thread...\n", r); fflush(stdout);
|
||||
|
||||
Sleep(10000);
|
||||
printf("[host] done\n"); fflush(stdout);
|
||||
return 0;
|
||||
}
|
||||
Reference in new issue
Block a user