11 "<title>rz-agent</title>"
13 "function file_open() {"
14 " var file = window.prompt ('path to file?');"
15 " window.open ('/file/open/'+file);"
23 " - <a href='javascript:file_open()'>open</a><br />"
24 " - <a href='/file/list'>list</a><br />"
36 #if __APPLE__ && (__arm__ || __arm64__ || __aarch64__)
37 #define USE_IOS_JETSAM 1
39 #define MEMORYSTATUS_CMD_SET_JETSAM_TASK_LIMIT 6
43 #define USE_IOS_JETSAM 0
47 printf(
"Usage: rz-agent [-adhs] [-p port]\n"
48 " -a listen for everyone (localhost by default)\n"
49 " -d run in daemon mode (background)\n"
50 " -h show this help message\n"
51 " -u enable http Authorization access\n"
52 " -t user:password authentication file\n"
53 " -p [port] specify listening port (defaults to 8080)\n");
67 bool listenlocal =
true;
68 const char *port =
"8080";
69 const char *httpauthfile =
NULL;
71 memset(&so, 0,
sizeof(so));
91 httpauthfile = opt.
arg;
100 if (opt.
ind != argc) {
109 eprintf(
"No authentication user list set\n");
118 eprintf(
"Empty list of HTTP users\\n");
123 memorystatus_control(MEMORYSTATUS_CMD_SET_JETSAM_TASK_LIMIT, getpid(), 256,
NULL, 0);
147 char *result_heap =
NULL;
157 if (!strcmp(
rs->method,
"GET")) {
158 if (!strncmp(
rs->path,
"/proc/kill/", 11)) {
160 int pid = atoi(
rs->path + 11);
168 }
else if (!strncmp(
rs->path,
"/file/open/", 11)) {
173 size_t escaped_len = strlen(escaped_filename);
174 size_t cmd_len = escaped_len + 40;
181 snprintf(
cmd, cmd_len,
"rizin -q %s-e http.port=%d -cRh \"%s\"",
182 listenlocal ?
"" :
"-e http.bind=public ",
183 session_port, escaped_filename);
188 free(escaped_filename);
189 result = result_heap =
malloc(1024 + escaped_len);
198 "<a href='/'>back</a><hr size=1/>"
199 " - <a target='_blank' href='http://localhost:%d/'>open</a><br />"
200 " - <a href='/proc/kill/%d'>kill</a><br />"
RZ_API RzCons * rz_cons_singleton(void)
RZ_API RzCons * rz_cons_new(void)
RZ_API RzCons * rz_cons_free(void)
_Use_decl_annotations_ int __cdecl printf(const char *const _Format,...)
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)
static const char * page_index
RZ_API int rz_main_rz_agent(int argc, const char **argv)
static int showversion(void)
RZ_API void rz_list_free(RZ_NONNULL RzList *list)
Empties the list and frees 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 pid
static static fork const void static count static fd const char const char static newpath char char argv
RZ_API RZ_OWN char * rz_file_slurp(const char *str, RZ_NULLABLE size_t *usz)
RZ_API void rz_getopt_init(RzGetopt *go, int argc, const char **argv, const char *ostr)
RZ_API int rz_getopt_next(RzGetopt *opt)
RZ_API int rz_main_version_print(const char *program)
RZ_API int rz_num_rand(int max)
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 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 RZ_OWN char * rz_str_escape(RZ_NONNULL const char *buf)
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 int rz_sys_fork(void)
RZ_API int rz_sys_kill(int pid, int sig)
Send signal sig to process with pid pid.
RZ_API int rz_sys_cmdbg(const char *cmd)
static struct sockaddr static addrlen static backlog const void static flags void flags