Skip to content

Commit

Permalink
update: start shell file
Browse files Browse the repository at this point in the history
  • Loading branch information
huhu415 committed Oct 16, 2024
1 parent 77ecfb3 commit ed790d7
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 13 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ $RECYCLE.BIN/
.Trashes

# Project
*.csv
.idea
docker-compose.yml
uaProxy
Expand Down
5 changes: 3 additions & 2 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ archives:
files:
- LICENSE
- README.md
- FAQ.md
- assets/FAQ.md
- assets/uaProxy-openwrt
checksum:
name_template: "checksums.txt"

Expand All @@ -73,4 +74,4 @@ release:
```
footer: |
**[FAQ](FAQ.md)**
**[FAQ](assets/FAQ.md)**
35 changes: 24 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

利用clash, v2ray的方案(iptables-redir)实现对所有流量的监控,
找出http流量后, 修改其中的`User-Agent`字段, 从而实现对所有http流量的`User-Agent`修改.
![uaProxy](uaProxy.png)
![uaProxy](assets/uaProxy.png)

## 代码思路
流量分为http和非http两种, 非http流量直接转发, http流量则可以通过看前几个字节判断是否是http流量.
Expand All @@ -19,19 +19,32 @@ iptables -t nat -N uaProxy # 新建一个名为 uaProxy 的链
iptables -t nat -A uaProxy -d 192.168.0.0/16 -j RETURN # 直连 192.168.0.0/16
iptables -t nat -A uaProxy -p tcp -j RETURN -m mark --mark 0xff
# 直连 SO_MARK 为 0xff 的流量(0xff 是 16 进制数,数值上等同与上面配置的 255),此规则目的是避免代理本机(网关)流量出现回环问题
iptables -t nat -A uaProxy -p tcp -j REDIRECT --to-ports 12345 # 其余流量转发到 12345 端口(即 uaProxy开启的redir-port)
iptables -t nat -A uaProxy -p tcp -j REDIRECT --to-ports 12345 # 其余流量转发到 12345 端口(即 uaProxy默认开启的redir-port)
iptables -t nat -A PREROUTING -p tcp -j uaProxy # 对局域网其他设备进行透明代理
iptables -t nat -A OUTPUT -p tcp -j uaProxy # 对本机进行透明代理
iptables -t nat -A OUTPUT -p tcp -j uaProxy # 对本机进行透明代理, 可以不加
```

3. 运行uaProxy(建议uaProxy和config.yaml在一个文件夹下面)
```sh
./uaProxy &
```
> ‼️注意, 因为是利用了iptables的REDIRECT功能, 所以不能和clash, v2ray等软件同时使用, 会有冲突.
3. 运行uaProxy (所有linux都可以用, 这里详细讲openWrt)
- 脚本
1. 执行``
- 手动
- 下载[相应](https://github.com/huhu415/uaProxy/releases)的压缩包, 解压后
- 把可执行程序放到`/usr/sbin`目录里面
-[脚本文件](assets/uaProxy-openwrt)放到`/etc/init.d`目录里面
- 执行`chmod +x /etc/init.d/uaProxy-openwrt`, 赋予执行权限
- 执行`/etc/init.d/uaProxy-openwrt enable`, 开机自启
- 执行`/etc/init.d/uaProxy-openwrt start`, 启动服务
- (可选)执行`logread | grep uaProxy` 查看日志; 同时也可以登陆web页面, 在`状态-系统日志`里面看

### 参数说明:
`--stats` 开启统计信息
- 不开启(默认): 修改所有`http`流量的`UA`为统一字段.
- 开启: 在可执行程序同目录下生成一个`stats-config.csv`文件, 里面记录了不同`User-Agent`字段的访问次数.
- 如果记录项有`**uaProxy**`前缀, 代表已经检测到特征, 会被修改为统一的UA字段; 否则不会修改.
- 建议只有在普通模式有问题时, 再开启统计模式, 以免影响性能和反检测效果.

> 但这样做也更纯净, 性能最快, 我觉得应该是这个需求的最佳实现方案了.

------------------------------------------
> ‼️注意, 因为是利用了iptables的REDIRECT功能, 所以不能和clash, v2ray等软件同时使用, 会有冲突.
> 但这样做也更纯净, 性能最快, 我觉得应该是这个需求的最佳实现方案了.
[FAQ](FAQ.md)
[FAQ](assets/FAQ.md)
File renamed without changes.
16 changes: 16 additions & 0 deletions assets/uaProxy-openwrt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/sh /etc/rc.common
# Copyright (C) 2018 Onion Corporation
START=90
USE_PROCD=1

PROG="uaProxy"

start_service() {
procd_open_instance
procd_set_param command $PROG
# procd_append_param command --stats
procd_set_param respawn # respawn the service if it exits
procd_set_param stdout 1 # forward stdout of the command to logd
procd_set_param stderr 1 # same for stderr
procd_close_instance
}
File renamed without changes

0 comments on commit ed790d7

Please sign in to comment.