0

I asked this question: Wrap packets in connect requests until reach the last proxy

And I learnt that to create a chains of proxies I have to:

  • create a socket
  • connect the socket to proxy A
  • create a tunnel via A to proxy B - either with HTTP or SOCKS protocol similar
  • create a tunnel via [A,B] to proxy C similar
  • create a tunnel via [A,B,C] to D
  • ... until your last proxy is instructed to built the tunnel to the
    final target T

I got what I have to do until the second point, cause I think I just have to add the "CONNECT" header to the http request to the proxy A. But my question is, in this example http request:

CONNECT ipproxy:80 HTTP/1.1
Host: ?:80

In the host header I should put again the proxy ip or something else? Like the proxy B ip or the final site domain?

Also, I didn't understand how to go on from the third point to the next... because I don't know how to tell the proxy A to create a tunnel to proxyB and then proxy B to create a tunnel to proxy C that goes to the final site..

Examples of how can I do it with python? Or some doc?

1

1 Answer 1

1

There is no Host header with CONNECT. I.e. to request HTTP proxy A to create a tunnel to HTTP proxy B you just use:

>>> CONNECT B_host:B_port HTTP/1.0
>>>
<<< 200 connections established
<<<

And then you have this tunnel to proxy B via proxy A. Inside this tunnel you then can create another tunnel to target T, i.e. on the same socket send and receive next:

>>> CONNECT T_host:T_port HTTP/1.0
>>>
<<< 200 connections established
<<<

Note that not all proxies allow you to CONNECT to arbitrary hosts and ports and they might also not allow arbitrary protocols like a tunnel inside a tunnel but only selected protocols like HTTPS.

Sign up to request clarification or add additional context in comments.

2 Comments

thanks again. before I mark your answer accepted, I want to ask you, what about socks request? For http proxy I have to send these CONNECT packet.. And for socks? Do I have to send an HTTP request with CONNECT header such as HTTP proxy?
@AllExJ: as I've written in my answer to your other question which you even cite: there is a documentation how SOCKS works and you have to follow it similar as you would have needed to just follow the RFC for CONNECT in case of HTTP proxies. Although SOCKS is more complex (especially if you not only implement SOCKS4 but also SOCKS4a and SOCKS5) the basic idea is the same as with a HTTP proxy.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.