Telnet (how to use it)

Post Reply
mcjohn
Posts: 11
Joined: Sat Mar 07, 2009 7:05 am

Telnet (how to use it)

Post by mcjohn »

Hi, I've been spending all night trying to learn how to use telent (I have windows xp) but I can't figure it out. Dos comes with microsoft telnet but seems to have limited capabilities. I have downloaded telstar and some other programs but none seem to work for me. I simply would like to know, in layman terms, how I can run telnet or use a script, for commands like get and host, etc. I've read how to use the commands, but no clue what program or script I can actually type them into! The programs I've tried always say connection attempt failed when putting in host of www.hacker.org and even if it did connect there is no place to type in a get or range or whatever command.

Cheers,

John
p2p
Posts: 4
Joined: Fri Feb 13, 2009 4:50 pm

Post by p2p »

Hi,

Afaik, it´s not possible to automate the telnet client of Windows. I think the best solution for your problem is to write you a script in an other language which establishes a network connection. Or if you only want to make http requests, just use Wget.

p2p
gfoot
Posts: 269
Joined: Wed Sep 05, 2007 11:34 pm
Location: Brighton, UK

Post by gfoot »

It depends what you want to do with telnet. Technically the telnet protocol is more than just a TCP connection, but you can generally also use it to just poke text at TCP ports and see what you get back as well. To get anything useful, though, you need to know what to send.

So if you want to send a web request, you need to connect to port 80 (put 80 on the command line after the hostname), then write:

Code: Select all

GET / HTTP/1.1
Host: www.hacker.org

Note the blank line at the end, i.e. you need to press Enter twice. The server should then send something back to you - at the very least, an error message.

The "/" is the path on the server. The protocol version number is important if you want certain headers to work - for a virtually-hosted site (most cheap hosting is virtual) you need a Host: header to tell the server which site you're after, as many sites are hosted on a single IP address.

Beyond that you can read the relevant RFCs (Internet standards documents) for full details of the protocol, including other headers. But as p2p said, command-line tools like wget and curl are often easier ways to send somewhat customized web requests. Sending raw data like this is only necessary if you need full control of the headers - and again as p2p said, there are other options - languages like Perl and Python are well equipped for doing this kind of thing in a more programmatic way.
mcjohn
Posts: 11
Joined: Sat Mar 07, 2009 7:05 am

Post by mcjohn »

Thanks for the reply's guys. Unfortunately I am still stuck. I mainly need this for a range problem.

To be more clear, Telstar for example, starts with a small windows that asks to type in the host, to which I type in www.hacker.org and it always says "could not open connection to the host on port 23" and shuts down right away. In Microsoft Telnet I type in o www.hacker.org and again says cannot connect. I've tried secure commnet, anzio lite, etc. I've made sure the telnet service is running in services.msc and the only thing I can think of is that telnet is not working through my at- home linksys router. I put telnet, port 23, under Port Range Forward in the router setup (although not sure if that helps any or was done correctly). Also, any host I try to connect to doesn't work, even with trying various ports, so it's not just here. And I have no firewall running. Help!
michuber
Posts: 57
Joined: Sun Oct 26, 2008 3:30 pm

Post by michuber »

mcjohn wrote:o www.hacker.org and again says cannot connect. Help!
That's correct, port 23 is blocked for security reasons :roll:

Read http://en.wikipedia.org/wiki/HTTP or search for "telnet http sample session".
User avatar
teebee
Posts: 89
Joined: Mon Nov 10, 2008 3:21 pm
Location: Germany

Post by teebee »

You have to specify which port to use by putting the port number after the IP address or server name:

Code: Select all

telnet www.hacker.org 80
or

Code: Select all

telnet
> open www.hacker.org 80
Then for example type the three lines

Code: Select all

GET / HTTP/1.1
Host: www.hacker.org

(the last line is empty).
Last edited by teebee on Tue Mar 31, 2009 10:15 pm, edited 2 times in total.
gfoot
Posts: 269
Joined: Wed Sep 05, 2007 11:34 pm
Location: Brighton, UK

Post by gfoot »

mcjohn wrote:I've made sure the telnet service is running in services.msc ... I put telnet, port 23, under Port Range Forward in the router setup ... And I have no firewall running. Help!
This all sets up your home PC so that other people can telnet into it. You *really* don't want to do that - the telnet protocol is about as insecure as they come. Remove the port forward and disable the telnet service ASAP. You only need the telnet client, not the server.
Post Reply