前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Ubuntu安装Proxychains

Ubuntu安装Proxychains

作者头像
drunkdream
发布2018-07-06 18:09:40
12.5K0
发布2018-07-06 18:09:40
举报
文章被收录于专栏:醉梦轩醉梦轩

Proxychains是Linux上一款全局代理工具,通过Hook Socket函数实现透明代理,这和Windows上的Proxifier有点类似。 在Ubuntu上安装Proxychains的方法是:

apt-get install proxychains

安装的是3.1版本,配置文件的路径是:/etc/proxychains.conf,内容如下:

代码语言:javascript
复制
# proxychains.conf  VER 3.1
#
#        HTTP, SOCKS4, SOCKS5 tunneling proxifier with DNS.
#

# The option below identifies how the ProxyList is treated.
# only one option should be uncommented at time,
# otherwise the last appearing option will be accepted
#
#dynamic_chain
#
# Dynamic - Each connection will be done via chained proxies
# all proxies chained in the order as they appear in the list
# at least one proxy must be online to play in chain
# (dead proxies are skipped)
# otherwise EINTR is returned to the app
#
strict_chain
#
# Strict - Each connection will be done via chained proxies
# all proxies chained in the order as they appear in the list
# all proxies must be online to play in chain
# otherwise EINTR is returned to the app
#
#random_chain
#
# Random - Each connection will be done via random proxy
# (or proxy chain, see  chain_len) from the list.
# this option is good to test your IDS :)

# Make sense only if random_chain
#chain_len = 2

# Quiet mode (no output from library)
#quiet_mode

# Proxy DNS requests - no leak for DNS data
proxy_dns 

# Some timeouts in milliseconds
tcp_read_time_out 15000
tcp_connect_time_out 8000

# ProxyList format
#       type  host  port [user pass]
#       (values separated by 'tab' or 'blank')
#
#
#        Examples:
#
#               socks5  192.168.67.78   1080    lamer   secret
#               http    192.168.89.3    8080    justu   hidden
#               socks4  192.168.1.49    1080
#               http    192.168.39.93   8080
#
#
#       proxy types: http, socks4, socks5
#        ( auth types supported: "basic"-http  "user/pass"-socks )
#
[ProxyList]
# add proxy here ...
# meanwile
# defaults set to "tor"
socks4         127.0.0.1 9050

Proxychains支持HTTP(HTTP-Connect)、SOCKS4和SOCKS5三种类型的代理,需要注意的是:配置代理服务器只能使用ip地址,不能使用域名,否则会连不上。

Proxychains支持3种模式:

  1. 动态模式 按照配置的代理顺序连接,不存活的代理服务器会被跳过
  2. 严格模式 按照配置的代理顺序连接,必须保证所有代理服务器都是存活的,否则会连接失败
  3. 随机模式 随机选择一台代理服务器连接,也可以使用代理链

如果不需要代理DNS的话,可以注释掉proxy_dns这行。

使用的时候在命令行前加上proxychains即可。

root@ubuntu-pc:~# proxychains telnet www.baidu.com 80 ProxyChains-3.1 (http://proxychains.sf.net) Trying 14.215.177.37… |R-chain|-<>-10.0.0.10:8080-<><>-14.215.177.37:80-<><>-OK Connected to www.a.shifen.com. Escape character is ‘^]’.

proxychains命令其实是个脚本文件,内容如下:

代码语言:javascript
复制
#!/bin/sh
echo "ProxyChains-3.1 (http://proxychains.sf.net)"
if [ $# = 0 ] ; then
        echo "  usage:"
        echo "          proxychains <prog> [args]"
        exit
fi
export LD_PRELOAD=libproxychains.so.3
exec "$@"

它的目的是设置LD_PRELOAD环境变量,以便创建的新进程会加载libproxychains.so.3,这个so的作用是Hook Socket函数。因此,也可以在当前shell中执行:

代码语言:javascript
复制
export LD_PRELOAD=libproxychains.so.3

这样之后执行的命令都会使用代理访问。

不过这个版本有个问题,配置代理后所有的连接都会走代理,包括对回环地址的访问。这并不是我们所期望的,幸好有个版本提供了解决方案。

git clone https://github.com/rofl0r/proxychains cd proxychains ./configure make make install

安装后在配置文件中加入:

localnet 127.0.0.0/255.0.0.0

安装后的命令是proxychains4,因此可以和旧版本命令并存。这样对于回环地址就可以绕过代理,使用直连了。

相对于Proxifier而言,这种方式还是弱了一点,毕竟有时候我们还是需要根据不同的情况使用不同的代理服务器。

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2017-02-24,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档