Giter Site home page Giter Site logo

memeditor's Introduction

MemEditor

MemEditor is a C program that can attach to a process, find the executable memory region of a specific module (e.g. a library such as kernel32.dll), and replace some opcodes with new ones. You can use this tool to change on-the-fly executable code (i.e. behaviour) of your target process. I wrote it in a single simple plain C file. You can use it as a debugger example.

The program uses various Windows API functions to perform the following tasks:

  • Enumerate the processes and modules in the system and get their information
  • Open the process and attach as a debugger
  • Suspend and resume the process execution
  • Query and modify the memory regions and their protection
  • Read and write the memory bytes
  • Convert the input hex strings (representing the opcodes) to byte arrays
  • Compare and replace the opcodes
  • Close the handles and detach from the process

The program is intended to demonstrate how to patch executable code on-the-fly in a Windows process. It may not work on some processes or modules that have anti-debugging or self-modifying techniques. It also assumes that the old and new opcodes have the same length.

This program should be used with caution and only for educational purposes.

Usage

The program takes four arguments: the process name, the module name, the old opcodes, and the new opcodes. The old and new opcodes should be strings of hex characters.

To compile the program, you can use any C compiler that supports the Windows API, such as Visual Studio or MinGW.

To run the program, you need to have administrator privileges.

Example of usage:

To replace the call instruction (E8 00 00 00 00) with five nop instructions (90 90 90 90 90) in the code section of the kernel32.dll module of the notepad.exe process, you can use the following command: memeditor.exe notepad.exe kernel32.dll E800000000 9090909090

memeditor's People

Contributors

echo-devim avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

captincook

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.