The Witchcraft Compiler Collection
WCC
 All Data Structures Files Functions Variables Typedefs Macros
Data Structures | Macros | Typedefs | Functions | Variables
wsh.h File Reference
#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
 

Macro Definition Documentation

#define _GNU_SOURCE

Definition at line 1 of file wsh.h.

#define BIND_FLAGS   RTLD_NOW

Definition at line 113 of file wsh.h.

#define DEFAULT_LEARN_FILE   "./learnwitch.log"

Definition at line 107 of file wsh.h.

#define default_poison   0x61

Definition at line 287 of file wsh.h.

#define DEFAULT_SCRIPT   "/usr/share/wcc/scripts/debug"

Definition at line 103 of file wsh.h.

#define DEFAULT_SCRIPT_INDEX   "/usr/share/wcc/scripts/INDEX"

Definition at line 104 of file wsh.h.

#define DMGL_ANSI   (1 << 1)

Definition at line 123 of file wsh.h.

#define DMGL_ARM   (1 << 11)

Definition at line 124 of file wsh.h.

#define DMGL_PARAMS   (1 << 0)

Definition at line 122 of file wsh.h.

#define ELF32_ST_BIND (   val)    (((unsigned char) (val)) >> 4)

Definition at line 142 of file wsh.h.

#define ELF32_ST_INFO (   bind,
  type 
)    (((bind) << 4) + ((type) & 0xf))

Definition at line 144 of file wsh.h.

#define ELF32_ST_TYPE (   val)    ((val) & 0xf)

Definition at line 143 of file wsh.h.

#define ELF64_ST_BIND (   val)    ELF32_ST_BIND (val)

Definition at line 146 of file wsh.h.

#define ELF64_ST_INFO (   bind,
  type 
)    ELF32_ST_INFO ((bind), (type))

Definition at line 148 of file wsh.h.

#define ELF64_ST_TYPE (   val)    ELF32_ST_TYPE (val)

Definition at line 147 of file wsh.h.

#define Elf_Dyn   Elf32_Dyn

Definition at line 133 of file wsh.h.

#define Elf_Ehdr   Elf32_Ehdr

Definition at line 134 of file wsh.h.

#define Elf_Phdr   Elf32_Phdr

Definition at line 135 of file wsh.h.

#define Elf_Shdr   Elf32_Shdr

Definition at line 136 of file wsh.h.

#define Elf_Sym   Elf32_Sym

Definition at line 137 of file wsh.h.

#define FAULT_EXEC   4

Definition at line 285 of file wsh.h.

#define FAULT_READ   1

Definition at line 283 of file wsh.h.

#define FAULT_WRITE   2

Definition at line 284 of file wsh.h.

#define HPERMSMAX   5

Definition at line 140 of file wsh.h.

#define LINES_MAX   50

Definition at line 165 of file wsh.h.

#define luaL_reg   luaL_Reg

Definition at line 279 of file wsh.h.

#define MAX_SIGNALS   2000000

Definition at line 109 of file wsh.h.

#define MIN_BIN_SIZE   10

Definition at line 281 of file wsh.h.

#define MY_CPU   1

Definition at line 111 of file wsh.h.

#define PROC_ASLR_PATH   "/proc/sys/kernel/randomize_va_space"

Definition at line 105 of file wsh.h.

#define read_arg (   arg,
 
)
Value:
{ \
if (lua_isnil(L, j)) { \
arg = 0; \
} else if (lua_isnumber(L, j)) { \
arg = (unsigned long) lua_tonumber(L, j); \
} else if (lua_isstring(L, j)) { \
arg = luaL_checkstring(L, j); \
} else if (lua_istable(L, j)) { \
} else if (lua_isfunction(L, j)) { \
arg = lua_tocfunction(L, j); \
} else if (lua_iscfunction(L, j)) { \
arg = lua_touserdata(L, j); \
} else if (lua_isuserdata(L, j)) { \
arg = lua_touserdata(L, j); \
} else { \
arg = 0; \
} \
}
LUA_API int() lua_isuserdata(lua_State *L, int idx)
LUA_API int() lua_isstring(lua_State *L, int idx)
#define lua_tonumber(L, i)
Definition: lua.h:341
LUA_API void *() lua_touserdata(lua_State *L, int idx)
LUA_API int() lua_isnumber(lua_State *L, int idx)
LUA_API lua_CFunction() lua_tocfunction(lua_State *L, int idx)
#define lua_isnil(L, n)
Definition: lua.h:355
LUA_API int() lua_iscfunction(lua_State *L, int idx)
#define lua_isfunction(L, n)
Definition: lua.h:352
#define lua_istable(L, n)
Definition: lua.h:353
#define luaL_checkstring(L, n)
Definition: lauxlib.h:116

