0

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.

Masterban
  • 265
  • 1
  • 2
  • 7
  • 2
    What language is your Code. It looks like Java, but to be sure you should tag your question with the language being used. – jigfox Aug 17 '10 at 19:12

2 Answers2

0

You could also try and take a look at either corkscrew or Proxytunnel, although these are basically SSH over HTTP(S) proxies.

plaes
  • 31,788
  • 11
  • 91
  • 89
0

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");
caf
  • 233,326
  • 40
  • 323
  • 462
  • I actually have one more question, when i start sending the packets i want to the server do i need to do anything special to it? like adding the empty line at the end? – Masterban Aug 18 '10 at 06:18
  • @Masterban: No, after you read the response headers from the server (which are terminated with an empty line), if the response code was 200 then you'll have a raw connection with the other side. – caf Aug 18 '10 at 06:29