Anyone who considers arithmetical methods of producing random digits is in a state of sin - John von Neumann
HomePostsTags
Red Teaming Experiments
IYADK
Anyone who considers arithmetical methods of producing random digits is in a state of sin - John von Neumann
Red Teaming Experiments

Building LIBZT Static Libs for x86 and x64 On Windows


Libzt is an awesome library for p2p encryption and to tunnel communications. It’s open source and you can integrate it in the project of your choice!

Some projects would not mind to simply building it from source and integrating the Dynamic Link Libraries (dll) and have their executables load them and link them at runtime.

However, for some projects, you might want to have a simple executable and hence have these libraries integrated inside your executable. The library compiled and linked code will be present inside the .data header and would seamlessly integrate the binary, making your project shipped as a simple executable.

As an example, my personal project [zero-rat] needed to be a simple executable project, used to as a dropper to RAT devices, a perfect red team attack tool since you can easily bypass firewalls with the encrypted communications.

For the dll built, documentation on the libzt is easily avaible on their github page, as a powershell script.

Simply run . .\build.ps1; Build-All;.

You should find all the dll libraries inside the dist folder. The statically linked build is different however.

Install cMake as well as visual studio (2019 or 2022). Visual studio installation might be long considering you need to download and install C++ packages.

I recommend using visual studio but you can use any IDE or no IDE at all and go with gcc if you like. I will provide only the Visual Studio way.

Run cmake-gui and set the base source code folder as well as the folder for the binaries.

Click configure and select your generator to be Visual Studio or any other platform, and in the optional platform for generator, select x64 or x86 depending on which target you want to build the libraries.

Usually you could have to chose between any of the two after the project is generated but since the project will be generate with 64 bit long variables if no options is selected, it doesn’t work this way anymore.

Understand you will need to restart this process two times for every target platform, just click on File and Delete Cache to restart, chose a new platform for the generator.

You will have your built environment generated, the values you see here might be a little different from yours, you can leave them as is, you will generate all the projects of the solution but you can chose afterwards to build any of them.

cmake-gui project config

Click Generate, then Open Project.

You should now have the whole solution ready for building. You will also see you have the built options:

cmake-gui solution configuration

Now to have the libzt as a static build, simply right click the zt-static project inside the solution and click build.

You should find your zt.lib inside the dist folder. Make sure you repeat the process for the release versions, as it does not have the debug symbols inside the build and makes it lighter, and hardly debuggable for anyone trying to reverse your application.

visual studio solution explorer

Make sure you copy zt.lib as well as zt.pdb for the debugging symbols. As you see other projects will be built as well, since they are needed and included inside the zt.lib library.

There you go!

Now you can link these libraries in your projects, include the code too and have a single executable running libzt!

Cheers!