基本篡改保护

时间:2018-01-08 10:30:29

标签: c++ tampering software-protection

我试图创建一个对licenseCheck功能具有篡改保护的基本程序,但它总是说它是正确的,即使我在Ollydbg中删除整个licenseCheck功能或更改并重建代码

我正在关注Surreptitious 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;
}

该程序基本上是哈希&#39; BEGIN函数和END函数之间的代码,但它似乎不起作用。即使在篡改之后,哈希仍然是正确的。

我使用Windows 7和Visual Studio 2017构建/运行程序。

0 个答案:

没有答案