Git Product home page Git Product logo

process_overwriting's Introduction

Process Overwriting

Build status

Process Overwriting is a PE injection technique, closely related to Process Hollowing and Module Overloading

Process Hollowing (aka RunPE) is an old and popular PE injection technique. It comes in has variety of flavors, but there are some steps in common:

  1. Start by creating a process in a suspended state
  2. Write our own PE module in its memory
  3. Redirect to the new module
  4. Resume the thread

Process Hollowing does not require manual loading of payload's imports. Thanks to the step 3 Windows loader treat our PE implant as the main module of the process, and will load imports automatically when its execution resumes.

To make our implant recognized by Windows loader, its Module Base must be set in the PEB. It is usually done by one of the two ways:

  • in the most classic variant, the original PE is unmapped from memory, and the new PE is mapped on its place, at the same address.
  • in another, yet common variant, the old module is left as is, and another PE is mapped in a new memory region. Then the new module's base address is manually written into the PEB (this variant was demonstrated here)

As a result of those classic implementations we get a payload running as main module, yet it is mapped as MEM_PRIVATE (not as MEM_IMAGE like typically loaded PEs). To obtain payload mapped as MEM_IMAGE we can use some closely related techniques, such as Transacted Hollowing or its variant "Ghostly Hollowing".

Process Overwriting is yet another take on solving this problem.

In contrast to the classic Process Hollowing, we are not unmapping the original PE, but writing over it. No new memory is allocated: we are using the memory that was originally allocated for the main module of the process.

Pros:

  • the implanted PE looks like if it was loaded by Windows loader:
    • mapped as MEM_IMAGE
    • divided into sections with specific access rights
    • the image is named
  • convenience of loading:
    • no need to manually relocate the implant prior to injection: Windows loader will take care of this (in classic Process Hollowing we have to relocate the module)
    • no need to fill imports (like in every variant of Process Hollowing)
    • no need to allocate new memory in the process

Cons:

  • It doesn't work if the target has GFG (Control Flow Guard) enabled (yet it is possible to disable it on process creation)
  • The target's ImageSize must not be smaller than payload's ImageSize (remember we are using only the memory that was already allocated!) - this limitation does not occur in other flavors of Process Hollowing
  • Can be detected by comparing of the module in memory with corresponding file (PE-sieve detects it) - just like every variant of Process Hollowing

Demo:

The demo payload (demo.bin) injected into Windows Calc (default target):

In memory (via Process Hacker):

Clone:

Use recursive clone to get the repo together with all the submodules:

git clone --recursive https://github.com/hasherezade/process_overwriting.git

process_overwriting's People

Contributors

dump-guy avatar fengjixuchui avatar hasherezade avatar

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.