Cross compile proxychains for mips router
为路由器交叉编译 proxychains
root@OpenWrt:~# proxychains curl google.com
[proxychains] config file found: /etc/proxychains.conf
[proxychains] preloading /lib/libproxychains4.so
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>302 Moved</TITLE></HEAD><BODY>
<H1>302 Moved</H1>
The document has moved
<A HREF="http://www.google.com.hk/?gfe_rd=cr&amp;ei=D4yfWPr7GZGC8AWtv6fAAw">here</A>.
</BODY></HTML>

首先下载源码,解压

wget https://github.com/haad/proxychains/archive/proxychains-4.2.0.tar.gz
tar zxvf proxychains-4.2.0.tar.gz
cd proxychains-proxychains-4.2.0
root@crazy:/home/src/proxychains-proxychains-4.2.0# ./configure --help
supported arguments
--prefix=/path 		default: /usr/local
--exec_prefix=/path	default: /usr/local/bin
--bindir=/path		default: /usr/local/bin
--libdir=/path		default: /usr/local/lib
--includedir=/path	default: /usr/local/include
--sysconfdir=/path	default: /usr/local/etc
--devel				default:no (set development mode)
--help : show this text

不支持–host,利用export指定cc即可。

export CC=mips-openwrt-linux-uclibc-gcc
root@crazy:/home/src/proxychains-proxychains-4.2.0# make
mips-openwrt-linux-uclibc-gcc -Wall -O2 -g -std=c99 -D_GNU_SOURCE -pipe -DTHREAD_SAFE -Werror    -DLIB_DIR="/usr/local/lib" -DINSTALL_PREFIX="/usr/local" -DDLL_NAME="libproxychains4.so" -DSYSCONFDIR="/usr/local/etc"  -fPIC -c -o src/core.o src/core.c
mips-openwrt-linux-uclibc-gcc -Wall -O2 -g -std=c99 -D_GNU_SOURCE -pipe -DTHREAD_SAFE -Werror    -DLIB_DIR="/usr/local/lib" -DINSTALL_PREFIX="/usr/local" -DDLL_NAME="libproxychains4.so" -DSYSCONFDIR="/usr/local/etc"  -fPIC -c -o src/common.o src/common.c
mips-openwrt-linux-uclibc-gcc -Wall -O2 -g -std=c99 -D_GNU_SOURCE -pipe -DTHREAD_SAFE -Werror    -DLIB_DIR="/usr/local/lib" -DINSTALL_PREFIX="/usr/local" -DDLL_NAME="libproxychains4.so" -DSYSCONFDIR="/usr/local/etc"  -fPIC -c -o src/libproxychains.o src/libproxychains.c
mips-openwrt-linux-uclibc-gcc -shared -fPIC -lpthread   -Wl,-soname=libproxychains4.so -o libproxychains4.so src/core.o src/common.o src/libproxychains.o
mips-openwrt-linux-uclibc-gcc -Wall -O2 -g -std=c99 -D_GNU_SOURCE -pipe -DTHREAD_SAFE -Werror    -DLIB_DIR="/usr/local/lib" -DINSTALL_PREFIX="/usr/local" -DDLL_NAME="libproxychains4.so" -DSYSCONFDIR="/usr/local/etc"  -fPIC -c -o src/main.o src/main.c
mips-openwrt-linux-uclibc-gcc src/main.o src/common.o -o proxychains4

很明显最后一个文件才是我们需要的,复制编译命令,添加-static选项后重新编译。

mips-openwrt-linux-uclibc-gcc src/main.o src/common.o -o proxychains4 -static
root@crazy:/home/src/proxychains-proxychains-4.2.0# file proxychains4
proxychains4: ELF 32-bit MSB executable, MIPS, MIPS32 rel2 version 1, statically linked, not stripped
root@crazy:/home/src/proxychains-proxychains-4.2.0# ll -h proxychains4
-rwxr-xr-x 1 root root 419K Feb 12 05:58 proxychains4*

419kb,strip处理一下

root@crazy:/home/src/proxychains-proxychains-4.2.0# ll -h proxychains4
-rwxr-xr-x 1 root root 62K Feb 12 05:59 proxychains4*

proxychains4复制到路由器 /binlibproxychains4.so 复制到路由器 /lib,在路由器 /etc 下创建proxychains.conf,内容如下:

strict_chain
quiet_mode
proxy_dns
tcp_read_time_out 15000
tcp_connect_time_out 8000
[ProxyList]
socks5 192.168.1.121 1080

即可使用。


最后修改于 Sun, 12 Feb 2017