python代码如下
[Asm] 纯文本查看 复制代码 keys = AES.new(dg.digest(), AES.MODE_ECB).decrypt(lsakey[60:])
[Asm] 纯文本查看 复制代码 #include <Windows.h>
#include <bcrypt.h>
#include <stdio.h>
#define NT_SUCCESS(Status) (((NTSTATUS)(Status)) >= 0)
void PrintHex(const BYTE* data, DWORD dataSize);
int main() {
BCRYPT_ALG_HANDLE hAlgorithm = NULL;
BCRYPT_KEY_HANDLE hKey = NULL;
NTSTATUS status;
BYTE syskey[] = { /* your syskey bytes here */ };
BYTE lsakey[] = { /* your lsakey bytes here */ };
BYTE aesKey[32]; // AES-256 密钥大小为 32 字节
// 打开 AES 加密提供程序
status = BCryptOpenAlgorithmProvider(&hAlgorithm, BCRYPT_AES_ALGORITHM, NULL, 0);
if (!NT_SUCCESS(status)) {
printf("BCryptOpenAlgorithmProvider failed with status: 0x%x\n", status);
return 1;
}
// 设置密钥对象
status = BCryptGenerateSymmetricKey(hAlgorithm, &hKey, NULL, 0, syskey, sizeof(syskey), 0);
if (!NT_SUCCESS(status)) {
printf("BCryptGenerateSymmetricKey failed with status: 0x%x\n", status);
BCryptCloseAlgorithmProvider(hAlgorithm, 0);
return 1;
}
// 解密 lsakey[60:] 使用 ECB 模式
BYTE decryptedKey[32]; // 解密后的密钥大小为 32 字节
status = BCryptDecrypt(hKey, lsakey + 60, 32, NULL, NULL, 0, decryptedKey, sizeof(decryptedKey), NULL, 0);
if (!NT_SUCCESS(status)) {
printf("BCryptDecrypt failed with status: 0x%x\n", status);
} else {
printf("Decrypted key:\n");
PrintHex(decryptedKey, sizeof(decryptedKey));
}
// 清理资源
BCryptDestroyKey(hKey);
BCryptCloseAlgorithmProvider(hAlgorithm, 0);
return 0;
}
void PrintHex(const BYTE* data, DWORD dataSize) {
for (DWORD i = 0; i < dataSize; ++i) {
printf("%02x", data[i]);
}
printf("\n");
}
虽然运行没出错,但结果不一样,求大佬把这个python代码改成c++
|