The Witchcraft Compiler Collection
WCC
|
#include <libwitch/wsh.h>
#include <libwitch/wsh_functions.h>
#include <libwitch/sigs.h>
#include <uthash.h>
Go to the source code of this file.
Data Structures | |
struct | help_t |
struct | learn_key_t |
struct | learn_t |
Macros | |
#define | REG_RIP 16 |
#define | Elf_Ehdr Elf32_Ehdr |
#define | Elf_Shdr Elf32_Shdr |
#define | Elf_Sym Elf32_Sym |
#define | Elf_Addr Elf32_Addr |
#define | Elf_Sword Elf64_Sword |
#define | Elf_Section Elf32_Half |
#define | ELF_ST_BIND ELF32_ST_BIND |
#define | ELF_ST_TYPE ELF32_ST_TYPE |
#define | Elf_Rel Elf32_Rel |
#define | Elf_Rela Elf32_Rela |
#define | ELF_R_SYM ELF32_R_SYM |
#define | ELF_R_TYPE ELF32_R_TYPE |
#define | ELF_R_INFO ELF32_R_INFO |
#define | Elf_Phdr Elf32_Phdr |
#define | Elf_Xword Elf32_Xword |
#define | Elf_Word Elf32_Word |
#define | Elf_Off Elf32_Off |
#define | ELFCLASS ELFCLASS32 |
#define | ELFMACHINE EM_386 |
#define | CS_MODE CS_MODE_32 |
#define | RELOC_MODE RELOC_X86_32 |
Typedefs | |
typedef struct help_t | help_t |
typedef struct learn_key_t | learn_key_t |
typedef struct learn_t | learn_t |
Functions | |
int | bfmap (lua_State *L) |
int | ptoh (int perms, char hperms[]) |
void | info_function (void *addr) |
void | fatal_error (lua_State *L, char *msg) |
void | script (char *path) |
void | hexdump (uint8_t *data, size_t size, size_t colorstart, size_t color_len) |
char * | symbol_tobind (int n) |
char * | symbol_totype (int n) |
unsigned int | ltrace (void) |
int | scan_symbol (char *symbol, char *libname) |
void | completion (const char *buf, linenoiseCompletions *lc) |
int | disable_aslr (void) |
int | enable_aslr (void) |
int | detailed_help (char *name) |
int | help (lua_State *L) |
char * | decode_flags (unsigned int flags) |
char * | decode_type (unsigned int type) |
int | phdr_callback (struct dl_phdr_info *info, size_t size, void *data) |
int | add_symbol (char *symbol, char *libname, char *htype, char *hbind, unsigned long value, unsigned int size, unsigned long int addr) |
void | section_add (unsigned long int addr, unsigned long int size, char *libname, char *name, char *perms, int flags) |
void | segment_add (unsigned long int addr, unsigned long int size, char *perms, char *fname, char *ptype, int flags) |
void | entry_point_add (unsigned long int addr, char *fname) |
void | scan_section (Elf_Shdr *shdr, char *strTab, int shnum, char *fname, unsigned long int baseaddr) |
int | scan_sections (char *fname, unsigned long int baseaddr) |
int | shdr_callback (struct dl_phdr_info *info, size_t size, void *data) |
int | phdrs (lua_State *L) |
sections_t * | section_from_addr (unsigned long int addr) |
segments_t * | segment_from_addr (unsigned long int addr) |
sections_t * | symbol_from_addr (unsigned long int addr) |
sections_t * | symbol_from_name (char *fname) |
int | headers (lua_State *L) |
int | empty_symbols (void) |
int | empty_phdrs (void) |
int | empty_shdrs (void) |
int | empty_eps (void) |
int | print_phdrs (void) |
int | print_symbols (lua_State *L) |
int | print_functions (lua_State *L) |
int | print_objects (lua_State *L) |
int | print_libs (lua_State *L) |
int | print_shdrs (void) |
int | print_eps (void) |
int | shdr_cmp (sections_t *a, sections_t *b) |
int | phdr_cmp (segments_t *a, segments_t *b) |
int | reload_elfs (void) |
int | shdrs (lua_State *L) |
int | entrypoints (lua_State *L) |
int | man (lua_State *L) |
int | info (lua_State *L) |
int | alloccharbuf (lua_State *L) |
int | setcharbuf (lua_State *L) |
int | rdstr (lua_State *L) |
int | rdnum (lua_State *L) |
int | getcharbuf (lua_State *L) |
int | run_shell (lua_State *L) |
int | learn_proto (unsigned long *arg, unsigned long int faultaddr, int reason) |
int | sort_learnt (learn_t *a, learn_t *b) |
int | prototypes (lua_State *L) |
int | libcall (lua_State *L) |
void | scan_syms (char *dynstr, Elf_Sym *sym, unsigned long int sz, char *libname) |
void | parse_dyn (struct link_map *map) |
void | parse_link_map_dyn (struct link_map *map) |
void | rescan (void) |
int | print_procmap (unsigned int pid) |
int | procmap_lua (void) |
int | execlib (lua_State *L) |
int | traceback (lua_State *L) |
void | print_backtrace (void) |
char * | sicodetoname (int code) |
char * | signaltoname (int signal) |
void | unset_align_flag (void) |
void | set_align_flag (void) |
void | unset_trace_flag (void) |
void | set_trace_flag (void) |
void | affinity (int procnum) |
void | btr_enable (int procnum) |
void | btr_disable (int procnum) |
void | set_branch_flag (void) |
void | unset_branch_flag (void) |
void | bushandler (int signal, siginfo_t *s, void *ptr) |
void | alarmhandler (int signal, siginfo_t *s, void *u) |
void | inthandler (int signal, siginfo_t *s, void *u) |
int | mk_backtrace (void) |
void | restore_exit (void) |
void | exit (int status) |
void | _exit (int status) |
void | exit_group (int status) |
int | printarg (unsigned long int val) |
void | traphandler (int signal, siginfo_t *s, void *ptr) |
char * | sicode_strerror (int signal, siginfo_t *s) |
void | sighandler (int signal, siginfo_t *s, void *ptr) |
int | set_sighandlers (void) |
int | test_stdin (void) |
int | verbose (lua_State *L) |
int | hollywood (lua_State *L) |
int | map (lua_State *L) |
int | bsspolute (lua_State *L) |
int | ralloc (lua_State *L) |
int | xalloc (lua_State *L) |
void | xfree (lua_State *L) |
void | traceunaligned (lua_State *L) |
void | untraceunaligned (lua_State *L) |
void | singlestep (lua_State *L) |
void | unsinglestep (lua_State *L) |
void | systrace (lua_State *L) |
void | rtrace (lua_State *L) |
void | unsystrace (lua_State *L) |
void | unrtrace (lua_State *L) |
void | verbosetrace (lua_State *L) |
void | unverbosetrace (lua_State *L) |
void | singlebranch (lua_State *L) |
void | unsinglebranch (lua_State *L) |
int | grepptr (lua_State *L) |
int | loadbin (lua_State *L) |
int | grep (lua_State *L) |
int | priv_memcpy (lua_State *L) |
int | priv_strcpy (lua_State *L) |
int | priv_strcat (lua_State *L) |
int | breakpoint (lua_State *L) |
void | declare_func (void *addr, char *name) |
void | declare_num (int val, char *name) |
void | declare_internals (void) |
struct link_map * | loadlibrary (char *libname) |
int | set_alloc_opt (void) |
int | gencore (lua_State *L) |
int | disable_core (lua_State *L) |
int | enable_core (lua_State *L) |
int | wsh_init (void) |
int | lua_strerror (int err) |
int | run_script (char *name) |
unsigned int | read_elf_sig (char *fname, struct stat *sb) |
int | wsh_run (void) |
int | add_script_arguments (int argc, char **argv, unsigned int i) |
int | add_script_exec (char *name) |
int | add_binary_preload (char *name) |
int | do_loadlib (char *libname) |
int | wsh_loadlibs (void) |
int | wsh_getopt (wsh_t *wsh1, int argc, char **argv) |
int | wsh_print_version (void) |
int | wsh_usage (char *name) |
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) |
Variables | |
wsh_t * | wsh |
help_t | cmdhelp [] |
help_t | fcnhelp [] |
learn_t * | protorecords = NULL |
#define ELF_ST_BIND ELF32_ST_BIND |
#define ELF_ST_TYPE ELF32_ST_TYPE |
#define REG_RIP 16 |
Witchcraft Compiler Collection
Author: Jonathan Brossard - endra zine @gmai l.co m
The MIT License (MIT) Copyright (c) 2016 Jonathan Brossard
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#define RELOC_MODE RELOC_X86_32 |
typedef struct learn_key_t learn_key_t |
int add_binary_preload | ( | char * | name | ) |
int add_script_arguments | ( | int | argc, |
char ** | argv, | ||
unsigned int | i | ||
) |
int add_script_exec | ( | char * | name | ) |
int add_symbol | ( | char * | symbol, |
char * | libname, | ||
char * | htype, | ||
char * | hbind, | ||
unsigned long | value, | ||
unsigned int | size, | ||
unsigned long int | addr | ||
) |
void affinity | ( | int | procnum | ) |
int alloccharbuf | ( | lua_State * | L | ) |
int bfmap | ( | lua_State * | L | ) |
int breakpoint | ( | lua_State * | L | ) |
void bushandler | ( | int | signal, |
siginfo_t * | s, | ||
void * | ptr | ||
) |
void completion | ( | const char * | buf, |
linenoiseCompletions * | lc | ||
) |
void declare_internals | ( | void | ) |
int detailed_help | ( | char * | name | ) |
int disable_core | ( | lua_State * | L | ) |
int do_loadlib | ( | char * | libname | ) |
int enable_core | ( | lua_State * | L | ) |
void entry_point_add | ( | unsigned long int | addr, |
char * | fname | ||
) |
void fatal_error | ( | lua_State * | L, |
char * | msg | ||
) |
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 | ) |
void info_function | ( | void * | addr | ) |
int learn_proto | ( | unsigned long * | arg, |
unsigned long int | faultaddr, | ||
int | reason | ||
) |
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 | ) |
void parse_dyn | ( | struct link_map * | map | ) |
int phdr_callback | ( | struct dl_phdr_info * | info, |
size_t | size, | ||
void * | data | ||
) |
int phdr_cmp | ( | segments_t * | a, |
segments_t * | b | ||
) |
int phdrs | ( | lua_State * | L | ) |
int print_libs | ( | lua_State * | L | ) |
int print_objects | ( | lua_State * | L | ) |
int print_phdrs | ( | void | ) |
int print_procmap | ( | unsigned int | pid | ) |
int priv_memcpy | ( | lua_State * | L | ) |
int priv_strcat | ( | lua_State * | L | ) |
int priv_strcpy | ( | lua_State * | L | ) |
int prototypes | ( | lua_State * | L | ) |
int ptoh | ( | int | perms, |
char | hperms[] | ||
) |
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 | ) |
unsigned int read_elf_sig | ( | char * | fname, |
struct stat * | sb | ||
) |
int reload_elfs | ( | void | ) |
void restore_exit | ( | void | ) |
int run_shell | ( | lua_State * | L | ) |
void scan_section | ( | Elf_Shdr * | shdr, |
char * | strTab, | ||
int | shnum, | ||
char * | fname, | ||
unsigned long int | baseaddr | ||
) |
int scan_sections | ( | char * | fname, |
unsigned long int | baseaddr | ||
) |
int scan_symbol | ( | char * | symbol, |
char * | libname | ||
) |
void scan_syms | ( | char * | dynstr, |
Elf_Sym * | sym, | ||
unsigned long int | sz, | ||
char * | libname | ||
) |
void section_add | ( | unsigned long int | addr, |
unsigned long int | size, | ||
char * | libname, | ||
char * | name, | ||
char * | perms, | ||
int | flags | ||
) |
sections_t* section_from_addr | ( | unsigned long int | addr | ) |
void segment_add | ( | unsigned long int | addr, |
unsigned long int | size, | ||
char * | perms, | ||
char * | fname, | ||
char * | ptype, | ||
int | flags | ||
) |
segments_t* segment_from_addr | ( | unsigned long int | addr | ) |
int shdr_callback | ( | struct dl_phdr_info * | info, |
size_t | size, | ||
void * | data | ||
) |
int shdr_cmp | ( | sections_t * | a, |
sections_t * | b | ||
) |
int shdrs | ( | lua_State * | L | ) |
void sighandler | ( | int | signal, |
siginfo_t * | s, | ||
void * | ptr | ||
) |
sections_t* symbol_from_addr | ( | unsigned long int | addr | ) |
sections_t* symbol_from_name | ( | char * | fname | ) |
char* symbol_tobind | ( | int | n | ) |
char* symbol_totype | ( | int | n | ) |
int test_stdin | ( | void | ) |
void traceunaligned | ( | lua_State * | L | ) |
void traphandler | ( | int | signal, |
siginfo_t * | s, | ||
void * | ptr | ||
) |
int wsh_getopt | ( | wsh_t * | wsh1, |
int | argc, | ||
char ** | argv | ||
) |
int wsh_run | ( | void | ) |
int xalloc | ( | lua_State * | L | ) |
void xfree | ( | lua_State * | L | ) |
help_t cmdhelp[] |
help_t fcnhelp[] |
wsh_t* wsh |
Main wsh context
Witchcraft Compiler Collection
Author: Jonathan Brossard - endra zine @gmai l.co m
The MIT License (MIT) Copyright (c) 2016 Jonathan Brossard
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Main wsh context