Skip to content

Instantly share code, notes, and snippets.

@hosct
Last active October 12, 2024 15:55
Show Gist options
  • Save hosct/456055c0eec4e71bb504489410ed7fb6 to your computer and use it in GitHub Desktop.
Save hosct/456055c0eec4e71bb504489410ed7fb6 to your computer and use it in GitHub Desktop.
ctBiosKey
#include <iostream>
#include <Windows.h>
int main()
{
DWORD firmwareTableProviderSignature = 0x41435049; // "ACPI"
DWORD firmwareTableMSDMID = 0x4d44534d; // "MSDM"
UINT structSize = EnumSystemFirmwareTables(firmwareTableProviderSignature, NULL, 0);
if (structSize == 0) {
std::cout << "EnumSystemFirmwareTables() fehlgeschlagen." << std::endl;
return 1;
}
char *tableBuffer = new char[structSize + 1];
EnumSystemFirmwareTables(firmwareTableProviderSignature, tableBuffer, structSize);
tableBuffer[structSize] = '\0';
BOOL found = strstr(tableBuffer, "MSDM") != NULL;
delete[] tableBuffer;
if (!found) {
std::cout << "Kein Product Key gefunden." << std::endl;
return 1;
}
structSize = GetSystemFirmwareTable(firmwareTableProviderSignature, firmwareTableMSDMID, NULL, 0);
if (structSize == 0) {
std::cout << "GetSystemFirmwareTable() fehlgeschlagen." << std::endl;
return 1;
}
tableBuffer = new char[structSize];
GetSystemFirmwareTable(firmwareTableProviderSignature, firmwareTableMSDMID, tableBuffer, structSize);
char key[30];
strncpy_s(key, tableBuffer + 56, 29);
key[29] = '\0';
delete[] tableBuffer;
std::cout << key << std::endl;
return 0;
}
@hosct
Copy link
Author

hosct commented Mar 2, 2023

Mehr zu Dokumentationszwecken als zum Nachbauen: Dies ist der komplette (!) Quelltext des Programms ctBiosKey, das im c't-Keyfinder enthalten ist und für Fehlalarme bei zahlreichen Virenscannern gesorgt hat.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment