整理readme

This commit is contained in:
chn 2019-10-18 21:22:41 +08:00
parent 37a5b4c0b2
commit 88d5490824
5 changed files with 102 additions and 88 deletions

View File

@ -2,7 +2,7 @@ include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/kernel.mk
PKG_NAME:=xmurp-ua
PKG_RELEASE:=29
PKG_RELEASE:=30
include $(INCLUDE_DIR)/package.mk

View File

@ -2,7 +2,7 @@ include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/kernel.mk
PKG_NAME:=xmurp-ua
PKG_RELEASE:=27
PKG_RELEASE:=30
include $(INCLUDE_DIR)/package.mk

View File

@ -1,8 +1,10 @@
喵喵喵,这里是一个修改 UA 的小模块。细致地讲,就是用在 OpenWrt 上修改发给外网 80 端口 GET 和 POST 请求的 UA 字段为 `XMURP/1.0` 再加很多个空格的内核模块,用来防止学校检测到使用代理(接路由器)。当然,你改一下 `Makefile`,用到其它 Linux 系统上也是可以的。如果你不了解 OpenWrt 的食用方法或者还是不明白这个插件是用来干什么的的话,又或是不知道怎么编译这个模块,可以看[这里]([https://catalog.chn.moe/%E6%96%87%E7%AB%A0/%E6%95%99%E7%A8%8B/OpenWrt/%E5%9C%A8%E5%8E%A6%E5%A4%A7%E5%AE%BF%E8%88%8D%E5%AE%89%E8%A3%85%E8%B7%AF%E7%94%B1%E5%99%A8.html](https://catalog.chn.moe/文章/教程/OpenWrt/在厦大宿舍安装路由器.html))。
喵喵喵,这里是一个修改 UA 的小模块。细致地讲,就是用在 OpenWrt 上修改发给外网 80 端口 GET 和 POST 请求的 UA 字段为 `XMURP/1.0` 再加很多个空格的内核模块,用来防止学校检测到使用代理(接路由器)。当然,你改一下 `Makefile`,用到其它 Linux 系统上也是可以的。如果你不了解 OpenWrt 的食用方法或者还是不明白这个插件是用来干什么的的话,可以看[这里]([https://catalog.chn.moe/%E6%96%87%E7%AB%A0/%E6%95%99%E7%A8%8B/OpenWrt/%E5%9C%A8%E5%8E%A6%E5%A4%A7%E5%AE%BF%E8%88%8D%E5%AE%89%E8%A3%85%E8%B7%AF%E7%94%B1%E5%99%A8.html](https://catalog.chn.moe/文章/教程/OpenWrt/在厦大宿舍安装路由器.html))。如果你不知道怎么编译,可以把 SDK 发给我我给你编译。如果要自己编译,看[这里](compile.md)。
到现在为止,在 `4.x``3.x` 的内核上好像用得都没问题。
注意,这个模块因为设计上的缺陷,不能修改到所有的 UA只能修改绝大多数的对于厦门大学的情况够用了。
27 及以前的版本会导致路由器随机卡死,注意更新到最新版本。
这个模块因为设计上的缺陷,不能修改到所有的 UA只能修改绝大多数的对于厦门大学的情况够用了。
如果有一些包不希望被改 UA只要在防火墙规则里将 MARK 的第九位设置为 1 就可以了。例如:
@ -21,83 +23,6 @@ iptables -t filter -I FORWARD -p tcp ! --dport 80 -m conntrack --ctstate RELATED
两句的区别的话,大概是前者用硬件,后者用软件。具体的东西我也不熟悉。
---
在老旧版本15.05)上编译时,尝试用 Makefile.cc 替换 Makefile。方法如下
```bash
git clone git@github.com:CHN-beta/xmurp-ua.git package/xmurp-ua
cp package/xmurp-ua/Makefile.cc package/xmurp-ua/Makefile
ln -s ../feeds/base/package/utils package/utils
make defconfig
make package/xmurp-ua/compile V=sc ARCH=mips
```
---
还有人在 LEDE 17.05.5 上编译失败了。所以说,能用新的就用新的,旧的总是会出麻烦的问题。不要听信什么旧的稳定,我不信。
我把编译方法和解决的过程放到这里,供参考。
* 首先当然是正常编译:
```bash
git clone git@github.com:CHN-beta/xmurp-ua.git package/xmurp-ua
make defconfig
make package/xmurp-ua/compile V=sc ARCH=mips CROSS_COMPILE=/home/chn/Desktop/lede-sdk-17.01.5-ar71xx-generic_gcc-5.4.0_musl-1.1.16.Linux-x86_64/staging_dir/toolchain-mips_24kc_gcc-5.4.0_musl-1.1.16/bin/mips-openwrt-linux-musl-
```
* 这时会看到这样的错误:
```bash
.find.bin: loadlocale.c:129: _nl_intern_locale_data: Assertion `cnt < (sizeof (_nl_value_type_LC_TIME) / sizeof (_nl_value_type_LC_TIME[0]))' failed.
.xargs.bin: loadlocale.c:129: _nl_intern_locale_data: Assertion `cnt < (sizeof (_nl_value_type_LC_TIME) / sizeof (_nl_value_type_LC_TIME[0]))' failed.
Aborted (core dumped)
Aborted (core dumped)
MODPOST 0 modules
.find.bin: loadlocale.c:129: _nl_intern_locale_data: Assertion `cnt < (sizeof (_nl_value_type_LC_TIME) / sizeof (_nl_value_type_LC_TIME[0]))' failed.
.xargs.bin: loadlocale.c:129: _nl_intern_locale_data: Assertion `cnt < (sizeof (_nl_value_type_LC_TIME) / sizeof (_nl_value_type_LC_TIME[0]))' failed.
.sed.bin: loadlocale.c:129: _nl_intern_locale_data: Assertion `cnt < (sizeof (_nl_value_type_LC_TIME) / sizeof (_nl_value_type_LC_TIME[0]))' failed.
Aborted (core dumped)
Aborted (core dumped)
Aborted (core dumped)
```
`.xargs.bin` 为例子。
```bash
find | grep .xargs.bin
```
得到
```bash
./staging_dir/host/bin/.xargs.bin
```
看看这个目录里的内容
```bash
ls staging_dir/host/bin
```
所以,这个目录里准备的就是一些宿主机上常用的命令,都是几年前的玩意儿,当时准备的 `find` 等工具放到现在的电脑上闪退了(如果是老系统的话,说不定还能用)。
* 解决办法就是,用自己电脑上的工具来替换这些老旧的东西。
```bash
rm -r staging_dir/host/bin
ln -s /usr/bin staging_dir/host/
```
* 然后把原来编译一半的删掉,重新编译。
```bash
rm -r build_dir/target-mips_24kc_musl-1.1.16/linux-ar71xx_generic/xmurp-ua
make package/xmurp-ua/compile V=sc ARCH=mips CROSS_COMPILE=/home/chn/Desktop/lede-sdk-17.01.5-ar71xx-generic_gcc-5.4.0_musl-1.1.16.Linux-x86_64/staging_dir/toolchain-mips_24kc_gcc-5.4.0_musl-1.1.16/bin/mips-openwrt-linux-musl-
```
---
有人问我为啥不能编译个二进制文件放出来,因为这是内核模块啊,和大多的 OpenWrt 模块是不一样的,要和内核版本(精确到 commit id严格对应。至于为啥要写到内核里是历史原因最开始我想修改 ipid这当然在内核里更方便后来又想改 ua就继续写在内核里了。最开始的功能还很简单后来代码一点点变复杂了我也后悔开始时写到内核里了。

94
compile.md Normal file
View File

@ -0,0 +1,94 @@
以下,我假定你至少稍有一点命令行基础,搞不清当前目录或者 `cp`、`rm` 都不会用的话,自己找资料。
#### 一般的编译方法
对于 18.06 以上的 SDK照这个方法就行了。
* 在电脑上安装一个 64 位的 Linux 系统。安装成虚拟机或双系统都可以。嫌麻烦的话,推荐使用 Win10 的 Ubuntu 子系统WSL。如果想要顺便体验实体机强烈推荐 deepin。我使用的是 kubuntu 19.10。
* 安装编译依赖项。
```bash
sudo apt-get update && sudo apt-get install git-core build-essential libssl-dev libncurses5-dev unzip gawk subversion mercurial ccache tar ssh
```
记得开代理,或者换源。
* 准备 SDK。
必须使用与镜像完全对应的 SDK而不能只是架构相同或者内核版本前三位相同。
官方 OpenWrt 的 SDK 和固件放在同一个目录下。比如WNDR4300 的固件下载地址为:
```
http://downloads.openwrt.org/releases/18.06.1/targets/ar71xx/nand/openwrt-18.06.1-ar71xx-nand-wndr4300-ubi-factory.img
```
打开网站:
```
http://downloads.openwrt.org/releases/18.06.1/targets/ar71xx/nand/
```
就可以找到对应 SDK 的下载地址。
下载好 SDK 后,放到用户目录下,解压 SDK 并进入。
```bash
cd ~ && tar xvf openwrt-sdk*.tar.xz && cd openwrt-sdk*
```
(如果使用 WSL可以将 SDK 放到 C 盘根目录,然后使用命令 `cd ~ && cp /mnt/c/*.tar.xz .` 将它复制到 WSL 中。)
* 下载 `xmurp-ua` 的源代码,并编译。
```bash
git clone https://github.com/CHN-beta/xmurp-ua.git package/xmurp-ua
make defconfig
make package/xmurp-ua/compile V=sc
```
编译好的包在 `bin` 中。
#### 增加编译参数
对于 18.06 以前的 SDK编译的时候需要手动指定一些参数。参考[这篇文章](https://blog.csdn.net/wr132/article/details/78946200)。按照我的经验,一般来说,指定 `ARCH``CROSS-COMPILE` 就足够了。例如:
```bash
make package/xmurp-ua/compile V=sc ARCH=mips CROSS_COMPILE=/home/chn/Desktop/lede-sdk-17.01.5-ar71xx-generic_gcc-5.4.0_musl-1.1.16.Linux-x86_64/staging_dir/toolchain-mips_24kc_gcc-5.4.0_musl-1.1.16/bin/mips-openwrt-linux-musl-
```
#### 使用旧版 Makefile
对于 Openwrt 15.05Chaos CalmerMakefile 的格式与最新版本不同。使用 `Makefile.cc` 代替 `Makefile` 再编译。
```bash
cp package/xmurp-ua/Makefile.cc package/xmurp-ua/Makefile
```
#### 失效的 host 命令
我还遇到过这样的情况:
```
.find.bin: loadlocale.c:129: _nl_intern_locale_data: Assertion `cnt < (sizeof (_nl_value_type_LC_TIME) / sizeof (_nl_value_type_LC_TIME[0]))' failed.
.xargs.bin: loadlocale.c:129: _nl_intern_locale_data: Assertion `cnt < (sizeof (_nl_value_type_LC_TIME) / sizeof (_nl_value_type_LC_TIME[0]))' failed.
Aborted (core dumped)
Aborted (core dumped)
MODPOST 0 modules
.find.bin: loadlocale.c:129: _nl_intern_locale_data: Assertion `cnt < (sizeof (_nl_value_type_LC_TIME) / sizeof (_nl_value_type_LC_TIME[0]))' failed.
.xargs.bin: loadlocale.c:129: _nl_intern_locale_data: Assertion `cnt < (sizeof (_nl_value_type_LC_TIME) / sizeof (_nl_value_type_LC_TIME[0]))' failed.
.sed.bin: loadlocale.c:129: _nl_intern_locale_data: Assertion `cnt < (sizeof (_nl_value_type_LC_TIME) / sizeof (_nl_value_type_LC_TIME[0]))' failed.
Aborted (core dumped)
Aborted (core dumped)
Aborted (core dumped)
```
解决办法就是,用自己电脑上的来替换 SDK 里给的那些命令,然后重新编译。
```bash
rm -r staging_dir/host/bin
ln -s /usr/bin staging_dir/host/
rm -r build_dir/target-mips_24kc_musl-1.1.16/linux-ar71xx_generic/xmurp-ua
make package/xmurp-ua/compile V=sc ARCH=mips CROSS_COMPILE=/home/chn/Desktop/lede-sdk-17.01.5-ar71xx-generic_gcc-5.4.0_musl-1.1.16.Linux-x86_64/staging_dirtoolchain-mips_24kc_gcc-5.4.0_musl-1.1.16/bin/mips-openwrt-linux-musl-
```

View File

@ -148,7 +148,7 @@ unsigned int hook_funcion(void *priv, struct sk_buff *skb, const struct nf_hook_
static u_int16_t sport, dport;
static u_int32_t n_ua_modified = 0, n_ua_modify_faild = 0, n_not_modifible = 0, n_mark_matched = 0;
static u_int32_t n_ua_modified_lastprint = 1, n_not_modifible_lastprint = 1;
static u_int32_t n_ua_modified_lastprint = 1;
static u_int8_t mark_matched = 0;
register u_int8_t jump_to_next_function = 0, ret;
@ -173,7 +173,7 @@ unsigned int hook_funcion(void *priv, struct sk_buff *skb, const struct nf_hook_
if(!mark_matched)
{
mark_matched = 1;
printk("xmurp-ua: Mark matched. Note that all packages with the mark will be ACCEPT without modify.\n");
printk("xmurp-ua: Mark matched. Note that all packages with the mark will be ACCEPT without modification.\n");
printk("xmurp-ua: If the mark is not set manually, it maybe a conflict there. "
"Find out which app is using the desired bit and let it use others, or modify and recompile me.\n");
}
@ -203,11 +203,6 @@ unsigned int hook_funcion(void *priv, struct sk_buff *skb, const struct nf_hook_
if(skb_ensure_writable(skb, (char*)data_end - (char*)skb -> data))
{
n_not_modifible++;
if(n_not_modifible == 2 * n_not_modifible_lastprint)
{
printk("xmurp-ua: There are %u packages not modifiable.\n", n_ua_modified);
n_ua_modified_lastprint *= 2;
}
n_ua_modify_faild++;
catch_next_frag = 0;
return NF_ACCEPT;