Read argument number j

Definition at line 259 of file wsh.h.

#define read_arg1 (   arg1)
Value:
{ \
if (lua_isnil(L, 1)) { \
arg1 = 0; \
} else if (lua_isnumber(L, 1)) { \
arg1 = (unsigned long) lua_tonumber(L, 1); \
} else if (lua_isstring(L, 1)) { \
arg1 = luaL_checkstring(L, 1); \
} else if (lua_istable(L, 1)) { \
} else if (lua_isfunction(L, 1)) { \
arg1 = lua_tocfunction(L, 1); \
} else if (lua_iscfunction(L, 1)) { \
arg1 = lua_touserdata(L, 1); \
} else if (lua_isuserdata(L, 1)) { \
arg1 = lua_touserdata(L, 1); \
} else { \
arg1 = 0; \
} \
}
LUA_API int() lua_isuserdata(lua_State *L, int idx)
LUA_API int() lua_isstring(lua_State *L, int idx)
#define lua_tonumber(L, i)
Definition: lua.h:341
LUA_API void *() lua_touserdata(lua_State *L, int idx)
LUA_API int() lua_isnumber(lua_State *L, int idx)
LUA_API lua_CFunction() lua_tocfunction(lua_State *L, int idx)
#define lua_isnil(L, n)
Definition: lua.h:355
LUA_API int() lua_iscfunction(lua_State *L, int idx)
#define lua_isfunction(L, n)
Definition: lua.h:352
#define lua_istable(L, n)
Definition: lua.h:353
#define luaL_checkstring(L, n)
Definition: lauxlib.h:116

Read arg1

Definition at line 171 of file wsh.h.

#define read_arg2 (   arg2)
Value:
{ \
if (lua_isnil(L, 2)) { \
arg2 = 0; \
} else if (lua_isnumber(L, 2)) { \
arg2 = (unsigned long) lua_tonumber(L, 2); \
} else if (lua_isstring(L, 2)) { \
arg2 = luaL_checkstring(L, 2); \
} else if (lua_istable(L, 2)) { \
} else if (lua_isfunction(L, 2)) { \
arg2 = lua_tocfunction(L, 2); \
} else if (lua_iscfunction(L, 2)) { \
arg2 = lua_touserdata(L, 2); \
} else if (lua_isuserdata(L, 2)) { \
arg2 = lua_touserdata(L, 2); \
} else { \
arg2 = 0; \
} \
}
LUA_API int() lua_isuserdata(lua_State *L, int idx)
LUA_API int() lua_isstring(lua_State *L, int idx)
#define lua_tonumber(L, i)
Definition: lua.h:341
LUA_API void *() lua_touserdata(lua_State *L, int idx)
LUA_API int() lua_isnumber(lua_State *L, int idx)
LUA_API lua_CFunction() lua_tocfunction(lua_State *L, int idx)
#define lua_isnil(L, n)
Definition: lua.h:355
LUA_API int() lua_iscfunction(lua_State *L, int idx)
#define lua_isfunction(L, n)
Definition: lua.h:352
#define lua_istable(L, n)
Definition: lua.h:353
#define luaL_checkstring(L, n)
Definition: lauxlib.h:116

Read arg2

Definition at line 193 of file wsh.h.

#define read_arg3 (   arg3)
Value:
{ \
if (lua_isnil(L, 3)) { \
arg3 = 0; \
} else if (lua_isnumber(L, 3)) { \
arg3 = (unsigned long) lua_tonumber(L, 3); \
} else if (lua_isstring(L, 3)) { \
arg3 = luaL_checkstring(L, 3); \
} else if (lua_istable(L, 3)) { \
} else if (lua_isfunction(L, 3)) { \
arg3 = lua_tocfunction(L, 3); \
} else if (lua_iscfunction(L, 3)) { \
arg3 = lua_touserdata(L, 3); \
} else if (lua_isuserdata(L, 3)) { \
arg3 = lua_touserdata(L, 3); \
} else { \
arg3 = 0; \
} \
}
LUA_API int() lua_isuserdata(lua_State *L, int idx)
LUA_API int() lua_isstring(lua_State *L, int idx)
#define lua_tonumber(L, i)
Definition: lua.h:341
LUA_API void *() lua_touserdata(lua_State *L, int idx)
LUA_API int() lua_isnumber(lua_State *L, int idx)
LUA_API lua_CFunction() lua_tocfunction(lua_State *L, int idx)
#define lua_isnil(L, n)
Definition: lua.h:355
LUA_API int() lua_iscfunction(lua_State *L, int idx)
#define lua_isfunction(L, n)
Definition: lua.h:352
#define lua_istable(L, n)
Definition: lua.h:353
#define luaL_checkstring(L, n)
Definition: lauxlib.h:116

