The Witchcraft Compiler Collection
WCC
|
#include <sys/prctl.h>
#include <setjmp.h>
#include <link.h>
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <getopt.h>
#include <dlfcn.h>
#include <string.h>
#include <unistd.h>
#include <limits.h>
#include <errno.h>
#include <stdbool.h>
#include <sys/wait.h>
#include <poll.h>
#include <stropts.h>
#include <signal.h>
#include <malloc.h>
#include <sys/mman.h>
#include <ucontext.h>
#include <ctype.h>
#include <execinfo.h>
#include <pthread.h>
#include <sys/resource.h>
#include <sys/ptrace.h>
#include <longjmp.h>
#include <lua.h>
#include <lauxlib.h>
#include <lualib.h>
#include <linenoise.h>
#include "helper.h"
#include <colors.h>
#include <config.h>
#include <utlist.h>
Go to the source code of this file.
Data Structures | |
struct | elfdata_t |
struct | range_t |
struct | breakpoint_t |
struct | preload_t |
struct | script_t |
struct | sections_t |
struct | segments_t |
struct | symbols_t |
struct | eps_t |
struct | wsh_t |
struct | tuple_t |
Macros | |
#define | _GNU_SOURCE |
#define | USE_LUA 1 |
#define | DEFAULT_SCRIPT "/usr/share/wcc/scripts/debug" |
#define | DEFAULT_SCRIPT_INDEX "/usr/share/wcc/scripts/INDEX" |
#define | PROC_ASLR_PATH "/proc/sys/kernel/randomize_va_space" |
#define | DEFAULT_LEARN_FILE "./learnwitch.log" |
#define | MAX_SIGNALS 2000000 |
#define | MY_CPU 1 |
#define | BIND_FLAGS RTLD_NOW |
#define | DMGL_PARAMS (1 << 0) |
#define | DMGL_ANSI (1 << 1) |
#define | DMGL_ARM (1 << 11) |
#define | Elf_Dyn Elf32_Dyn |
#define | Elf_Ehdr Elf32_Ehdr |
#define | Elf_Phdr Elf32_Phdr |
#define | Elf_Shdr Elf32_Shdr |
#define | Elf_Sym Elf32_Sym |
#define | HPERMSMAX 5 |
#define | ELF32_ST_BIND(val) (((unsigned char) (val)) >> 4) |
#define | ELF32_ST_TYPE(val) ((val) & 0xf) |
#define | ELF32_ST_INFO(bind, type) (((bind) << 4) + ((type) & 0xf)) |
#define | ELF64_ST_BIND(val) ELF32_ST_BIND (val) |
#define | ELF64_ST_TYPE(val) ELF32_ST_TYPE (val) |
#define | ELF64_ST_INFO(bind, type) ELF32_ST_INFO ((bind), (type)) |
#define | STB_LOCAL 0 |
#define | STB_GLOBAL 1 |
#define | STB_WEAK 2 |
#define | STB_GNU_UNIQUE 10 |
#define | STB_GNU_SECONDARY 11 |
#define | STT_NOTYPE 0 |
#define | STT_OBJECT 1 |
#define | STT_FUNC 2 |
#define | STT_SECTION 3 |
#define | STT_FILE 4 |
#define | STT_COMMON 5 |
#define | STT_TLS 6 |
#define | LINES_MAX 50 |
#define | read_arg1(arg1) |
#define | read_arg2(arg2) |
#define | read_arg3(arg3) |
#define | read_arg4(arg4) |
#define | read_arg(arg, j) |
#define | SHELL_HISTORY_NAME ".wsh_history" |
#define | luaL_reg luaL_Reg |
#define | MIN_BIN_SIZE 10 |
#define | FAULT_READ 1 |
#define | FAULT_WRITE 2 |
#define | FAULT_EXEC 4 |
#define | default_poison 0x61 |
#define | SKIP_INIT 3 |
#define | SKIP_BOTTOM 13 |
Typedefs | |
typedef struct range_t | range_t |
typedef struct breakpoint_t | breakpoint_t |
typedef struct preload_t | preload_t |
typedef struct script_t | script_t |
typedef struct sections_t | sections_t |
typedef struct segments_t | segments_t |
typedef struct symbols_t | symbols_t |
typedef struct eps_t | eps_t |
typedef struct wsh_t | wsh_t |
typedef struct tuple_t | tuple_t |
Functions | |
char * | cplus_demangle (const char *mangled, int options) |
int | do_loadlib (char *libname) |
int | empty_phdrs (void) |
int | empty_shdrs (void) |
int | getsize (lua_State *L) |
int | newarray (lua_State *L) |
int | print_functions (lua_State *L) |
int | print_libs (lua_State *L) |
int | print_objects (lua_State *L) |
int | print_phdrs (void) |
int | print_shdrs (void) |
int | entrypoints (lua_State *L) |
int | print_symbols (lua_State *L) |
int | print_version (void) |
int | setarray (lua_State *L) |
int | usage (char *name) |
void | set_align_flag (void) |
void | set_branch_flag (void) |
void | set_trace_flag (void) |
void | singlebranch (lua_State *L) |
void | singlestep (lua_State *L) |
void | traceunaligned (lua_State *L) |
void | unset_align_flag (void) |
void | unset_branch_flag (void) |
void | unset_trace_flag (void) |
void | unsinglebranch (lua_State *L) |
void | unsinglestep (lua_State *L) |
void | untraceunaligned (lua_State *L) |
void | unverbosetrace (lua_State *L) |
void | verbosetrace (lua_State *L) |
void | xfree (lua_State *L) |
void | systrace (lua_State *L) |
void | rtrace (lua_State *L) |
void | unsystrace (lua_State *L) |
void | unrtrace (lua_State *L) |
int | add_symbol (char *symbol, char *libname, char *htype, char *hbind, unsigned long value, unsigned int size, unsigned long int addr) |
void | segment_add (unsigned long int addr, unsigned long int size, char *perms, char *fname, char *ptype, int flags) |
int | alloccharbuf (lua_State *L) |
int | bfmap (lua_State *L) |
int | breakpoint (lua_State *L) |
int | execlib (lua_State *L) |
int | getcharbuf (lua_State *L) |
int | grep (lua_State *L) |
int | grepptr (lua_State *L) |
int | help (lua_State *L) |
int | hollywood (lua_State *L) |
int | info (lua_State *L) |
int | libcall (lua_State *L) |
int | loadbin (lua_State *L) |
int | man (lua_State *L) |
int | map (lua_State *L) |
int | phdrs (lua_State *L) |
int | priv_memcpy (lua_State *L) |
int | priv_strcat (lua_State *L) |
int | priv_strcpy (lua_State *L) |
int | rdnum (lua_State *L) |
int | rdstr (lua_State *L) |
int | setcharbuf (lua_State *L) |
int | shdrs (lua_State *L) |
int | verbose (lua_State *L) |
int | xalloc (lua_State *L) |
int | ralloc (lua_State *L) |
int | headers (lua_State *L) |
int | prototypes (lua_State *L) |
int | bsspolute (lua_State *L) |
unsigned int | ltrace (void) |
int | procmap_lua (void) |
void | rescan (void) |
void | hexdump (uint8_t *data, size_t size, size_t colorstart, size_t color_len) |
int | disable_aslr (void) |
int | enable_aslr (void) |
void | script (char *path) |
int | enable_core (lua_State *L) |
int | disable_core (lua_State *L) |
int | gencore (lua_State *L) |
char * | signaltoname (int signal) |
char * | sicode_strerror (int signal, siginfo_t *s) |
int | rawmemread (lua_State *L) |
int | rawmemwrite (lua_State *L) |
int | rawmemstr (lua_State *L) |
int | rawmemusage (lua_State *L) |
int | rawmemaddr (lua_State *L) |
int | rawmemstrlen (lua_State *L) |
int | wsh_init (void) |
int | wsh_getopt (wsh_t *wsh1, int argc, char **argv) |
int | wsh_loadlibs (void) |
int | reload_elfs (void) |
int | wsh_run (void) |
Variables | |
char * | __progname_full |
#define ELF32_ST_INFO | ( | bind, | |
type | |||
) | (((bind) << 4) + ((type) & 0xf)) |
#define ELF64_ST_BIND | ( | val | ) | ELF32_ST_BIND (val) |
#define ELF64_ST_INFO | ( | bind, | |
type | |||
) | ELF32_ST_INFO ((bind), (type)) |
#define ELF64_ST_TYPE | ( | val | ) | ELF32_ST_TYPE (val) |
#define read_arg | ( | arg, | |
j | |||
) |
Read argument number j
#define read_arg1 | ( | arg1 | ) |
Read arg1
#define read_arg2 | ( | arg2 | ) |
Read arg2
#define read_arg3 | ( | arg3 | ) |
Read arg3
#define read_arg4 | ( | arg4 | ) |
Read arg4
typedef struct breakpoint_t breakpoint_t |
Breakpoint structure
typedef struct sections_t sections_t |
Representation of ELF Sections
typedef struct segments_t segments_t |
Representation of ELF Segments
int add_symbol | ( | char * | symbol, |
char * | libname, | ||
char * | htype, | ||
char * | hbind, | ||
unsigned long | value, | ||
unsigned int | size, | ||
unsigned long int | addr | ||
) |
int alloccharbuf | ( | lua_State * | L | ) |
int bfmap | ( | lua_State * | L | ) |
int breakpoint | ( | lua_State * | L | ) |
char* cplus_demangle | ( | const char * | mangled, |
int | options | ||
) |
Imported declarations prototypes
int disable_core | ( | lua_State * | L | ) |
int do_loadlib | ( | char * | libname | ) |
int enable_core | ( | lua_State * | L | ) |
int getsize | ( | lua_State * | L | ) |
int grep | ( | lua_State * | L | ) |
int grepptr | ( | lua_State * | L | ) |
int headers | ( | lua_State * | L | ) |
void hexdump | ( | uint8_t * | data, |
size_t | size, | ||
size_t | colorstart, | ||
size_t | color_len | ||
) |
int info | ( | lua_State * | L | ) |
int libcall | ( | lua_State * | L | ) |
Main wrapper around a library call. This function returns 9 values: ret (returned by library call), errno, firstsignal, total number of signals, firstsicode, firsterrno, faultaddr, reason, context
Handle (reverse-) system calls tracing
Make the library call
Analyse return value
Learn prototypes
Create output execution context table
Push errno to lua table
Push strerror(errno) to lua table
Push first signal
Push first signal name
Push total of signals emmited during this libcall
Push first errno
Push first sicode
Push first sicode name
Address of last caller in backtrace
Push fault address
Push reason
Push mode
Push errctx
Push pointer to ucontext
Push arguments as a new table
Push number of non NULL arguments
Push retval
Push libcall/libname
Invoke store running function on context
int loadbin | ( | lua_State * | L | ) |
int newarray | ( | lua_State * | L | ) |
int phdrs | ( | lua_State * | L | ) |
int print_libs | ( | lua_State * | L | ) |
int print_objects | ( | lua_State * | L | ) |
int print_phdrs | ( | void | ) |
int priv_memcpy | ( | lua_State * | L | ) |
int priv_strcat | ( | lua_State * | L | ) |
int priv_strcpy | ( | lua_State * | L | ) |
int prototypes | ( | lua_State * | L | ) |
int ralloc | ( | lua_State * | L | ) |
int rawmemaddr | ( | lua_State * | L | ) |
int rawmemread | ( | lua_State * | L | ) |
int rawmemstr | ( | lua_State * | L | ) |
int rawmemstrlen | ( | lua_State * | L | ) |
int rawmemwrite | ( | lua_State * | L | ) |
int reload_elfs | ( | void | ) |
void segment_add | ( | unsigned long int | addr, |
unsigned long int | size, | ||
char * | perms, | ||
char * | fname, | ||
char * | ptype, | ||
int | flags | ||
) |
int setarray | ( | lua_State * | L | ) |
int shdrs | ( | lua_State * | L | ) |
void traceunaligned | ( | lua_State * | L | ) |
int wsh_getopt | ( | wsh_t * | wsh1, |
int | argc, | ||
char ** | argv | ||
) |
int wsh_run | ( | void | ) |
int xalloc | ( | lua_State * | L | ) |
void xfree | ( | lua_State * | L | ) |
char* __progname_full |
Imported globals