Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / January 2008

Tip: Looking for answers? Try searching our database.

Parsing Telnet Commands?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
pbd22 - 09 Jan 2008 20:54 GMT
Hi.

Anybody know of any good code examples out there on
how to take a telnet command and parse it?

Thanks!
Nicholas Paldino [.NET/C# MVP] - 09 Jan 2008 21:00 GMT
There is a sourceforge project which claims to parse telnet commands:

http://dotnettelnet.sourceforge.net/

   There are some other commercial offerings, I believe.

   In the end, you can always do it yourself, using the protocol reference:

http://www.faqs.org/rfcs/rfc854.html

Signature

         - Nicholas Paldino [.NET/C# MVP]
         - mvp@spam.guard.caspershouse.com

> Hi.
>
> Anybody know of any good code examples out there on
> how to take a telnet command and parse it?
>
> Thanks!
pbd22 - 10 Jan 2008 00:14 GMT
Thanks.

I'll take a look at the ideas behind the opensource project tonight.

I don't see it being too too complicated (of course, i shouldn't count
my eggs).
The point, really, where I am having problems is this:

telnet command( "open" ) >> .net parser ( "something new").

I mean, a telnet command can be turned into a string, right?

So, if somebody remotely telnets to my computer and then
types some commands, I should be able to use TcpListener
to catch those commands and manipulate them, right?

The point where I am having problems is reading the bytestream
and translating that into a string.

Does anybody out there have some initial ideas?
Barry Kelly - 10 Jan 2008 09:24 GMT
Telnet (AFAIK) isn't a whole lot more than a terminal emulator stuck
onto the client side of a TCP connection. And you seem to be focused on
the server side, so we can leave aside terminal control codes.

> telnet command( "open" ) >> .net parser ( "something new").
>
> I mean, a telnet command can be turned into a string, right?

The characters typed on the client end get sent over the TCP connection
pretty much literally as ASCII, yes.

> So, if somebody remotely telnets to my computer and then
> types some commands, I should be able to use TcpListener
> to catch those commands and manipulate them, right?

Yes. Create a TCP server program which listens on port 23.

> The point where I am having problems is reading the bytestream
> and translating that into a string.
> Does anybody out there have some initial ideas?

For very basic initial support, read and buffer (in a List<byte> for
example) each byte one at a time until you see a line-feed (byte value
10), then convert it into a string using Encoding.ASCII, or maybe by
manually casting the byte values into chars and stuffing into a
StringBuilder.

-- Barry

Signature

http://barrkel.blogspot.com/

pbd22 - 11 Jan 2008 18:32 GMT
Should I be sending the

username:
password:

prompt when the user initiates the session?
There is no other way to do this, right?

I have hijacked the session so all interactivity
is coming from my program at that point, right?

If this is true, then I need to be reading from some
DB or file for access permissions, right?

Thanks.
Peter
pbd22 - 11 Jan 2008 21:21 GMT
Can somebody please show me what the code would look like for sending
a
username and
password request once a telnet session is started and how to capture
that
information and parse it (if that isnt too tall a call).

Below is what I have (in a nutshell) and I am unclear what to put in
my
"TheConnectionHandler()" method. I am guessing this is where i send
user/pass request, wait for response, and parse accordingly?

I would really appreciate some help and code suggestions in the
Handler.

Thanks!

               TcpClient socket;
               TcpListener listener = new TcpListener(IPAddress.Any,
23);

               listener.Start();

               while( true)
               {

                   socket = listener.AcceptTcpClient();
                   connectionQueue.Enqueue( socket);

                   Thread workingthread = new Thread( new
ThreadStart(TheConnectionHandler));
                   workingthread.Start();

               }

public void TheConnectionHandler()
       {

               System.Net.Sockets.TcpClient socket =
(System.Net.Sockets.TcpClient)connectionQueue.Dequeue();
}

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.