Page 1 of 2

ProxHTTPSProxy: Proxomitron SSL 助手

Posted: Jun 10 2010, 11:30
by phoenix
这是我用 Python 写的一个代理服务器程序,主要用来解决 Proxomitron 的 SSL 问题

工作原理

- 对 https 请求,返回 "307 Moved Temporarily",将 https 请求变形为 http 格式放在 "Location" header 中。目的是将浏览器从 https 模式切换到 http 模式。

- 对 http 请求,本代理服务器将其还原为 https 请求,获取 https 内容,解密后传递给浏览器。代理服务器和远端服务器的通讯是 https 加密的,而和浏览器的通讯是 http 明文的。这样, Proxomitron 就可以对明文内容进行过滤。

安装

- 从 http://www.python.org/download/ 下载安装 Python 2.x 分支 (或许需要翻墙,感谢郭嘉)
- 从 http://www.slproweb.com/products/Win32OpenSSL.html 下载安装 OpenSSL
- 解压缩附件,执行 ProxHTTPSProxy.py

ProxHTTPSProxy 最初只能作为 Proxomitron 的上级代理来工作。经过改进,现在的版本也可以脱离 Proxomitron 单独使用。本程序支持 http 和 socks5 类型的上级代理, 以及 http 头信息显示。运行选项请参考 config.py 文件。

配合 Proxomitron 使用

很简单,对于想要过滤的 https 网页,将 ProxHTTPSProxy 设为 Proxomitron 的上级代理。注意 https 和 http 请求都需要转发给 ProxHTTPSProxy。别忘了先要将 ProxHTTPSProxy 添加到 Proxomitron 的代理列表里: http://www.proxomitron.cn/help/External ... ialog.html

下面以 sidki 的配置包为例,演示如何修改 Exceptions-U.ptxt 文件。

- 如果想过滤所有 https 网页, 请将浏览器的 https 代理设置为 ProxHTTPSProxy,做如下修改:

Code: Select all

