Network protocol: still using HTTP proxy? Weak explosion! Try Socks5

Time:2022-5-11

brief introduction

Existence is reasonable. The emergence of Socks5 is to solve the big problem that Socks4 does not support identity authentication. After all, we pay more and more attention to the security of the network. The network without authentication is like a life under the camera. It has no privacy. It’s really terrible.

Today, I will give you an in-depth explanation of Socks5 and its application.

Why use socks

Socks is an agent service agreement. Why is there an agent service agreement?

Because in modern networks, in many cases, due to the network or firewall, it is difficult for us to directly access each other’s network, so we need a proxy mechanism to act as the gateway between the local network and the large network.

The proxy server works by intercepting the connection between the sender and the receiver. All incoming data enters through one port and is forwarded to the target network through another port.

Of course, traffic forwarding is the most basic function of the proxy server. The proxy server can also realize the security of network access by hiding the IP address of the client or server. In addition, because the proxy server acts as the proxy of the target server, the proxy server can be used as the cache server of the target server, so as to improve the efficiency of network access.

In addition, the proxy server can intercept the data to perform some special operations, such as encrypting the data, so as to ensure the security of data transmission. In addition, the proxy server can also control the access of the client, for example, it can prevent the client from accessing an IP address or website.

Socks is a standard of proxy protocol. Through this protocol, standard proxy services can be realized.

In the enterprise network, in order to ensure the security of the enterprise network, a firewall is usually installed, which not only ensures the security of the enterprise network, but also prevents the client from accessing the external network. Therefore, a socks proxy server is needed to replace the connection and data communication between the client and the target website.

Socks agent can bypass the firewall to relay users’ TCP and UDP sessions.

SOCKS5

Because socks is the fifth session layer running in the OSI seven layer protocol, it can handle a variety of request types including HTTP, HTTPS, POP3, SMTP and FTP. Therefore, socks protocol can be used for mail sending, web browsing, file transmission, etc.

Compared with sock4, Socks5 adds an authentication mechanism, so a complete TCP connection can be established through authentication. Socks5 is usually used together with SSH to relay traffic by Using SSH encryption tunnel method.

So why do we need to use Socks5?

First, we can access the services behind the firewall through Socks5.

Generally speaking, for the sake of security, the server is placed behind the firewall, but there are two ways for outsiders to access the server. The first is to remove the firewall and open the service to the public, but this will bring security risks. The second is to filter illegal access requests by setting the IP white list of the client. However, the IP address of the client usually changes, so this approach is not feasible.

If you use the SSH proxy of Socks5, you can access the service behind the firewall through the proxy server, so as to ensure the security of the service.

In addition, by establishing an SSH tunnel, in which various TCP and UDP traffic are routed to their respective services using Socks5 protocol, only SSH is needed instead of other VPN networks. So it’s easy to use.

Finally, because Socks5 only forwards data, it is less likely to make errors and has higher performance.

Use of Socks5

We have introduced various advantages of Socks5 above, so how should Socks5 be used? Next, let’s introduce a simple Socks5 proxy server using SSH command.

Let’s first look at the command of SSH to establish socks service:

ssh -f -C -N -D bindaddress:port [email protected]

-F indicates that SSH is executed in the background as a daemon.

-N means that the remote command is not executed and is only used for port forwarding.

-D indicates dynamic forwarding on the port. This command supports Socks4 and Socks5.

-C means compressed data before sending.

Bindaddress the binding address of the local server.

Port indicates the specified listening port of the local server.

Name indicates the ssh server login name.

Server indicates the ssh server address.

The above command means to establish port binding on the local machine and then forward it to the remote proxy server.

For example, we can open a 2000 port on the local machine and forward it to the remote machine 168.121.100.23:

ssh -f -N -D 0.0.0.0:2000 [email protected]

After you have a proxy server, you can use it. First, introduce how to use socks proxy in curl command.

We want to visit www.flybean.com through a proxy server What should I do? Www. 68mn?

curl -x socks5h://localhost:2000 -v -k -X GET http://www.flydean.com:80

To check the connection of socks, you can also use the netcat command as follows:

ncat –proxy 127.0.0.1:2000 –proxy-type socks5 www.flydean.com 80 -nv

summary

Socks5 is a very useful proxy protocol. You can use it when you need it. you’ll see!

This article has been included inhttp://www.flydean.com/10-socks5-more/

The most popular interpretation, the most profound dry goods, the most concise tutorial, and many tips you don’t know are waiting for you to find!

Welcome to my official account: “procedures and things”. I understand technology and you better!

Recommended Today

JS generate guid method

JS generate guid method https://blog.csdn.net/Alive_tree/article/details/87942348 Globally unique identification(GUID) is an algorithm generatedBinaryCount Reg128 bitsNumber ofidentifier , GUID is mainly used in networks or systems with multiple nodes and computers. Ideally, any computational geometry computer cluster will not generate two identical guids, and the total number of guids is2^128In theory, it is difficult to make two […]