Giter Site home page Giter Site logo

payload-obfuscation-using-shannon-encoding's Introduction

Payload Obfuscation using Shannon Encoding

This C++ program uses Shannon encoding to obscure the contents of a payload in an effort to evade detection by static signature analysis. By introducing patterns that lower the global entropy or randomness of the payload, it may be possible to use more advanced obfuscation techniques and still avoid detection by anti-malware solutions. The payload is divided into segments, with a low-complexity sequence of bytes inserted between each section. The original payload can be recovered by removing these low-complexity sequences. This approach allows for the obfuscated code to be of any size and can be used as a way to mask the harmful, obfuscated code by diminishing its unpredictability and global entropy. This allows for the use of more advanced techniques to obscure the code and remain undetected by anti-malware solutions.

What is Shannon Encoding?

Shannon encoding is a technique for creating a prefix code for a set of symbols based on their frequencies. It was developed by mathematician and engineer Claude Shannon in the 1950s as a way to efficiently transmit data over a noisy channel.

In Shannon encoding, each symbol is assigned a code consisting of a series of 0s and 1s, with the most frequently occurring symbols being assigned shorter codes. This allows the encoded data to be transmitted more efficiently, because the shorter codes take up less space.

Shannon encoding can be used to create a low-entropy pattern of bytes that can be inserted between chunks of a payload in order to bypass static signature detection.

How Shannon Encoding Helps Bypass Anti-Virus

Anti-virus software uses static signature detection to identify known malware by searching for specific patterns of bytes, known as signatures, in the code.

These signatures are often high-entropy patterns that are characteristic of malware. Shannon encoding can be used to reduce the overall entropy of the payload by inserting low-entropy patterns of bytes between chunks of the payload.

This makes it less likely to be detected by static signature detection because the high-entropy chunks are separated by low-entropy patterns.

When the payload is run, the low-entropy pattern is removed and the original payload is reconstructed in memory for execution. This technique can make it less likely for signature-based detectors to identify the high-entropy chunks of the payload due to the reduced overall entropy.

Features

  • Create a Shannon encoding for a given payload
  • Insert a low-entropy pattern of bytes between chunks of a payload
  • Reconstruct the original payload from the obfuscated version

How the PoC Works

The proof of concept (PoC) works by using Shannon encoding to create a low-entropy pattern of bytes that can be inserted between chunks of a payload. The original payload can then be reconstructed by removing the low-entropy pattern.

The PoC consists of three main functions:

  1. createShannonEncoding: This function takes a payload as input and creates a Shannon encoding for each symbol in the payload based on its frequency. It then concatenates the encodings to create a low-entropy pattern of bytes.

  2. insertLowEntropyPattern: This function takes a payload, a low-entropy pattern, and a chunk size as input, and inserts the low-entropy pattern between chunks of the payload. It returns the obfuscated payload.

  3. restoreOriginalPayload: This function takes an obfuscated payload and a low-entropy pattern as input, and removes the low-entropy pattern to reconstruct the original payload.

To use the PoC, you can call the createShannonEncoding function to create a low-entropy pattern, and then pass the payload and the low-entropy pattern to the insertLowEntropyPattern function to create the obfuscated payload. To restore the original payload, you can call the restoreOriginalPayload function with the obfuscated payload and the low-entropy pattern.

Disadvantages

There are several disadvantages to using Shannon encoding to obfuscate a payload:

  1. Increased size: The low-entropy pattern added by the Shannon encoding increases the size of the payload, which can make it more difficult to transmit or store.

  2. Complexity: The process of creating a Shannon encoding and inserting a low-entropy pattern between chunks of a payload can be complex and time-consuming, especially for large payloads.

  3. Detection: While Shannon encoding can be effective at bypassing static signature detection, it may not be effective against more advanced detection methods, such as machine learning-based detectors. These detectors can analyze the behavior of the payload and detect it even if it has been obfuscated using Shannon encoding.

  4. Maintenance: If the payload changes, the low-entropy pattern may need to be updated, which can be a tedious process.

Overall, while Shannon encoding can be a useful technique for bypassing static signature detection, it is not a foolproof method and may not be suitable for all situations. It is important to

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.