GithubHelp home page GithubHelp logo

zxilly / ua2f Goto Github PK

View Code? Open in Web Editor NEW
326.0 5.0 72.0 906 KB

Change User-Agent to F-words on OpenWRT router to prevent being detected.

Home Page: https://learningman.top/archives/304

License: GNU General Public License v3.0

CMake 2.52% C 89.94% Makefile 1.53% Shell 4.31% C++ 1.70%

ua2f's Introduction

UA2F

CodeQL Build OpenWRT Package

参照 博客文章 完成操作

如果遇到了任何问题,欢迎提出 Issues,但是更欢迎直接提交 Pull Request

由于新加入的 CONNMARK 影响,编译内核时需要添加 NETFILTER_NETLINK_GLUE_CT flag

uci command

# 启用 UA2F
uci set ua2f.enabled.enabled=1

# 可选的防火墙配置选项
# 是否自动添加防火墙规则
uci set ua2f.firewall.handle_fw=1

# 是否尝试处理 443 端口的流量, 通常来说,流经 443 端口的流量是加密的,因此无需处理
uci set ua2f.firewall.handle_tls=1

# 是否处理微信的流量,微信的流量通常是加密的,因此无需处理。这一规则在启用 nftables 时无效
uci set ua2f.firewall.handle_mmtls=1

# 是否处理内网流量,如果你的路由器是在内网中,且你想要处理内网中的流量,那么请启用这一选项
uci set ua2f.firewall.handle_intranet=1

# 使用自定义 User-Agent
uci set ua2f.main.custom_ua="Test UA/1.0"

# 应用配置
uci commit ua2f

# 开机自启
service ua2f enable

# 启动 UA2F
service ua2f start

自定义 User-Agent

集成到二进制

make menuconfig 后,使用 option 设置

image

UA2F_CUSTOM_UA 的值必须是一个字符串,且长度不超过 (65535 + (MNL_SOCKET_BUFFER_SIZE / 2)) 字节。 MNL_SOCKET_BUFFER_SIZE 的值通常为 8192。

使用 uci 设置

uci set ua2f.main.custom_ua="Test UA/1.0"
uci commit ua2f

UA2F 不会修改包的大小,因此即使自定义了 User-Agent, 运行时实际的 User-Agent 会是一个从 custom ua 中截取的长度与原始 User-Agent 相同的子串,长度不足时会在末尾补空格。

在非 OpenWRT 系统上运行

v4.5.0 起,UA2F 支持在非 OpenWRT 系统上运行,但是需要手动配置防火墙规则,将需要处理的流量转发到 netfilter-queue 的 10010 队列中。

编译时,需要添加 -DUA2F_ENABLE_UCI=OFF flag 至 CMake。

TODO

  • pthread 支持,由不同线程完成入队出队
  • 重写正则匹配为 parser
  • 以连接为单位维护 parser 状态

License

GPL-3.0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.