Compare commits

..
2 Commits
Author SHA1 Message Date
PoliEcho e80336cb58 fix config 2026-09-19 13:02:20 +02:00
PoliEcho 677909272b add config 2026-09-19 13:02:11 +02:00
2 changed files with 12 additions and 5 deletions
+5
View File
@@ -0,0 +1,5 @@
#pragma once
#include <linux/bpf.h>
#define LOW_PORT 1
const __u16 open_ports[] = {22};
#define HIGH_PORT 65535
+6 -4
View File
@@ -1,5 +1,6 @@
#include <linux/bpf.h> #include <linux/bpf.h>
#define fuck_formater #define fuck_formater
#include "config.h"
#include <bpf/bpf_endian.h> #include <bpf/bpf_endian.h>
#include <bpf/bpf_helpers.h> #include <bpf/bpf_helpers.h>
@@ -47,9 +48,7 @@
#define SYN_MASK 0b00000010 #define SYN_MASK 0b00000010
#define ACK_MASK 0b00010000 #define ACK_MASK 0b00010000
#define LOW_PORT 4000
const __u16 open_ports[] = {4444};
#define HIGH_PORT 5000
#define MAX_ITERATIONS 1024 #define MAX_ITERATIONS 1024
@@ -221,6 +220,9 @@ int xdp_drop_prog(struct xdp_md *ctx) {
// check SYN // check SYN
if (tcp_flags & SYN_MASK) { 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) { if (mulberry32_at((__u32)time_seed, dst_port) % 3 == 0) {
__u16 *src_port_ptr = (__u16 *)(tcp_packet_data + TCP_SRC_PORT_OFFSET); __u16 *src_port_ptr = (__u16 *)(tcp_packet_data + TCP_SRC_PORT_OFFSET);
const __u16 src_port = bpf_ntohs(*src_port_ptr); const __u16 src_port = bpf_ntohs(*src_port_ptr);
@@ -336,10 +338,10 @@ int xdp_drop_prog(struct xdp_md *ctx) {
__builtin_memcpy((__u8 *)data, src_mac, MAC_SIZE); __builtin_memcpy((__u8 *)data, src_mac, MAC_SIZE);
} }
return XDP_TX; return XDP_TX;
}
} else { } else {
return XDP_DROP; return XDP_DROP;
} }
}
return XDP_PASS; return XDP_PASS;
} }