Linux - curl command uses proxy and introduction to proxy types
Link: https://www.cnblogs.com/panxuejun/p/10574038.html
1. Proxy server classification:
Category | subcategory | Subclass | describe |
---|---|---|---|
http proxy |
http proxy
https proxy |
transparent proxy | The http server knows that the browser uses a proxy and can obtain the original IP address of the browser. |
anonymous proxy | The http server knows that the browser uses a proxy, but cannot obtain the original IP of the browser; | ||
High Anonymity Proxy | The http server does not know that the browser uses a proxy and cannot obtain the original IP of the browser; | ||
SOCKS proxy | SOCKS4 |
Known as a universal
proxy , it supports http and other protocols |
Only TCP applications are supported; |
SOCKS4A | Support TCP applications; support server-side domain name resolution; | ||
SOCKS5 |
Supports TCP and UDP applications; supports server-side domain name resolution;
supports multiple authentications; supports IPV6; |
2. Linux curl command proxy setting parameters:
The linux curl command can use the following parameters to set the http(s) proxy and socks proxy. Their username, password and authentication method have been set:
parameter | usage |
---|---|
-x host:port
-x [protocol://[user:pwd@]host[:port] --proxy [protocol://[user:pwd@]host[:port] |
Use HTTP proxy for access; if the port is not specified, port 8080 is used by default;
protocol defaults to http_proxy, other possible values include: http_proxy, HTTPS_PROXY, socks4, socks4a, socks5; such as: --proxy 8.8.8.8:8080; -x "http_proxy://aiezu:123@aiezu.com:80" |
--socks4 <host[:port]>
--socks4a <host[:port]> --socks5 <host[:port]> |
Use SOCKS4 proxy;
use SOCKS4A proxy; use SOCKS5 proxy ; this parameter will override the "-x" parameter; |
--proxy-anyauth
--proxy-basic --proxy-diges --proxy-negotiate --proxy-ntlm |
Proxy authentication method, refer to:
--anyauth --basic --diges --negotiate --ntlm |
-U <user:password>
--proxy-user <user:password> |
Set the username and password of the agent; |
3. Example of setting proxy using Linux curl command:
1. Linux curl command sets http proxy:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
|
2. Linux curl command sets socks proxy:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
|
4. Test the anonymity of the agent:
1. Preparation before testing:
Before testing, we first create a PHP page "test.php" in the root directory of the website to output the visitor IP address information received by the http server. The code of the "test.php" test page is as follows:
1 2 3 4 5 6 7 8 9 |
|
After saving "test.php", we then access it without a proxy, or by using a transparent proxy, an anonymous proxy, a high-anonymity proxy, and SOCKS to see the content results output by the page.
2. Test the output results using different agents:
①. Access via linux curl without proxy:
[root@aiezu.com ~]# curl http://aiezu.com/test.php
Array
(
[REMOTE_ADDR] => 114.112.104.126
)
It can be seen that the "REMOTE_ADDR" IP address obtained by the http server is "114.112.104.126", and this IP address is the real IP address of the client lcurl.
②. Use http transparent proxy access through linux curl command:
[root@aiezu.com ~]# curl -x 37.139.9.11:80 http://aiezu.com/test.php
Array
(
[HTTP_VIA] => 1.1 ThunderVPN (squid/3.3.8)
[HTTP_X_FORWARDED_FOR] => 114.112.104.126
[HTTP_CACHE_CONTROL] => max-age=259200
[HTTP_CONNECTION] => keep-alive
[REMOTE_ADDR] => 37.139.9.11
)
It can be seen that the REMOTE_ADDR field becomes the IP address of the proxy server. At the same time, the real IP address can also be obtained from the HTTP_X_FORWARDED_FOR field. There is also an additional "HTTP_VIA" field. It can be seen that the proxy cannot hide the real IP, and it will also allow The http server automatically uses a proxy on the browser side.
③. Use http anonymous proxy access through linux curl command:
[root@aiezu.com ~]# curl -x 60.21.209.114:8080 http://aiezu.com/test.php
Array
(
[HTTP_PROXY_CONNECTION] => Keep-Alive
[REMOTE_ADDR] => 60.21.209.114
)
As can be seen from the above, the REMOTE_ADDR field becomes the IP address of the proxy server, and the response does not contain the original real IP address. However, with the addition of HTTP_PROXY_CONNECTION, it can be judged that a proxy is used, and it can be concluded that this browser client uses Anonymous proxy.
④. Use http high-anonymity proxy access through the linux curl command:
[root@aiezu.com ~]# curl -x 114.232.1.13:8088 http://aiezu.com/test.php
Array
(
[REMOTE_ADDR] => 114.232.1.13
)
This time we were surprised to find that REMOTE_ADDR also became the IP address of the proxy without leaving any residual evidence to prove the use of a proxy. We can conclude that this is the legendary high-anonymity proxy.
④. Use socks5 proxy to access through linux curl command:
[root@aiezu.com ~]# curl --socks5 122.192.32.76:7280 http://aiezu.com/test.php
Array
(
[REMOTE_ADDR] => 180.96.54.198
)
It can be seen that this SOCKS5 proxy is also a high-anonymity proxy.
The spring recruitment has begun. If you are not adequately prepared, it will be difficult to find a good job during the spring recruitment.
I’m sending you a big employment gift package, so you can raid the spring recruitment and find a good job!