将 HTTP 请求转换为 SOCKS5

将 HTTP 请求转换为 SOCKS5

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

是否可以在中间放一些东西?例如它就这样了。

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

答案1

看起来像代表可以这样做,类似如下(DeleGate 将在端口 8080 上接受 HTTP 连接并转发到端口 9050 上的 SOCKS 服务器):

delegated -P8080 SERVER=http SOCKS=localhost:9050

答案2

您还可以使用私有网络. 将此行添加到其config.txt文件:

forward-socks5 / 127.0.0.1:9050 .

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

然后使用 HTTP 或 HTTPS 代理127.0.0.1:8118

答案3

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

过去,Tor 软件包中包含了 Privoxy 或 Polipo 之类的 HTTP 代理,仅仅是为了解决 Firefox 中的一个错误,该错误最终在 Firefox 6 中得到了修复。现在,您不需要单独的 HTTP 代理来使用 Tor,事实上,省去它可以让您更安全,因为 Torbutton 可以更好地控制 Firefox 与网站的交互。

如果你尝试将某些外部应用程序与 Tor 结合使用,那么步骤零应该是重新阅读警告集,以了解你可能搞砸的方式。第一步应该是尝试使用 Socks 代理而不是 http 代理 — Tor 在 Windows 上的端口 9050 上运行 Socks 代理,或者往上看 适用于OSX和Linux。

如果失败,请随意安装私有网络。但是,请注意,这种方法不推荐新手用户使用。Privoxy 有一个示例配置Tor 和 Privoxy

答案4

您未指定操作系统。请稍后再指定。


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


##视窗

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

###高级设置

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

取自https://www.irif.fr/~jch/software/polipo/tor.html

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

###配置

Polipo 的配置是通过在 Polipo 的配置文件(一个纯文本文件)中设置一些配置变量来实现的。为了告诉 Polipo 使用 tor 并且不在磁盘上缓存任何获取的页面,您需要在配置文件中添加以下几行:

socksParentProxy = localhost:9050
diskCacheRoot=""

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

disableLocalInterface=true

运行它

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

> polipo.exe -c "/Program Files/Polipo/config.txt"

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

Polipo 默认监听端口是 8123。

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


###尼克斯

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

再次摘自https://www.irif.fr/~jch/software/polipo/tor.html

从您使用的任何存储库下载软件包。Google 可能会有所帮助。或者,可以直接下载二进制文件。

###配置

Polipo 的配置是通过在 Polipo 的配置文件中设置一些配置变量来实现的,这些变量可以是~/.polipo/etc/polipo/config,以现有变量为准。为了告诉 Polipo 使用 tor 而不是在磁盘上缓存任何获取的页面,您需要在配置文件中添加以下几行:

socksParentProxy = localhost:9050
diskCacheRoot=""

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

disableLocalInterface=true

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

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

运行它

如果您从发行版提供的软件包安装了 Polipo,那么 Polipo 可能已在运行;您需要重新启动它,以便它将其新配置考虑在内。否则,只需打开一个空闲的终端窗口并输入:

$ polipo

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

$ polipo -c "/Program Files/Polipo/config.txt"

Polipo 默认监听端口是 8123。

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


##默认 Polipo 配置(Vidalia 捆绑包)

这是我的默认 Polipo 配置,来自适用于 Windows 的 Vidalia 软件包。从外观上看,它也应该可以在 *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

相关内容