Read arg3

Definition at line 215 of file wsh.h.

#define read_arg4 (   arg4)
Value:
{ \
if (lua_isnil(L, 4)) { \
arg4 = 0; \
} else if (lua_isnumber(L, 4)) { \
arg4 = (unsigned long) lua_tonumber(L, 4); \
} else if (lua_isstring(L, 4)) { \
arg4 = luaL_checkstring(L, 4); \
} else if (lua_istable(L, 4)) { \
} else if (lua_isfunction(L, 4)) { \
arg4 = lua_tocfunction(L, 4); \
} else if (lua_iscfunction(L, 4)) { \
arg4 = lua_touserdata(L, 4); \
} else if (lua_isuserdata(L, 4)) { \
arg4 = lua_touserdata(L, 4); \
} else { \
arg4 = 0; \
} \
}
LUA_API int() lua_isuserdata(lua_State *L, int idx)
LUA_API int() lua_isstring(lua_State *L, int idx)
#define lua_tonumber(L, i)
Definition: lua.h:341
LUA_API void *() lua_touserdata(lua_State *L, int idx)
LUA_API int() lua_isnumber(lua_State *L, int idx)
LUA_API lua_CFunction() lua_tocfunction(lua_State *L, int idx)
#define lua_isnil(L, n)
Definition: lua.h:355
LUA_API int() lua_iscfunction(lua_State *L, int idx)
#define lua_isfunction(L, n)
Definition: lua.h:352
#define lua_istable(L, n)
Definition: lua.h:353
#define luaL_checkstring(L, n)
Definition: lauxlib.h:116

Read arg4

Definition at line 237 of file wsh.h.

#define SHELL_HISTORY_NAME   ".wsh_history"

Definition at line 278 of file wsh.h.

#define SKIP_BOTTOM   13

Definition at line 297 of file wsh.h.

#define SKIP_INIT   3

Backtrace parameters

Definition at line 296 of file wsh.h.

#define STB_GLOBAL   1

Definition at line 151 of file wsh.h.

#define STB_GNU_SECONDARY   11

Definition at line 154 of file wsh.h.

#define STB_GNU_UNIQUE   10

Definition at line 153 of file wsh.h.

#define STB_LOCAL   0

Definition at line 150 of file wsh.h.

#define STB_WEAK   2

Definition at line 152 of file wsh.h.

#define STT_COMMON   5

Definition at line 161 of file wsh.h.

#define STT_FILE   4

Definition at line 160 of file wsh.h.

#define STT_FUNC   2

Definition at line 158 of file wsh.h.

#define STT_NOTYPE   0

Definition at line 156 of file wsh.h.

#define STT_OBJECT   1

Definition at line 157 of file wsh.h.

#define STT_SECTION   3

Definition at line 159 of file wsh.h.

#define STT_TLS   6

Definition at line 162 of file wsh.h.

#define USE_LUA   1

Definition at line 71 of file wsh.h.

Typedef Documentation

typedef struct breakpoint_t breakpoint_t

Breakpoint structure

typedef struct eps_t eps_t
typedef struct preload_t preload_t

Libraries to be preloaded (before shell/script execution)

typedef struct range_t range_t

Memory ranges

typedef struct script_t script_t

Scripts to be executed

typedef struct sections_t sections_t

Representation of ELF Sections

typedef struct segments_t segments_t

Representation of ELF Segments

typedef struct symbols_t symbols_t

Representation of ELF Symbols

typedef struct tuple_t tuple_t
typedef struct wsh_t wsh_t

wsh context

Function Documentation

int add_symbol ( char *  symbol,
char *  libname,
char *  htype,
char *  hbind,
unsigned long  value,
unsigned int  size,
unsigned long int  addr 
)

Add a symbol to linked list

Definition at line 719 of file wsh.c.

int alloccharbuf ( lua_State L)

Buffer management subroutines

Definition at line 1590 of file wsh.c.

int bfmap ( lua_State L)

Bruteforce valid memory mapping ranges

Definition at line 100 of file wsh.c.

int breakpoint ( lua_State L)

Set a breakpoint

Make sure destination address is mapped

Change memory protections to RWX on destionation's page

Backup byte at destination

Write Breakpoint

Save breakpoint informations

Definition at line 4218 of file wsh.c.

int bsspolute ( lua_State L)

Pollute .bss sections

