How to make a builder + Stub(noob friendly)

Heres your chance to share your own tutorials with the community. Just post them on here. If your lucky they may even be posted on the main site.
8 posts Page 1 of 1
Contributors
User avatar
Proprogrammer
VIP - Donator
VIP - Donator
Posts: 415
Joined: Sun Oct 03, 2010 11:14 pm

How To Make A Builder And a Stub!

Tutorial done by
& Legon
I made this tutorial even though easy to me, it could be hard to many people so i simplified it. I can usually do a whole program like this under 3 days. Now to the tutorial.

Hello there! today we are going to make a Builder! and a Stub! I know what your thinking, "Why would i want to do this? i just want to make a builder for a certain program!" truth be told, this is the base for most builders! Want to make a keylogger? Then how would you send the user name and password for the gmail to the other program? the easiest way, is with a builder!

If you get any errors. or dont understand somthing, just post your question, I will be happy to help any and every problem that occurs with my Tutorial.

Note: if you dont understand where a function goes. Either download the source at the bottom, Or just look ahead, i will be posting full page of source as i go along.

Requirements to use this tutorial:
some basic knowledge
Visual Basic Express (or Visual Studio)


Well then, now that we have all that, lets get started!

We are going to make a new project. lets call it "Our Builder".

What you will need:
1 Button, name it "Generate"
3 textboxes, name them "UsernameBox", "PasswordBox" and "RandomBox"
4 Check Boxes, name them "AntiDebuggerCB", "AntiSantaCB", "AntiNaziCB" and "AntiEverythingCB"


Good so far, double click the button labeled "MAKE ME!", a you should see somthing like this:
Code: Select all
Public Class Form1

    Private Sub Generate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Generate.Click

    End Sub
End Class

Now we need to import System.IO so we don't have to type io.* when we are doing somthing with out files. its just a time saver.
put this on the very top of the code, Above "Public Class Form1"
Code:
Imports System.IO


Now lets make our strings, these will go right after "Public Class Form1"

lets make a constant. this will be used so when we split the file on the other side. It tells the command we are going to call later, how to split the file. this needs to be completely unique but still memorable so put this
Code: Select all
Const FileSplit = "--!ZOMG-A-TUTORIAL!--"
Now we need some strings! this will hold all our stuff, right now all we need is somthing to hold the stub in. and the strings for the boxes
Code: Select all
Dim stub, AntiSanta, AntiDebugger, AntiNazi, AntiEverything As String

Our code so far should look like this:
Code: Select all
Imports System.IO
Public Class Form1
    Const FileSplit = "--!ZOMG-A-TUTORIAL!--"
    Dim stub, AntiSanta, AntiDebugger, AntiNazi, AntiEverything As String
    Private Sub Generate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Generate.Click

    End Sub
End Class


As to prevent crashing, lets put all of this inside of a "Try" statement that way, if there is an error. it doesn't just crash. it will tell us the error
Code: Select all
Try
        
Catch ex As Exception
    MsgBox(ex.ToString)
End Try
From here on, everything will go inside the Try statement, that being said, lets open the stub. if you don't know how to do that i'l go through it...if not...i still will

First we need to open our stub:
Code: Select all
FileOpen(1, Application.StartupPath & "\sub.exe", OpenMode.Binary, OpenAccess.Read)

heres how this works:.


FileOpen(Reference number, file name including the path, mode to open the file as, Mode Of Access)

Reference number: pick a number, this number will be used to call the file, you will see this more in effect later just make sure you dont use the same number twice. when you get more advanced and get to the point that you are opening more then one file at a time. you want to make sure your not opening the wrong file.

File name including the path: This is the path to the file and the name of the file. just like opening a file it needs to know where to open it, the Application.StartupPath is the path that it was started in, we do this to make sure that even if the file is in some random folder, as long as the stub is in the same folder it will still open it

