|
|
@ -62,10 +62,10 @@ void create_data_packet(char** out_packet, int* out_packet_len, struct tcp_sessi |
|
|
|
struct sockaddr_in sin; |
|
|
|
|
|
|
|
//some address resolution |
|
|
|
strcpy(source_ip , "10.0.0.116"); // cli ip |
|
|
|
strcpy(source_ip , ""); // cli wifi ip |
|
|
|
sin.sin_family = AF_INET; |
|
|
|
sin.sin_port = htons(50508); // server port |
|
|
|
sin.sin_addr.s_addr = inet_addr ("207.246.62.210"); // server ip |
|
|
|
sin.sin_addr.s_addr = inet_addr (""); // server public ip |
|
|
|
|
|
|
|
|
|
|
|
// IP header configuration |
|
|
@ -224,23 +224,27 @@ void create_syn_packet(char** out_packet, int* out_packet_len) |
|
|
|
*out_packet_len = sizeof(struct iphdr) + sizeof(struct tcphdr) + OPT_SIZE; |
|
|
|
free(pseudogram); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int write_data_packet(const struct arguments *args, int epoll_fd, const uint8_t *buffer, size_t length) { |
|
|
|
// send PSH data |
|
|
|
char* psh_packet; |
|
|
|
int psh_packet_len; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
psh_packet = "testoooo"; |
|
|
|
psh_packet_len = 8; |
|
|
|
|
|
|
|
//create_data_packet(&psh_packet, &psh_packet_len, tcps); |
|
|
|
//handle_ip(args, psh_packet, (size_t) psh_packet_len, epoll_fd, 10, 200); |
|
|
|
|
|
|
|
int open_data_packet(const struct arguments *args, int epoll_fd, struct tcp_session tcps) { |
|
|
|
// send PSH data |
|
|
|
char* packet; |
|
|
|
int packet_len; |
|
|
|
//create_data_packet(&packet, &packet_len, tcps); |
|
|
|
//write(debug_socket->socket, psh_packet, (size_t) psh_packet_len); |
|
|
|
write(debug_socket->socket, buffer, length); |
|
|
|
|
|
|
|
log_android(ANDROID_LOG_ERROR, "Handling push data IP create"); |
|
|
|
//write_ack(args, &debug_socket->tcp); this will send acks from dst to source (wrong direction) if uncommented |
|
|
|
log_android(ANDROID_LOG_ERROR, "Handling push data IP create with length: %d", psh_packet_len); |
|
|
|
|
|
|
|
//handle_ip(args, packet, (size_t) packet_len, epoll_fd, 10, 200); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -251,16 +255,12 @@ int open_debug_packet(const struct arguments *args, int epoll_fd) { |
|
|
|
// send SYN |
|
|
|
char* packet; |
|
|
|
int packet_len; |
|
|
|
create_syn_packet(&packet, &packet_len); |
|
|
|
|
|
|
|
create_syn_packet(&packet, &packet_len); |
|
|
|
|
|
|
|
//read(args->tun, packet, packet_len); |
|
|
|
//ssize_t res = read(args->tun, packet, packet_len); |
|
|
|
//log_android(ANDROID_LOG_ERROR, "writing to file descriptor: %d", args->tun); |
|
|
|
handle_ip(args, packet, (size_t) packet_len, epoll_fd, 10, 200); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
ssize_t res = write(args->tun, packet, (size_t) packet_len); |
|
|
|
|
|
|
@ -270,10 +270,6 @@ int open_debug_packet(const struct arguments *args, int epoll_fd) { |
|
|
|
} else { |
|
|
|
log_android(ANDROID_LOG_ERROR, "tcp write error.."); |
|
|
|
} |
|
|
|
|
|
|
|
//handle_debug_ip(args, buffer, packet_length, epoll_fd); |
|
|
|
//handle_ip(args, packet, (size_t) packet_len, epoll_fd, 10, 200); |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
@ -321,18 +317,13 @@ void read_debug_socket() { |
|
|
|
return ; |
|
|
|
} |
|
|
|
|
|
|
|
void write_debug_socket(const struct arguments *args, int epoll_fd, const uint8_t *buffer, size_t length, char* dest_ip) { |
|
|
|
void write_debug_socket(const struct arguments *args, int epoll_fd, const uint8_t *buffer, size_t length) { |
|
|
|
// TODO: This function is modelled after write_pcap_ret so I made |
|
|
|
// parameters for this function the same since we basically want to do the same thing. |
|
|
|
|
|
|
|
|
|
|
|
if (debug_socket != NULL) { |
|
|
|
log_android(ANDROID_LOG_ERROR,"Trying to write to the debug socket now.."); |
|
|
|
|
|
|
|
|
|
|
|
open_data_packet(args, epoll_fd, debug_socket->tcp); |
|
|
|
|
|
|
|
//write_data(args, &debug_socket->tcp, buffer, length); |
|
|
|
write_data_packet(args, epoll_fd, buffer, length); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|