Definition at line 3712 of file wsh.c.

char* cplus_demangle ( const char *  mangled,
int  options 
)

Imported declarations prototypes

int disable_aslr ( void  )

Disable ASLR

Definition at line 455 of file wsh.c.

int disable_core ( lua_State L)

Disable core files generation

Definition at line 4351 of file wsh.c.

int do_loadlib ( char *  libname)

Forward prototypes declarations

Do load a shared binary into the address space

Definition at line 4581 of file wsh.c.

int empty_phdrs ( void  )

Empty linked list of segments

Definition at line 999 of file wsh.c.

int empty_shdrs ( void  )

Empty linked list of sections

Definition at line 1018 of file wsh.c.

int enable_aslr ( void  )

Enable ASLR

Definition at line 473 of file wsh.c.

int enable_core ( lua_State L)

Enable core files generation

Definition at line 4359 of file wsh.c.

int entrypoints ( lua_State L)

Display ELF Entry points

Definition at line 1469 of file wsh.c.

int execlib ( lua_State L)

Definition at line 2792 of file wsh.c.

int gencore ( lua_State L)

Generate a core file

Definition at line 4340 of file wsh.c.

int getcharbuf ( lua_State L)

Definition at line 1657 of file wsh.c.

int getsize ( lua_State L)
int grep ( lua_State L)

search a pattern over all sections mapped in memory

Definition at line 4069 of file wsh.c.

int grepptr ( lua_State L)

Search a given value in memory

grepptr(Pattern, patternlen, hexadumplen, nbytesbeforematch)

Definition at line 3979 of file wsh.c.

int headers ( lua_State L)

Generate headers

generate headers for imported objects

generate forward prototypes for imported functions

Definition at line 931 of file wsh.c.

int help ( lua_State L)

Display help

Definition at line 574 of file wsh.c.

void hexdump ( uint8_t *  data,
size_t  size,
size_t  colorstart,
size_t  color_len 
)

Simple hexdump routine

Definition at line 184 of file wsh.c.

int hollywood ( lua_State L)

Definition at line 3632 of file wsh.c.

int info ( lua_State L)

Display information on an object/memory address

Address is mapped

Search corresponding symbols

Search corresponding section

Search corresponding segment

Search corresponding symbols

Resolve symbol...

Definition at line 1495 of file wsh.c.

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

Definition at line 2087 of file wsh.c.

int loadbin ( lua_State L)

Load a binary into the address space

Definition at line 4054 of file wsh.c.

unsigned int ltrace ( void  )

Definition at line 328 of file wsh.c.

int man ( lua_State L)

Open a manual page

Definition at line 1478 of file wsh.c.

int map ( lua_State L)

Display mapped sections

Definition at line 3658 of file wsh.c.

int newarray ( lua_State L)
int phdrs ( lua_State L)

Display Program headers (ELF Segments)

Definition at line 859 of file wsh.c.

int print_functions ( lua_State L)

Display functions

Definition at line 1176 of file wsh.c.

int print_libs ( lua_State L)

Display mapped librairies, return a list of library names

Definition at line 1308 of file wsh.c.

int print_objects ( lua_State L)

Display objects (typically globals)

Definition at line 1255 of file wsh.c.

int print_phdrs ( void  )

Display program headers (ELF Segments)

Definition at line 1052 of file wsh.c.

int print_shdrs ( void  )

Display ELF sections

Definition at line 1344 of file wsh.c.

int print_symbols ( lua_State L)

Display symbols

Definition at line 1108 of file wsh.c.

int print_version ( void  )

Definition at line 3821 of file wcc.c.

int priv_memcpy ( lua_State L)

Our own version of memcpy callable from LUA

Definition at line 4154 of file wsh.c.

int priv_strcat ( lua_State L)

Our own version of strcat callable from LUA

Definition at line 4197 of file wsh.c.

int priv_strcpy ( lua_State L)

Our own version of strcpy callable from LUA

Definition at line 4176 of file wsh.c.

int procmap_lua ( void  )

Definition at line 2787 of file wsh.c.

int prototypes ( lua_State L)

Display learned prototypes

Read all the lines to learnt data structure

Sort learnt data structures

Definition at line 1885 of file wsh.c.

int ralloc ( lua_State L)

ralloc(unsigned int size, unsigned char poison); allocate 1 page set to 0x00, set size bytes to poison, remap the page R only

Definition at line 3755 of file wsh.c.

int rawmemaddr ( lua_State L)

int addr rawmemaddr(obj)

Return the address in memory of the object passed as argument. Or returns an address itself if an address is given as argument.

Definition at line 4833 of file wsh.c.

