text stringlengths 0 1.99k |
|---|
user's home directory. Gone are the days of every program installing |
itself in the Program Files directory, now is the dawn of AppData and the |
user's document folder where they unzip various packages of unsigned |
executables. We can simply recursively iterate the user's home directory |
for targets. |
As for what it should do on infection? I'm a particular fan of the |
Desktop Pet project[4], formerly known as eSheep in the 90s. An |
appropriate payload to send up an infection technique from the 90s. |
It provides a great visual if the payload executes for testing purposes. |
Our payload should simply download (if the file doesn't exist) and execute |
this cute little sheep onto the user's desktop. Who would oppose such |
adorable software augmenting executables with a delightful animal friend? |
A simple download-exec of this payload will be perfect. |
--[ 4. Building the Virus |
Quick and dirty, to build Broodsac, uudecode the artifacts in section 9 |
to get the tarball, extract it, and run the following: |
$ cd broodsac |
$ mkdir build |
$ cd build |
$ cmake ../ -A x64 |
$ cmake --build ./ --config Release |
Naturally, I am assuming you won't be foolish enough to run the result on |
a system you don't want tampered with. Unless you *want* sheep friends in |
your executables, then by all means. |
While you are building your virus, you are undoubtedly going to encounter |
bugs. Considering we are building software, we should borrow from |
software's philosophy of creating and performing tests. These do not have |
to be formal unit tests, per se, where functionality is verified at |
individual code points, but they should somehow test the functionality |
of your virus. Considering the volatility of the undefined behavior of |
targets we work with in our dark development, you should absolutely |
build with tests in mind at the forefront. |
There are three key questions we need to consider for our testing |
purposes: |
+ Does the payload work? |
+ Does the infector successfully infect? |
+ Does the infection succeed without disrupting original execution? |
The first question has an actionable task for us: how do we test this? |
Naturally, we don't have to do it programatically-- we simply need to run |
the payload in its many forms to see if it successfully launches a cute |
little sheep. C and Assembly have various development pitfalls that will |
become apparent during this simple testing process. To build and test our |
64-bit payload, for example, we can simply do this: |
$ cd infection/asm/64 |
$ mkdir build |
$ cd build |
$ cmake ../ -DINFECTION_STANDALONE=ON -A x64 |
$ cmake --build ./ --config Release |
$ ./Release/infection_asm_64.exe |
If our payload succeeds, we are rewarded with a cute little sheep. |
A simple test. |
This is similar to the configure/make process on Linux. CMake takes the |
CMakeLists.txt in the target directory and builds the configuration for |
your compilation tools necessary in order to perform a build. We have |
configured our ASM files to be compileable as either standalone binaries |
for individual testing, or as static libraries to be included with the |
infector binary. |
A static library was chosen as the method of merging our payloads into our |
binary because it's simple and elegant, since the payload's architecture |
will match. Instinctively, we see shellcode as a unit to be stored away, |
to be converted to a hex string and stashed away in some C code. So we |
wind up doing creative things with it, as to us, it is merely a blob of |
data to be wrangled into something. We tend to forget that the shellcode |
can be its own individual code unit. |
But with a build system on your side, you can augment the way your |
shellcode comes out at the compilation stage. After doing various build |
customizations to our shellcode payload, in our infector binary's CMake |
file, we include this and the 32-bit version this way: |
add_subdirectory(${PROJECT_SOURCE_DIR}/infection/asm/32) |
add_subdirectory(${PROJECT_SOURCE_DIR}/infection/asm/64) |
add_executable(broodsac WIN32 main.c) |
target_link_libraries(broodsac infection_asm_32 infection_asm_64) |
In a rather clean way, with a simple set of "extern" keywords in the |
infector's main.c file, we have included our shellcode payloads into the |
main binary. While not shown yet, in addition to this process, we have |
managed to automate a step of encrypting the strings within the payload |
code, so every time our build is executed, the strings are re-encrypted |
and re-assembled in the infector executable. |
We have avoided the tedium of manually converting our shellcode into an |
array of some kind and even added an obfuscation step along the way. |
The beauty of this method is that it avoids the unseen hazards that tend |
to spring up from the speedy solutions we're used to. And at the end of |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.