Skip to main content Link Menu Expand (external link) Document Search Copy Copied

Encoders are intended to encode payloads, evade malware detection techniques or obfuscate code. After deciding what your encoder should do, take this template and edit it for your needs.

Template

"""
This encoder requires HatSploit: https://hatsploit.com
Current source: https://github.com/EntySec/HatSploit
"""

from hatsploit.lib.encoder.basic import *


class HatSploitEncoder(Encoder):
    def __init__(self):
        super().__init__()

        self.details.update({
            'Name': "full name",
            'Encoder': "name",
            'Authors': [
                'Your name (your nickname) - encoder developer',
            ],
            'Description': "description",
            'Architecture': Arch,
        })

    def run(self):
        return self.payload

NOTE: All encoders should inherit from Encoder, otherwise encoder won’t be imported.

Let’s go through all the necessary methods:

  • self.details - Is a dictionary containing all necessary information (Full name, name, description, authors, etc.)
  • self.payload - Payload which can be encoded.
  • self.run() - Method, which is called on run.

Encoder arch (Arch)

For now, HatSploit does accept these architectures:

  • Architectures: ARCH_X64, ARCH_X86, ARCH_AARCH64, ARCH_MIPSLE, ARCH_MIPSBE, ARCH_ARMLE, ARCH_ARMBE.

Encoder options

You can add options to the encoder, read about them here.

Examples

You can always refer to the main repository which contains some encoders and rely on them. We will be glad if you first explore already existing encoders before writing new ones.