Giter Site home page Giter Site logo

mangle's Introduction

THIS REPOSITORY HAS BEEN ARCHIVED

To view the latest version of Mangle or to submit an issue, reference https://github.com/Tylous/Mangle.

Mangle

Authored By Tyl0us

Featured at Source Zero Con 2022

Mangle is a tool that manipulates aspects of compiled executables (.exe or DLL). Mangle can remove known Indicators of Compromise (IoC) based strings and replace them with random characters, change the file by inflating the size to avoid EDRs, and can clone code-signing certs from legitimate files. In doing so, Mangle helps loaders evade on-disk and in-memory scanners.

Contributing

Mangle was developed in Golang.

Install

The first step, as always, is to clone the repo. Before you compile Mangle, you'll need to install the dependencies. To install them, run the following commands:

go get github.com/Binject/debug/pe

Then build it

go build Mangle.go

Important

While Mangle is written in Golang, a lot of the features are designed to work on executable files from other languages. At the time of release, the only feature that is Golang specific is the string manipulation part.

Usage

./mangle -h

	   _____                        .__
	  /     \ _____    ____    ____ |  |   ____
	 /  \ /  \\__  \  /    \  / ___\|  | _/ __ \
	/    Y    \/ __ \|   |  \/ /_/  >  |_\  ___/
	\____|__  (____  /___|  /\___  /|____/\___  >
		\/     \/     \//_____/   	  \/
					(@Tyl0us)
Usage of ./Mangle:
  -C string
        Path to the file containing the certificate you want to clone
  -I string
        Path to the orginal file
  -M    Edit the PE file to strip out Go indicators
  -O string
        The new file name
  -S int
        How many MBs to increase the file by

Strings

Mangle takes the input executable and looks for known strings that security products look for or alert on. These strings alone are not the sole point of detection. Often, these strings are in conjunction with other data points and pieces of telemetry for detection and prevention. Mangle finds these known strings and replaces the hex values with random ones to remove them. IMPORTANT: Mangle replaces the exact size of the strings it’s manipulating. It doesn’t add any more or any less, as this would create misalignments and instabilities in the file. Mangle does this using the -M command-line option.

Currently, Mangle only does Golang files but as time goes on other languages will be added. If you know of any for other languages, please open an issue ticket and submit them.

Before

After

Inflate

Pretty much all EDRs can’t scan both on disk or in memory files beyond a certain size. This simply stems from the fact that large files take longer to review, scan, or monitor. EDRs do not want to impact performance by slowing down the user's productivity. Mangle inflates files by creating a padding of Null bytes (Zeros) at the end of the file. This ensures that nothing inside the file is impacted. To inflate an executable, use the -S command-line option along with the number of bytes you want to add to the file. Large payloads are really not an issue anymore with how fast Internet speeds are, that being said, it's not recommended to make a 2 gig file.

Based on test cases across numerous userland and kernel EDRs, it is recommended to increase the size by either 95-100 megabytes. Because vendors do not check large files, the activity goes unnoticed, resulting in the successful execution of shellcode.

Example:

Certificate

Mangle also contains the ability to take the full chain and all attributes from a legitimate code-signing certificate from a file and copy it onto another file. This includes the signing date, counter signatures, and other measurable attributes.

While this feature may sound similar to another tool I developed, Limelighter, the major difference between the two is that Limelighter makes a fake certificate based off a domain and signs it with the current date and time, versus using valid attributes where the timestamp is taken from when the original file. This option can use DLL or .exe files to copy using the -C command-line option, along with the path to the file you want to copy the certificate from.

Credit

  • Special thanks to Jessica of SuperNovasStore for creating the logo.
  • Special thanks to Binject for his repo

mangle's People

Contributors

tweathers-sec avatar tylous avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mangle's Issues

Detection from Windows defender

Hi, i tested chisel with your tool and i didn't get any luck got detected by defender when i dropped on the disk. Do you have any suggestion?

Issue while cloning a windows certificate

me@DESKTOP:/path$ mangle -I calc_edit.exe -O new_calc_edit.exe -C windows.storage.dll

           _____                        .__
          /     \ _____    ____    ____ |  |   ____
         /  \ /  \\__  \  /    \  / ___\|  | _/ __ \
        /    Y    \/ __ \|   |  \/ /_/  >  |_\  ___/
        \____|__  (____  /___|  /\___  /|____/\___  >
                \/     \/     \//_____/           \/
                                        (@Tyl0us)
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x138 pc=0x4aa29f]

goroutine 1 [running]:
main.Stealer({0xc000136000, 0xa279, 0xa27a}, {0xc000180000, 0x79a9b8, 0x79a9b9})
        /home/me/Mangle/Mangle.go:142 +0x11f
main.main()
        /home/me/Mangle/Mangle.go:83 +0x1f1
me@DESKTOP:/path$

Certificate file is attached
windows.storage.zip

file go.mod

Hi man,
You not insert go.mod file in project.

how does it works?

hello i have installed yor tool... then tried to clone certificate, so i havee download kmp player and so open sourse tool from github...

./mangle -C KMP.exe -I Captura.exe -O 1.exe -S 3

it just broke new file it does not work... why what i did wrong?

Sign file after inflating

When I try to sign the file after inflating it, it goes back to normal size, and when I first sign the file and then inflate it, it loses the signature.

Only Error: Please provide a path to a file you wish to mangle

D:\NoScan\Mangle\Mangle>Mangle.exe -S 100 test.exe

       _____                        .__
      /     \ _____    ____    ____ |  |   ____
     /  \ /  \\__  \  /    \  / ___\|  | _/ __ \
    /    Y    \/ __ \|   |  \/ /_/  >  |_\  ___/
    \____|__  (____  /___|  /\___  /|____/\___  >
            \/     \/     \//_____/           \/
                                    (@Tyl0us)

2022/07/19 20:52:32 Error: Please provide a path to a file you wish to mangle

go get

Cant install dependency

PS D:\Pobrane\Mangle> go get github.com/Binject/debug/pe
go: go.mod file not found in current directory or any parent directory.
'go get' is no longer supported outside a module.
To build and install a command, use 'go install' with a version,
like 'go install example.com/cmd@latest'
For more information, see https://golang.org/doc/go-get-install-deprecation
or run 'go help get' or 'go help install'.
PS D:\Pobrane\Mangle> go install github.com/Binject/debug/pe
go: 'go install' requires a version when current directory is not in a module
Try 'go install github.com/Binject/debug/pe@latest' to install the latest version
PS D:\Pobrane\Mangle> go install github.com/Binject/debug/pe@latest
package github.com/Binject/debug/pe is not a main package
PS D:\Pobrane\Mangle>

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.