Hack Forums
[.NET] [TUT][VB.NET] How to make a Builder with Built-In Stub WITHOUT DROPPING it out! - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [.NET] [TUT][VB.NET] How to make a Builder with Built-In Stub WITHOUT DROPPING it out! (/showthread.php?tid=357028)

Pages: Pages 1 2


[TUT][VB.NET] How to make a Builder with Built-In Stub WITHOUT DROPPING it out! - cysto - Apr 8, 2010

Welcome HF coders,
This is my first tutorial on HF, so I hope you like it!

Goal: Know how to make a built-in stub without dropping it out on the hard disk.

Let's start:

Step 1:
-------
Take any builder project you have (binder\crypter\...), and open it.

Step 2:
-------
In the solution explorer, right click your project, hover your mouse over "Add", and press "Existing item..." from the sub-menu:
[img]http://img232.imageshack.us/img232/487/96689237.jpg[/img]

Step 3:
-------
Browse for your stub, and press "Add"
P.S: Be sure that the file type is: "Executable Files (*.exe; *.dll; *.ocx)

Step 4:
-------
In the solution explorer, right click your stub, and press "Properties"
The Properties panel will get focus.

Step 5:
-------
Change the stub's "Build Action" to "Embedded Resource":
[img]http://img189.imageshack.us/img189/478/propk.jpg[/img]
Optional: You can rename your stub to any other name, even another extension, by changing its property "File Name" to your desired name.

Step 6:
-------
Add this Function to your code:
Code
Private Function ReadExeFromResources(ByVal filename As String) As Byte()
        Dim CurrentAssembly As Reflection.Assembly = Reflection.Assembly.GetExecutingAssembly()
        Dim Resource As String = String.Empty
        Dim ArrResources As String() = CurrentAssembly.GetManifestResourceNames()
        For Each Resource In ArrResources
            If Resource.IndexOf(filename) > -1 Then Exit For
        Next
        Dim ResourceStream As IO.Stream = CurrentAssembly.GetManifestResourceStream(Resource)
        If ResourceStream Is Nothing Then
            Return Nothing
        End If
        Dim ResourcesBuffer(CInt(ResourceStream.Length) - 1) As Byte
        ResourceStream.Read(ResourcesBuffer, 0, ResourcesBuffer.Length)
        ResourceStream.Close()
        Return ResourcesBuffer
    End Function
Credits to Deathader

Step 7:
-------
Now, I'm sure that MOST of you coders declare the "stub" As String. This is going to change now. Declare it As Byte(), like this:
Code
Dim stub As Byte()
And delete this piece of code that gets the stub its value:
Code
FileOpen(1, Application.ExecutablePath, OpenMode.Binary, OpenAccess.Read)
stub = Space(LOF(1))
FileGet(1, stub)
FileClose(1)
And replace it with this code:
Code
stub = ReadExeFromResources("the name of the stub in the resources, with extension")

Step 8:
-------
After the above replacement, an error in the error list will appear, warning you that "&" cannot be used with 1-dimensional array of Byte and String.
For that reason, we're going to change this code:
Code
FilePut(2, stub & fileSplit & cryptedFile & etc...)
To this code:
Code
FilePut(2, stub)
FilePut(2, fileSplit & cryptedFile & etc...)

This finishes our tutorial for making a built-in stub!
Hope you learned something from it!
Enjoy!!


* - tameem - Apr 8, 2010

Very nice, Thanks =] .. Will use


* - newbie223 - Apr 8, 2010

deathadder posted this b4 i think why does it need to be reposted


* - cysto - Apr 8, 2010

Really? I searched for it, and only found something like this:
https://hackforums.net/showthread.php?tid=174098
But those drop the stub to the application's path.
Mine doesn't drop it at all. It stays in memory.
In addition, I gave Deathader credits for the ReadExeFromResources() function.


* - newbie223 - Apr 8, 2010

Well ok then i must have seen on other forum then


* - flashlight - Apr 8, 2010

thankyou cysto this is very helpful


* - aquarian92 - Apr 8, 2010

Nice thanks for sharing


* - iProfit - Apr 8, 2010

Thanks :) this is pretty useful


* - Onyx - Apr 8, 2010

thanks for sharing, shall come in pretty useful...


* - HaXZX0r - Apr 8, 2010

Shit! i accidentally voted No. -.- It´s a great tut and i used it! Can any admin delete my vote??? :P


* - Diebspiel - Apr 8, 2010

Hi,

FileGet(1, stub)
FileClose(1)

is very old VB6 code.

it works in .net, but please use the IO namespace.


* - dayan - Apr 11, 2010

Interesting method! I will try diz


* - WarlockSyno - Apr 11, 2010

This is great! Thanks!


* - heavy-scientist - Apr 11, 2010

hi you write the wtrong code what kinda programmer are you dont trust this guy he is a freak.

Go back to school dude you suck


* - [Eprouvez] - Apr 11, 2010

This method is obsolete, not trolling or anything but why have that function because when you add the stub to your project, it's already it a byte array!

So instead of:

Code
stub = ReadExeFromResources("Blah")

You can just do:

Code
stub = My.Resources.Stub

Also, building method you've used is obsolete:

https://hackforums.net/showthread.php?tid=361286 - Binder tutorial, but some method.

Other than that, good for a first tutorial, I like the layout and steps you've put in to make it easier for everyone to understand.