Giter Site home page Giter Site logo

exe2c_sh's Introduction

exe2c_sh

Converts PE executables into shellcode and loads it into usable C code, the default type is unsigned char shellcode[].

It also has support for loader templates, the default output template is located at /template/.

Installation

git clone https://github.com/gatariee/exe2c_sh.git
pip install -r requirements.txt

Usage

./exe2sh.py -i <path_to_bin> -o <output_folder>

Templates

Shellcode generated will also automatically be passed into a loader template, located at /template/. These should be edited to your liking, the default template is a simple loader that will load the shellcode into memory and execute it.

  • main.c
    • The main loader template, this is where the shellcode will be loaded into.
  • shellcode.c
    • This is where the shellcode is generated and parsed to.
  • shellcode.h
    • The shellcode header template, this is where the shellcode will be defined.

Example

main.c

#include <windows.h>
#include "shellcode.h"

int main(int argc, char *argv[]) {
    size_t shellcode_size = 42965; // auto-generated based on size of bin
    void *exec = VirtualAlloc(0, shellcode_size, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
    memcpy(exec, shellcode, shellcode_size);
    ((void(*)())exec)();
    return 0;
}

shellcode.c

unsigned char shellcode[] = { 0xE8, 0xC0, 0x45, 0x00, 0x00, 0xC0, 0x45 ... };

shellcode.h

#ifndef SHELLCODE_H
#define SHELLCODE_H

extern unsigned char shellcode[];

#endif

Donut

You may face AV issues when installing the donut-shellcode library, add an exclusion to the folder before installing.

exe2c_sh's People

Contributors

gatariee avatar

Stargazers

Muhammad Usman avatar kepler404 avatar  avatar pengs avatar Ryota Sakai avatar

Watchers

 avatar

Forkers

retkoussa

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.