18

I am behind a proxy server in my college. It uses a simple username and password authentication. And i connect to the proxy server to port 3128. now i want to telnet simply to say any website on the internet like

$ telnet www.google.com 80

this gives me

error telnet: could not resolve www.udacity.com/80: Name or service not known

How can I define the proxy settings for telnet? I have already set environment variables http_proxy and HTTP_PROXY. Also have applied system wide proxy.

sr_
  • 15,224
  • 49
  • 55
Aakash Sigdel
  • 183
  • 1
  • 1
  • 5

2 Answers2

24

You could do what the browser does, i.e. connect to the proxy,

$ telnet proxy-server 3128

and talk to it. If there was no authentication, a simple GET request (followed by two newlines (Enter)) with a full hostname and protocol, e.g.

GET http://www.google.com/ HTTP/1.1

should suffice. Since you need authentication, you need to provide your username and password base64-encoded in a Proxy-Authentication header, e.g.

GET http://www.google.com/ HTTP/1.1
Proxy-Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=

To create the base64 string, you could use echo -n username:password | openssl base64

sr_
  • 15,224
  • 49
  • 55
9

You can use Proxychains for this.

First install proxychains, using the command:

$ apt-get install proxychains

Then configure your proxy settings in /etc/proxychains.conf file.

Add at last, these lines for HTTP and HTTPS proxy.

http    proxy-ip   proxy-port    username        password
https   proxy-ip   proxy-port    username        password

Now you can do telnet by using the following command:

$ proxychains telnet www.google.com 80
pradeepchhetri
  • 9,859
  • 12
  • 51
  • 59
  • i am getting this error: aakash@sigdel:~$ proxychains telnet www.google.com 3128ProxyChains-3.1 (http://proxychains.sf.net) |DNS-response|: sigdel is not exist |DNS-request| www.google.com |S-chain|-<>-127.0.0.1:9050-<--timeout |DNS-response|: www.google.com is not exist telnet: could not resolve www.google.com/3128: Unknown error – Aakash Sigdel Apr 23 '12 at 02:21
  • @AakashSigdel: Sorry, the last command which I wrote should be `$ proxychains telnet www.google.com 80`. It should work now !! – pradeepchhetri Apr 23 '12 at 03:37
  • 1
    @pradeepchhetri i got error when i use this proxychains telnet www.google.com 80 `ProxyChains-3.1 (http://proxychains.sf.net) |DNS-response|: xyz does not exist |DNS-request| www.google.com |S-chain|-<>-proxy-ip:proxy-port-<><>-4.2.2.2:53-<--denied |DNS-response|: www.google.com does not exist telnet: could not resolve www.google.com/80: Unknown error` – john Mar 15 '15 at 18:39
  • @john I was seeing the same error; I got around it by commenting out the `proxy_dns` line in `/etc/proxychains.conf`. I'm assuming this is because my proxy server does not provide DNS. – Adam Oct 02 '21 at 02:41