14 int content_length = 0, xx, yy;
15 int pxx = 1, first = 0;
16 char buf[1500], *
p, *q;
45 if (!yy || (!xx && !pxx)) {
52 if (strlen(
buf) < 3) {
62 q = strstr(
p + 1,
" HTTP");
69 if (!hr->
referer && !strncmp(
buf,
"Referer: ", 9)) {
71 }
else if (!hr->
agent && !strncmp(
buf,
"User-Agent: ", 12)) {
73 }
else if (!hr->
host && !strncmp(
buf,
"Host: ", 6)) {
75 }
else if (!strncmp(
buf,
"Content-Length: ", 16)) {
76 content_length = atoi(
buf + 16);
77 }
else if (so->
httpauth && !strncmp(
buf,
"Authorization: Basic ", 21)) {
78 char *authtoken =
buf + 21;
79 size_t authlen = strlen(authtoken);
82 char *decauthtoken =
calloc(4, authlen + 1);
84 eprintf(
"Could not allocate decoding buffer\n");
89 eprintf(
"Could not decode authorization token\n");
92 if (!strcmp(decauthtoken, curauthtoken)) {
102 eprintf(
"Failed attempt login from '%s'\n", hr->
host);
107 if (content_length > 0) {
111 eprintf(
"Could not allocate hr data\n");
117 hr->
data[content_length] = 0;
123 const char *strcode =
124 code == 200 ?
"ok" :
code == 301 ?
"Moved permanently"
125 :
code == 302 ?
"Found"
126 :
code == 401 ?
"Unauthorized"
127 :
code == 403 ?
"Permission denied"
128 :
code == 404 ?
"not found"
134 headers =
code == 401 ?
"WWW-Authenticate: Basic realm=\"R2 Web UI Access\"\n" :
"";
137 "Connection: close\r\nContent-Length: %d\r\n\r\n",
148 if (!strncmp((
const char *)
str,
"----------", 10)) {
151 const char *data, *token = (
const char *)
str + 10;
152 const char *
end = strchr(token,
'\n');
156 data = strstr(
end,
"Content-Disposition: form-data; ");
158 data = strchr(data,
'\n');
160 data = strchr(data + 1,
'\n');
164 while (*data == 10 || *data == 13) {
168 while (*
end ==
'-') {
171 if (*
end == 10 || *
end == 13) {
175 ret =
malloc(datalen + 1);
179 memcpy(ret, data, datalen);
205 eprintf(
"Cannot listen here\n");
212 if (!strcmp(
rs->method,
"GET")) {
214 "<html><body><form method=post action=/>"
215 "<input name=a /><input type=button></form></body>");
216 }
else if (!strcmp(
rs->method,
"POST")) {
218 strcpy(
buf,
"<html><body><h2>XSS test</h2>\n");
220 strcat(
buf,
rs->data);
223 }
else if (!strcmp(
rs->method,
"OPTIONS")) {
const lzma_allocator const uint8_t size_t uint8_t * out
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))
void * malloc(size_t size)
void * calloc(size_t number, 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")
int main(int argc, char **argv)
RZ_API int rz_base64_decode(ut8 *bout, const char *bin, int len)
RZ_API int rz_socket_read_block(RzSocket *s, unsigned char *buf, int len)
RZ_API int rz_socket_ready(RzSocket *s, int secs, int usecs)
RZ_API RzSocket * rz_socket_accept(RzSocket *s)
RZ_API bool rz_socket_listen(RzSocket *s, const char *port, const char *certfile)
RZ_API bool rz_socket_block_time(RzSocket *s, bool block, int sec, int usec)
RZ_API int rz_socket_gets(RzSocket *s, char *buf, int size)
RZ_API void rz_socket_printf(RzSocket *s, const char *fmt,...) RZ_PRINTF_CHECK(2
RZ_API RzSocket * rz_socket_accept_timeout(RzSocket *s, unsigned int timeout)
RZ_API RzSocket * rz_socket_new(bool is_ssl)
RZ_API int rz_socket_free(RzSocket *s)
RZ_API int rz_socket_write(RzSocket *s, void *buf, int len)
RZ_API int rz_str_unescape(char *buf)
#define ST32_ADD_OVFCHK(a, x)
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 len, const char *headers)
RZ_API void rz_socket_http_server_set_breaked(bool *b)
RZ_API ut8 * rz_socket_http_handle_upload(const ut8 *str, int len, int *retlen)
RZ_API void rz_socket_http_close(RzSocketHTTPRequest *rs)