Code Monkey home page Code Monkey logo

pe-union's Introduction

PEunion

Crypter, binder & downloader

PEunion encrypts executables, which are decrypted at runtime and executed in-memory.

Stub

Two stubs are available to choose from, both of which work in a similar way.

  • Native: Written in assembly (FASM)
  • .NET: Written in C#

Key feature overview

  • Emulator detection
  • Low-entropy packing scheme
  • Two-layer execution architecture
  • Code obfuscation
  • File compression
  • Binder (combine multiple files)
  • Downloader
  • RunPE (process hollowing)
  • In-memory invocation of .NET executables
  • Drop files to disk
  • Melt (self-deleting stub)
  • EOF support
  • Specify icon, version information & manifest
  • Well-designed UI
  • Commandline compiler

Multiple files can be compiled into the stub. A file can either be embedded within the compiled executable, or the stub downloads the file at runtime.

Typically, an executable is decrypted and executed in-memory by the stub. If the executable is a native PE file, RunPE (process hollowing) is used. For .NET executables, the .NET stub uses Invoke. Legitimate files with no known signatures can be written to the disk.

Implementation & execution flow

Obfuscation and evasive features are fundamental to the design of PEunion and do not need further configuration. The exact implementation is fine tuned to decrease detection and is subject to change in future releases.

This graph illustrates the execution flow of the native stub decrypting and executing a PE file. The .NET stub works similarly.

The fundamental concept is that the stub only contains code to detect emulators and to decrypt and pass execution to the next layer. The second stage is position independent shellcode that retrieves function pointers from the PEB and handles the payload. To mitigate AV detections, only the stub requires adjustments. Stage 2 contains all the "suspicious" code that is not readable at scantime and not decrypted, if an emulator is detected.

The shellcode is encrypted using a proprietary 4-byte XOR stream cipher. To decrease entropy, the encrypted shellcode is intermingled with null-bytes at randomized offsets. Because the resulting data has no repeating patterns, it is impossible to identify this particular encoding and infer YARA rules from it. Hence, AV detection is limited to the stub itself.

Obfuscation

Assembly code is obfuscated by nop-like instructions intermingled with the actual code, such as an increment followed by a decrement. Strings are not stored in the data section, but instead constructed on the stack using mov-opcodes.

The C# obfuscator replaces symbol names with barely distinguishable Unicode characters. Both string and integer literals are decrypted at runtime.

Right-To-Left Override Tool

The Unicode character U+202e allows to create a filename that masquerades the actual extension of a file.

It is a simple renaming technique, where all characters followed by U+202e are displayed in reversed order. This way, an executable can be crafted in such a way that it looks like a JPEG file.

Audience

In order to use this program, you should:

  • be familiar with crypters and the basic concept of what a crypter does
  • have a basic understanding of in-memory execution and evasion techniques
  • acknowledge that uploading the stub to VirusTotal will decrease the time that the stub remains FUD

I do not take any responsibility for anybody who uses PEunion in illegal malware campaigns. This is an educational project.

FUD

This project is FUD on the day of release (September 2021). A crypter that is free, publicly available, and open source will not remain undetected for a long time. Adjusting the stub so it does not get detected is a daunting task and all efforts are in vain several days later. Therefore, there will be no updates to fix detection issues.

Rather, PEunion offers a fully functional implementation that is easy to modify and extend. If you want PEunion to be FUD, please get familiar with the code of the stub and adjust it until you are satisfied with the result.

However, additional evasion techniques may be implemented in future releases to improve the baseline design.

Downloads

PEunion 4.0.0.zip (ZIP Password: bytecode77)

Project Page

bytecode77.com/pe-union

pe-union's People

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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pe-union's Issues

Crypt

If I do not know if the .exe that I am gluing is encrypted and if I turn on the cryptor during the gluing, will the files work if they have already been encrypted?

Great Tool and Suggestions for 4.0

