we also need to capture the target

This commit is contained in:
Quentin 2020-02-24 16:20:15 +01:00
parent 61b66a9198
commit ccd8fb68a7

View file

@ -156,8 +156,9 @@ int on_torctl_server_auth_write(struct evt_core_ctx* ctx, struct evt_core_fdinfo
int on_torctl_server_add_onion_read(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo) {
char buffer[1024] = {0};
char host[1024] = {0};
char *strtok_ptr, *str_target, *token;
int i, port;
int i, port1, port2;
ssize_t nread = recv(fdinfo->fd, buffer, sizeof(buffer), MSG_PEEK);
if (nread == -1 && errno == EAGAIN) return EVT_CORE_FD_EXHAUSTED;
@ -182,10 +183,11 @@ int on_torctl_server_add_onion_read(struct evt_core_ctx* ctx, struct evt_core_fd
if (i < 2) continue;
if (token == NULL) break;
int captured = sscanf(token, "Port=%d", &port);
if (captured != 1) continue;
int captured = sscanf(token, "Port=%d,%[^:]:%d", &port1, host, &port2);
if (captured != 3) continue;
printf("Captured port %d\n", port);
//create_tcp_client();
printf("Captured internet: %d, target: %s %d\n", port1, host, port2);
}
evt_core_mv_fd2 (ctx, fdinfo, "torctl-server-add-onion-write");
@ -204,7 +206,7 @@ int on_torctl_server_add_onion_write(struct evt_core_ctx* ctx, struct evt_core_f
return EVT_CORE_FD_EXHAUSTED;
error:
perror("@FIXME: unproper handling of non blocking sockets, you have been bitten in torctl server add onion write\n");
perror("@FIXME: unproper handling of non blocking sockets, you have been bitten in torctl_server_add_onion_write\n");
exit(EXIT_FAILURE);
}