Sometimes you need to connect to a machine, but the connection is blocked. Although you can use a proxy to handle some applicationsProgramBut many programs do not support proxies, or only some types of proxies, you can try proxychains.
For example, SVN only supports HTTP proxy and does not support socks4 proxy. SVN + SSH is also quite troublesome. If only socks proxy is available, it cannot be used directly. You can use a socks to switch to the HTTP Proxy software, but you need ~ /. Subversion/servers. In this case, it is more convenient to use proxychains.
Proxychains are used directly as the prefix of other commands, just like commands such as time, strace, and ccache. The program is loaded and run in the agent environment, and proxy is not required.
To use proxychains, you must first have a proxy. If you have a unix host that can be accessed through SSH, you can use it as a proxy:
Ssh-D connects to the machine on which the NEN can access the target network, and a socks4 dynamic forwarding proxy can be enabled. Specific commands:
$ Ssh-NF username @ hostname-D 61000
Explanation:
-N: no command is executed.
-F: run the command in the background.
-D 61000 listens to localhost: Port 61000 and forwards all requests to the Connected Server.
This proxy is valid as long as the SSH process is not killed and the machine is not restarted.
Install and use proxychains below
The installation and configuration of proxychains are as follows:
Configure compilation and installation. I modify the configuration file/etc/proxychains. conf and find this section:
[Proxylist]
# Add proxy here...
# Meanwile
# Defaults set to "tor"
Socks4 127.0.0.161000
This 61000 is the port parameter of SSH-D.
.
Do not use DNS proxy, so remove
# Proxy DNS requests-no leak for DNS data
# Proxy_dns
After installation and configuration, enter
$ Proxychains SVN Co https ://.....
Object 'libproxychains. so' from ld_preload cannot be preloaded: ignored
If there is a problem, you can find that the machine is x86_64, SVN is installed with 32 bits, and the library is compiled into 64 bits, which naturally cannot be loaded.
So I compiled a 32-bit package and put it on.
Set alias to save the trouble:
Alias SVN = 'proxychains SVN'
The principle of proxychains is very simple. The environment variable ld_preload is used to hook library functions, mainly connect
Function. In addition, I hook the following DNS-related functions for DNS proxy, so I don't care if I don't use them.
The executable file of proxychains is a script with simple content. You can set ld_preload and then exec $ @. There is a line of Logo output at the beginning, which can be removed.
For non-root users, so can be installed in the user directory, and the proxychains script can also be installed in ~ /Bin, modify the content and load the correct so.
Proxychains supports the configuration file named proxychains. The search order is .,~, /Etc. For specific options, see the example.