// vfy shell —— VS 2026 暗黑风(Direct2D + DirectWrite) // 两种形态:独立 exe(内嵌加密载荷)/ 注入用 DLL(导出 VerifyMain,验证后跳原入口 OEP) #include #include #include #include #include #include #include #include #include #include #include #include #define CARD_W 420.0f #define CARD_H 404.0f #define PAD 20.0f #define D2D_VER 1 static float g_S = 1.0f; static inline float L(float v) { return v * g_S; } /* VS 2026 dark */ static D2D1_COLOR_F C_CARD, C_BAR, C_BORDER, C_INPUT, C_INPUT_BD, C_FOCUS, C_TXT, C_TXT2, C_ACCENT, C_ACCENT_H, C_ACCENT_P, C_LINK, C_RED, C_GREEN, C_WHITE, C_TAG; static ID2D1Factory *g_d2d = NULL; static IDWriteFactory *g_dw = NULL; static ID2D1DCRenderTarget *g_rt = NULL; static const wchar_t *g_famCJK = L"Microsoft YaHei UI"; static const wchar_t *g_famLat = L"Segoe UI"; static HWND g_hwnd, g_hUser, g_hPass; static HFONT g_fontEdit = NULL; static HBRUSH g_brInput = NULL; static int g_focus = 0; static int g_hBtn, g_hChk, g_hTag, g_hEye, g_hClose, g_hMin, g_hLink; static int g_pressBtn, g_checked, g_showPass; static volatile LONG g_busy = 0; static int g_statusKind = 0; static wchar_t g_status[256] = L"\x5C31\x7EEA"; static int g_tick = 0; static int g_done = 0; static const RECT LR_CLOSE = {420 - 44, 0, 420, 32}; static const RECT LR_MIN = {420 - 88, 0, 420 - 44, 32}; static const RECT LR_USER = {20, 124, 400, 156}; static const RECT LR_PASS = {20, 186, 400, 218}; static const RECT LR_EYE = {368, 190, 392, 214}; static const RECT LR_CHK = {20, 233, 34, 247}; static const RECT LR_REM = {20, 228, 150, 252}; static const RECT LR_TAG = {244, 228, 400, 252}; static const RECT LR_BTN = {20, 264, 400, 298}; static const RECT LR_L1 = {20, 316, 116, 338}; static const RECT LR_L2 = {128, 316, 224, 338}; static const RECT LR_L3 = {236, 316, 332, 338}; /* ---------- 载荷(仅 exe 形态使用) ---------- */ static unsigned char *g_file = NULL; static DWORD g_fileSize = 0; static const unsigned char *g_payload = NULL; static DWORD g_payloadSize = 0; static unsigned char g_nonce[12], g_tag[16]; static char g_cfg[4096], g_api[512]; static char g_name[128] = "\xE6\xBC\x94\xE7\xA4\xBA\xE7\xA8\x8B\xE5\xBA\x8F"; static char g_device[64] = "A1B2-3C4D"; static char g_auto[128], g_offline[64]; static const char TAIL_MAGIC[8] = {'V', 'F', 'Y', 'D', '1', 0, 0, 0}; static void logf_(const char *fmt, ...) { char tmp[MAX_PATH] = {0}; GetTempPathA(MAX_PATH, tmp); char path[MAX_PATH]; snprintf(path, sizeof(path), "%svfy_debug.log", tmp); FILE *f = fopen(path, "a"); if (!f) return; va_list ap; va_start(ap, fmt); vfprintf(f, fmt, ap); va_end(ap); fputc('\n', f); fclose(f); } static int json_str(const char *src, const char *key, char *out, int cap) { char pat[64]; snprintf(pat, sizeof(pat), "\"%s\"", key); const char *p = strstr(src, pat); if (!p) return 0; p = strchr(p + strlen(pat), ':'); if (!p) return 0; p = strchr(p, '"'); if (!p) return 0; p++; int i = 0; while (*p && *p != '"' && i < cap - 1) out[i++] = *p++; out[i] = 0; return 1; } static void load_cfg(const char *json) { snprintf(g_cfg, sizeof(g_cfg), "%s", json ? json : ""); json_str(g_cfg, "api", g_api, sizeof(g_api)); json_str(g_cfg, "name", g_name, sizeof(g_name)); json_str(g_cfg, "device", g_device, sizeof(g_device)); json_str(g_cfg, "offline_pass", g_offline, sizeof(g_offline)); } /* ---------- 文本:CJK/拉丁分段 ---------- */ static int is_cjk(wchar_t c) { return (c >= 0x2E80 && c <= 0x9FFF) || (c >= 0xF900 && c <= 0xFAFF) || (c >= 0xFF00 && c <= 0xFF65) || (c >= 0x3000 && c <= 0x303F); } static void draw_run(const wchar_t *s, int n, const wchar_t *fam, float x, float y, float h, float px, D2D1_COLOR_F c, int bold) { IDWriteTextFormat *f = NULL; if (FAILED(g_dw->CreateTextFormat(fam, NULL, bold ? DWRITE_FONT_WEIGHT_SEMI_BOLD : DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, L(px), L"zh-cn", &f))) return; f->SetWordWrapping(DWRITE_WORD_WRAPPING_NO_WRAP); f->SetTextAlignment(DWRITE_TEXT_ALIGNMENT_LEADING); f->SetParagraphAlignment(DWRITE_PARAGRAPH_ALIGNMENT_CENTER); wchar_t sub[512]; int k = n > 511 ? 511 : n; for (int i = 0; i < k; i++) sub[i] = (s[i] == 0x20) ? (wchar_t)0x00A0 : s[i]; sub[k] = 0; IDWriteTextLayout *lay = NULL; if (FAILED(g_dw->CreateTextLayout(sub, (UINT32)k, f, 4000.0f, L(h), &lay))) { f->Release(); return; } ID2D1SolidColorBrush *b = NULL; if (SUCCEEDED(g_rt->CreateSolidColorBrush(c, &b))) { g_rt->DrawTextLayout(D2D1::Point2F(L(x), L(y)), lay, b, D2D1_DRAW_TEXT_OPTIONS_NONE); b->Release(); } lay->Release(); f->Release(); } static float run_width(const wchar_t *s, int n, const wchar_t *fam, float px, int bold) { IDWriteTextFormat *f = NULL; if (FAILED(g_dw->CreateTextFormat(fam, NULL, bold ? DWRITE_FONT_WEIGHT_SEMI_BOLD : DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, L(px), L"zh-cn", &f))) return 0; f->SetWordWrapping(DWRITE_WORD_WRAPPING_NO_WRAP); IDWriteTextLayout *lay = NULL; float w = 0; if (SUCCEEDED(g_dw->CreateTextLayout(s, (UINT32)n, f, 4000.0f, L(px * 2), &lay))) { DWRITE_TEXT_METRICS m; if (SUCCEEDED(lay->GetMetrics(&m)) && m.width > 0.5f) w = m.width / g_S - 0.6f; lay->Release(); } if (w <= 0.5f) for (int i = 0; i < n; i++) w += is_cjk(s[i]) ? px : (s[i] == 0x20 ? px * 0.28f : px * 0.56f); f->Release(); return w; } static void textL(const wchar_t *s, float x, float y, float w, float h, float px, D2D1_COLOR_F c, int bold, int align) { int len = (int)wcslen(s); if (!len) return; int starts[64], lens[64], fams[64], cnt = 0, i = 0; while (i < len && cnt < 64) { int cjk = is_cjk(s[i]); int j = i; while (j < len && is_cjk(s[j]) == cjk) j++; starts[cnt] = i; lens[cnt] = j - i; fams[cnt] = cjk; cnt++; i = j; } float total = 0; for (int k = 0; k < cnt; k++) total += run_width(s + starts[k], lens[k], fams[k] ? g_famCJK : g_famLat, px, bold); float ox = x; if (align == 1) ox = x + (w - total) * 0.5f; else if (align == 2) ox = x + w - total; for (int k = 0; k < cnt; k++) { const wchar_t *fam = fams[k] ? g_famCJK : g_famLat; draw_run(s + starts[k], lens[k], fam, ox, y, h, px, c, bold); ox += run_width(s + starts[k], lens[k], fam, px, bold); } } /* ---------- 形状 ---------- */ static void fillRound(float x, float y, float w, float h, float r, D2D1_COLOR_F c) { ID2D1SolidColorBrush *b = NULL; if (FAILED(g_rt->CreateSolidColorBrush(c, &b))) return; g_rt->FillRoundedRectangle(D2D1::RoundedRect(D2D1::RectF(L(x), L(y), L(x + w), L(y + h)), L(r), L(r)), b); b->Release(); } static void strokeRound(float x, float y, float w, float h, float r, float wd, D2D1_COLOR_F c) { ID2D1SolidColorBrush *b = NULL; if (FAILED(g_rt->CreateSolidColorBrush(c, &b))) return; g_rt->DrawRoundedRectangle(D2D1::RoundedRect(D2D1::RectF(L(x), L(y), L(x + w), L(y + h)), L(r), L(r)), b, L(wd)); b->Release(); } static void fillRect(float x, float y, float w, float h, D2D1_COLOR_F c) { ID2D1SolidColorBrush *b = NULL; if (FAILED(g_rt->CreateSolidColorBrush(c, &b))) return; g_rt->FillRectangle(D2D1::RectF(L(x), L(y), L(x + w), L(y + h)), b); b->Release(); } static void line(float x1, float y1, float x2, float y2, float wd, D2D1_COLOR_F c) { ID2D1SolidColorBrush *b = NULL; if (FAILED(g_rt->CreateSolidColorBrush(c, &b))) return; g_rt->DrawLine(D2D1::Point2F(L(x1), L(y1)), D2D1::Point2F(L(x2), L(y2)), b, L(wd)); b->Release(); } static D2D1_COLOR_F status_color(void) { return g_statusKind == 1 ? C_GREEN : (g_statusKind == 2 ? C_RED : C_TXT2); } /* ---------- 画面 ---------- */ static void paint(void) { for (int i = 14; i >= 1; i--) fillRound(PAD - i, PAD - i + 2 + i / 8.0f, CARD_W + i * 2, CARD_H + i * 2, 6 + i, D2D1::ColorF(0, 0, 0, 0.02f + (15 - i) * 0.006f)); fillRound(PAD, PAD, CARD_W, CARD_H, 6, C_CARD); strokeRound(PAD, PAD, CARD_W, CARD_H, 6, 1.0f, C_BORDER); g_rt->SetTransform(D2D1::Matrix3x2F::Translation(L(PAD), L(PAD))); /* 标题栏 */ fillRound(0, 0, CARD_W, 32 + 6, 6, C_BAR); fillRect(0, 32, CARD_W, 6, C_CARD); fillRect(0, 31.6f, CARD_W, 0.6f, C_BORDER); if (g_hClose) fillRect(LR_CLOSE.left, 0, 44, 32, D2D1::ColorF(0.91f, 0.07f, 0.14f, 1)); else if (g_hMin) fillRect(LR_MIN.left, 0, 44, 32, D2D1::ColorF(1, 1, 1, 0.07f)); { D2D1_COLOR_F ic = C_TXT; float cx = (LR_CLOSE.left + LR_CLOSE.right) / 2.0f, cy = 16; line(cx - 4.5f, cy - 4.5f, cx + 4.5f, cy + 4.5f, 1.0f, ic); line(cx + 4.5f, cy - 4.5f, cx - 4.5f, cy + 4.5f, 1.0f, ic); float mx = (LR_MIN.left + LR_MIN.right) / 2.0f; line(mx - 4.5f, cy, mx + 4.5f, cy, 1.0f, ic); } fillRound(12, 8, 16, 16, 3, C_ACCENT); { wchar_t t[256] = {0}; MultiByteToWideChar(CP_UTF8, 0, g_name, -1, t, 256); textL(t, 36, 0, 260, 32, 12, C_TXT, 0, 0); } /* 标题区 */ textL(L"\x767B\x5F55\x4EE5\x7EE7\x7EED", 20, 46, 300, 26, 15, C_TXT, 1, 0); textL(L"\x8BF7\x4F7F\x7528\x8D26\x53F7\x6216\x5361\x5BC6\x767B\x5F55", 20, 72, 320, 16, 11, C_TXT2, 0, 0); /* 账号 */ textL(L"\x8D26\x53F7", 20, 102, 100, 16, 11, C_TXT2, 0, 0); fillRound(20, 124, 380, 32, 3, C_INPUT); strokeRound(20, 124, 380, 32, 3, 1.0f, g_focus == 1 ? C_FOCUS : C_INPUT_BD); if (g_focus == 1) strokeRound(21.5f, 125.5f, 377, 29, 2.4f, 1.0f, C_FOCUS); if (GetWindowTextLengthW(g_hUser) == 0 && g_focus != 1) textL(L"\x8BF7\x8F93\x5165\x8D26\x53F7", 32, 124, 340, 32, 12, D2D1::ColorF(0.52f, 0.52f, 0.55f, 1), 0, 0); /* 密码 */ textL(L"\x5BC6\x7801", 20, 164, 100, 16, 11, C_TXT2, 0, 0); fillRound(20, 186, 380, 32, 3, C_INPUT); strokeRound(20, 186, 380, 32, 3, 1.0f, g_focus == 2 ? C_FOCUS : C_INPUT_BD); if (g_focus == 2) strokeRound(21.5f, 187.5f, 377, 29, 2.4f, 1.0f, C_FOCUS); if (GetWindowTextLengthW(g_hPass) == 0 && g_focus != 2) textL(L"\x8BF7\x8F93\x5165\x5BC6\x7801", 32, 186, 320, 32, 12, D2D1::ColorF(0.52f, 0.52f, 0.55f, 1), 0, 0); { D2D1_COLOR_F ec = g_hEye ? C_FOCUS : D2D1::ColorF(0.6f, 0.6f, 0.63f, 1); ID2D1SolidColorBrush *b = NULL; if (SUCCEEDED(g_rt->CreateSolidColorBrush(ec, &b))) { g_rt->DrawEllipse(D2D1::Ellipse(D2D1::Point2F(L(376), L(202)), L(8.5f), L(5.5f)), b, L(1.0f)); if (g_showPass) line(368, 210, 384, 194, 1.0f, ec); else { ID2D1SolidColorBrush *pb = NULL; if (SUCCEEDED(g_rt->CreateSolidColorBrush(ec, &pb))) { g_rt->FillEllipse(D2D1::Ellipse(D2D1::Point2F(L(376), L(202)), L(2.4f), L(2.4f)), pb); pb->Release(); } } b->Release(); } } /* 记住账号 */ fillRound(20, 233, 14, 14, 2, g_checked ? C_FOCUS : C_INPUT); strokeRound(20, 233, 14, 14, 2, 1.0f, g_checked ? C_FOCUS : (g_hChk ? C_TXT2 : C_INPUT_BD)); if (g_checked) { line(23.2f, 240.2f, 25.6f, 242.8f, 1.4f, C_WHITE); line(25.6f, 242.8f, 31.0f, 236.8f, 1.4f, C_WHITE); } textL(L"\x8BB0\x4F4F\x8D26\x53F7", 40, 233, 100, 14, 11, C_TXT2, 0, 0); /* 设备码(VS 标签样式:小圆角 + 细边) */ fillRound(244, 228, 156, 24, 2, C_TAG); strokeRound(244, 228, 156, 24, 2, 1.0f, C_INPUT_BD); { wchar_t tg[160], dev[64] = {0}; MultiByteToWideChar(CP_UTF8, 0, g_device, -1, dev, 64); swprintf(tg, 160, L"\x8BBE\x5907 %ls", dev); textL(tg, 244, 228, 156, 24, 10.5f, C_TXT2, 0, 1); } /* 主按钮 */ if (g_busy) { fillRound(20, 264, 380, 34, 3, D2D1::ColorF(0.22f, 0.22f, 0.24f, 1)); wchar_t d[16] = L"\x9A8C\x8BC1\x4E2D"; int k = g_tick % 4; for (int i = 0; i < k; i++) d[3 + i] = L'.'; d[3 + k] = 0; textL(d, 20, 264, 380, 34, 12.5f, D2D1::ColorF(0.62f, 0.62f, 0.65f, 1), 0, 1); } else { fillRound(20, 264, 380, 34, 3, g_pressBtn ? C_ACCENT_P : (g_hBtn ? C_ACCENT_H : C_ACCENT)); textL(L"\x767B\x5F55", 20, 264, 380, 34, 12.5f, C_WHITE, 0, 1); } /* 链接 */ textL(L"\x6CE8\x518C\x8D26\x53F7", 20, 316, 96, 22, 11, g_hLink == 1 ? C_LINK : C_TXT2, 0, 0); textL(L"\x5361\x5BC6\x5145\x503C", 128, 316, 96, 22, 11, g_hLink == 2 ? C_LINK : C_TXT2, 0, 0); textL(L"\x5FD8\x8BB0\x5BC6\x7801", 236, 316, 96, 22, 11, g_hLink == 3 ? C_LINK : C_TXT2, 0, 0); /* 状态 + 页脚 */ fillRound(20, 356, 5, 5, 2.5f, status_color()); textL(g_status, 32, 348, 340, 20, 11, status_color(), 0, 0); line(20, 374, 400, 374, 0.6f, C_BORDER); textL(L"v1.0.0 \xB7 \x53EF\x4FE1\x8BBE\x5907\x7ED1\x5B9A \xB7 \x5F02\x5E38\x767B\x5F55\x81EA\x52A8\x9501\x5B9A", 20, 380, 380, 16, 10, D2D1::ColorF(0.55f, 0.55f, 0.58f, 1), 0, 0); g_rt->SetTransform(D2D1::Matrix3x2F::Identity()); } /* ---------- 离屏渲染 + 提交 ---------- */ static void render(void) { if (!g_rt || !g_hwnd) return; int w = (int)((CARD_W + PAD * 2) * g_S), h = (int)((CARD_H + PAD * 2) * g_S); HDC screen = GetDC(NULL); HDC mem = CreateCompatibleDC(screen); BITMAPINFO bi; ZeroMemory(&bi, sizeof(bi)); bi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); bi.bmiHeader.biWidth = w; bi.bmiHeader.biHeight = -h; bi.bmiHeader.biPlanes = 1; bi.bmiHeader.biBitCount = 32; bi.bmiHeader.biCompression = BI_RGB; void *bits = NULL; HBITMAP dib = CreateDIBSection(screen, &bi, DIB_RGB_COLORS, &bits, NULL, 0); if (!dib) { DeleteDC(mem); ReleaseDC(NULL, screen); return; } HGDIOBJ old = SelectObject(mem, dib); memset(bits, 0, (size_t)w * h * 4); RECT rc = {0, 0, w, h}; g_rt->BindDC(mem, &rc); g_rt->SetDpi(96.0f, 96.0f); g_rt->SetAntialiasMode(D2D1_ANTIALIAS_MODE_PER_PRIMITIVE); g_rt->SetTextAntialiasMode(D2D1_TEXT_ANTIALIAS_MODE_GRAYSCALE); g_rt->BeginDraw(); g_rt->Clear(D2D1::ColorF(0, 0, 0, 0)); paint(); HRESULT hr = g_rt->EndDraw(); if (FAILED(hr)) logf_("EndDraw hr=0x%lx", (unsigned long)hr); RECT wr; GetWindowRect(g_hwnd, &wr); POINT dst = {wr.left, wr.top}, src = {0, 0}; SIZE sz = {w, h}; BLENDFUNCTION bf = {AC_SRC_OVER, 0, 255, AC_SRC_ALPHA}; UpdateLayeredWindow(g_hwnd, screen, &dst, &sz, mem, &src, 0, &bf, ULW_ALPHA); SelectObject(mem, old); DeleteObject(dib); DeleteDC(mem); ReleaseDC(NULL, screen); } /* ---------- 字体自检 ---------- */ static int font_cov(const wchar_t *fam, const wchar_t *sample) { const int W = 200, H = 40; HDC screen = GetDC(NULL); HDC mem = CreateCompatibleDC(screen); BITMAPINFO bi; ZeroMemory(&bi, sizeof(bi)); bi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); bi.bmiHeader.biWidth = W; bi.bmiHeader.biHeight = -H; bi.bmiHeader.biPlanes = 1; bi.bmiHeader.biBitCount = 32; bi.bmiHeader.biCompression = BI_RGB; void *bits = NULL; HBITMAP dib = CreateDIBSection(screen, &bi, DIB_RGB_COLORS, &bits, NULL, 0); if (!dib) { DeleteDC(mem); ReleaseDC(NULL, screen); return 0; } HGDIOBJ old = SelectObject(mem, dib); memset(bits, 0, W * H * 4); RECT rc = {0, 0, W, H}; g_rt->BindDC(mem, &rc); g_rt->SetDpi(96.0f, 96.0f); g_rt->SetTextAntialiasMode(D2D1_TEXT_ANTIALIAS_MODE_GRAYSCALE); g_rt->BeginDraw(); g_rt->Clear(D2D1::ColorF(0, 0, 0, 0)); draw_run(sample, (int)wcslen(sample), fam, 4, 2, 30, 15, D2D1::ColorF(1, 1, 1, 1), 0); g_rt->EndDraw(); int n = 0; unsigned char *p = (unsigned char *)bits; for (int i = 0; i < W * H; i++) if (p[i * 4 + 3] > 16) n++; SelectObject(mem, old); DeleteObject(dib); DeleteDC(mem); ReleaseDC(NULL, screen); return n; } static void detect_fonts(void) { const wchar_t *cjk[] = {L"Microsoft YaHei UI", L"Microsoft YaHei", L"WenQuanYi Micro Hei", L"Noto Sans CJK SC", L"DejaVu Sans"}; const wchar_t *lat[] = {L"Segoe UI", L"Microsoft YaHei UI", L"DejaVu Sans", L"Arial", L"Tahoma"}; int best = 0; for (int i = 0; i < 5; i++) { int c = font_cov(cjk[i], L"\x8BBE\x5907\x8D26\x53F7"); if (c > best) { best = c; g_famCJK = cjk[i]; } } best = 0; for (int i = 0; i < 5; i++) { int c = font_cov(lat[i], L"A1B2-3C4D v1.0.0"); if (c > best) { best = c; g_famLat = lat[i]; } } logf_("fonts: cjk/ lat ok"); } /* ---------- 鉴权 + 载荷 ---------- */ static int aes_decrypt(const unsigned char *in, DWORD inLen, unsigned char **out, DWORD *outLen) { static const char secret[] = "vfy-demo-secret-2026"; BCRYPT_ALG_HANDLE hAlg = NULL; BCRYPT_HASH_HANDLE hHash = NULL; BCRYPT_KEY_HANDLE hKey = NULL; unsigned char key[32]; int ok = 0; unsigned char *buf = NULL; ULONG got = 0; NTSTATUS st = 0; BCRYPT_AUTHENTICATED_CIPHER_MODE_INFO info; if (BCryptOpenAlgorithmProvider(&hAlg, BCRYPT_SHA256_ALGORITHM, NULL, 0) != 0) return 0; if (BCryptCreateHash(hAlg, &hHash, NULL, 0, NULL, 0, 0) != 0) goto done; BCryptHashData(hHash, (PUCHAR)secret, (ULONG)strlen(secret), 0); BCryptFinishHash(hHash, key, 32, 0); BCryptCloseAlgorithmProvider(hAlg, 0); hAlg = NULL; if (BCryptOpenAlgorithmProvider(&hAlg, BCRYPT_AES_ALGORITHM, NULL, 0) != 0) goto done; if (BCryptSetProperty(hAlg, BCRYPT_CHAINING_MODE, (PUCHAR)BCRYPT_CHAIN_MODE_GCM, sizeof(BCRYPT_CHAIN_MODE_GCM), 0) != 0) goto done; if (BCryptGenerateSymmetricKey(hAlg, &hKey, NULL, 0, key, 32, 0) != 0) goto done; BCRYPT_INIT_AUTH_MODE_INFO(info); info.pbNonce = g_nonce; info.cbNonce = 12; info.pbTag = g_tag; info.cbTag = 16; buf = (unsigned char *)malloc(inLen + 16); st = BCryptDecrypt(hKey, (PUCHAR)in, inLen, &info, NULL, 0, buf, inLen, &got, 0); logf_("bcrypt st=0x%lx len=%lu", (unsigned long)st, (unsigned long)got); if (st != 0) { free(buf); goto done; } *out = buf; *outLen = got; ok = 1; done: if (hKey) BCryptDestroyKey(hKey); if (hAlg) BCryptCloseAlgorithmProvider(hAlg, 0); if (hHash) BCryptDestroyHash(hHash); return ok; } static int http_login(const char *user, const char *pass, char *msg, int cap) { wchar_t wHost[256], wPath[512]; char host[256] = {0}, path[512] = {0}; snprintf(path, sizeof(path), "%s", g_api); char *p = strstr(path, "://"); if (!p) return 0; p += 3; char *slash = strchr(p, '/'); if (slash) { *slash = 0; snprintf(path, sizeof(path), "%s", slash + 1); } snprintf(host, sizeof(host), "%s", p); unsigned short port = 80; char *colon = strrchr(host, ':'); if (colon) { *colon = 0; port = (unsigned short)atoi(colon + 1); } MultiByteToWideChar(CP_UTF8, 0, host, -1, wHost, 256); MultiByteToWideChar(CP_UTF8, 0, path, -1, wPath, 512); char body[512]; snprintf(body, sizeof(body), "{\"user\":\"%s\",\"pass\":\"%s\",\"device\":\"%s\"}", user, pass, g_device); int ok = 0; HINTERNET hS = WinHttpOpen(L"vfy/5.0", WINHTTP_ACCESS_TYPE_NO_PROXY, NULL, NULL, 0); if (!hS) return 0; HINTERNET hC = WinHttpConnect(hS, wHost, port, 0); HINTERNET hR = hC ? WinHttpOpenRequest(hC, L"POST", wPath, NULL, NULL, NULL, 0) : NULL; if (hR) { const wchar_t *hdr = L"Content-Type: application/json\r\n"; WinHttpSendRequest(hR, hdr, (DWORD)-1L, body, (DWORD)strlen(body), (DWORD)strlen(body), 0); WinHttpReceiveResponse(hR, NULL); char resp[1024] = {0}; DWORD cl = 0; if (WinHttpReadData(hR, resp, sizeof(resp) - 1, &cl)) resp[cl < sizeof(resp) ? cl : sizeof(resp) - 1] = 0; logf_("http resp=%.300s", resp); if (strstr(resp, "\"ok\":true")) ok = 1; json_str(resp, "msg", msg, cap); if (!ok && !msg[0]) snprintf(msg, cap, "\xE9\xAA\x8C\xE8\xAF\x81\xE5\xA4\xB1\xE8\xB4\xA5"); } if (hR) WinHttpCloseHandle(hR); if (hC) WinHttpCloseHandle(hC); WinHttpCloseHandle(hS); return ok; } /* exe 形态:解密内嵌载荷并启动 */ static int launch_payload(void) { unsigned char *plain = NULL; DWORD plainLen = 0; if (!aes_decrypt(g_payload, g_payloadSize, &plain, &plainLen)) return 0; wchar_t tmp[MAX_PATH]; GetTempPathW(MAX_PATH, tmp); wchar_t dir[MAX_PATH], out[MAX_PATH]; swprintf(dir, MAX_PATH, L"%lsvfy_demo_%lu", tmp, (unsigned long)GetCurrentProcessId()); CreateDirectoryW(dir, NULL); swprintf(out, MAX_PATH, L"%ls\\app.exe", dir); HANDLE h = CreateFileW(out, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL); if (h == INVALID_HANDLE_VALUE) { free(plain); return 0; } DWORD w = 0; WriteFile(h, plain, plainLen, &w, NULL); CloseHandle(h); free(plain); STARTUPINFOW si; ZeroMemory(&si, sizeof(si)); si.cb = sizeof(si); PROCESS_INFORMATION pi; if (!CreateProcessW(out, NULL, NULL, NULL, FALSE, 0, NULL, dir, &si, &pi)) return 0; logf_("child pid=%lu", (unsigned long)pi.dwProcessId); CloseHandle(pi.hThread); CloseHandle(pi.hProcess); return 1; } static void set_status(int kind, const wchar_t *s) { g_statusKind = kind; wcsncpy(g_status, s, 255); g_status[255] = 0; InvalidateRect(g_hwnd, NULL, FALSE); } static void set_status_u8(int kind, const char *u8) { wchar_t w[256] = {0}; MultiByteToWideChar(CP_UTF8, 0, u8, -1, w, 256); set_status(kind, w); } /* 验证通过后的动作 */ typedef void (*PFN_OEP)(void); static PFN_OEP g_oep = NULL; static void on_success(void) { if (g_oep) { logf_("calling original entry %p", (void *)g_oep); g_oep(); /* 原程序自己的入口,正常会自己退出 */ ExitProcess(0); } if (launch_payload()) ExitProcess(0); set_status(2, L"\x542F\x52A8\x5931\x8D25"); } static DWORD WINAPI login_thread(LPVOID) { char user[128] = {0}, pass[128] = {0}, msg[256] = {0}; GetWindowTextA(g_hUser, user, sizeof(user)); GetWindowTextA(g_hPass, pass, sizeof(pass)); if (!user[0]) { set_status(2, L"\x8BF7\x8F93\x5165\x8D26\x53F7"); g_busy = 0; return 0; } set_status_u8(0, "\xE9\xAA\x8C\xE8\xAF\x81\xE4\xB8\xAD"); int passed = http_login(user, pass, msg, sizeof(msg)); if (!passed && g_offline[0] && strcmp(pass, g_offline) == 0) { logf_("offline mode"); passed = 1; } if (passed) { set_status_u8(1, "\xE9\xAA\x8C\xE8\xAF\x81\xE9\x80\x9A\xE8\xBF\x87"); Sleep(180); g_done = 1; on_success(); return 0; } if (msg[0]) set_status_u8(2, msg); else set_status(2, L"\x9A8C\x8BC1\x5931\x8D25"); g_busy = 0; return 0; } static void do_login(void) { if (InterlockedExchange(&g_busy, 1) != 0) return; InvalidateRect(g_hwnd, NULL, FALSE); CreateThread(NULL, 0, login_thread, NULL, 0, NULL); } static int in_rect(const RECT &r, int x, int y) { return x >= r.left && x < r.right && y >= r.top && y < r.bottom; } static LRESULT CALLBACK WndProc(HWND h, UINT m, WPARAM w, LPARAM l) { switch (m) { case WM_CREATE: g_hwnd = h; g_hUser = CreateWindowExW(0, L"EDIT", L"", WS_CHILD | WS_VISIBLE | ES_AUTOHSCROLL, (int)L(32), (int)L(125), (int)L(356), (int)L(30), h, (HMENU)201, NULL, NULL); g_hPass = CreateWindowExW(0, L"EDIT", L"", WS_CHILD | WS_VISIBLE | ES_PASSWORD | ES_AUTOHSCROLL, (int)L(32), (int)L(187), (int)L(324), (int)L(30), h, (HMENU)202, NULL, NULL); SendMessage(g_hUser, WM_SETFONT, (WPARAM)g_fontEdit, TRUE); SendMessage(g_hPass, WM_SETFONT, (WPARAM)g_fontEdit, TRUE); if (g_auto[0]) { SetWindowTextA(g_hUser, "demo"); SetWindowTextA(g_hPass, g_auto); SetTimer(h, 1, 500, NULL); } SetTimer(h, 2, 200, NULL); return 0; case WM_TIMER: if (w == 1) { KillTimer(h, 1); do_login(); } if (w == 2) { g_tick++; if (g_busy) InvalidateRect(h, NULL, FALSE); } return 0; case WM_CTLCOLOREDIT: { HDC dc = (HDC)w; SetTextColor(dc, RGB(230, 230, 230)); SetBkColor(dc, RGB(37, 37, 38)); return (LRESULT)g_brInput; } case WM_ERASEBKGND: return 1; case WM_PAINT: { PAINTSTRUCT ps; BeginPaint(h, &ps); render(); EndPaint(h, &ps); return 0; } case WM_NCHITTEST: { POINT pt = {GET_X_LPARAM(l), GET_Y_LPARAM(l)}; ScreenToClient(h, &pt); int lx = (int)(pt.x / g_S) - (int)PAD, ly = (int)(pt.y / g_S) - (int)PAD; if (lx >= 0 && lx < (int)CARD_W && ly >= 0 && ly < 32 && !in_rect(LR_CLOSE, lx, ly) && !in_rect(LR_MIN, lx, ly)) return HTCAPTION; if (!(lx >= 0 && lx < (int)CARD_W && ly >= 0 && ly < (int)CARD_H)) return HTCAPTION; break; } case WM_MOUSEMOVE: { int lx = (int)(GET_X_LPARAM(l) / g_S) - (int)PAD, ly = (int)(GET_Y_LPARAM(l) / g_S) - (int)PAD; int nb = in_rect(LR_BTN, lx, ly), nc = in_rect(LR_REM, lx, ly), nt = in_rect(LR_TAG, lx, ly); int ne = in_rect(LR_EYE, lx, ly), nx = in_rect(LR_CLOSE, lx, ly), nm = in_rect(LR_MIN, lx, ly); int nl = in_rect(LR_L1, lx, ly) ? 1 : (in_rect(LR_L2, lx, ly) ? 2 : (in_rect(LR_L3, lx, ly) ? 3 : 0)); if (nb != g_hBtn || nc != g_hChk || nt != g_hTag || ne != g_hEye || nx != g_hClose || nm != g_hMin || nl != g_hLink) { g_hBtn = nb; g_hChk = nc; g_hTag = nt; g_hEye = ne; g_hClose = nx; g_hMin = nm; g_hLink = nl; InvalidateRect(h, NULL, FALSE); } TRACKMOUSEEVENT tme = {sizeof(tme), TME_LEAVE, h, 0}; TrackMouseEvent(&tme); return 0; } case WM_MOUSELEAVE: g_hBtn = g_hChk = g_hTag = g_hEye = g_hClose = g_hMin = g_hLink = 0; InvalidateRect(h, NULL, FALSE); return 0; case WM_SETCURSOR: { POINT pt; GetCursorPos(&pt); ScreenToClient(h, &pt); int lx = (int)(pt.x / g_S) - (int)PAD, ly = (int)(pt.y / g_S) - (int)PAD; if (in_rect(LR_BTN, lx, ly) || in_rect(LR_REM, lx, ly) || in_rect(LR_TAG, lx, ly) || in_rect(LR_EYE, lx, ly) || in_rect(LR_CLOSE, lx, ly) || in_rect(LR_MIN, lx, ly) || in_rect(LR_L1, lx, ly) || in_rect(LR_L2, lx, ly) || in_rect(LR_L3, lx, ly)) { SetCursor(LoadCursor(NULL, IDC_HAND)); return TRUE; } break; } case WM_LBUTTONDOWN: { int lx = (int)(GET_X_LPARAM(l) / g_S) - (int)PAD, ly = (int)(GET_Y_LPARAM(l) / g_S) - (int)PAD; if (in_rect(LR_CLOSE, lx, ly)) { DestroyWindow(h); return 0; } if (in_rect(LR_MIN, lx, ly)) { ShowWindow(h, SW_MINIMIZE); return 0; } if (in_rect(LR_BTN, lx, ly)) { g_pressBtn = 1; InvalidateRect(h, NULL, FALSE); return 0; } if (in_rect(LR_REM, lx, ly)) { g_checked = !g_checked; InvalidateRect(h, NULL, FALSE); return 0; } if (in_rect(LR_EYE, lx, ly)) { g_showPass = !g_showPass; SendMessage(g_hPass, EM_SETPASSWORDCHAR, g_showPass ? 0 : 0x25CF, 0); InvalidateRect(h, NULL, FALSE); return 0; } if (in_rect(LR_TAG, lx, ly)) { if (OpenClipboard(h)) { EmptyClipboard(); int n = MultiByteToWideChar(CP_UTF8, 0, g_device, -1, NULL, 0); HGLOBAL hg = GlobalAlloc(GMEM_MOVEABLE, n * 2); if (hg) { wchar_t *d = (wchar_t *)GlobalLock(hg); MultiByteToWideChar(CP_UTF8, 0, g_device, -1, d, n); GlobalUnlock(hg); SetClipboardData(CF_UNICODETEXT, hg); } CloseClipboard(); } set_status(1, L"\x8BBE\x5907\x7801\x5DF2\x590D\x5236"); return 0; } if (in_rect(LR_L1, lx, ly)) { set_status(0, L"\x6CE8\x518C\xFF1A\x6253\x5F00\x5B98\x7F51"); return 0; } if (in_rect(LR_L2, lx, ly)) { set_status(0, L"\x5361\x5BC6\x5145\x503C\xFF1A\x5F39\x51FA\x5145\x503C\x7A97"); return 0; } if (in_rect(LR_L3, lx, ly)) { set_status(0, L"\x5FD8\x8BB0\x5BC6\x7801\xFF1A\x8BF7\x8054\x7CFB\x5BA2\x670D"); return 0; } break; } case WM_LBUTTONUP: { int lx = (int)(GET_X_LPARAM(l) / g_S) - (int)PAD, ly = (int)(GET_Y_LPARAM(l) / g_S) - (int)PAD; if (g_pressBtn) { g_pressBtn = 0; InvalidateRect(h, NULL, FALSE); if (in_rect(LR_BTN, lx, ly)) do_login(); return 0; } break; } case WM_COMMAND: if (HIWORD(w) == EN_SETFOCUS) { g_focus = (LOWORD(w) == 201) ? 1 : 2; InvalidateRect(h, NULL, FALSE); } else if (HIWORD(w) == EN_KILLFOCUS) { g_focus = 0; InvalidateRect(h, NULL, FALSE); } else if (HIWORD(w) == EN_CHANGE) InvalidateRect(h, NULL, FALSE); break; case WM_CLOSE: DestroyWindow(h); return 0; case WM_DESTROY: PostQuitMessage(0); return 0; } return DefWindowProcW(h, m, w, l); } /* ---------- 启动壳(DLL 与 exe 共用) ---------- */ static const wchar_t *CLS_NAME = L"VfyShellV5"; static void make_colors(void) { C_CARD = D2D1::ColorF(0.118f, 0.118f, 0.118f, 1); /* #1E1E1E */ C_BAR = D2D1::ColorF(0.145f, 0.145f, 0.153f, 1); /* #252527 */ C_BORDER = D2D1::ColorF(0.247f, 0.247f, 0.275f, 1); /* #3F3F46 */ C_INPUT = D2D1::ColorF(0.145f, 0.145f, 0.149f, 1); /* #252526 */ C_INPUT_BD = D2D1::ColorF(0.247f, 0.247f, 0.275f, 1); C_FOCUS = D2D1::ColorF(0.0f, 0.471f, 0.831f, 1); /* #0078D4 */ C_TXT = D2D1::ColorF(0.902f, 0.902f, 0.902f, 1); /* #E6E6E6 */ C_TXT2 = D2D1::ColorF(0.616f, 0.616f, 0.616f, 1); /* #9D9D9D */ C_ACCENT = D2D1::ColorF(0.055f, 0.388f, 0.612f, 1); /* #0E639C */ C_ACCENT_H = D2D1::ColorF(0.067f, 0.467f, 0.733f, 1); /* #1177BB */ C_ACCENT_P = D2D1::ColorF(0.039f, 0.306f, 0.478f, 1); /* #0A4E7A */ C_LINK = D2D1::ColorF(0.216f, 0.58f, 1.0f, 1); /* #3794FF */ C_RED = D2D1::ColorF(0.96f, 0.35f, 0.35f, 1); C_GREEN = D2D1::ColorF(0.35f, 0.78f, 0.45f, 1); C_WHITE = D2D1::ColorF(1, 1, 1, 1); C_TAG = D2D1::ColorF(1, 1, 1, 0.05f); } static int shell_main(PFN_OEP oep) { g_oep = oep; typedef BOOL(WINAPI * PFN_SetCtx)(HANDLE); PFN_SetCtx setCtx = (PFN_SetCtx)GetProcAddress(GetModuleHandleW(L"user32.dll"), "SetProcessDpiAwarenessContext"); if (setCtx) setCtx((HANDLE)-4); HDC sdc = GetDC(NULL); g_S = GetDeviceCaps(sdc, LOGPIXELSX) / 96.0f; ReleaseDC(NULL, sdc); if (g_S < 1.0f) g_S = 1.0f; make_colors(); CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); if (FAILED(D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, &g_d2d))) return -1; if (FAILED(DWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED, __uuidof(IDWriteFactory), (IUnknown **)&g_dw))) return -1; g_fontEdit = CreateFontW((int)-L(13), 0, 0, 0, FW_NORMAL, 0, 0, 0, DEFAULT_CHARSET, 0, 0, CLEARTYPE_QUALITY, 0, L"Microsoft YaHei UI"); g_brInput = CreateSolidBrush(RGB(37, 37, 38)); WNDCLASSEXW wc; ZeroMemory(&wc, sizeof(wc)); wc.cbSize = sizeof(wc); wc.lpfnWndProc = WndProc; wc.hInstance = GetModuleHandleW(NULL); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.lpszClassName = CLS_NAME; wc.hbrBackground = NULL; RegisterClassExW(&wc); int w = (int)((CARD_W + PAD * 2) * g_S), h = (int)((CARD_H + PAD * 2) * g_S); HWND hwnd = CreateWindowExW(WS_EX_LAYERED | WS_EX_APPWINDOW | WS_EX_TOPMOST, CLS_NAME, L"\x9A8C\x8BC1\x767B\x5F55", WS_POPUP, 0, 0, w, h, NULL, NULL, wc.hInstance, NULL); if (!hwnd) return -1; SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, w, h, SWP_NOMOVE | SWP_NOACTIVATE); D2D1_RENDER_TARGET_PROPERTIES props = D2D1::RenderTargetProperties( D2D1_RENDER_TARGET_TYPE_DEFAULT, D2D1::PixelFormat(DXGI_FORMAT_B8G8R8A8_UNORM, D2D1_ALPHA_MODE_PREMULTIPLIED), 0, 0, D2D1_RENDER_TARGET_USAGE_NONE, D2D1_FEATURE_LEVEL_DEFAULT); if (FAILED(g_d2d->CreateDCRenderTarget(&props, &g_rt))) return -1; detect_fonts(); RECT wa; SystemParametersInfoW(SPI_GETWORKAREA, 0, &wa, 0); int sx = wa.left + ((wa.right - wa.left) - w) / 2; int sy = wa.top + ((wa.bottom - wa.top) - h) / 2; SetWindowPos(hwnd, HWND_TOPMOST, sx, sy, w, h, SWP_NOACTIVATE); render(); ShowWindow(hwnd, SW_SHOW); SetForegroundWindow(hwnd); MSG msg; while (GetMessageW(&msg, NULL, 0, 0)) { if (msg.message == WM_KEYDOWN && msg.wParam == VK_RETURN) { do_login(); continue; } if (msg.message == WM_KEYDOWN && msg.wParam == VK_ESCAPE) { ShowWindow(hwnd, SW_MINIMIZE); continue; } TranslateMessage(&msg); DispatchMessageW(&msg); } return g_done ? 0 : -2; } /* ================= 导出(DLL 形态) ================= */ #ifdef SHELL_DLL extern "C" __declspec(dllexport) int VerifyMain(void *oep, const char *cfgjson) { load_cfg(cfgjson); return shell_main((PFN_OEP)oep); } extern "C" __declspec(dllexport) int VerifyShellVersion(void) { return 5; } BOOL WINAPI DllMain(HINSTANCE h, DWORD reason, LPVOID) { if (reason == DLL_PROCESS_ATTACH) DisableThreadLibraryCalls(h); return TRUE; } #else /* ================= 独立 exe 形态 ================= */ static int read_self(void) { wchar_t path[MAX_PATH]; DWORD n = GetModuleFileNameW(NULL, path, MAX_PATH); if (!n) return 0; HANDLE h = CreateFileW(path, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); if (h == INVALID_HANDLE_VALUE) return 0; LARGE_INTEGER sz; GetFileSizeEx(h, &sz); g_fileSize = (DWORD)sz.QuadPart; g_file = (unsigned char *)malloc(g_fileSize); DWORD got = 0; BOOL ok = ReadFile(h, g_file, g_fileSize, &got, NULL); CloseHandle(h); return ok && got == g_fileSize; } static unsigned int le32(const unsigned char *p) { return (unsigned int)p[0] | ((unsigned int)p[1] << 8) | ((unsigned int)p[2] << 16) | ((unsigned int)p[3] << 24); } static int parse_tail(void) { if (g_fileSize < 64) return 0; const unsigned char *t = g_file + g_fileSize - 64; if (memcmp(t, TAIL_MAGIC, 8) != 0) return 0; unsigned int poff = le32(t + 8), psize = le32(t + 12), coff = le32(t + 16), csize = le32(t + 20); memcpy(g_nonce, t + 24, 12); memcpy(g_tag, t + 36, 16); if (poff + psize > g_fileSize) return 0; g_payload = g_file + poff; g_payloadSize = psize; DWORD cs = csize < sizeof(g_cfg) - 1 ? csize : sizeof(g_cfg) - 1; if (coff + cs > g_fileSize) return 0; char buf[4096] = {0}; memcpy(buf, g_file + coff, cs); buf[cs] = 0; load_cfg(buf); return 1; } int WINAPI wWinMain(HINSTANCE, HINSTANCE, LPWSTR, int) { if (!read_self() || !parse_tail()) { MessageBoxW(NULL, L"\x7A0B\x5E8F\x5DF2\x635F\x574F", L"\x9519\x8BEF", MB_ICONERROR); return 1; } int argc = 0; LPWSTR *argv = CommandLineToArgvW(GetCommandLineW(), &argc); for (int i = 1; i + 1 < argc; i++) if (!wcscmp(argv[i], L"--auto")) WideCharToMultiByte(CP_UTF8, 0, argv[i + 1], -1, g_auto, sizeof(g_auto), NULL, NULL); int r = shell_main(NULL); return r == 0 ? 0 : 1; } #endif