Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e80336cb58 | ||
|
|
677909272b |
@@ -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
@@ -1,5 +1,6 @@
|
||||
#include <linux/bpf.h>
|
||||
#define fuck_formater
|
||||
#include "config.h"
|
||||
#include <bpf/bpf_endian.h>
|
||||
#include <bpf/bpf_helpers.h>
|
||||
|
||||
@@ -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,10 +338,10 @@ int xdp_drop_prog(struct xdp_md *ctx) {
|
||||
__builtin_memcpy((__u8 *)data, src_mac, MAC_SIZE);
|
||||
}
|
||||
return XDP_TX;
|
||||
}
|
||||
} else {
|
||||
return XDP_DROP;
|
||||
}
|
||||
}
|
||||
|
||||
return XDP_PASS;
|
||||
}
|
||||
Reference in New Issue
Block a user