int rawmemread ( lua_State L)

string res rawmemread(addr, len)

Read len bytes at address addr and return them as a lua string.

Definition at line 4759 of file wsh.c.

int rawmemstr ( lua_State L)

Returns a string, from an address passed as argument.

Definition at line 4797 of file wsh.c.

int rawmemstrlen ( lua_State L)

int rawmemstrlen(addr) Returns the length of a string passed as argument

Definition at line 4845 of file wsh.c.

int rawmemusage ( lua_State L)

Display memory usage.

Definition at line 4811 of file wsh.c.

int rawmemwrite ( lua_State L)

int written rawmemwrite(addr, data, len)

Raw write to addr of len bytes of data returns number of bytes written.

Definition at line 4778 of file wsh.c.

int rdnum ( lua_State L)

Read a number (to a LUA number)

Definition at line 1642 of file wsh.c.

int rdstr ( lua_State L)

Read a string (to a LUA string)

Definition at line 1621 of file wsh.c.

int reload_elfs ( void  )

Reload linked lists from ELFs binaries

Definition at line 1441 of file wsh.c.

void rescan ( void  )

Rescan address space

Definition at line 2752 of file wsh.c.

void rtrace ( lua_State L)

Definition at line 3921 of file wsh.c.

void script ( char *  path)

Run a script

Definition at line 166 of file wsh.c.

void segment_add ( unsigned long int  addr,
unsigned long int  size,
char *  perms,
char *  fname,
char *  ptype,
int  flags 
)

Add a segment to linked list

Definition at line 769 of file wsh.c.

void set_align_flag ( void  )
inline

Definition at line 2904 of file wsh.c.

void set_branch_flag ( void  )
inline

Definition at line 2999 of file wsh.c.

void set_trace_flag ( void  )
inline

Definition at line 2931 of file wsh.c.

int setarray ( lua_State L)
int setcharbuf ( lua_State L)

Definition at line 1603 of file wsh.c.

int shdrs ( lua_State L)

Display section headers (ELF Sections)

Definition at line 1459 of file wsh.c.

char* sicode_strerror ( int  signal,
siginfo_t *  s 
)

Definition at line 3340 of file wsh.c.

char* signaltoname ( int  signal)

Definition at line 2878 of file wsh.c.

void singlebranch ( lua_State L)

Definition at line 3945 of file wsh.c.

void singlestep ( lua_State L)

Definition at line 3903 of file wsh.c.

void systrace ( lua_State L)

Definition at line 3916 of file wsh.c.

void traceunaligned ( lua_State L)

Resize a xallocated memory zone

Definition at line 3891 of file wsh.c.

void unrtrace ( lua_State L)

Definition at line 3931 of file wsh.c.

void unset_align_flag ( void  )
inline

Definition at line 2890 of file wsh.c.

void unset_branch_flag ( void  )
inline

Definition at line 3022 of file wsh.c.

void unset_trace_flag ( void  )
inline

Definition at line 2917 of file wsh.c.

void unsinglebranch ( lua_State L)

Definition at line 3967 of file wsh.c.

void unsinglestep ( lua_State L)

Definition at line 3909 of file wsh.c.

void unsystrace ( lua_State L)

Definition at line 3926 of file wsh.c.

void untraceunaligned ( lua_State L)

Definition at line 3897 of file wsh.c.

void unverbosetrace ( lua_State L)

Definition at line 3941 of file wsh.c.

int usage ( char *  name)

Definition at line 3795 of file wcc.c.

int verbose ( lua_State L)

Definition at line 3618 of file wsh.c.

void verbosetrace ( lua_State L)

Definition at line 3937 of file wsh.c.

int wsh_getopt ( wsh_t wsh1,
int  argc,
char **  argv 
)

Parse command line

Definition at line 4629 of file wsh.c.

int wsh_init ( void  )

Definition at line 4364 of file wsh.c.

int wsh_loadlibs ( void  )

Load all preload libraries

Definition at line 4608 of file wsh.c.

int wsh_run ( void  )

Run a lua shell/script

Run all the scripts specified in the command line

Run a lua shell

Definition at line 4475 of file wsh.c.

int xalloc ( lua_State L)

xalloc(unsigned int size, unsigned char poison, unsigned int perms); Allocate size bytes (% getpagesize())

The mapping auto-references itself, unless a poison byte is given

[page unmaped] [mapped][OURPTR, size] [page unmaped]

Definition at line 3807 of file wsh.c.

void xfree ( lua_State L)

Release a bloc allocated via xalloc()

Definition at line 3868 of file wsh.c.

Variable Documentation

char* __progname_full

Imported globals