EntropyReducer – Reduce Entropy And Obfuscate Youre Payload With Serialized Linked Lists

66887354d260120baf5d60939e34811c316cd07d0d03a7606e8ec1d395f66768


EntropyReducer: Reduce The Entropy Of Youre Payload And Obfuscate It With Serialized Linked Lists


How Does It Work

EntropyReducer algorithm is determined by BUFF_SIZE and NULL_BYTES values. The following is how would EntropyReducer organize your payload if BUFF_SIZE was set to 4, and NULL_BYTES to 2.


Obfuscation Algorithm

  • EntropyReducer first checks if the input raw payload is of a size that’s multiple of BUFF_SIZE, if not, it pads it to be as so.
  • It then takes every BUFF_SIZE chunk from the payload, and makes a linked list node for it, using the InitializePayloadList function, initializing the payload as a linked list.
  • The created node will have an empty buffer of size NULL_BYTES, that will be used to lower the entropy
  • At this point, although EntropyReducer completed its task by lowering the entropy of the payload, it doesn’t stop here. It then continues to randomize the order of each node in the linked list, breaking down the raw payload’s order. This step is done via a Merge Sort Algorithm that is implemented through the MergeSort function.
  • The sorted linked list is in random order because the value in which the linked list is sorted is the XOR value of the first three bytes of the raw payload, this value determines its position in the re-organized linked list, this step can be shown here
  • Since saving a linked list to a file is impossible due to the fact that it’s linked together by pointers. We are forced to serialize it.
  • Serialization of the generated linked list is done via the Obfuscate function here.
  • After that, the serialized data is ready to be written to the output file.

Deobfuscation Algorithm

  • Since the last step in the Obfuscation Algorithm was serializing the linked list, the first thing that must be done here is to deserialize the obfuscated payload, generating a linked list from it, this step is done here in the Deobfuscate function.
  • Next step is to sort the linked list using the node’s Id, which is done using the same Merge Sort Algorithm used before.
  • Now, the linked list is in the right order to re-construct the payload’s bytes as they should. So we simply strip the payload’s original bytes from each node, as done here.
  • Last step is to free the allocated nodes, which is done here.

Usage

  • EntropyReducer simply read the raw payload file from the command line, and writes the obfuscated version to the same file’s name prefixed with “.ER”.
  • The size of the final obfuscated payload varies depending on the values of both BUFF_SIZE and NULL_BYTES. However, it can be determined using the following equation
FinalSize = ((OriginalSize + BUFF_SIZE - OriginalSize % BUFF_SIZE ) / BUFF_SIZE) * (BUFF_SIZE + NULL_BYTES + sizeof(INT))
  • The PoC project in this repo is used to execute the ".ER" file generated as an example of deserializing and deobfuscating it.

Include In Your Projects

All you have to do is add EntropyReducer.c and EntropyReducer.h files to your project, and call the Deobfuscate function. You can check PoC/main.c for reference.


Output Example

In this example, BUFF_SIZE was set to 3, and NULL_BYTES to 1.

  • The raw payload, first payload chunk (FC 48 83)

1867dedc15fa9eabf787ee4b34c17a8bb3cfd545d88698b5329d23fd9c0cf8f1

  • The same payload chunk, but at a different offset

8974147d24c8cf174d513aeaabb3c9760e486bd6996a16590da6cf1c7df41250


Profit

e96cd49180275520854646d89039cb640f810f34fde9fb61a2d03d402199f512

  • The same file, AES encrypted, scores entropy of 7.110.

bf0386d954ea4fd536841f7370f334b0c73d26b14cb5d3e4472cca6e5f39c11a

  • Nearly the same result with the RC4 algorithm as well; 7.210

b429506be82853ac0d127b05bdd3bed094128fb2c5a7a519fdedf7b0adde71f4

  • Using EntropyReducer however, scoring entropy even lower that that of the original raw payload; 4.093

597dabc4b3ba8e5aff251bbb4dbbad84d0d76d1ce8a02b38e7fc502178059788


The Merge Sort Algorithm Is Taken From c-linked-list.




Original Source


 


A considerable amount of time and effort goes into maintaining this website, creating backend automation and creating new features and content for you to make actionable intelligence decisions. Everyone that supports the site helps enable new functionality.

If you like the site, please support us on “Patreon” or “Buy Me A Coffee” using the buttons below

Buy Me A Coffee
Patreon

 To keep up to date follow us on the below channels.

join
Telegram
discord
Discord
reddit
Reddit
linkedin
LinkedIn