mirror of
https://github.com/radareorg/radare2.git
synced 2024-12-05 03:56:46 +00:00
parent
08c5adee04
commit
e1efde0b1c
@ -20,6 +20,7 @@ SECURITY IMPLICATIONS
|
||||
|
||||
static RSocket *s = NULL;
|
||||
static RThread *httpthread = NULL;
|
||||
static RThread *rapthread = NULL;
|
||||
static const char *listenport = NULL;
|
||||
|
||||
typedef struct {
|
||||
@ -34,6 +35,11 @@ typedef struct {
|
||||
char *path;
|
||||
} HttpThread;
|
||||
|
||||
typedef struct {
|
||||
RCore *core;
|
||||
const char* input;
|
||||
} RapThread;
|
||||
|
||||
static char *rtrcmd (TextLog T, const char *str) {
|
||||
char *res, *ptr2;
|
||||
char *ptr = r_str_uri_encode (str);
|
||||
@ -779,9 +785,13 @@ the_end:
|
||||
static int r_core_rtr_http_thread (RThread *th) {
|
||||
int ret;
|
||||
|
||||
if (!th) return false;
|
||||
if (!th) {
|
||||
return false;
|
||||
}
|
||||
HttpThread *ht = th->user;
|
||||
if (!ht || !ht->core) return false;
|
||||
if (!ht || !ht->core) {
|
||||
return false;
|
||||
}
|
||||
ret = r_core_rtr_http_run (ht->core, ht->launch, ht->path);
|
||||
R_FREE (ht->path);
|
||||
return ret;
|
||||
@ -816,8 +826,8 @@ R_API int r_core_rtr_http(RCore *core, int launch, const char *path) {
|
||||
} else {
|
||||
const char *tpath = r_str_trim_const (path + 1);
|
||||
HttpThread ht = { core, launch, strdup (tpath) };
|
||||
httpthread = r_th_new (r_core_rtr_http_thread, &ht, 0);
|
||||
r_th_start (httpthread, 1);
|
||||
httpthread = r_th_new (r_core_rtr_http_thread, &ht, false);
|
||||
r_th_start (httpthread, true);
|
||||
eprintf ("Background http server started.\n");
|
||||
}
|
||||
return 0;
|
||||
@ -843,6 +853,7 @@ R_API void r_core_rtr_help(RCore *core) {
|
||||
"!=!", "", "enable remote cmd mode",
|
||||
"\nrap server:","","",
|
||||
"=", ":port", "listen on given port using rap protocol (o rap://9999)",
|
||||
"=&", ":port", "start rap server in background",
|
||||
"=", ":host:port cmd", "run 'cmd' command on remote server",
|
||||
"\nhttp server:", "", "",
|
||||
"=h", " port", "listen for http connections (r2 -qc=H /bin/ls)",
|
||||
@ -1188,15 +1199,45 @@ static void r_rap_packet_fill(ut8 *buf, const ut8* src, int len) {
|
||||
}
|
||||
}
|
||||
|
||||
static void r_core_rtr_rap_run(RCore *core, const char *input) {
|
||||
r_core_cmdf (core, "o rap://%s", input);
|
||||
}
|
||||
|
||||
static int r_core_rtr_rap_thread (RThread *th) {
|
||||
if (!th) {
|
||||
return false;
|
||||
}
|
||||
RapThread *rt = th->user;
|
||||
if (!rt || !rt->core) {
|
||||
return false;
|
||||
}
|
||||
r_core_rtr_rap_run (rt->core, rt->input);
|
||||
return true;
|
||||
}
|
||||
|
||||
R_API void r_core_rtr_cmd(RCore *core, const char *input) {
|
||||
char bufw[1024], bufr[8], *cmd_output = NULL;
|
||||
const char *cmd = NULL;
|
||||
int i, cmd_len, fd = atoi (input);
|
||||
|
||||
if (*input==':' && !strchr (input + 1, ':')) {
|
||||
r_core_cmdf (core, "o rap://%s", input);
|
||||
r_core_rtr_rap_run (core, input);
|
||||
return;
|
||||
}
|
||||
|
||||
if (*input=='&') {
|
||||
if (rapthread) {
|
||||
eprintf ("RAP Thread is already running\n");
|
||||
eprintf ("This is experimental and probably buggy. Use at your own risk\n");
|
||||
} else {
|
||||
RapThread rt = { core, input + 1 };
|
||||
rapthread = r_th_new (r_core_rtr_rap_thread, &rt, false);
|
||||
r_th_start (rapthread, true);
|
||||
eprintf ("Background rap server started.\n");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (fd != 0) {
|
||||
RSocket *fh = rtr_host[rtr_n].fd;
|
||||
for (rtr_n = 0; fh && fh->fd != fd && rtr_n < RTR_MAX_HOSTS - 1; rtr_n++) {
|
||||
|
Loading…
Reference in New Issue
Block a user