将 HTTP 请求转换为 SOCKS5

Dus*_*tin 54 proxy http tor socks

我目前正在使用 TOR 进行一些测试工作,但遇到了一个小问题。Tor 的客户端仅支持通过 SOCKS5 协议接收连接,但我使用的应用程序仅支持 HTTP 代理协议。

中间可以放东西吗?因此,例如它去了。

我的程序(仅限 HTTP)> HTTP 到 SOCKS 转换器 > Tor SOCKS5 服务器

mgo*_*ven 46

看起来DeleGate可以做到这一点,如下所示(其中 DeleGate 将接受端口 8080 上的 HTTP 连接并转发到端口 9050 上的 SOCKS 服务器):

delegated -P8080 SERVER=http SOCKS=localhost:9050
Run Code Online (Sandbox Code Playgroud)

  • @pradeepchhetri 在玩了一天的 `delegate(d)` 后,我得出结论,尽管配置文档中有多个相反的声明,但它绝对确定要泄漏 DNS 请求。我很想发现我在这一点上是错的,但我在这一点上很悲观。 (2认同)
  • delegate.org 似乎已关闭,有其他选择吗? (2认同)

小智 16

您也可以使用Privoxy。将此行添加到其config.txt文件中:

forward-socks5 / 127.0.0.1:9050 .
Run Code Online (Sandbox Code Playgroud)

(不要忘记末尾的小点。)

然后在以下位置使用 HTTP 或 HTTPS 代理 127.0.0.1:8118


小智 11

Tor 包不再有 polipo,这是来自官方 Tor 常见问题解答

过去,Tor 捆绑包包含一个 HTTP 代理,如 Privoxy 或 Polipo,仅用于解决 Firefox 中最终在 Firefox 6 中修复的错误。现在您不需要单独的 HTTP 代理来使用 Tor,实际上保留它out 让您更安全,因为 Torbutton 可以更好地控制 Firefox 与网站的交互。

如果您尝试将某些外部应用程序与 Tor 一起使用,则第 0 步应该是重新阅读警告集以了解您可能会搞砸的方法。第一步应该是尝试使用 Socks 代理而不是 http 代理——Tor 在 Windows 上的端口 9050 上运行 Socks 代理,或者参见上面 的 OSX 和 Linux。

如果失败,请随意安装privoxy。但是,请注意,不建议新手用户使用这种方法。Privoxy 有Tor 和 Privoxy的示例配置。


小智 11

Socks5 的 HTTP 代理

安装python 代理

$ pip3 install pproxy
$ pproxy -r socks5://127.0.0.1:9150 -vv
Run Code Online (Sandbox Code Playgroud)

用法

http://127.0.0.1:8080
https://127.0.0.1:8080
Run Code Online (Sandbox Code Playgroud)


Bob*_*Bob 5

您没有指定操作系统。以后请这样做。


这个答案推荐 Polipo,它包含在 Tor 项目托管的 Vidalia 包中,因此他们可能推荐用于 Windows。Polipo 也有一个 *nix 版本(最初是为 *nix 设计的),所以我已经包含了如何设置它的说明 - 请参阅下面的第二部分。如果重要的话,这是一个相当轻量级的解决方案。


视窗

下载 Vidalia 捆绑包。它包括 Vidalia GUI 和一个名为 Polipo 的程序,以及 Tor。在捆绑包中,Polipo 默认在端口 8118 上运行 HTTP 代理,该代理通过端口 9050 上的 Tor SOCKS 代理重定向。

高级设置

也可以手动配置 Polipo,无需 Vidalia 捆绑包。

取自http://www.pps.jussieu.fr/~jch/software/polipo/tor.html

他们还提供您应该下载的二进制文件。

配置

Polipo 是通过在 Polipo 的配置文件中设置多个配置变量来配置的,该文件是一个纯文本文件。为了告诉 Polipo 使用 tor 而不是在磁盘上缓存任何获取的页面,您需要将以下行添加到您的配置文件中:

socksParentProxy = localhost:9050
diskCacheRoot=""
Run Code Online (Sandbox Code Playgroud)

您还需要禁用本地配置界面以保护自己免受浏览器漏洞的影响:

disableLocalInterface=true
Run Code Online (Sandbox Code Playgroud)

运行它

运行 Polipo 时,您应该使用 Polipo 命令行上的 -c 标志指定配置文件的位置:

> polipo.exe -c "/Program Files/Polipo/config.txt"
Run Code Online (Sandbox Code Playgroud)

请注意,即使在 Windows 下,您也必须使用 Unix 语法作为文件名(使用正斜杠),并且您不能指定要使用的设备(“驱动器”)。

Polipo 默认监听端口是 8123。

Vidalia 捆绑包中的默认配置包含在此答案的底部。


*尼克斯

包括 Linux、Unix、BSD、OS X、大多数非基于 NT (Windows) 的现代 (2012) 操作系统。

再次取自http://www.pps.jussieu.fr/~jch/software/polipo/tor.html

从您使用的任何存储库下载包。谷歌可能会在这里提供帮助。或者,可以下载直接二进制文件。

配置

Polipo 是通过在 Polipo 的配置文件中设置多个配置变量来配置的,该文件为~/.polipo/etc/polipo/config,以存在者为准。为了告诉 Polipo 使用 tor 而不是在磁盘上缓存任何获取的页面,您需要将以下行添加到您的配置文件中:

