Search code examples
httpssltcptunnelingproxies

Tunneling through HTTP


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");