diff --git a/src/config.h b/src/config.h new file mode 100644 index 0000000..a30d9fc --- /dev/null +++ b/src/config.h @@ -0,0 +1,5 @@ +#pragma once +#include +#define LOW_PORT 1 +const __u16 open_ports[] = {22, 4444}; +#define HIGH_PORT 65535 \ No newline at end of file diff --git a/src/main.c b/src/main.c index 9fc3c15..dd7c989 100644 --- a/src/main.c +++ b/src/main.c @@ -1,5 +1,6 @@ #include #define fuck_formater +#include "config.h" #include #include @@ -47,9 +48,7 @@ #define SYN_MASK 0b00000010 #define ACK_MASK 0b00010000 -#define LOW_PORT 4000 -const __u16 open_ports[] = {4444}; -#define HIGH_PORT 5000 + #define MAX_ITERATIONS 1024 @@ -221,6 +220,9 @@ int xdp_drop_prog(struct xdp_md *ctx) { // check SYN if (tcp_flags & SYN_MASK) { + if (tcp_flags & ACK_MASK) { + return XDP_PASS; // pass if syn-ack; + } if (mulberry32_at((__u32)time_seed, dst_port) % 3 == 0) { __u16 *src_port_ptr = (__u16 *)(tcp_packet_data + TCP_SRC_PORT_OFFSET); const __u16 src_port = bpf_ntohs(*src_port_ptr); @@ -336,9 +338,9 @@ int xdp_drop_prog(struct xdp_md *ctx) { __builtin_memcpy((__u8 *)data, src_mac, MAC_SIZE); } return XDP_TX; + } else { + return XDP_DROP; } - } else { - return XDP_DROP; } return XDP_PASS;