Skip to content

Commit 9d97a6c

Browse files
committed
xtables-wgobfs: add an iptables extension module to obfuscate WireGuard
Port from https://github.com/infinet/xt_wgobfs, this kernel module obfuscates WireGuard. It can work as server, client, or relay. Performance =========== Test in two Alpine linux VMs on same host. Each VM has 1 CPU and 256M RAM. Iperf3 over wg reports 1.1Gbits/sec without obfuscation, 950Mbits/sec with obfuscation. How it works ============ The sender and receiver share a secret key, which is used by `chacha6` to hash the same input into identical pseudo-random numbers. These pseudo-random numbers are used in obfuscation. The input to hash function is from 16th to 31st bytes of a WG message. The first byte of input is incremented when need to generate a different PRN. - The first 16 bytes of WG message is obfuscated. - The mac2 field is also obfuscated, if it is all zeros. - Padding WG message with random bytes of random length. - Drop keepalive message with 80% probability. - Change the Diffserv field to zero. `Chacha6` is chosen for its speed, as the goal is not encryption. See https://github.com/infinet/xt_wgobfs/blob/main/README.md for usage.
1 parent 3f52746 commit 9d97a6c

File tree

1 file changed

+74
-0
lines changed

1 file changed

+74
-0
lines changed

net/xtables-wgobfs/Makefile

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#
2+
# Copyright (C) 2022-2025 Wei Chen <weichen302@gmail.com>
3+
#
4+
5+
include $(TOPDIR)/rules.mk
6+
7+
PKG_NAME:=xtables-wgobfs
8+
PKG_VERSION:=0.6.2
9+
PKG_RELEASE:=1
10+
11+
PKG_BUILD_DIR:=$(BUILD_DIR)/xt_wgobfs-$(PKG_VERSION)
12+
PKG_SOURCE:=xt_wgobfs-$(PKG_VERSION).tar.xz
13+
PKG_SOURCE_URL:= https://github.com/infinet/xt_wgobfs/releases/download/v$(PKG_VERSION)/$(PKG_SOURCE)
14+
PKG_HASH:=ba4c410c9dc304360d944249d5314ef4987515de381b1274873f8597928cb67f
15+
16+
PKG_LICENSE:=GPL-2.0-only
17+
PKG_LICENSE_FILES:=COPYING
18+
19+
PKG_BUILD_DEPENDS:=iptables
20+
PKG_BUILD_PARALLEL:=1
21+
PKG_INSTALL:=1
22+
PKG_MAINTAINER:=Wei Chen <weichen302@gmail.com>
23+
24+
include $(INCLUDE_DIR)/kernel.mk
25+
include $(INCLUDE_DIR)/package.mk
26+
27+
define Package/xtables-wgobfs/description
28+
An iptables extension for WireGuard obfuscation
29+
endef
30+
31+
XTLIB_DIR:=/usr/lib/iptables
32+
33+
# uses GNU configure
34+
CONFIGURE_ARGS+= \
35+
--with-kbuild="$(LINUX_DIR)" \
36+
--with-xtlibdir="$(XTLIB_DIR)"
37+
38+
MAKE_FLAGS = \
39+
ARCH="$(LINUX_KARCH)" \
40+
CROSS_COMPILE="$(TARGET_CROSS)" \
41+
DESTDIR="$(PKG_INSTALL_DIR)" \
42+
DEPMOD="/bin/true"
43+
44+
define Build/Install
45+
mkdir -p $(PKG_INSTALL_DIR)/$(XTLIB_DIR)
46+
$(call Build/Install/Default)
47+
endef
48+
49+
define Package/iptables-mod-wgobfs
50+
SECTION:=net
51+
CATEGORY:=Network
52+
SUBMENU:=Firewall
53+
TITLE:=iptables WireGuard obfuscation extension
54+
URL:=https://github.com/infinet/xt_wgobfs
55+
DEPENDS:= +iptables +libxtables +kmod-ipt-wgobfs
56+
endef
57+
58+
define Package/iptables-mod-wgobfs/install
59+
$(INSTALL_DIR) $(1)/$(XTLIB_DIR)
60+
$(CP) \
61+
$(PKG_INSTALL_DIR)/$(XTLIB_DIR)/libxt_WGOBFS.so \
62+
$(1)/$(XTLIB_DIR)
63+
endef
64+
65+
define KernelPackage/ipt-wgobfs
66+
SUBMENU:=Netfilter Extensions
67+
TITLE:=WireGuard obfuscation netfilter module
68+
DEPENDS:=+kmod-ipt-core
69+
FILES:=$(PKG_BUILD_DIR)/src/xt_WGOBFS.$(LINUX_KMOD_SUFFIX)
70+
AUTOLOAD:=$(call AutoProbe,xt_WGOBFS)
71+
endef
72+
73+
$(eval $(call BuildPackage,iptables-mod-wgobfs))
74+
$(eval $(call KernelPackage,ipt-wgobfs))

0 commit comments

Comments
 (0)