Making your own keylogger in VB6 Part 1

Post new topic   Reply to topic

View previous topic View next topic Go down

Making your own keylogger in VB6 Part 1

Post  jkymmel on Mon Jun 29, 2009 11:53 am

When you are done with this tutorial you will be able to Make and Use a keylogger that is close to fully undetectable,
without the victim getting suspicious. You will be able to keylog just about anyone.

This Guide will be split into 2 parts:
Writing your own undetectable keylogger
- The language
- Logging and storing
- Uploading logs
Setting it up to be un-suspicious and trustworthy
- Binding with other files
- Making sure its existence is hidden

Before we begin i want to point out that this keylogger is NOT perfect.
It will be unable to record some symbols
It will occasionally rearrange a letter with one another if the user types fast
But the passwords should easily get through.

Writing the Keylogger.

In this guide we will be using Microsoft Visual Basic 6.0 (vb6 for short)
If you do not know/have this, dont leave just yet.
Reading this guide its not "Necessary" to have vb6 knowledge (highly recommended tho)


Open up VB6 and choose standard EXE.

Put on your form:
3 timers
1 label

double-click your form (design) and you see the source of our keylogger, almost empty at this point.

Go back to the design and set properties for the form
Set the form name to a few random letters (title doesnt matter)
Set Visible = false
Set ShowInTaskbar = false
This should make it invisible from the user.

go back to the source and write the following in the "Form_Load" sub

If app.previnstance = true then end
app.taskvisible = false

Which means that if its already running and opened again, it will not start another keylogger (2 keyloggers running would cause errors), and it will not show in the taskmanagers Program list (but still in process list)

Now lets go to the General Section of our source and declare some API functions in order to start writing. General section can be found by using (General) in the top left scrollbar

There are 2 effective methods to keylog with VB6
- Keyhooks
- GetAsyncKeyState

We will be using GetAsyncKeyState, which checks if a key is being pressed when executed
But before we can start using GetAsyncKeyState we must declare it in the general section

GetAsyncKeyState Declaration:


Code:
Private Declare Function GetAsyncKeyState Lib "user32" (byval vkey as long) as integer

^ tells what Lib we need for GetAsyncKeyState.

With this code placed we can start using GetAsyncKeyState commands.

To find out what key is pressed we need to use getasynckeystate as so:


Code:
If GetAsyncKeyState(number) <> 0 then
'code to execute if key is pressed
end if


Now you might be wondering what the "number" means, actually, the number we type here is a keyboard key,
you see, every key has a number (KeyCode), from around 1 to 200. (1 and 2 being mouse buttons)
Full list of KeyCode values

Thats alot of keycode. Now, theres an easy way of checking all of the keys at the same time. But it appears that doing it causes alot of weird symbols and capital letters only.
But i want it done properly so im gonna check One key at a time. You can decide yourself what you want to do.
I will show you the easy method too later on tho.

Now that we know how to check for a keypress we want it to write it down somewheres temporary. There are many ways to do so, i will be using a label. You can use a String aswell.
Set the caption of the label to nothing. Now a full example of the letter "a" would be this:

Code:
if GetAsyncKeyState(65) <> 0 then
label1.caption = label1.caption + "a"
end if

So that if "a" key is pressed an "a" is added to our label.

Code 65-90 is a-z

To check if a key is pressed more than one time we put the code in a timer. I find that it works best when the interval is set to around 125.
Which means that the code is executed 8 times a second. (125 milliseconds). You must change the interval from 0 to 50-150, else it will not work. you can change the interval in the properties of the timer
If you have less interval, it might double record the keystroke, if you have more, it might miss it.
To start writing to a timer either choose "timer1" in the scrollbar in the top-left corner of the source page, or double-click the timer icon on the form design
Do this again and again with all keys from a-z, and numbers 0-9 (also in numpad)

Now it records letters and numbers, not bad, but we are far from done yet.
if we finished up now our logs would be one big pile of letters, pretty much unreadable.
so what we need to do is add spaces, and a hell lot of em. The user browses around alot, clicking here and there, so if we add spaces on keys like mouse buttons, space, enter, ctrl etc. we would get something readable with alot of spaces.
So find Keycodes for those keys and add a space to the label if pressed. Most important is the mouse clicks.

now, were not done just yet. We want to check if a letter is Capital. we do that by checking if shift or caps-lock has been pressed before every key. And if it has, make it print a capital letter instead.

Now to do this, we want to use booleans (true / false), so goto the general section and write this:

Code:
dim caps as boolean
The keycode for capsLock is 20. We want to write capslock like this in the timer.





Go to PART 2

_________________

JKymmelDisain::WebDesign

jkymmel
Admin
Admin

Posts: 76
Activity: -639
Reputation: 3
Join date: 2009-06-27
Age: 14
Location: Estonia

http://jkymmel.tk

Back to top Go down

View previous topic View next topic Back to top


Post new topic   Reply to topic
Permissions of this forum:
You cannot reply to topics in this forum