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:
2rax committed 2026-11-08 11:27:38 -05:00
1 parent 7b19c3ee9f
commit 593391f215
15 files changed
+668 -2

No files matched your search

+128 -2
View File
@@ -1,3 +1,129 @@
# crackme # Slinky crackme — cracked
Posting the crackme on this when im done. Will explain how i did it Target: `lib_beta_win_unpacked.devirt.bin` — the **Slinky Minecraft client** DLL
(PE x86-64, 55,961,600 bytes, image base `0x180000000`,
SHA-256 `a225f9b51903982fbb5a9f65a5f80f0964b71091b52f90199fd6cea85054ff4f`),
an unpacked + devirtualized VMProtect dump (custom sections `.slinky0/.slinky1/.slinky2`,
`.vdvrt`, leftover VMP bytecode/handlers).
Result: **any 32-character license key is accepted** — 7-byte patch, verified
dynamically (`status: 0`, DLL no longer self-unloads).
```
key='WRONGKEY-THIS-IS-NOT-A-REAL-KEY!' (len 32)
[host] init -> 1; validation thread spawned; waiting...
[host] survived 12s - DLL still mapped
status: 0
```
---
## 1. The license mechanism
All offsets are RVAs from image base `0x180000000`.
```
DllMain (VM entry 0x35053D7)
└─> init +0x1220 (reason == DLL_PROCESS_ATTACH)
├─ hinstDLL -> global 0x2F9110
├─ _wgetenv(L"SLINKY_LICENSE") <-- key source: env var
└─ CreateThread(NULL, NULL, +0x10F0, key, 0, NULL)
thread +0x10F0
├─ wcslen(key) must == 0x20 (32 chars) else "Invalid license key", ret 0x1B5B
├─ UTF-16 -> byte fold (mod 127) into 33-byte stack buffer
├─ lock cmpxchg one-shot guard @ 0x2F9118
├─ call validate() +0x1290
│ ├─ lea rcx, [0x140064] ; 16-byte blob:
│ │ E9 84 C6 54 98 46 2E 0B B9 87 71 36 F4 36 85 35
│ ├─ call 0x1835556EC ; mutated VMP stubs (.vdvrt) -> VM
│ ├─ call 0x18356D25F ; handlers in .slinky0/.slinky2
│ └─ call 0x18354E385 ; (hash + HWID fingerprint; un-lifted)
│ returns EAX: 0 == valid
├─ EAX != 0 → fprintf(stderr, "status: %lu", code)
│ Sleep(1000); FreeLibraryAndExitThread(hinst, 0) <-- self-unload
└─ EAX == 0 → "status: 0", DLL stays loaded
```
Supporting evidence: imports `CryptAcquireContextA / CryptCreateHash /
CryptHashData / CryptGetHashParam`, `BCryptGenRandom`, `IPHLPAPI` (HWID);
strings `"SLINKY_LICENSE"` (UTF-16), `"Invalid license key"`, `"status: %lu"`,
`"Authentication failed: %s"`, `"API error: status %u"`.
## 2. How it was reversed (methodology)
1. **Static triage without a decompiler.** No Ghidra/IDA/Hopper provider was
available, so: objdump section/PE-header dumps, a raw keyword scan found the
license strings, and IAT slots were resolved by hand from the import table
(`_wgetenv`, `CreateThread`, `CloseHandle`, `Sleep`,
`FreeLibraryAndExitThread`, `__acrt_iob_func`). RIP-relative `lea` targets
were computed from a full `.text` disassembly to find the code referencing
each string → located the license cluster at the very start of `.text`.
2. **Function bounds via `.pdata`.** The data-directory exception table was a
stale protector artifact, but the on-disk `.pdata` section had 8,818 real
RUNTIME_FUNCTION entries — that gave `validate()` = `0x180001290–0x18000F7D4`
(57 KB, mostly inline VM bytecode) and proved the license thread/init were
clean native code.
3. **Dynamic analysis, three attempts.**
- Plain `LoadLibraryW` host → process killed inside the packer entry
(VMP anti-host/anti-analysis checks).
- Frida spawn+attach → detected, killed via a path that bypassed hooks.
- **Manual mapping** at the preferred base `0x180000000` + calling the clean
init `+0x1220` directly → license thread runs.
4. **gdb + hardware breakpoints.** Software bps and inline hooks are
detectable/CRC-checked; hardware bps (4 slots) + a Python driver that
distinguishes breakpoint SIGTRAPs from VMP's *exception-based control flow*
(deliberate `int3`/SEGV handled by the packer's own VEH) let me follow the
thread into the VM.
5. **Why standalone VM execution fails.** The devirtualizer only lifted part of
the logic; the VMP stubs still verify packer runtime state (initialized by
the original entry, which refuses non-Minecraft hosts and fails its own
integrity checks in the rebuilt image) → computed-context loads fault at
`0x180A6F4DF` / `0x1820DD058` whenever the VM is entered.
6. **Conclusion: don't fight the VM — bypass it.** The wrapper is clean native
code and returns `EAX` straight from `validate()`; the VM's only observable
effect on the wrapper is that return value. Forcing it to 0 = success,
without executing any un-lifted bytecode.
## 3. The crack
`validate()` @ `+0x1290` patched to return 0 unconditionally:
```
file offset 0x6AE (VA 0x1800012AE)
original: 48 8D 0D AF ED 13 00 lea rcx,[0x180140064] ; -> VM calls
patched: 31 C0 E9 22 00 00 00 xor eax,eax ; EAX = 0 = valid
jmp 0x1800012D7 ; -> epilogue
```
Patched file SHA-256:
`2a71d3850ed15d275850f6c20cfb689f886ee1ecf641a848e3c45edddccd2820`
Reproduce with `patch/crack_patch.py`.
## 4. Repo contents
```
patch/crack_patch.py applies the 7-byte crack to the devirt binary
loader/slinky_crack.c manual-map test loader (maps at 0x180000000, calls
loader/slinky_crack.exe clean init +0x1220, sets SLINKY_LICENSE from argv[1])
hosts/ the other loader variants used during analysis
gdb/ hardware-breakpoint + SIGTRAP-passing debug drivers
analysis/
slinky_pe.txt full PE headers + import table
slinky_funcs.xml .pdata function bounds (8,818 functions)
slinky_validate.asm validate() disassembly
```
Excluded for size (rebuild locally): the original binaries, the 261 MB `.i64`,
the full 38 MB `.text` disassembly. `crack_patch.py` regenerates the cracked
binary from `lib_beta_win_unpacked.devirt.bin`.
## 5. Notes / limits
- The key's cryptographic check itself lives in un-lifted VM bytecode (consumes
the 16-byte blob; CryptoAPI + HWID fingerprint). A genuine *keygen* would
require lifting that bytecode — the shipped `.i64` is the right artifact.
The patch instead makes any 32-char key validate, which is sufficient.
- VM'd message functions (`+0x55680`, the failure dialog path) can only run in
the real injected (Minecraft) process; the patched success path avoids them.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+36
View File
@@ -0,0 +1,36 @@
set pagination off
set confirm off
set print thread-events off
break main
run
delete
hbreak *0x180001290
hbreak *0x1800011c8
hbreak *0x1800011f6
hbreak *0x1800ad320
# hbreak dropped - only 4 hw slots
continue
printf "\n=== STOP 1 ===\n"
info threads
x/4i $pc
continue
printf "\n=== STOP 2 ===\n"
info threads
x/4i $pc
bt 5
continue
printf "\n=== STOP 3 ===\n"
info threads
x/4i $pc
bt 5
continue
printf "\n=== STOP 4 ===\n"
info threads
x/4i $pc
bt 5
continue
printf "\n=== STOP 5 ===\n"
info program
info threads
x/4i $pc
bt 5
+19
View File
@@ -0,0 +1,19 @@
set pagination off
set confirm off
set print thread-events off
break main
run
delete
# stop on first exception, don't pass anything
continue
printf "\n=== STOPPED ===\n"
info program
info threads
x/8i $pc
info registers rip rax rbx rcx rdx rsi rdi rbp rsp
bt 6
continue
printf "\n=== STOP 2 ===\n"
info program
x/8i $pc
bt 6
+33
View File
@@ -0,0 +1,33 @@
set pagination off
set confirm off
set print thread-events on
break main
run
# image is mapped by the time we hit the __debugbreak in main (SLINKY_BREAK=1)
hbreak *0x180001290
hbreak *0x1835556ec
hbreak *0x18356d25f
hbreak *0x18354e385
continue
printf "\n=== stopped, where ===\n"
info threads
x/16i $pc
continue
printf "\n=== second stop ===\n"
info threads
bt 8
x/16i $pc
continue
printf "\n=== third stop ===\n"
info threads
bt 8
x/16i $pc
continue
printf "\n=== fourth stop ===\n"
info threads
bt 8
x/24i $pc
continue
printf "\n=== still alive? ===\n"
info threads
info program
+11
View File
@@ -0,0 +1,11 @@
set pagination off
set confirm off
set print thread-events off
break main
run
delete
handle SIGSEGV nostop noprint pass
handle SIGTRAP nostop noprint pass
handle SIGILL nostop noprint pass
continue
info program
+69
View File
@@ -0,0 +1,69 @@
import gdb
gdb.execute("set pagination off")
gdb.execute("set confirm off")
gdb.execute("set print thread-events on")
gdb.execute("file C:/Users/nicot/AppData/Local/Temp/opencode/slinky_mm.exe")
gdb.execute("break main")
gdb.execute("run")
# image mapped by now (SLINKY_BREAK=1 __debugbreak was hit on the way? no - break main first)
# Actually map happens later in main; we need to continue until the debugbreak
gdb.execute("tbreak _mingw.h:616") # not reliable; instead continue until SIGTRAP from __debugbreak
# Remove main bp, continue to __debugbreak SIGTRAP
gdb.execute("delete")
gdb.execute("continue") # should stop at __debugbreak SIGTRAP (thread 1)
BPS = {
0x180001290: "VALIDATE_ENTER",
0x1800011C8: "POST_VALIDATE(test eax)",
0x1835556EC: "VM1",
0x18356D25F: "VM2",
}
for a, n in BPS.items():
gdb.execute("hbreak *0x%x" % a)
log = []
stops = 0
MAX = 400
try:
while stops < MAX:
pc = int(gdb.parse_and_eval("$pc").cast(gdb.lookup_type("unsigned long long")))
tid = gdb.selected_thread().num if gdb.selected_thread() else -1
name = BPS.get(pc)
if name:
extra = ""
if name == "VALIDATE_ENTER":
try:
key = gdb.execute("x/s $rcx", to_string=True).strip()
extra = " key=" + key
except Exception:
pass
if name == "POST_VALIDATE":
try:
rax = int(gdb.parse_and_eval("$rax"))
extra = " eax(validate result)=0x%x (%d)" % (rax & 0xffffffff, rax & 0xffffffff)
except Exception:
pass
log.append("STOP#%d tid=%d %s pc=0x%x%s" % (stops, tid, name, pc, extra))
gdb.execute("continue")
else:
dis = gdb.execute("x/2i $pc", to_string=True).replace("\n", " | ")
log.append("STOP#%d tid=%d TRAP pc=0x%x %s [passing SIGTRAP]" % (stops, tid, pc, dis))
gdb.execute("signal SIGTRAP")
stops += 1
except gdb.error as e:
log.append("GDB-ERROR: %s" % e)
except Exception as e:
log.append("ERR: %r" % e)
log.append("=== final info threads ===")
try:
log.append(gdb.execute("info threads", to_string=True))
log.append(gdb.execute("info program", to_string=True))
except Exception:
pass
with open("C:/Users/nicot/AppData/Local/Temp/opencode/gdbtrace.log", "w") as f:
f.write("\n".join(log))
print("\n".join(log[:200]))
+75
View File
@@ -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;
}
+31
View File
@@ -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;
}
+118
View File
@@ -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;
}
+84
View File
@@ -0,0 +1,84 @@
/* Patched-loader: maps the devirt DLL, patches validate() to return 0
* unconditionally (bypassing the un-runnable VM stubs), then spawns the
* license thread via the clean init at base+0x1220.
*
* Patch at 0x1800012ae (7 bytes, replacing the lea of the VM blob):
* 31 c0 xor eax, eax
* e9 24 00 00 00 jmp 0x1800012d7 (validate epilogue, past mov eax,r14d)
* => validate() always returns 0 (STATUS_SUCCESS).
*/
#include <windows.h>
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <stdlib.h>
static int map_pe(const char *path, uint8_t **out_base) {
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);
uint8_t *base = (uint8_t *)VirtualAlloc((LPVOID)(uintptr_t)nt->OptionalHeader.ImageBase,
(SIZE_T)nt->OptionalHeader.SizeOfImage,
MEM_RESERVE | MEM_COMMIT, PAGE_EXECUTE_READWRITE);
if (!base) { printf("[mm] preferred base taken\n"); return 0; }
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];
IMAGE_IMPORT_DESCRIPTOR *d = (IMAGE_IMPORT_DESCRIPTOR *)(base + idd->VirtualAddress);
for (; d->Name; d++) {
HMODULE h = LoadLibraryA((char *)(base + d->Name));
if (!h) 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) return 0;
iat[i] = (uintptr_t)p;
}
}
*out_base = base;
return 1;
}
int main(int argc, char **argv) {
const char *defkey = "AAAA-BBBB-CCCC-DDDD-EEEE-FFFF-0";
const char *ck = (argc > 1) ? 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 (len %zu)\n", ck, n); fflush(stdout);
uint8_t *base = NULL;
const char *dllpath = getenv("SLINKY_DLL");
if (!dllpath) dllpath = "lib_beta_win_unpacked.devirt.CRACKED.bin"; /* default: cracked file next to this exe */
if (!map_pe(dllpath, &base)) { printf("[host] map failed\n"); return 1; }
printf("[mm] mapped %s at 0x%p\n", dllpath, (void *)base);
if (getenv("SLINKY_NOPATCH") == NULL) {
static const unsigned char p[] = { 0x31, 0xC0, 0xE9, 0x22, 0x00, 0x00, 0x00 };
DWORD old;
VirtualProtect(base + 0x12ae, sizeof(p), PAGE_EXECUTE_READWRITE, &old);
memcpy(base + 0x12ae, p, sizeof(p));
VirtualProtect(base + 0x12ae, sizeof(p), old, &old);
printf("[patch] validate() -> always returns 0 (SUCCESS)\n"); fflush(stdout);
}
typedef int (*init_t)(void *, unsigned);
int r = ((init_t)(base + 0x1220))(base, 1);
printf("[host] init -> %d; validation thread spawned; waiting...\n", r); fflush(stdout);
for (int i = 0; i < 12; i++) { Sleep(1000); fflush(stdout); }
printf("[host] survived 12s - DLL still mapped\n"); fflush(stdout);
return 0;
}
Binary file not shown.
+64
View File
@@ -0,0 +1,64 @@
#!/usr/bin/env python3
"""Apply the Slinky crackme patch to lib_beta_win_unpacked.devirt.bin.
Patches validate() (VA 0x180001290, file offset 0x6AE) to return 0
(success) unconditionally, bypassing the VMProtect license check:
original: 48 8D 0D AF ED 13 00 lea rcx,[0x180140064] ; -> VM calls
patched: 31 C0 E9 22 00 00 00 xor eax,eax ; jmp 0x1800012D7 (epilogue)
Result: any 32-character SLINKY_LICENSE key validates ("status: 0") and the
DLL no longer unloads itself on failure.
Usage: python crack_patch.py <input.bin> [output.bin]
"""
import hashlib
import sys
OFFSET = 0x6AE
ORIG = bytes.fromhex("48 8D 0D AF ED 13 00")
PATCH = bytes.fromhex("31 C0 E9 22 00 00 00")
SRC_SHA256 = "a225f9b51903982fbb5a9f65a5f80f0964b71091b52f90199fd6cea85054ff4f"
DST_SHA256 = "2a71d3850ed15d275850f6c20cfb689f886ee1ecf641a848e3c45edddccd2820"
def main() -> int:
if len(sys.argv) not in (2, 3):
print(__doc__)
return 1
src = sys.argv[1]
dst = sys.argv[2] if len(sys.argv) == 3 else src.rsplit(".", 1)[0] + ".CRACKED.bin"
with open(src, "rb") as f:
data = bytearray(f.read())
digest = hashlib.sha256(data).hexdigest()
if digest == DST_SHA256:
print("input is already patched")
return 0
if digest != SRC_SHA256:
print(f"warning: input sha256 {digest} != expected {SRC_SHA256}")
current = bytes(data[OFFSET : OFFSET + 7])
if current == PATCH:
print("offset 0x6AE already patched")
return 0
if current != ORIG:
print(f"error: unexpected bytes at 0x{OFFSET:X}: {current.hex(' ')}")
return 1
data[OFFSET : OFFSET + 7] = PATCH
with open(dst, "wb") as f:
f.write(data)
out = hashlib.sha256(data).hexdigest()
print(f"patched {src} -> {dst}")
print(f"sha256: {out}")
assert out == DST_SHA256, "patch produced unexpected digest"
return 0
if __name__ == "__main__":
sys.exit(main())