Tunneling through HTTP
Question
WRITTEN IN JAVA
Im creating a program that connects to a proxy and then tunneling to another server to send TCP packets, this is my code:
{
Socket skt = new Socket(proxy_address, proxy_port);
PrintStream myOutput = new PrintStream(skt.getOutputStream());
String Request = "CONNECT " + host + ":" + 443 + " HTTP/1.0";
String host3 = "Host: " + host + ":" + 443;
myOutput.println(Request + "\r\n" + host3 );
}
Trying to find out why im not getting a response from the proxy server.
Solution
You need two more line endings - one to indicate the end of the Host:
header, and one for an empty line to indicate the end of the connection request. Try:
myOutput.println(Request + "\r\n" + host3 + "\r\n\r\n");
OTHER TIPS
You could also try and take a look at either corkscrew or Proxytunnel, although these are basically SSH over HTTP(S) proxies.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow