27 eprintf(
"Cannot find http.root or http.homeroot\n");
43 if (!strcmp(port,
"0")) {
52 if (!strcmp(host,
"::1")) {
54 }
else if (!strcmp(host,
"localhost")) {
56 }
else if (!strcmp(host,
"127.0.0.1")) {
58 }
else if (!strcmp(host,
"local")) {
61 }
else if (host[0] ==
'0' || !strcmp(host,
"public")) {
72 memset(&so, 0,
sizeof(so));
76 eprintf(
"Cannot listen on http.port\n");
83 browser, host, atoi(port),
path ?
path :
"");
91 eprintf(
"No user list set for HTTP Authentication\n");
101 eprintf(
"Empty list of HTTP users\n");
121 eprintf(
"Starting http server...\n");
122 eprintf(
"open http://%s:%d/\n", host, atoi(port));
123 eprintf(
"rizin -C http://%s:%d/cmd/\n", host, atoi(port));
127 int newblksz, origblksz = core->
blocksize;
128 ut8 *newblk, *origblk = core->
block;
139 core->
block = newblk;
151 newblk = core->
block;
155 core->
block = origblk;
168 origblk = core->
block;
171 core->
block = newblk;
187 if (allow && *allow) {
188 bool accepted =
false;
189 const char *allows_host;
191 char *allows =
strdup(allow);
194 p = strchr(peer,
':');
201 if (!strcmp(allows_host, peer)) {
213 if (!
rs->method || !
rs->path) {
214 http_logf(core,
"Invalid http headers received from client\n");
235 strcpy(headers,
"Access-Control-Allow-Origin: *\n"
236 "Access-Control-Allow-Headers: Origin, "
237 "X-Requested-With, Content-Type, Accept\n");
239 if (!strcmp(
rs->method,
"OPTIONS")) {
241 }
else if (!strcmp(
rs->method,
"GET")) {
242 if (!strncmp(
rs->path,
"/up/", 4)) {
245 if (!
rs->path[3] || (
rs->path[3] ==
'/' && !
rs->path[4])) {
276 }
else if (!strncmp(
rs->path,
"/cmd/", 5)) {
278 if (colon &&
rs->path[5] !=
':') {
281 char *
cmd =
rs->path + 5;
284 const bool httpref_enabled = (httpref && *httpref);
286 if (httpref_enabled) {
287 if (strstr(httpref,
"http")) {
290 refstr =
rz_str_newf(
"http://localhost:%d/", atoi(port));
294 while (*
cmd ==
'/') {
297 if (httpref_enabled && (!
rs->referer || (refstr && !strstr(
rs->referer, refstr)))) {
300 if (httpcmd && *httpcmd) {
316 if ((!strcmp(
cmd,
"Rh*") ||
317 !strcmp(
cmd,
"Rh--"))) {
319 }
else if (*
cmd ==
':') {
330 "Content-Type: text/plain\n%s", headers);
339 if (!strcmp(
cmd,
"Rh*")) {
346 }
else if (!strcmp(
cmd,
"Rh--")) {
361 if (!strcmp(
rs->path,
"/")) {
370 }
else if (homeroot && *homeroot) {
385 if (
rs->path[strlen(
rs->path) - 1] ==
'/') {
390 char *res =
rz_str_newf(
"Location: %s/\n%s",
rs->path, headers);
403 const char *ct =
NULL;
404 if (strstr(
path,
".js")) {
405 ct =
"Content-Type: application/javascript\n";
407 if (strstr(
path,
".css")) {
408 ct =
"Content-Type: text/css\n";
410 if (strstr(
path,
".html")) {
411 ct =
"Content-Type: text/html\n";
434 }
else if (!strcmp(
rs->method,
"POST")) {
452 "<html><body><h2>uploaded %d byte(s). Thanks</h2>\n", retlen);
497 eprintf(
"http server is already running\n");
501 while (*
path ==
'&') {
static bool the_end(void *p)
const lzma_allocator const uint8_t size_t uint8_t * out
RZ_API char * rz_core_cmd_str_pipe(RzCore *core, const char *cmd)
RZ_API int rz_core_cmd0(RzCore *core, const char *cmd)
RZ_API int rz_core_cmdf(RzCore *core, const char *fmt,...)
RZ_API ut64 rz_config_get_i(RzConfig *cfg, RZ_NONNULL const char *name)
RZ_API RzConfigNode * rz_config_set(RzConfig *cfg, RZ_NONNULL const char *name, const char *value)
RZ_API RzConfig * rz_config_clone(RzConfig *cfg)
RZ_API RzConfigNode * rz_config_set_i(RzConfig *cfg, RZ_NONNULL const char *name, const ut64 i)
RZ_API RZ_BORROW const char * rz_config_get(RzConfig *cfg, RZ_NONNULL const char *name)
RZ_API void rz_config_free(RzConfig *cfg)
RZ_API void * rz_cons_sleep_begin(void)
RZ_API void rz_cons_break_pop(void)
RZ_API void rz_cons_break_push(RzConsBreak cb, void *user)
RZ_API bool rz_cons_is_breaked(void)
RZ_API void rz_cons_println(const char *str)
RZ_API void rz_cons_sleep_end(void *user)
static static fork const void static count static fd const char const char static newpath const char static path const char path
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 count
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 cmd
RZ_API void Ht_() free(HtName_(Ht) *ht)
return memset(p, 0, total)
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
RZ_API void rz_list_free(RZ_NONNULL RzList *list)
Empties the list and frees the list pointer.
void * malloc(size_t size)
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")
RZ_API int rz_core_rtr_http_stop(RzCore *u)
static void http_logf(RzCore *core, const char *fmt,...)
static char * rtr_dir_files(const char *path)
static void activateDieTime(RzCore *core)
RZ_API int rz_core_rtr_http(RzCore *core, int launch, int browse, const char *path)
static int rz_core_rtr_http_run(RzCore *core, int launch, int browse, const char *path)
RZ_API bool rz_file_is_directory(const char *str)
RZ_API bool rz_file_exists(const char *str)
RZ_API char * rz_file_abspath(const char *file)
RZ_API RZ_OWN char * rz_file_slurp(const char *str, RZ_NULLABLE size_t *usz)
RZ_API char * rz_file_root(const char *root, const char *path)
RZ_API bool rz_file_dump(const char *file, const ut8 *buf, int len, bool append)
RZ_API int rz_num_rand(int max)
RZ_API void rz_num_irand(void)
RZ_API RzSocketHTTPRequest * rz_socket_http_accept(RzSocket *s, RzSocketHTTPOptions *so)
RZ_API void rz_socket_http_response(RzSocketHTTPRequest *rs, int code, const char *out, int x, const char *headers)
RZ_API bool rz_socket_listen(RzSocket *s, const char *port, const char *certfile)
RZ_API ut8 * rz_socket_http_handle_upload(const ut8 *str, int len, int *olen)
RZ_API char * rz_socket_to_string(RzSocket *s)
RZ_API char * rz_socket_http_get(const char *url, int *code, int *rlen)
RZ_API RzSocket * rz_socket_new(bool is_ssl)
RZ_API int rz_socket_free(RzSocket *s)
RZ_API void rz_socket_http_close(RzSocketHTTPRequest *rs)
RZ_API char * rz_str_uri_encode(const char *buf)
RZ_API char * rz_str_newf(const char *fmt,...) RZ_PRINTF_CHECK(1
RZ_API char * rz_str_append(char *ptr, const char *string)
RZ_API RzList * rz_str_split_list(char *str, const char *c, int n)
Split the string str according to the substring c and returns a RzList with the result.
RZ_API const char * rz_str_word_get0(const char *str, int idx)
RZ_API void rz_str_uri_decode(char *buf)
RZ_API size_t rz_str_split(char *str, char ch)
Split string str in place by using ch as a delimiter.
RZ_API int rz_sys_cmdf(const char *fmt,...) RZ_PRINTF_CHECK(1
RZ_API int rz_sys_usleep(int usecs)
Sleep for usecs microseconds.
ut64(WINAPI *w32_GetEnabledXStateFeatures)()