Skip to content

EntySec/libpawn

Repository files navigation

libpawn

Developer Language Forks Stars CodeFactor

C library that is intended for providing methods for executing and injecting code.

Features

  • Supports different ways of loading executable files in-memory.
  • Supports most common executable file formats: ELF, PE and Mach-O.
  • Lightweight and small library that can be ported to almost every single program.

Building libpawn

cmake -B build
cd build
make
sudo make install
Arch Support
x64 yes
aarch64 yes
armv5l yes
i486 yes
mips yes
powerpc yes
s390x yes
armv5b yes
mips64 yes
mipsel yes
powerpc64le yes

API usage

#include <pawn.h>

Mach-O

Execute main function from Mach-O bundle from buffer and pass argv and env as arguments.

int pawn_exec_bundle(usigned char *bundle, size_t size, char *argv[], char *env[]);

ELF

Execute ELF from buffer and pass argv and env to it.

int pawn_exec(unsigned char *elf, char *argv[], char *env[])

NOTE: This method does not work for statically linked targets since it uses dynamic interpreter as a part of ELF loading chain.

Write ELF to the file descriptor from buffer and execute it.

int pawn_exec_fd(unsigned char *elf, char *argv[], char *env[])

Examples