Mode to open the file as: this is fairly simple. since we are opening a binary file, the mode is binary (I've never needed to use the other modes)

Mode Of Access: there are Read, ReadWrite, Write and Default, we are selecting Read, since we don't need to write to the file right now


Our code so far:
Code: Select all
Imports System.IO
Public Class Form1
    Const FileSplit = "--!ZOMG-A-TUTORIAL!--"
    Dim stub, AntiSanta, AntiDebugger, AntiNazi, AntiEverything As String
    Private Sub Generate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Generate.Click

        Try
        
        FileOpen(1, Application.StartupPath & "\sub.exe", OpenMode.Binary, OpenAccess.Read)
        
        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try
    End Sub
End Class

Next we need to make sure the stubs length is the same as the file
Code: Select all
stub = Space(LOF(1))

How this function works:
Code: Select all
Space(Size)
&
LOF(Reference number)
The Space(Size) function fills the string with the amount of bytes as the length specified the LOF(File number) function stands for Length Of File. and it does as it says, it gets the Length of the Specified via the files Reference number

So this command makes the "stub" string the same length as the File specified.



Now that that is done. lets get the file and put it into our "stub" string
Code: Select all
FileGet(1, stub)
How this code works:

FileGet(Reference Number, String to put file into)
Reference number: should be the number of the file you want to get, because we are getting the file number 1, we will use 1 as the number


String to put file into: this is where we are going to store the file


Now we no longer need the file open so we can close it

FileClose(1)

How the Code works:

FileClose(Reference Number)
This is rather simple, if you have caught on so far, we are just closing the file 1, since we have stored it in the "stub" string


Our code so far:
Code: Select all
Imports System.IO
Public Class Form1
    Const FileSplit = "--!ZOMG-A-TUTORIAL!--"
    Dim stub, AntiSanta, AntiDebugger, AntiNazi, AntiEverything As String
    Private Sub Generate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Generate.Click

        Try
        
        FileOpen(1, Application.StartupPath & "\sub.exe", OpenMode.Binary, OpenAccess.Read)
        stub = Space(LOF(1))
        FileGet(Reference Number, String to put file into)
        FileClose(1)
        
        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try
    End Sub
End Class

Awesome! Now the hard part is over....it just gets confusing for some. haha, but don't worry I'll walk you through it.


The way we are passing over our information, I haven't been able to passover anything but strings, (if its possible please tell me)

So we are going to make sure everything that we are passing over is a string

Here is what we are passing over to our stub:
Username (string)
Password (string)
Text in the random box (string)
Check boxes:
anti-debugger (boolean)
anti-santa (boolean)
anti-nazi (boolean)
anti-everything (boolean)

well it looks like we have a small problem, we have 3 items that are ready to be passed over already, however the check boxes are not, as we can not pass boolean values. so lets make some simple code to make sure that we can do this, im not going to explain this. you should get it. im just explaining making the generator. If you have problems with this just post or PM me, I will be happy to help.

Code: Select all
If AntiDebuggerCB.Checked = True Then
     AntiDebugger = "True"
ElseIf AntiSantaCB.Checked = True Then
     AntiSanta = "True"
ElseIf AntiNaziCB.Checked = True Then
      AntiNazi = "True"
ElseIf AntiEverythingCB.Checked = True Then
      AntiEverything = "True"
End If
Our code so far:
Code: Select all
Imports System.IO
Public Class Form1
    Const FileSplit = "--!ZOMG-A-TUTORIAL!--"
    Dim stub, AntiSanta, AntiDebugger, AntiNazi, AntiEverything As String
    Private Sub Generate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Generate.Click

        Try
        
        FileOpen(1, Application.StartupPath & "\sub.exe", OpenMode.Binary, OpenAccess.Read)
        stub = Space(LOF(1))
        FileGet(Reference Number, String to put file into)
        FileClose(1)
        
        If AntiDebuggerCB.Checked = True Then
            AntiDebugger = "True"
        ElseIf AntiSantaCB.Checked = True Then
            AntiSanta = "True"
        ElseIf AntiNaziCB.Checked = True Then
            AntiNazi = "True"
        ElseIf AntiEverythingCB.Checked = True Then
            AntiEverything = "True"
        End If
        
        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try
    End Sub
End Class
OK! now we have everything in string form, lets move on then!

Our next step is to open a new file and save all this information to it. but first, lets make sure that the file isn't there so we don't over write it or cause an error.
Code: Select all
If File.Exists(Application.StartupPath & "\Program.exe") Then
    File.Delete(Application.StartupPath & "\Program.exe")
End If
You should be able to see what this does. if the file we want to make exists it deletes it, that way we aren't writing over a file. and possibly screwing somthing up



So lets open the file, just as before. except this time. we are going to use the OpenMode.ReadWrite option. insted of OpenMode.Read, that way we can actualy write to the file.


FileOpen(2, Application.StartupPath & "\Program.exe", OpenMode.Binary, OpenAccess.ReadWrite)

Notice that we used a different Reference number. this is because its a different file.



OMG almost done! lets cram alllll this information into this, BUT WAIT! we need to do this a special way. first. note how we save it, as we are not going to have any reference as to what file is what, we have to either remember the order. or copy+paste it some where

So, lets call a FilePut() function (don't let your brain explode....il explain it)


FilePut(2, stub & FileSplit & UsernameBox.Text & FileSplit & PasswordBox.Text & FileSplit & RandomBox.Text & FileSplit & AntiDebugger & FileSplit & AntiNazi & FileSplit & AntiSanta & FileSplit & AntiEverything)

I know, your thinking "SLOW DOWN Proprogrammer! I CAN THINK THAT FAST HOLY SHIT!" just take it one step at a time. and relax :) i'm walking you through it

Heres how the function is called:
Code:
FilePut(Reference Number, String to put in the file)

Clearly the reference number is the number of the file we want to write to, and for us, thats 2 so it points to "Program.exe"

But now for the long..... brain blowing.... crotch popping part.... the string.... Dont be scared. This is just like a normal string.

But to combine all our strings into one. We are adding "FileSplit" in between each one, so that we can split it later. so the "&" char is just like before when opening our stub, it takes two strings and combines them into one. we are just putting them in one area so we dont have to dim a string just for that.

Now that that is done, we can close the file


FileClose(2)

Same as before, just closeting the file since its written.


ZOMG! we are done with the Generator! lets make a message box to congratulate us!


MsgBox("WAY TO GO! IT WORKED!")


Our full code:
Code: Select all
Imports System.IO
Public Class Form1
    Const FileSplit = "--!ZOMG-A-TUTORIAL!--"
    Dim stub, AntiSanta, AntiDebugger, AntiNazi, AntiEverything As String
    Private Sub Generate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Generate.Click

        Try
        
        FileOpen(1, Application.StartupPath & "\sub.exe", OpenMode.Binary, OpenAccess.Read)
        stub = Space(LOF(1))
        FileGet(Reference Number, String to put file into)
        FileClose(1)
        
        If AntiDebuggerCB.Checked = True Then
            AntiDebugger = "True"
        ElseIf AntiSantaCB.Checked = True Then
            AntiSanta = "True"
        ElseIf AntiNaziCB.Checked = True Then
            AntiNazi = "True"
        ElseIf AntiEverythingCB.Checked = True Then
            AntiEverything = "True"
        End If
        
        If File.Exists(Application.StartupPath & "\Program.exe") Then
            File.Delete(Application.StartupPath & "\Program.exe")
        End If
        
        FileOpen(2, Application.StartupPath & "\Program.exe", OpenMode.Binary, OpenAccess.ReadWrite)
        FilePut(2, stub & FileSplit & UsernameBox.Text & FileSplit & PasswordBox.Text & FileSplit & RandomBox.Text & FileSplit & AntiDebugger & FileSplit & AntiNazi & FileSplit & AntiSanta & FileSplit & AntiEverything)
        FileClose(2)
        
        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try
    End Sub
End Class
WHOOO!!!! half done! Yes i know its extremely long, but hey, its detailed!

right about now would be a good time to grabs some food, maybe a drink. pr0n...what ever floats your boat.

On to the Stub, just like before make your Stub form look like this:
[Image: 9hktxt.jpg]

the names are as follows:
three labels for the textbox's text, named "UsernameText", "PasswordText" and "RandomText"
Four labels for the Checkbox's, named "AntiDebuggerText", "AntiSantaText", "AntiEverythingText" and "AntiNaziText"

This time instead of double clicking a button, double click the background. you should see somthing like this:
Code:
Public Class Form1

     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    
     End Sub
End Class
now, all of our code is going to go within "Form1_Load", the rest of this will be easy. since we already did it!, The only hard part will be the Split function, well understanding it will be hard for some.

Note: if you have not read the first half, please do so now before continuing

Just like before we need to import System.IO so we dont have to write IO.* infront of what we are doing with the file.

Imports System.IO

this is extremely important! make sure this is EXACTLY as it is in the other side. or this wont work because we are using this as a spacer to tell Split() how to split the string.

Const FileSplit = "--!ZOMG-A-TUTORIAL!--"

And before we can do anything. we need to dim us some new strings, you will notice that we have a new thing here. "Settings()", no its not a function, its a string, to be more specific. this is an array. it can hold more then one string, addressed by a number, just like with the files.


Dim self, Settings() As String

You will notice that this is different. we don't have a button, we are going to do all this while its still starting up. it makes it easier.

Lets open the program. however this time, we are not opening a different file. we are having our program open itself. so instead of typing "Application.StartupPath", since the file could have been renamed, lets type "Application.ExecutablePath" this is the path and the filename to the executable. this makes it alot easyer

FileOpen(1, Application.ExecutablePath, OpenMode.Binary, OpenAccess.Read)
Just as we did in the builder. lets just open this with the Access mode "Read"

And once again. we need to fill the string with the right amount of bytes. if you need to know how this works. please read the first half of this tutorial

self = Space(LOF(1))


now we will get the file. but notice something, this time, we are not getting a different file, we are storing our full EXE in a string why is this you may ask? its simple, when use the FilePut() function we put our Stub into the file, but we put more then that! we added all our information to it didn't we? such as the username and password. and our check boxes! and that is appended to the back of our file!

FileGet(1, self)


Now to close the file.

FileClose(1)

Our code so far:
Code: Select all
Imports System.IO
Public Class Form1
    Const FileSplit = "--!ZOMG-A-TUTORIAL!--"
    Dim self, Settings() As String
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    
        FileOpen(1, Application.ExecutablePath, OpenMode.Binary, OpenAccess.Read)
        self = Space(LOF(1))
        FileClose(1)
    
    End Sub
End Class
OK OK this is where i am going to confuse a lot of you, we are going to take our "self" string. and split it up, so that we can use it later.

Settings = Split(self, FileSplit)

Now lets explain how this works, so that you can use this for anything you want.
The function goes as follows:

Split(String to split, Char or string to split by)

So lets say we have a string that says "We Are LeG10N" and we split it by spaces, the function would be:

OurString = Split("We Are LeG10N", " ")

To put it simply. the function finds each space, (" ") and splits it there, to break it down into several strings

After that, OurString now has 3 parts. (0), (1), and (2), this will be hard for a lot of new programmers. seeing as most of us count starting at 1, and not 0, but in the programing world 0 the base number.

OurString now has the following strings

OurString(0) = "We"
OurString(1) = "Are"
OurString(2) = "Proprogrammer"

And thats exactly how this works for our use, remember how we ordered our FilePut() function? (this is why i said it would be a good idea to copy+paste
Lets review our FilePut() Function.

FilePut(2, stub & FileSplit & UsernameBox.Text & FileSplit & PasswordBox.Text & FileSplit & RandomBox.Text & FileSplit & AntiDebugger & FileSplit & AntiNazi & FileSplit & AntiSanta & FileSplit & AntiEverything)

OK so the way we ordered this. and since we are splitting this massive string into parts via "FileSplit" we should have 8 strings in Settings() and they are as follows


Settings(0) = our stub (this file)
Settings(1) = the text from our username box
Settings(2) = the text from our password box
Settings(3) = the text from our random box
Settings(4) = the string we made for our Anti-Debugger check box
Settings(5) = the string we made for our Anti-Nazi check box
Settings(6) = the string we made for our Anti-Santa check box
Settings(7) = the string we made for our Anti-Everything check box[/qoute]

So for now we can use this as our reference. so that we don't have to think of this like crazy while we are programing.

Now! since we got the hard part out of the way. lets put out Settings() strings to work!


UserNameText.Text = Settings(1)
PasswordText.Text = Settings(2)
RandomText.Text = Settings(3)
This should be clear by now, our username text now equals the text we stored from out username text box in the first program. The same thing for the password text and the random text.

We are almost done! using our reference we made, we can make a if then elseif statement!

'from here on it just requires a little thinking. we just piece together what we know so far. and we test the remaining Settings()
'strings to see if they = "True" like we set them to be if it was checked!
If Settings(4) = "True" Then
AntiDebuggerText.Text = "Hey you cant debug me!"
ElseIf Settings(5) = "True" Then
AntiNaziText.Text = "Good, I dont like Nazi's either"
ElseIf Settings(6) = "True" Then
AntiSantaText.Text = "ZOMG! your going to get coal in your stocking!"
ElseIf Settings(7) = "True" Then
AntiEverythingText.Text = "Well in that case. I'm Anti-you!"
End If

Our Final code for this project:
Code: Select all
Imports System.IO
Public Class Form1
    Const FileSplit = "--!ZOMG-A-TUTORIAL!--"
    Dim self, Settings() As String
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    
        FileOpen(1, Application.ExecutablePath, OpenMode.Binary, OpenAccess.Read)
        self = Space(LOF(1))
        FileClose(1)
    
        Settings = Split(self, FileSplit)
    
        UserNameText.Text = Settings(1)
        PasswordText.Text = Settings(2)
        RandomText.Text = Settings(3)
        
    If Settings(4) = "True" Then
        AntiDebuggerText.Text = "Hey you cant debug me!"
    ElseIf Settings(5) = "True" Then
        AntiNaziText.Text = "Good, I dont like Nazi's either"
    ElseIf Settings(6) = "True" Then
        AntiSantaText.Text = "ZOMG! your going to get coal in your stocking!"
    ElseIf Settings(7) = "True" Then
        AntiEverythingText.Text = "Well in that case. I'm Anti-you!"
    End If

    End Sub
End Class

Mery Christmas! WHERE DONE! haha, good work! you finished a Builder and a stub!

''happy programing!''
Last edited by Proprogrammer on Fri Dec 24, 2010 5:25 pm, edited 1 time in total.
------------------------------------------------------------------------------
Proprogrammer, not just a Programmer.
User avatar
mandai
Coding God
Coding God
Posts: 2585
Joined: Mon Apr 26, 2010 6:51 pm

Can you give some examples on what we would use this for?
Last edited by mandai on Sun May 06, 2012 5:16 pm, edited 1 time in total.
User avatar
Proprogrammer
VIP - Donator
VIP - Donator
Posts: 415
Joined: Sun Oct 03, 2010 11:14 pm

I did.
------------------------------------------------------------------------------
Proprogrammer, not just a Programmer.
User avatar
mandai
Coding God
Coding God
Posts: 2585
Joined: Mon Apr 26, 2010 6:51 pm

How could I integerate a keylogger into this as you say?
User avatar
Proprogrammer
VIP - Donator
VIP - Donator
Posts: 415
Joined: Sun Oct 03, 2010 11:14 pm

Basicly your are passing on the code from one program to another so in the stub you will need to have the code for the keylogging. In the builder you will need to put in the code for example having a checkbox, if it is checked once you press a build button then there should be a code like
If checkbox = true then
keylog = True
else
keylog = false
End if

Of course you will need to declare keylog is a string.
then just use that type of code + use the tutorial above to help you.

then in the stub you should have something that takes the splitted memory then once it unsplits all the memory transfered you should put this


If keylog(1) = true then
do keylog()
else
do nothing()
end if




Just use the tutorial and do something like this. Sorry that i didnt explain it that well.
------------------------------------------------------------------------------
Proprogrammer, not just a Programmer.
GoodGuy17
Coding God
Coding God
Posts: 1610
Joined: Mon Sep 07, 2009 12:25 am

Is the only reason for this to share values from one program to another?
Because I would probably use text files and streamreaders :P lol
User avatar
Proprogrammer
VIP - Donator
VIP - Donator
Posts: 415
Joined: Sun Oct 03, 2010 11:14 pm

lol yeah, but this is a bit more complexe so i like it.
------------------------------------------------------------------------------
Proprogrammer, not just a Programmer.
User avatar
mandai
Coding God
Coding God
Posts: 2585
Joined: Mon Apr 26, 2010 6:51 pm

So is this supposed to call the stub each time a key is pressed? I can't imagine that would be very practical.
I'll be sticking with memory mapped files.
8 posts Page 1 of 1
Return to “Tutorials”