Giter Club home page Giter Club logo

xarch_shellcode's Introduction

Cross Arch Shellcode Compiler

2016 - ixty

Information

This program allows to build portable, architecture independant shellcode from C code. It currently supports the following architectures:

  • x86
  • x86_64
  • arm
  • arm_64

It works by:

  • compiling the same C code for each architecture
  • linking it to arch specific syscall implementation
  • using a polyglot dispatching shellcode

The final layout of the output binary is: [ DISPATCHER ] [ X86 BLOCK ] [ X86_64 BLOCK ] [ ARM BLOCK ] [ ARM_64 BLOCK ]

The dispatcher is in stage0 Open stage0/README for information on how it works

Each arch specific block has the following layout:

[ LOADER    ]
[ RELOC NUM ]
[ RELOC 0   ]
[ RELOC 1   ]
    ...
[ RELOC N   ]
[ START OFF ]
[ CODE      ]

Open stage1/README for information on loaders

The final payload code is the stage2. Open stage2/README for information on the payload

Dependencies

  • python2.7
  • nasm
  • gcc
  • pyelftools (pip install pyelftools)
  • qemu-user-static
  • qemu-utils
  • arm chroot with gcc
  • arm64 chroot with gcc

Assuming you use debian:

# apt-get install gcc nasm python2.7 python-pip
# apt-get install qemu qemu-user-static qemu-utils binfmt-support debootstrap
# qemu-debootstrap --arch=arm64 jessie /opt/arm64/ http://ftp.debian.org/debian
# qemu-debootstrap --arch=armhf jessie /opt/armhfxx/ http://ftp.debian.org/debian

# chroot /opt/arm64
# apt-get install gcc
# exit

# chroot /opt/armhf
# apt-get install gcc
# exit

Running & testing

$ ./build.py

If everything goes well, it creates ./ouput which is the portable multi-arch shellcode.

To test that everything works, use the provided 'sc' utility:

On the local x86_64 machine
user@x86_64-box   $ ./sc_86     ./output
user@x86_64-box   $ ./sc_x86_64 ./output
... And in the chroots for arm/arm64
user@armhf-chroot $ ./sc_arm    ./output
user@arm64-chroot $ ./sc_arm_64 ./output

Credits

Thanks to feliam

https://github.com/feliam/mkShellcode

http://blog.binamuse.com/2013/01/about-shellcodes-in-c.html

The x86 / x86_64 loader code is taken from this project and the shellcode extraction technique is based upon his work aswell.

xarch_shellcode's People

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.