This isn't an issue but I'm just telling you this tool is very good and I appreciate you will continue to update it after 4 years. However I have a suggestion to the new version which you are working on. It would be great to see that you could change the dropping location to a custom one eg. in the system folder. This is because the preset ones are very bad for tech savvy users, they could open task manager and find the file location. Also the UI design is very nice compared to other Binders and Crypters.
Great Job and best of luck to you

Not fully undetectable

I wanted to test this and noticed that:

Unencryped - 43/70 engines detected it.
Encrypted - 39/70 engines detected it.

There isn't much change...

command line support

Hello @bytecode77 !

Any plans on adding CLI / command line support for your tool? :)
I would love to add support for it in my ProtectMyTooling but currently cannot do so due to inability to invoke it from CLI.

Or is it pebuild.exe I should use to invoke it instead? I'm unsure.

Happy Christmas,
Mariusz.

Detected by Windows Defender

No matter what I try to do, the file is detected by windows defender as "Trojan:Win32/Wacatac.B!ml" in version 4.0

Problem with the download file from url option

I have a problem with the download file from url option. the file is downloaded, but it is not saved in its original form, it has much less kilobytes and therefore does not run. Tested on various upload sites.

modifying stub

first of all i'd love to thank you for the immense work u've made :)

so u've said that only the stub needed modification to be FUD. but i dont know where to look at in the code lmao.

when i open the pe-union.sln file in VS, could u give me some indication as where to look at ? (peunion, pebuild or pe compiler folder?

im relatively new to this game, sorry if it seems to be a dumb question.

also if u have some tips to make it FUD i'd love to hear from a pro.

thanks for everything

dependency

can u share all .net dependency's i m not sure way after installing .net as instructed pe dos not start i dont know its win7 or something else

Fully detectable

Hello and thank you for reading and replying to my problem.
I've binded 2 files [one .exe around 40kb and one .txt around 3.5MB, both separated by an error appearing image]. I only selected encrypt, compress and hidden for the executable I'm interested in, and also selected ,,run as administrator'' execution in the ,exe's config prior to building it. After building it, zipping it with winrar and uploading it online, I tried to download it through google drive/anon files and many other upload sites, I can't even get to the point that I got it In my PC, can't say anything about even unzipping the folder. This is what i get:
image
Basically there's no chance that anyone could even try to open that folder. Can I have some advice? Bless.

Question abt editing stub

Hello I am new to coding in general. I am wondering in what way can I edit the stub to make it a different signature so it is FUD again?

RunPE,Invoke error

Cannot use .NET executable file.exe with RunPE.
And when i use Invoke gives me this error:
.NET Invocation is only supported in a .NET stub.
How can i fix that?

Doesn't Work

When binding multiple files for example
if I bind my exe with a portable software which depends on its files in that folder.
It doesn't get executed or end up broken I tried the portable.exe execution directory option still nothing and the other file gets executed with a huge delay like 1 minute later.

New to C#

I am new to C++ and C#. I have been a webdeveloper for years, but in the field of C and C# I have little to no experience. Do you have any idea how I can get resrouces on learning about crypters and stub.

While I was researching I found this repo, but I don't really know how I should get started. On Google and youtube there is very little information available as far as I know.

Any suggestions?

Issues compiling.

When I try to compile the file I get the error shown here,

CS2001: Source file 'dir*\AppData\Local\Temp\tmp2D4.tmp' could not be found

*my windows directory does have a space in it, maybe that is to blame?

Any help is appreciated.
Thank you.

encrypter ! FUD

Hello

Can i use it as just a crypter to make my exe undetectable ?
i have tried to encrypter xmrig miner but the final build doesn't work
btw really Nice tool

video hướng dẫn

hi vọng bạn ra video hướng dẫn sử dụng cho tool này, và cho hỏi là nó có vượt qua" windows defender? "

App crashes

Hello there, when i try to compile 2 apps/exe's. It runs through the compiling and then later crashes. I'm left with a process running for C# taking up to 90% of my memory.

image

support for x64 native stub

Hello sir, it's a really awesome tool. Could you please add x64 native stub, so that I can runpe my x64 pe file.

Stub.cs

i downloaded binary and runed it, added file and tryied to build it, line 0 CS2001 on every try descripton Stub.cs

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.