# ProxHTTPSProxy
[^/]++:443&$URL(http://*) $SET(0=i_proxy:3.) $SETPROXY(127.0.0.1:8081)
- 如果只想过滤某些 https 网页,做如下修改:

Code: Select all

# ProxHTTPSProxy
# Add specific URLs like below
ssl.scroogle.org:         $SET(0=i_proxy:3.) $SETPROXY(127.0.0.1:8081)
(可选): 由于我们不再使用 Proxomitron 的 SSL dll 进行 https 过滤,可以在 Proxomitron 的 config settings 中取消 https 的设定。

如果不打算安装 python,可以选择安装 exe 版本: http://proxfilter.net/ProxHTTPSProxy.zip

Re: ProxHTTPSProxy: Proxomitron SSL 助手

Posted: Jun 10 2010, 20:32
by red
用起来没发现啥问题,很正常。除了以前已知的在https和http之间一直跳转,比如 https://mail.qq.comhttps://sourceforge.net
想过滤所有 https 网页,sidki似乎应该是这样

Code: Select all

# ProxHTTPSProxy
[^/]++:443  $SET(0=i_proxy:3.) $SETPROXY(127.0.0.1:8081)

Code: Select all

[^/]++:443&$URL(http://*)
的形式我这里不成功

Re: ProxHTTPSProxy: Proxomitron SSL 助手

Posted: Jun 10 2010, 22:45
by phoenix
red wrote:用起来没发现啥问题,很正常。除了以前已知的在https和http之间一直跳转,比如 https://mail.qq.com 和 https://sourceforge.net
https://sourceforge.net 我这里自动跳转到 http 版本,加载正常。

https://mail.qq.com 是页面中有 script 检测协议,可以自行过滤,不是 ProxHTTPSProxy 的问题。

Code: Select all

<script>if(location.protocol=="http:"){location.href="https://mail.qq.com";}</script>
red wrote: 想过滤所有 https 网页,sidki似乎应该是这样

Code: Select all

# ProxHTTPSProxy
[^/]++:443  $SET(0=i_proxy:3.) $SETPROXY(127.0.0.1:8081)

Code: Select all

[^/]++:443&$URL(http://*)
的形式我这里不成功
请仔细看首帖,加 &$URL(http://*) 的话要把浏览器的 https 代理设为 ProxHTTPSProxy 。如果你设到 Proxomitron ,就用你说的那种形式。

Re: ProxHTTPSProxy: Proxomitron SSL 助手

Posted: Jul 09 2010, 22:58
by liumailong
不用 sidki 配置包,如何使用?

Re: ProxHTTPSProxy: Proxomitron SSL 助手

Posted: Jul 13 2010, 16:30
by phoenix

Re: ProxHTTPSProxy: Proxomitron SSL 助手

Posted: Mar 02 2011, 20:11
by liuxb
有一个vBulletin的论坛不能登录,输入id密码登录以后,提示 "In order to accept POST request originating from this domain, the admin must add this domain to the whitelist."

log如下:

Code: Select all

+++GET 1077+++
Using Proxy - 127.0.0.1:8081
POST http://bbs.et8.net:443/bbs/login.php?do=login HTTP/1.1
Host: bbs.et8.net:443
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:2.0) Gecko/20100710 Firefox/4.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: zh-cn,zh;q=0.8,en-us;q=0.6,en;q=0.4,zh-tw;q=0.2
Accept-Encoding: gzip, deflate
Accept-Charset: x-gbk,utf-8;q=0.7,*;q=0.7
Keep-Alive: 115
DNT: 1
Referer: http://bbs.et8.net:443/bbs/forumdisplay.php?f=17
Cookie: OAID=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx(这个我编辑了)
Content-Type: application/x-www-form-urlencoded
Content-Length: 172
Connection: keep-alive
Posting 172 bytes...
RESP 1077 : Vary killed: Accept-Encoding

+++RESP 1077+++
HTTP/1.1 200 OK
Server: Zeus/4.3
Date: Wed, 02 Mar 2011 12:00:41 GMT
Content-Type: text/html; charset=utf8
Connection: close
Content-Encoding: gzip
Cache-Control: max-age=1
+++CLOSE 1077+++

Re: ProxHTTPSProxy: Proxomitron SSL 助手

Posted: Mar 10 2011, 20:03
by red
ph,能否给出打包exe的脚本,py2exe的setup.py还真麻烦,如下的写法会生成一堆文件

Code: Select all

#! /usr/bin/env python
# coding=utf-8

from distutils.core import setup
import py2exe

setup(
    options = {"py2exe": 
        {
          "skip_archive": ["config.py"],
        }
    },

    console=['ProxHTTPSProxy.py'],
    data_files =['config.py']
)

Re: ProxHTTPSProxy: Proxomitron SSL 助手

Posted: Mar 17 2011, 16:44
by phoenix
liuxb wrote:有一个vBulletin的论坛不能登录,输入id密码登录以后,提示 "In order to accept POST request originating from this domain, the admin must add this domain to the whitelist."
不知道是不是服务器检查 Referer 的问题,你试试用 Proxomitron 把 Referer 去掉。
red wrote:ph,能否给出打包exe的脚本
我是用 cx_Freeze 打包的。

Re: ProxHTTPSProxy: Proxomitron SSL 助手

Posted: May 28 2014, 11:12
by phoenix
打算写一个新版本。 :D
ProxHTTPSProxy.png
ProxHTTPSProxy.png (30.16 KiB) Viewed 91013 times

Re: ProxHTTPSProxy: Proxomitron SSL 助手

Posted: May 29 2014, 10:34
by phoenix
0.5 版本供测试 :lol:
  • Install the latest Python 3.x https://www.python.org/download/
  • Install the latest OpenSSL from http://www.slproweb.com/products/Win32OpenSSL.html
  • Install pyOpenSSL

    Code: Select all

    c:\Python34\Scripts>pip install pyopenssl
  • Import "CA.crt " to your browser's trusted certificate authorities
  • Point browser's https proxy to front server's port (default 8079)
  • Set Proxomitron's parent proxy to rear server (default 8081) for tagged connections

    Code: Select all

    Exceptions-U.ptxt:
    $OHDR(Tagged:Proxomitron FrontProxy/*)		$SET(0=i_proxy:3.) $SETPROXY(127.0.0.1:8081)