Pages

Thursday, 1 March 2012

iOS设备设定3proxy和ssh -D以翻墙

需要一台越狱了iOS设备,部骤如是:

1.Cydia安装3proxy
2.新增3proxy.cfg文件到/etc ; 输入命令 nano /etc/3proxy.cfg 注意nano是命令行文本编辑器,可在Cydia安装,
   3proxy.cfg 内容如是

程序代码:

#! /usr/bin/3proxy
daemon
auth iponly
log /var/log/3proxy.log D
rotate 5
fakeresolve
internal 127.0.0.1
allow * 127.0.0.1 *
parent 1000 socks5+ 127.0.0.1 7070
proxy -a -p1080 -i127.0.0.1


chmod +x /etc/3proxy.cfg , 这是把Socks5代理转化为Http代理, 但每次要在终端输入 ssh -NfD 7070 user@host -p 22
再输入密码,执行 /etc/3proxy.cfg 一堆命令,免麻烦,简单写个脚本执行和停止,如是

程序代码:
#! /bin/bash
# $PN: gfw.sh Usage: gfw.sh [start|stop]
Usage="${0##*/} start|stop"
if [ $# -ne 1 ] ; then
  echo "$Usage" >&2 ; exit 5
fi

case "$1" in
  start) /etc/3proxy.cfg ; ssh -NfD 7070 user@host -p 22 ;; #change here for user,host and remote port if need
   stop) ssh_pid=$(ps ux | grep 'ssh -NfD' | grep -v grep | awk '{print $2}') ;
         proxy_pid=$(ps ux | grep '3proxy' | grep -v grep | awk '{print $2}') ;
         if [ -z "$ssh_pid" ]  ; then
            echo "ssh port forword is not running." >&2
            exit 6
         fi
         if [ -z "$proxy_pid" ] ; then
            echo "3proxy is not running" >&2
            exit 7
         fi
         if kill "$ssh_pid" "$proxy_pid" ; then
            echo "Proxy service is  stopped."
         fi
         ;;
      *) echo "$Usage" >&2 ; exit 5 ;;
esac
exit 0


只需输入密码即完成运行代理,如果SSH主机支援公/私钥匙,就不需要每次输入密码,因为sshpass -p "密码" ssh -NfD 7070 user@host -p ssh主机端口 不能生效,iOS没有expect ,还是要每次输入密码,暂时找不到方法.

以iPad2 wifi 为例,执行 ./gfw.sh start 启动代理後,只需在"设定" -> "Wi-Fi" -> "HTTP代理服务器" -> "手动"
在"伺服器"输入: 127.0.0.1 端口: 1080 就可全局代理翻墙

如需停止代理服务,输入: ./gfw.sh stop

FROM https://cmded.net/forum/index.php?topic=5642.0

No comments:

Post a Comment