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

.NET 

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

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!!
Very nice, Thanks =] .. Will use
deathadder posted this b4 i think why does it need to be reposted
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.
Well ok then i must have seen on other forum then
thankyou cysto this is very helpful
Nice thanks for sharing
Thanks :) this is pretty useful
thanks for sharing, shall come in pretty useful...
Shit! i accidentally voted No. -.- It´s a great tut and i used it! Can any admin delete my vote??? :P
Hi,

FileGet(1, stub)
FileClose(1)

is very old VB6 code.

it works in .net, but please use the IO namespace.
Interesting method! I will try diz
This is great! Thanks!
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
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.


Possibly Related Threads...
Thread / Author Replies Views Last Post
[C] by SIM-4717218Aug 21, 2020 11:33 AM 0 160 Aug 21, 2020 11:33 AM
Last Post: SIM-4717218
[C] by jBarrelFeb 14, 2020 03:47 AM 11 396 Feb 14, 2020 03:47 AM
Last Post: Backbone
[C] by jimcola99Jan 14, 2020 03:29 PM 1 184 Jan 14, 2020 03:29 PM
Last Post: akali