40 default:
return "linux";
98 rz_list_foreach (
a->plugins,
iter,
h) {
140 const char *asmcpu =
NULL;
144 if (!strcmp(
arch,
"x86")) {
158 }
else if (!strcmp(
arch,
"arm")) {
170 }
else if (!strcmp(
arch,
"trace")) {
225 RZ_LOG_ERROR(
"Failure while parsing '%s'\n", fileSanitized);
258 if (!strcmp(
arg,
"close")) {
282 int outlen =
len * 2;
296 int outlen =
len * 2;
349 char *asm_name =
NULL;
354 for (asm_ = asm_list; *asm_; asm_ += 2) {
355 if (!strcmp(egg->
remit->
arch, asm_[0])) {
376 if (asmcode->
len > 0) {
384 bool ret =
code ? asmcode !=
NULL :
true;
398 if (
r !=
sizeof(
b) || !egg->
remit) {
406 eprintf(
"ERROR: elem too large.\n");
410 if (
r !=
sizeof(
b)) {
416 eprintf(
"ERROR: expected '}' at the end of the file. %d left\n", egg->
context);
456 #define RZ_EGG_FILL_TYPE_TRAP
457 #define RZ_EGG_FILL_TYPE_NOP
458 #define RZ_EGG_FILL_TYPE_CHAR
459 #define RZ_EGG_FILL_TYPE_SEQ
460 #define RZ_EGG_FILL_TYPE_SEQ
462 static inline char *
eon(
char *
n) {
463 while (*
n && (*
n >=
'0' && *
n <=
'9')) {
479 number = strtol(
p,
NULL, 10);
482 eprintf(
"Invalid padding length at %d\n", number);
490 case 'S': padding_byte = 0;
break;
492 case 'N': padding_byte = 0x90;
break;
494 case 'A': padding_byte =
'A';
break;
496 case 'T': padding_byte = 0xcc;
break;
498 eprintf(
"Invalid padding format (%c)\n", *
p);
515 if (
f >=
'a' &&
f <=
'z') {
546 eprintf(
"%s Shellcode has failed\n",
p->name);
615 eprintf(
"Error during patch\n");
619 eprintf(
"Cannot patch outside\n");
631 eprintf(
"Invalid debruijn pattern length.\n");
RZ_API void * rz_asm_code_free(RzAsmCode *acode)
static RzILOpEffect * cmp(cs_insn *insn, bool is_thumb)
RZ_API void rz_asm_free(RzAsm *a)
RZ_API bool rz_asm_set_big_endian(RzAsm *a, bool b)
RZ_API RzAsm * rz_asm_new(void)
RZ_DEPRECATE RZ_API int rz_asm_set_bits(RzAsm *a, int bits)
RZ_API bool rz_asm_set_syntax(RzAsm *a, int syntax)
RZ_API RzAsmCode * rz_asm_massemble(RzAsm *a, const char *assembly)
RZ_API bool rz_asm_use(RzAsm *a, const char *name)
Puts an Asm plugin in use and disables the previous one.
int bits(struct state *s, int need)
const lzma_allocator const uint8_t size_t uint8_t * out
#define RZ_EGG_STATIC_PLUGINS
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void static offset struct stat static buf void long static basep static whence static length const void static len key
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void static offset struct stat static buf void long static basep static whence static length const void static len static semflg const void static shmflg const struct timespec struct timespec static rem const char static group const void length
RZ_API int rz_egg_shellcode(RzEgg *egg, const char *name)
RZ_API int rz_egg_run_rop(RzEgg *egg)
static int rz_egg_append_bytes(RzEgg *egg, const ut8 *b, int len)
RZ_API void rz_egg_reset(RzEgg *egg)
RZ_API char * rz_egg_get_source(RzEgg *egg)
RZ_API char * rz_egg_to_string(RzEgg *egg)
RZ_API void rz_egg_append(RzEgg *egg, const char *src)
static int rz_egg_prepend_bytes(RzEgg *egg, const ut8 *b, int len)
static char * eon(char *n)
RZ_API void rz_egg_free(RzEgg *egg)
RZ_API void rz_egg_finalize(RzEgg *egg)
RZ_API RzEgg * rz_egg_new(void)
static int rz_egg_raw_prepend(RzEgg *egg, const ut8 *b, int len)
RZ_API bool rz_egg_patch_num(RzEgg *egg, int off, ut64 num, ut32 bits)
RZ_API bool rz_egg_load_file(RzEgg *egg, const char *file)
RZ_API char * rz_egg_option_get(RzEgg *egg, const char *key)
RZ_API int rz_egg_padding(RzEgg *egg, const char *pad)
RZ_API int rz_egg_run(RzEgg *egg)
RZ_API void rz_egg_syscall(RzEgg *egg, const char *arg,...)
RZ_API void rz_egg_fill(RzEgg *egg, int pos, int type, int argc, int length)
RZ_API int rz_egg_add(RzEgg *a, RzEggPlugin *foo)
RZ_API int rz_egg_patch(RzEgg *egg, int off, const ut8 *buf, int len)
RZ_API void rz_egg_pattern(RzEgg *egg, int size)
RZ_API bool rz_egg_assemble_asm(RzEgg *egg, char **asm_list)
static RzEggPlugin * egg_static_plugins[]
RZ_API void rz_egg_alloc(RzEgg *egg, int n)
RZ_API void rz_egg_label(RzEgg *egg, const char *name)
RZ_API void rz_egg_if(RzEgg *egg, const char *reg, char cmp, int v)
void egg_patch_free(void *p)
RZ_API void rz_egg_math(RzEgg *egg)
RZ_API char * rz_egg_get_assembly(RzEgg *egg)
RZ_API int rz_egg_encode(RzEgg *egg, const char *name)
RZ_API const char * rz_egg_os_as_string(int os)
RZ_API void rz_egg_printf(RzEgg *egg, const char *fmt,...)
RZ_API int rz_egg_compile(RzEgg *egg)
RZ_API RzBuffer * rz_egg_get_bin(RzEgg *egg)
RZ_API void rz_egg_option_set(RzEgg *egg, const char *key, const char *val)
RZ_API void rz_egg_load(RzEgg *egg, const char *code, int format)
RZ_API int rz_egg_include(RzEgg *egg, const char *file, int format)
RZ_API bool rz_egg_assemble(RzEgg *egg)
RZ_API bool rz_egg_setup(RzEgg *egg, const char *arch, int bits, int endian, const char *os)
RZ_API int rz_egg_raw(RzEgg *egg, const ut8 *b, int len)
RZ_API char * rz_egg_Cfile_parser(const char *file, const char *arch, const char *os, int bits)
RZ_API void rz_egg_lang_init(RzEgg *egg)
RZ_API int rz_egg_lang_parsechar(RzEgg *egg, char c)
RZ_API void rz_egg_lang_include_init(RzEgg *egg)
RZ_API void rz_egg_lang_free(RzEgg *egg)
RZ_API void Ht_() free(HtName_(Ht) *ht)
return memset(p, 0, total)
RZ_API RZ_OWN RzList * rz_list_newf(RzListFree f)
Returns a new initialized RzList pointer and sets the free method.
RZ_API RZ_OWN RzList * rz_list_new(void)
Returns a new initialized RzList pointer (free method is not initialized)
RZ_API RZ_BORROW RzListIter * rz_list_append(RZ_NONNULL RzList *list, void *data)
Appends at the end of the list a new element.
RZ_API void rz_list_free(RZ_NONNULL RzList *list)
Empties the list and frees the list pointer.
RZ_API void rz_list_purge(RZ_NONNULL RzList *list)
Empties the list without freeing the list pointer.
void * malloc(size_t size)
static static fork const void static count static fd const char const char static newpath char char char static envp time_t static t const char static mode static whence const char static dir time_t static t unsigned static seconds const char struct utimbuf static buf static inc static sig const char static mode static oldfd struct tms static buf static getgid static geteuid const char static filename static arg static mask struct ustat static ubuf static getppid static setsid static egid sigset_t static set struct timeval struct timezone static tz fd_set fd_set fd_set struct timeval static timeout const char char static bufsiz const char static swapflags void static offset const char static length static mode static who const char struct statfs static buf unsigned unsigned num
return strdup("=SP r13\n" "=LR r14\n" "=PC r15\n" "=A0 r0\n" "=A1 r1\n" "=A2 r2\n" "=A3 r3\n" "=ZF zf\n" "=SF nf\n" "=OF vf\n" "=CF cf\n" "=SN or0\n" "gpr lr .32 56 0\n" "gpr pc .32 60 0\n" "gpr cpsr .32 64 0 ____tfiae_________________qvczn\n" "gpr or0 .32 68 0\n" "gpr tf .1 64.5 0 thumb\n" "gpr ef .1 64.9 0 endian\n" "gpr jf .1 64.24 0 java\n" "gpr qf .1 64.27 0 sticky_overflow\n" "gpr vf .1 64.28 0 overflow\n" "gpr cf .1 64.29 0 carry\n" "gpr zf .1 64.30 0 zero\n" "gpr nf .1 64.31 0 negative\n" "gpr itc .4 64.10 0 if_then_count\n" "gpr gef .4 64.16 0 great_or_equal\n" "gpr r0 .32 0 0\n" "gpr r1 .32 4 0\n" "gpr r2 .32 8 0\n" "gpr r3 .32 12 0\n" "gpr r4 .32 16 0\n" "gpr r5 .32 20 0\n" "gpr r6 .32 24 0\n" "gpr r7 .32 28 0\n" "gpr r8 .32 32 0\n" "gpr r9 .32 36 0\n" "gpr r10 .32 40 0\n" "gpr r11 .32 44 0\n" "gpr r12 .32 48 0\n" "gpr r13 .32 52 0\n" "gpr r14 .32 56 0\n" "gpr r15 .32 60 0\n" "gpr r16 .32 64 0\n" "gpr r17 .32 68 0\n")
static void pad(RzStrBuf *sb, ut32 count)
#define rz_return_if_fail(expr)
#define rz_return_val_if_fail(expr, val)
RZ_API bool rz_buf_prepend_bytes(RZ_NONNULL RzBuffer *b, RZ_NONNULL const ut8 *buf, ut64 len)
Prepend an array of bytes to the buffer.
RZ_API bool rz_buf_append_bytes(RZ_NONNULL RzBuffer *b, RZ_NONNULL const ut8 *buf, ut64 len)
Append an array of bytes to the buffer.
RZ_API st64 rz_buf_seek(RZ_NONNULL RzBuffer *b, st64 addr, int whence)
Modify the current cursor position in the buffer.
RZ_API st64 rz_buf_write_at(RZ_NONNULL RzBuffer *b, ut64 addr, RZ_NONNULL const ut8 *buf, ut64 len)
Write len bytes of the buffer at the specified address.
RZ_API void rz_buf_free(RzBuffer *b)
Free all internal data hold by the buffer and the buffer.
RZ_API RZ_OWN RzBuffer * rz_buf_new_with_bytes(RZ_NULLABLE RZ_BORROW const ut8 *bytes, ut64 len)
Creates a new buffer with a bytes array.
RZ_API st64 rz_buf_read(RZ_NONNULL RzBuffer *b, RZ_NONNULL RZ_OUT ut8 *buf, ut64 len)
RZ_DEPRECATE RZ_API RZ_BORROW ut8 * rz_buf_data(RZ_NONNULL RzBuffer *b, RZ_NONNULL RZ_OUT ut64 *size)
Return a borrowed array of bytes representing the buffer data.
RZ_API ut64 rz_buf_size(RZ_NONNULL RzBuffer *b)
Return the size of the buffer.
RZ_API RZ_OWN char * rz_buf_to_string(RZ_NONNULL RzBuffer *b)
Stringify the buffer.
RZ_API RZ_OWN char * rz_debruijn_pattern(int size, int start, const char *charset)
Generate a cyclic pattern following the Debruijn pattern.
#define RZ_EGG_PLUGIN_SHELLCODE
#define RZ_EGG_OS_DEFAULT
#define RZ_EGG_OS_WATCHOS
#define RZ_EGG_OS_WINDOWS
#define RZ_EGG_PLUGIN_ENCODER
#define RZ_EGG_OS_FREEBSD
static void rz_write_ble(void *dst, ut64 val, bool big_endian, int size)
RZ_API RZ_OWN char * rz_file_slurp(const char *str, RZ_NULLABLE size_t *usz)
RZ_API bool rz_file_rm(const char *file)
RZ_API int rz_hex_bin2str(const ut8 *in, int len, char *out)
#define RZ_LOG_ERROR(fmtstr,...)
RZ_API ut64 rz_str_djb2_hash(const char *str)
RZ_API bool rz_str_endswith(RZ_NONNULL const char *str, RZ_NONNULL const char *needle)
Checks if a string ends with a specifc sequence of characters (case sensitive)
RZ_API void rz_str_sanitize(char *c)
RZ_API int rz_sys_run_rop(const ut8 *buf, int len)
RZ_API int rz_sys_run(const ut8 *buf, int len)
RZ_API const char * rz_sys_arch_str(int arch)
RZ_API Sdb * sdb_new(const char *path, const char *name, int lock)
RZ_API int sdb_set(Sdb *s, const char *key, const char *val, ut32 cas)
RZ_API char * sdb_get(Sdb *s, const char *key, ut32 *cas)
RZ_API bool sdb_free(Sdb *s)
char *(* syscall)(RzEgg *egg, int num)
struct rz_egg_emit_t * remit
RZ_API RzSyscall * rz_syscall_new(void)
Creates a new RzSyscall type.
RZ_API void rz_syscall_free(RzSyscall *s)
Frees an RzSyscall type.
RZ_API void rz_syscall_item_free(RzSyscallItem *si)
RZ_API int rz_syscall_get_num(RzSyscall *s, const char *str)
RZ_API RzSyscallItem * rz_syscall_get(RzSyscall *s, int num, int swi)
RZ_API bool rz_syscall_setup(RzSyscall *s, const char *arch, int bits, const char *cpu, const char *os)
ut64(WINAPI *w32_GetEnabledXStateFeatures)()