Better use of the R_SOCKET_PROTO_DEFAULT and add _NONE (#17644)

* Better use of the R_SOCKET_PROTO_DEFAULT and add _NONE ##http

* Fix regressions in: r2 -C and =+ ##r2pipe

Introduced in 04edfa82c1

* Implement sleep command ##shell

* Add tests for the webserver and remoting

* Implement daemon directive in rarun2, fix http test ##rarun2

* Fix socket timeout on Windows (patch by @GustavoLCR) ##socket

* Missing http.root is not a reason to not start the webserver ##http

* Fix r2 -C, =!=0, replace curl with r2 in the webserver test ##http

* Honor anal.in/from/to in aae, optimize db/formats/mach0/thumb ##anal

* Bug fixes and performance improvements

Co-authored-by: pancake <pancake@nopcode.org>
This commit is contained in:
pancake 2020-09-25 13:51:23 +02:00 committed by GitHub
parent 83d3e7bf18
commit 62c2128b6f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
27 changed files with 352 additions and 131 deletions

View file

@ -3466,7 +3466,9 @@ R_API int r_core_config_init(RCore *core) {
SETPREF ("http.index", "index.html", "Main html file to check in directory");
SETPREF ("http.bind", "localhost", "Server address");
SETPREF ("http.homeroot", R_JOIN_2_PATHS ("~", R2_HOME_WWWROOT), "http home root directory");
#if __ANDROID__
#if __WINDOWS__
SETPREF ("http.root", "www", "http root directory");
#elif __ANDROID__
SETPREF ("http.root", "/data/data/org.radare.radare2installer/www", "http root directory");
#else
SETPREF ("http.root", R2_WWWROOT, "http root directory");

View file

@ -792,10 +792,11 @@ static int cmd_rap(void *data, const char *input) {
eprintf ("TODO: list connections in json\n");
break;
case '!': // "=!"
if (input[1] == '=') {
// swap core->cmdremote = core->cmdremote? 0: 1;
core->cmdremote = input[2]? 1: 0;
r_cons_println (r_str_bool (core->cmdremote));
if (input[1] == 'q') {
R_FREE (core->cmdremote);
} else if (input[1] == '=') { // =!=0 or =!= for iosystem
R_FREE (core->cmdremote);
core->cmdremote = r_str_trim_dup (input + 2);
} else {
char *res = r_io_system (core->io, input + 1);
if (res) {
@ -2240,8 +2241,7 @@ static int cmd_system(void *data, const char *input) {
r_cons_printf ("Usage: !=[!] - enable/disable remote commands\n");
} else {
if (!r_sandbox_enable (0)) {
core->cmdremote = input[1]? 1: 0;
r_cons_println (r_str_bool (core->cmdremote));
R_FREE (core->cmdremote);
}
}
break;
@ -6744,11 +6744,23 @@ R_API int r_core_cmd(RCore *core, const char *cstr, int log) {
}
}
if (core->cmdremote) {
if (*cstr != '=' && *cstr != 'q' && strncmp (cstr, "!=", 2)) {
char *res = r_io_system (core->io, cstr);
if (res) {
r_cons_printf ("%s\n", res);
free (res);
if (*cstr == 'q') {
R_FREE (core->cmdremote);
goto beach; // false
} else if (*cstr != '=' && strncmp (cstr, "!=", 2)) {
if (core->cmdremote[0]) {
char *s = r_str_newf ("%s %s", core->cmdremote, cstr);
r_core_rtr_cmd (core, s);
free (s);
} else {
char *res = r_io_system (core->io, cstr);
if (res) {
r_cons_printf ("%s\n", res);
free (res);
}
}
if (log) {
r_line_hist_add (cstr);
}
goto beach; // false
}

View file

@ -9741,11 +9741,28 @@ static int cmd_anal_all(RCore *core, const char *input) {
if (!list) {
break;
}
r_list_foreach (list, iter, map) {
r_core_seek (core, map->itv.addr, true);
r_core_anal_esil (core, "$SS", NULL);
if (!strcmp ("range", r_config_get (core->config, "anal.in"))) {
ut64 from = r_config_get_i (core->config, "anal.from");
ut64 to = r_config_get_i (core->config, "anal.to");
if (to > from) {
char *len = r_str_newf (" 0x%"PFMT64x, to - from);
r_core_seek (core, from, true);
r_core_anal_esil (core, len, NULL);
free (len);
} else {
eprintf ("Assert: anal.from > anal.to\n");
}
} else {
r_list_foreach (list, iter, map) {
if (map->perm & R_PERM_X) {
char *ss = r_str_newf (" 0x%"PFMT64x, map->itv.size);
r_core_seek (core, map->itv.addr, true);
r_core_anal_esil (core, ss, NULL);
free (ss);
}
}
r_list_free (list);
}
r_list_free (list);
r_core_seek (core, at, true);
}
break;

View file

@ -52,6 +52,7 @@ static const char *help_msg_sl[] = {
"sl", "[+-][line]", "Seek to relative line",
"slc", "", "Clear line cache",
"sll", "", "Show total number of lines",
"sleep", " [seconds]", "Sleep for an specific amount of time",
NULL
};
@ -751,6 +752,18 @@ static int cmd_seek(void *data, const char *input) {
{
int sl_arg = r_num_math (core->num, input + 1);
switch (input[1]) {
case 'e': // "sleep"
{
const char *arg = strchr (input, ' ');
if (arg) {
void *bed = r_cons_sleep_begin ();
r_sys_sleep (atoi (arg + 1));
r_cons_sleep_end (bed);
} else {
eprintf ("Usage: sleep [seconds]\n");
}
}
break;
case '\0': // "sl"
if (!core->print->lines_cache) {
__init_seek_line (core);

View file

@ -60,7 +60,7 @@ static int __core_patch_bracket(RCore *core, const char *str, ut64 *noff) {
return 0;
}
for (;*p;) {
if (*p=='\n') {
if (*p == '\n') {
*p++ = 0;
} else {
p++;

View file

@ -1,4 +1,4 @@
/* radare - Copyright 2009-2019 - pancake, nibble */
/* radare - Copyright 2009-2020 - pancake, nibble */
#include "r_core.h"
#include "r_socket.h"
@ -194,7 +194,7 @@ R_API int r_core_rtr_http_stop(RCore *u) {
return 0;
}
static char *rtr_dir_files (const char *path) {
static char *rtr_dir_files(const char *path) {
char *ptr = strdup ("<html><body>\n");
const char *file;
RListIter *iter;
@ -213,13 +213,13 @@ static char *rtr_dir_files (const char *path) {
}
#if __UNIX__
static void dietime (int sig) {
static void dietime(int sig) {
eprintf ("It's Die Time!\n");
exit (0);
}
#endif
static void activateDieTime (RCore *core) {
static void activateDieTime(RCore *core) {
int dt = r_config_get_i (core->config, "http.dietime");
if (dt > 0) {
#if __UNIX__
@ -293,7 +293,7 @@ static int write_big_reg(char *buf, ut64 sz, const utX *val, int regsize, bool b
}
}
static int swap_big_regs (char *dest, ut64 sz, const char *src, int regsz) {
static int swap_big_regs(char *dest, ut64 sz, const char *src, int regsz) {
utX val;
char sdup[128] = {0};
if (!src || !src[0] || !src[1]) {
@ -799,7 +799,8 @@ R_API void r_core_rtr_add(RCore *core, const char *_input) {
return;
}
core->num->value = 0;
eprintf ("Connected to: 'http://%s'\n", host);
// eprintf ("Connected to: 'http://%s:%s'\n", host, port);
free (str);
}
break;
case RTR_PROTOCOL_RAP:
@ -887,39 +888,6 @@ R_API void r_core_rtr_remove(RCore *core, const char *input) {
R_API void r_core_rtr_session(RCore *core, const char *input) {
__rtr_shell (core, atoi (input));
return;
char prompt[64], buf[1024];
int fd;
prompt[0] = 0;
if (IS_DIGIT (input[0])) {
fd = r_num_math (core->num, input);
for (rtr_n = 0; rtr_host[rtr_n].fd && rtr_host[rtr_n].fd->fd != fd && rtr_n < RTR_MAX_HOSTS - 1; rtr_n++) {
;
}
}
while (!r_cons_is_breaked ()) {
if (rtr_host[rtr_n].fd) {
snprintf (prompt, sizeof (prompt),
"fd:%d> ", (int)(size_t)rtr_host[rtr_n].fd->fd);
}
free (r_line_singleton ()->prompt);
r_line_singleton ()->prompt = strdup (prompt);
if (r_cons_fgets (buf, sizeof (buf), 0, NULL) < 1) {
break;
}
if (!*buf || *buf == 'q') {
break;
}
if (*buf == 'V') {
eprintf ("Visual mode not supported\n");
continue;
}
r_core_rtr_cmd (core, buf);
r_cons_flush ();
}
}
static bool r_core_rtr_rap_run(RCore *core, const char *input) {
@ -942,7 +910,7 @@ static bool r_core_rtr_rap_run(RCore *core, const char *input) {
// r_core_cmdf (core, "o rap://%s", input);
}
static RThreadFunctionRet r_core_rtr_rap_thread (RThread *th) {
static RThreadFunctionRet r_core_rtr_rap_thread(RThread *th) {
if (!th) {
return false;
}
@ -1005,7 +973,7 @@ R_API void r_core_rtr_cmd(RCore *core, const char *input) {
cmd = input;
}
if (!rtr_host[rtr_n].fd){
if (!rtr_host[rtr_n].fd) {
eprintf ("Error: Unknown host\n");
core->num->value = 1; // fail
return;
@ -1054,7 +1022,7 @@ R_API void r_core_rtr_cmd(RCore *core, const char *input) {
}
core->num->value = 0;
str[len] = 0;
r_cons_println (str);
r_cons_print (str);
free ((void *)str);
free ((void *)uri);
return;

View file

@ -23,10 +23,8 @@ static int r_core_rtr_http_run(RCore *core, int launch, int browse, const char *
if (!r_file_is_directory (root)) {
if (!r_file_is_directory (homeroot)) {
eprintf ("Cannot find http.root (%s) or http.homeroot (%s)\n", root, homeroot);
return false;
eprintf ("Cannot find http.root or http.homeroot\n");
}
return false;
}
if (!path) {
return false;

View file

@ -309,7 +309,7 @@ struct r_core_t {
int incomment;
int curtab; // current tab
int seltab; // selected tab
int cmdremote;
char *cmdremote;
char *lastsearch;
char *cmdfilter;
bool break_loop;

View file

@ -82,10 +82,11 @@ typedef struct r_socket_http_options {
bool httpauth;
} RSocketHTTPOptions;
#define R_SOCKET_PROTO_DEFAULT 0
#define R_SOCKET_PROTO_TCP IPPROTO_TCP
#define R_SOCKET_PROTO_UDP IPPROTO_UDP
#define R_SOCKET_PROTO_UNIX 0x1337
#define R_SOCKET_PROTO_NONE 0
#define R_SOCKET_PROTO_DEFAULT R_SOCKET_PROTO_TCP
#ifdef R_API
R_API RSocket *r_socket_new_from_fd(int fd);
@ -209,6 +210,7 @@ R_API int r_socket_rap_client_seek(RSocket *s, ut64 offset, int whence);
typedef struct r_run_profile_t {
char *_args[R_RUN_PROFILE_NARGS];
int _argc;
bool _daemon;
char *_system;
char *_program;
char *_runlib;

View file

@ -1,4 +1,4 @@
/* radare - LGPL - Copyright 2008-2016 - pancake */
/* radare - LGPL - Copyright 2008-2020 - pancake */
#include "r_io.h"
#include "r_lib.h"
@ -76,7 +76,7 @@ static RIODesc *__open(RIO *io, const char *pathname, int rw, int mode) {
int rlen, code;
if (__plugin_open (io, pathname, 0)) {
out = r_socket_http_get (pathname, &code, &rlen);
if (out && rlen>0) {
if (out) {
RIOMalloc *mal = R_NEW0 (RIOMalloc);
if (!mal) {
return NULL;

View file

@ -451,7 +451,8 @@ R_API int r_main_radare2(int argc, const char **argv) {
while ((c = r_getopt_next (&opt)) != -1) {
switch (c) {
case '=':
r->cmdremote = 1;
R_FREE (r->cmdremote);
r->cmdremote = strdup ("");
break;
case '2':
noStderr = true;
@ -819,13 +820,13 @@ R_API int r_main_radare2(int argc, const char **argv) {
return 1;
}
if (strstr (uri, "://")) {
r_core_cmdf (r, "=+%s", uri);
r_core_cmdf (r, "=+ %s", uri);
} else {
r_core_cmdf (r, "=+http://%s/cmd/", argv[opt.ind]);
argv[opt.ind] = r_str_newf ("http://%s/cmd/", argv[opt.ind]);
r_core_cmdf (r, "=+ %s", argv[opt.ind]);
}
r_core_cmd0 (r, "=!=");
//LISTS_FREE ();
// return 0;
r_core_cmd0 (r, "=!=0");
argv[opt.ind] = "-";
}
switch (zflag) {

View file

@ -330,6 +330,7 @@ parse_plugins = [
'mips_pseudo',
'ppc_pseudo',
'sh_pseudo',
'v850_pseudo',
'wasm_pseudo',
'x86_pseudo',
'z80_pseudo'

View file

@ -8,12 +8,12 @@ r_parse_sources = [
'p/parse_att2intel.c',
'p/parse_avr_pseudo.c',
'p/parse_chip8_pseudo.c',
'p/parse_tms320_pseudo.c',
'p/parse_dalvik_pseudo.c',
'p/parse_m68k_pseudo.c',
'p/parse_mips_pseudo.c',
'p/parse_ppc_pseudo.c',
'p/parse_sh_pseudo.c',
'p/parse_tms320_pseudo.c',
'p/parse_v850_pseudo.c',
'p/parse_wasm_pseudo.c',
'p/parse_x86_pseudo.c',

View file

@ -54,6 +54,7 @@
#ifdef _MSC_VER
#include <direct.h> // to compile chdir in msvc windows
#include <process.h> // to compile execv in msvc windows
#define pid_t int
#endif
#if EMSCRIPTEN
@ -473,7 +474,7 @@ R_API bool r_run_parseline(RRunProfile *p, const char *b) {
return 0;
}
*e++ = 0;
if (*e=='$') {
if (*e == '$') {
must_free = true;
e = r_sys_getenv (e);
}
@ -482,6 +483,8 @@ R_API bool r_run_parseline(RRunProfile *p, const char *b) {
}
if (!strcmp (b, "program")) {
p->_args[0] = p->_program = strdup (e);
} else if (!strcmp (b, "daemon")) {
p->_daemon = true;
} else if (!strcmp (b, "system")) {
p->_system = strdup (e);
} else if (!strcmp (b, "runlib")) {
@ -626,6 +629,7 @@ R_API const char *r_run_help(void) {
"# arg6=@arg.txt\n"
"# arg7=@300@ABCD # 300 chars filled with ABCD pattern\n"
"# system=r2 -\n"
"# daemon=false\n"
"# aslr=no\n"
"setenv=FOO=BAR\n"
"# unsetenv=FOO\n"
@ -706,6 +710,13 @@ static int redirect_socket_to_stdio(RSocket *sock) {
return 0;
}
#if __WINDOWS__
static RThreadFunctionRet exit_process(RThread *th) {
// eprintf ("\nrarun2: Interrupted by timeout\n");
exit (0);
}
#endif
static int redirect_socket_to_pty(RSocket *sock) {
#if HAVE_PTY
// directly duplicating the fds using dup2() creates problems
@ -792,7 +803,7 @@ R_API int r_run_config_env(RRunProfile *p) {
#endif
if (!p->_program && !p->_system && !p->_runlib) {
printf ("No program, system or runlib rule defined\n");
eprintf ("No program, system or runlib rule defined\n");
return 1;
}
// when IO is redirected to a process, handle them together
@ -865,11 +876,7 @@ R_API int r_run_config_env(RRunProfile *p) {
is_child = true;
if (p->_dofork && !p->_dodebug) {
#ifdef _MSC_VER
int child_pid = r_sys_fork ();
#else
pid_t child_pid = r_sys_fork ();
#endif
if (child_pid == -1) {
eprintf("rarun2: cannot fork\n");
r_socket_free (child);
@ -1041,13 +1048,17 @@ R_API int r_run_config_env(RRunProfile *p) {
}
sleep (p->_timeout);
if (!kill (mypid, 0)) {
eprintf ("\nrarun2: Interrupted by timeout\n");
// eprintf ("\nrarun2: Interrupted by timeout\n");
}
kill (mypid, use_signal);
exit (0);
}
#else
eprintf ("timeout not supported for this platform\n");
if (p->_timeout_sig < 1 || p->_timeout_sig == 9) {
r_th_new (exit_process, NULL, p->_timeout);
} else {
eprintf ("timeout with signal not supported for this platform\n");
}
#endif
}
return 0;
@ -1111,7 +1122,59 @@ R_API int r_run_start(RRunProfile *p) {
if (p->_pid) {
eprintf ("PID: Cannot determine pid with 'system' directive. Use 'program'.\n");
}
exit (r_sys_cmd (p->_system));
if (p->_daemon) {
#if __WINDOWS__
// eprintf ("PID: Cannot determine pid with 'system' directive. Use 'program'.\n");
#else
pid_t child = r_sys_fork ();
if (child == -1) {
perror ("fork");
exit (1);
}
if (child) {
if (p->_pidfile) {
char pidstr[32];
snprintf (pidstr, sizeof (pidstr), "%d\n", child);
r_file_dump (p->_pidfile,
(const ut8*)pidstr,
strlen (pidstr), 0);
}
exit (0);
}
setsid ();
if (p->_timeout) {
#if __UNIX__
int mypid = getpid ();
if (!r_sys_fork ()) {
int use_signal = p->_timeout_sig;
if (use_signal < 1) {
use_signal = SIGKILL;
}
sleep (p->_timeout);
if (!kill (mypid, 0)) {
// eprintf ("\nrarun2: Interrupted by timeout\n");
}
kill (mypid, use_signal);
exit (0);
}
#else
eprintf ("timeout not supported for this platform\n");
#endif
}
#endif
#if __UNIX__
close(0);
close(1);
exit (execl ("/bin/sh","/bin/sh", "-c", p->_system, NULL));
#else
exit (r_sys_cmd (p->_system));
#endif
} else {
if (p->_pidfile) {
eprintf ("Warning: pidfile doesnt work with 'system'.\n");
}
exit (r_sys_cmd (p->_system));
}
}
if (p->_program) {
if (!r_file_exists (p->_program)) {
@ -1158,6 +1221,31 @@ R_API int r_run_start(RRunProfile *p) {
}
#else
eprintf ("nice not supported for this platform\n");
#endif
}
if (p->_daemon) {
#if __WINDOWS__
eprintf ("PID: Cannot determine pid with 'system' directive. Use 'program'.\n");
#else
pid_t child = r_sys_fork ();
if (child == -1) {
perror ("fork");
exit (1);
}
if (child) {
if (p->_pidfile) {
char pidstr[32];
snprintf (pidstr, sizeof (pidstr), "%d\n", child);
r_file_dump (p->_pidfile,
(const ut8*)pidstr,
strlen (pidstr), 0);
exit (0);
}
}
setsid ();
#if !LIBC_HAVE_FORK
exit (execv (p->_program, (char* const*)p->_args));
#endif
#endif
}
// TODO: must be HAVE_EXECVE

View file

@ -143,7 +143,7 @@ static bool __connect_unix(RSocket *s, const char *file) {
return true;
}
static bool __listen_unix (RSocket *s, const char *file) {
static bool __listen_unix(RSocket *s, const char *file) {
struct sockaddr_un unix_name;
int sock = socket (PF_UNIX, SOCK_STREAM, 0);
if (sock < 0) {
@ -269,8 +269,8 @@ R_API bool r_socket_connect(RSocket *s, const char *host, const char *port, int
int ret;
struct addrinfo hints = { 0 };
struct addrinfo *res, *rp;
if (!proto) {
proto = R_SOCKET_PROTO_TCP;
if (proto == R_SOCKET_PROTO_NONE) {
proto = R_SOCKET_PROTO_DEFAULT;
}
#if __UNIX__
r_sys_signal (SIGPIPE, SIG_IGN);
@ -494,11 +494,10 @@ R_API bool r_socket_listen(RSocket *s, const char *port, const char *certfile) {
return false;
}
#endif
if (s->proto == R_SOCKET_PROTO_NONE) {
s->proto = R_SOCKET_PROTO_DEFAULT;
}
switch (s->proto) {
case R_SOCKET_PROTO_DEFAULT:
s->proto = R_SOCKET_PROTO_TCP;
/* fallthrough */
case R_SOCKET_PROTO_TCP:
if ((s->fd = socket (AF_INET, SOCK_STREAM, R_SOCKET_PROTO_TCP)) == R_INVALID_SOCKET) {
return false;
@ -852,6 +851,7 @@ R_API RSocket *r_socket_new_from_fd(int fd) {
RSocket *s = R_NEW0 (RSocket);
if (s) {
s->fd = fd;
s->proto = R_SOCKET_PROTO_DEFAULT;
}
return s;
}

View file

@ -119,7 +119,7 @@ static char *socket_http_answer(RSocket *s, int *code, int *rlen, ut32 redirecti
}
}
} else {
res = NULL;
res = strdup ("");
}
exit:
free (buf);
@ -162,7 +162,7 @@ static char *http_get_w32(const char *url, int *code, int *rlen) {
ret = tmp;
} while (!(res = InternetReadFile (hOpenUrl, ret + w, read_sz, &r)) || r);
if (w) {
if (res) {
char *tmp = realloc (ret, (size_t)w + 1);
if (tmp) {
ret = tmp;

View file

@ -73,6 +73,7 @@ extern char **environ;
#include <psapi.h>
#include <process.h> // to allow getpid under windows msvc compilation
#include <direct.h> // to allow getcwd under windows msvc compilation
#define sig_t int
#endif
#endif

View file

@ -25,17 +25,11 @@ static void *_r_th_launcher(void *_th) {
int ret;
RThread *th = _th;
th->ready = true;
#if __UNIX__
if (th->delay > 0) {
sleep (th->delay);
r_sys_sleep (th->delay);
} else if (th->delay < 0) {
r_th_lock_wait (th->lock);
}
#else
if (th->delay < 0) {
r_th_lock_wait (th->lock);
}
#endif
r_th_lock_enter (th->lock);
do {
r_th_lock_leave (th->lock);

View file

@ -58,6 +58,8 @@ set the maximum number of file descriptors
set the niceness level of the process
.It Ar preload
preload a library (not supported on Windows, only linux,osx,bsd)
.It Ar daemon
Set to false by default, otherwise it will run the program in background, detached from the terminal.
.It Ar program
path to program to be executed
.It Ar execve

View file

@ -128,6 +128,7 @@ parse.tms320_pseudo
parse.att2intel
parse.dalvik_pseudo
parse.mips_pseudo
parse.v850_pseudo
parse.wasm_pseudo
parse.x86_pseudo"
SHARED="asm.6502

View file

@ -2,42 +2,49 @@ NAME=aav find xrefs
FILE=bins/mach0/macho-bash
CMDS=<<EOF
e anal.loads=true
aa;afna;aac;aar;aan;aav
e anal.in=range
e anal.from=0x8000
e anal.to=0x8000+4K
aac
afna
aar
aan
aav
# aa;afna;aac;aar;aan;aav
pd 17 @0x8058
EOF
EXPECT=<<EOF
| 0x00008058 .dword 0x0000e403
; DATA XREF from sub.free_7890 @ 0x7d30
| `=< 0x00008058 03e4 b 0x7862
0x0000805a 0000 movs r0, r0
; DATA XREF from sub.free_73a0 @ 0x7d30
0x0000805c .dword 0x000693da
; DATA XREF from sub.free_7890 @ 0x7d3e
0x00008060 .dword 0x0006c1f4 ; aav.0x0006c1f4
; DATA XREF from sub.free_7890 @ 0x7d48
; DATA XREF from sub.free_73a0 @ 0x7d3e
0x00008060 .dword 0x0006c1f4
; DATA XREF from sub.free_73a0 @ 0x7d48
0x00008064 .dword 0x0006c1a6
; DATA XREF from sub.free_7890 @ 0x7e30
; DATA XREF from sub.free_73a0 @ 0x7e30
0x00008068 .dword 0x0006c102
; DATA XREF from sub.free_7890 @ 0x7e3a
0x0000806c .dword 0x0006c0b4 ; aav.0x0006c0b4
; DATA XREF from sub.free_7890 @ 0x7e58
; DATA XREF from sub.free_73a0 @ 0x7e3a
0x0000806c .dword 0x0006c0b4
; DATA XREF from sub.free_73a0 @ 0x7e58
0x00008070 .dword 0x0006c0da
; DATA XREF from sub.free_7890 @ 0x7e62
0x00008074 .dword 0x0006c08c ; aav.0x0006c08c
; DATA XREF from sub.free_7890 @ 0x7e80
; DATA XREF from sub.free_73a0 @ 0x7e62
0x00008074 .dword 0x0006c08c
; DATA XREF from sub.strcpy_7890 @ 0x7e80
0x00008078 .dword 0x0006c0b2
; DATA XREF from sub.free_7890 @ 0x7e8a
0x0000807c .dword 0x0006c064 ; aav.0x0006c064
; DATA XREF from sub.free_7890 @ 0x7ed8
; DATA XREF from sub.strcpy_7890 @ 0x7e8a
0x0000807c .dword 0x0006c064
; DATA XREF from sub.strcpy_7890 @ 0x7ed8
0x00008080 .dword 0x00069232
; DATA XREF from sub.free_7890 @ 0x7ee8
; DATA XREF from sub.strcpy_7890 @ 0x7ee8
0x00008084 .dword 0x0006c04a
; DATA XREF from sub.free_7890 @ 0x7ef2
0x00008088 .dword 0x0006bffc ; aav.0x0006bffc
; DATA XREF from sub.free_7890 @ 0x7f64
; DATA XREF from sub.strcpy_7890 @ 0x7ef2
0x00008088 .dword 0x0006bffc
; DATA XREF from sub.free_73a0 @ 0x7f64
0x0000808c .dword 0x0006bfce
; DATA XREF from sub.free_7890 @ 0x7f72
0x00008090 .dword 0x0006bf7c ; aav.0x0006bf7c
; DATA XREF from sub.free_7890 @ 0x7fcc
; DATA XREF from sub.free_73a0 @ 0x7f72
0x00008090 .dword 0x0006bf7c
; DATA XREF from sub.free_73a0 @ 0x7fcc
0x00008094 .dword 0x0006bf66
; DATA XREF from sub.free_7890 @ 0x7fd6
0x00008098 .dword 0x0006bf18 ; aav.0x0006bf18
EOF
RUN

View file

@ -4,6 +4,7 @@ BROKEN=1
CMDS=<<EOF
s+128
e asm.arch=v850
e asm.parser=v850.pseudo
e asm.pseudo=true
b 64
pi~=

View file

@ -0,0 +1,60 @@
NAME==h
FILE=--
CMDS=!scripts/test-webserver.sh
EXPECT=<<EOF
; [14] -r-x section size 594 named .text
;-- entry0:
;-- section..text:
;-- .text:
;-- _start:
0x000006a0 xor ebp, ebp
0x000006a2 mov r9, rdx
0x000006a5 pop rsi
0x000006a6 mov rdx, rsp
0x000006a9 and rsp, 0xfffffffffffffff0
0x000006ad push rax
0x000006ae push rsp
; 0x8f0
0x000006af lea r8, sym.__libc_csu_fini
; 0x880
; "AWAVA\x89\xffAUATL\x8d%\xfe\x04 "
0x000006b6 lea rcx, sym.__libc_csu_init
; 0x81e
0x000006bd lea rdi, main
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=false" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="language" content="en" />
<title>radare2 webui</title>
<script type="text/javascript" src="m/vendors/jquery.min.js"></script>
<script type="text/javascript" src="m/r2.js"></script>
EOF
EXPECT_ERR=<<EOF
EOF
RUN
NAME=r2 remote webserver two
FILE=--
CMDS=<<EOF
& !rarun2 timeout=3 daemon=1 system="r2 -e http.root=/404 -e http.port=9292 -c=h -qcq -"
sleep 1
=+ http://127.0.0.1:9292/cmd/
=
=0 ?e hello remote world
EOF
EXPECT=<<EOF
0 fd:-1 http://127.0.0.1:9292/cmd/
hello remote world
EOF
EXPECT_ERR=<<EOF
Cannot find http.root or http.homeroot
Starting http server...
open http://localhost:9292/
r2 -C http://localhost:9292/cmd/
EOF
RUN

View file

@ -3,18 +3,60 @@ BROKEN=1
FILE=--
CMDS=!scripts/test-webserver.sh
EXPECT=<<EOF
; [14] -r-x section size 594 named .text
;-- entry0:
;-- section..text:
;-- .text:
;-- _start:
0x000006a0 xor ebp, ebp
0x000006a2 mov r9, rdx
0x000006a5 pop rsi
0x000006a6 mov rdx, rsp
0x000006a9 and rsp, 0xfffffffffffffff0
0x000006ad push rax
0x000006ae push rsp
; 0x8f0
0x000006af lea r8, sym.__libc_csu_fini
; 0x880
; "AWAVA\x89\xffAUATL\x8d%\xfe\x04 "
0x000006b6 lea rcx, sym.__libc_csu_init
; 0x81e
0x000006bd lea rdi, main
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=false" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="language" content="en" />
<title>radare2 webui</title>
<script type="text/javascript" src="m/vendors/jquery.min.js"></script>
<script type="text/javascript" src="m/r2.js"></script>
EOF
EXPECT_ERR=<<EOF
Starting http server...
open http://localhost:9090/
r2 -C http://localhost:9090/cmd/
EOF
RUN
# this test fails on newshell and windows better to mark it as broken
NAME=r2 remote webserver two
BROKEN=1
FILE=--
CMDS=<<EOF
e cfg.newshell=true
& !rarun2 timeout=3 daemon=1 system="r2 -e http.root=/404 -e http.port=9292 -c=h -qcq -"
sleep 1
=+ http://127.0.0.1:9292/cmd/
=
=0 ?e hello remote world
EOF
EXPECT=<<EOF
0 fd:-1 http://127.0.0.1:9292/cmd/
hello remote world
EOF
EXPECT_ERR=<<EOF
Cannot find http.root or http.homeroot
Starting http server...
open http://localhost:9292/
r2 -C http://localhost:9292/cmd/
EOF
RUN

View file

@ -29,6 +29,9 @@ e asm.bytes=0
e asm.lines.bb=0
e asm.comments=0
pd 1~push
e anal.in=range
e anal.from=$$
e anal.to=$$+4K
aae
pd 1~push
EOF

View file

@ -1,8 +1,14 @@
# XXX this is a very slow test
NAME=MZ: corkami cdogs.exe - open
FILE=bins/le/cdogs.exe
ARGS=-A
CMDS=q!
CMDS=<<EOF
aac
# aaef
aflc
EOF
EXPECT=<<EOF
794
EOF
RUN

View file

@ -1,7 +1,9 @@
#!/bin/sh
r2 -qq -c=h - &
r2 -N -e http.port=9393 -qq -c=h bins/elf/arg > /dev/null 2>&1 &
CHILD=$!
sleep 2
curl -s --retry 6 --retry-connrefused http://localhost:9090/ | head -n 8
# curl -s --retry 6 --retry-connrefused http://localhost:9090/ | head -n 8
r2 -N -qc '=0 pd 10' -C http://127.0.0.1:9393/cmd
r2 -N -c 'b $s;pr~:0..9' -qcq http://127.0.0.1:9393/
kill $CHILD