0

licenseCheck 関数を改ざんから保護する基本的なプログラムを作成しようとしていますが、Ollydbg で licenseCheck 関数全体を nop したり、コードを変更して再構築したりしても、常に正しいと表示されます。

私は Sureptitious Software の本に従っており、次のプログラムを作成しました。

#include "stdafx.h"

#define HASH 5131241 

void BEGIN() {}

const std::string correctlicense("ABC");

bool licenseCheck() {

    std::cout << "Enter license: ";

    std::string license;
    std::cin >> license;

    volatile DWORD d;

    // Fingerprint
    __asm {
        lea ebx, d
        mov ebx, 0x050b072b
    }

    return license.compare(correctlicense) == 0;
}

UINT hash(UINT *beginAddress, UINT *endAddress) {

    UINT h = *beginAddress;

    for (; beginAddress <= endAddress; beginAddress++) {
        h ^= *beginAddress;
    }

    return h;
}
void END() {}


int main()
{

    UINT uHash = hash((UINT*)BEGIN, (UINT*)END);

    std::cout << "[Protection checks]" << std::endl;
    std::cout << "Tampering: ";

    if (uHash != HASH) {
        std::cout << "Tampering detected! ( " << uHash << " )" << std::endl;
        system("PAUSE");
        return 0;
    }
    else {
        std::cout << "Correct" << std::endl;
    }

    if (licenseCheck()) {
        std::cout << "Correct!" << std::endl;
    }
    else {
        std::cout << "Failed!" << std::endl;
    }


    system("PAUSE");
    return 0;
}

プログラムは基本的に BEGIN 関数と END 関数の間のコードを「ハッシュ」しますが、機能していないようです。ハッシュは、改ざんされた後でも常に正しいです。

私はWindows 7とVisual Studio 2017を使用してプログラムをビルド/実行しています。

4

0 に答える 0