socksParentProxy = localhost:9050
diskCacheRoot=""
Run Code Online (Sandbox Code Playgroud)

您还需要禁用本地配置界面以保护自己免受浏览器漏洞的影响:

disableLocalInterface=true
Run Code Online (Sandbox Code Playgroud)

如果要为配置文件指定不同的位置,可以使用 Polipo 命令行上的 -c 标志来指定它。

请注意,如果您从发行版提供的二进制文件安装 Polipo,它可能不会考虑 ~/.polipo — 您需要编辑 /etc/polipo/config。

运行它

如果您从分发提供的软件包安装 Polipo,则 Polipo 可能已经在运行;您将需要重新启动它,以便将其新配置考虑在内。否则,只需获取一个免费的终端窗​​口并输入:

$ polipo
Run Code Online (Sandbox Code Playgroud)

如果您对 Polipo 的配置文件使用非标准位置,请在命令行中指定它,例如:

$ polipo -c "/Program Files/Polipo/config.txt"
Run Code Online (Sandbox Code Playgroud)

Polipo 默认监听端口是 8123。

Vidalia 捆绑包中的默认配置包含在此答案的底部。


默认 Polipo 配置(Vidalia 包)

这是 Windows 的 Vidalia 包中我的默认 Polipo 配置。从它的外观来看,它也应该在 *nix 中工作 - 据我所知,没有任何特定于平台的内容。是的,它是一个 IPv4 配置。

### $Id$
#
### Basic configuration
### *******************

# Uncomment one of these if you want to allow remote clients to
# connect:

# proxyAddress = "::0"        # both IPv4 and IPv6
# proxyAddress = "0.0.0.0"    # IPv4 only

proxyAddress = "127.0.0.1"
proxyPort = 8118

# If you do that, you'll want to restrict the set of hosts allowed to
# connect:

# allowedClients = "127.0.0.1, 134.157.168.57"
# allowedClients = "127.0.0.1, 134.157.168.0/24"

allowedClients = 127.0.0.1
allowedPorts = 1-65535

# Uncomment this if you want your Polipo to identify itself by
# something else than the host name:

proxyName = "localhost"

# Uncomment this if there's only one user using this instance of Polipo:

cacheIsShared = false

# Uncomment this if you want to use a parent proxy:

# parentProxy = "squid.example.org:3128"

# Uncomment this if you want to use a parent SOCKS proxy:

socksParentProxy = "localhost:9050"
socksProxyType = socks5


### Memory
### ******

# Uncomment this if you want Polipo to use a ridiculously small amount
# of memory (a hundred C-64 worth or so):

# chunkHighMark = 819200
# objectHighMark = 128

# Uncomment this if you've got plenty of memory:

# chunkHighMark = 50331648
# objectHighMark = 16384

chunkHighMark = 33554432

### On-disk data
### ************

# Uncomment this if you want to disable the on-disk cache:

diskCacheRoot = ""

# Uncomment this if you want to put the on-disk cache in a
# non-standard location:

# diskCacheRoot = "~/.polipo-cache/"

# Uncomment this if you want to disable the local web server:

localDocumentRoot = ""

# Uncomment this if you want to enable the pages under /polipo/index?
# and /polipo/servers?.  This is a serious privacy leak if your proxy
# is shared.

# disableIndexing = false
# disableServersList = false

disableLocalInterface = true
disableConfiguration = true

### Domain Name System
### ******************

# Uncomment this if you want to contact IPv4 hosts only (and make DNS
# queries somewhat faster):
#
# dnsQueryIPv6 = no

# Uncomment this if you want Polipo to prefer IPv4 to IPv6 for
# double-stack hosts:
#
# dnsQueryIPv6 = reluctantly

# Uncomment this to disable Polipo's DNS resolver and use the system's
# default resolver instead.  If you do that, Polipo will freeze during
# every DNS query:

dnsUseGethostbyname = yes


### HTTP
### ****

# Uncomment this if you want to enable detection of proxy loops.
# This will cause your hostname (or whatever you put into proxyName
# above) to be included in every request:

disableVia = true

# Uncomment this if you want to slightly reduce the amount of
# information that you leak about yourself:

# censoredHeaders = from, accept-language
# censorReferer = maybe

censoredHeaders = from,accept-language,x-pad,link
censorReferer = maybe

# Uncomment this if you're paranoid.  This will break a lot of sites,
# though:

# censoredHeaders = set-cookie, cookie, cookie2, from, accept-language
# censorReferer = true

# Uncomment this if you want to use Poor Man's Multiplexing; increase
# the sizes if you're on a fast line.  They should each amount to a few
# seconds' worth of transfer; if pmmSize is small, you'll want
# pmmFirstSize to be larger.

# Note that PMM is somewhat unreliable.

# pmmFirstSize = 16384
# pmmSize = 8192

# Uncomment this if your user-agent does something reasonable with
# Warning headers (most don't):

# relaxTransparency = maybe

# Uncomment this if you never want to revalidate instances for which
# data is available (this is not a good idea):

# relaxTransparency = yes

# Uncomment this if you have no network:

# proxyOffline = yes

# Uncomment this if you want to avoid revalidating instances with a
# Vary header (this is not a good idea):

# mindlesslyCacheVary = true

# Suggestions from Incognito configuration
maxConnectionAge = 5m
maxConnectionRequests = 120
serverMaxSlots = 8
serverSlots = 2
tunnelAllowedPorts = 1-65535
Run Code Online (Sandbox Code Playgroud)