MSDOTnet.org Forum Index
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Parsing Telnet Commands?

 
Post new topic   Reply to topic    MSDOTnet.org Forum Index -> C Sharp
Author Message
pbd22



Joined: 08 Aug 2007
Posts: 5

PostPosted: Wed Jan 09, 2008 5:54 pm    Post subject: Parsing Telnet Commands? Reply with quote

Hi.

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

Thanks!

Archived from group: microsoft>public>dotnet>languages>csharp
Back to top
View user's profile Send private message
Nicholas Paldino [.NET/C#



Joined: 08 Aug 2007
Posts: 71

PostPosted: Wed Jan 09, 2008 9:02 pm    Post subject: Re: Parsing Telnet Commands? Reply with quote

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


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

"pbd22" wrote in message @v29g2000hsf.googlegroups.com...
> Hi.
>
> Anybody know of any good code examples out there on
> how to take a telnet command and parse it?
>
> Thanks!
Back to top
View user's profile Send private message
pbd22



Joined: 08 Aug 2007
Posts: 5

PostPosted: Wed Jan 09, 2008 9:14 pm    Post subject: Re: Parsing Telnet Commands? Reply with quote

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?
Back to top
View user's profile Send private message
Barry Kelly



Joined: 08 Aug 2007
Posts: 42

PostPosted: Thu Jan 10, 2008 2:24 pm    Post subject: Re: Parsing Telnet Commands? Reply with quote

pbd22 wrote:

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 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

--
http://barrkel.blogspot.com/
Back to top
View user's profile Send private message
pbd22



Joined: 08 Aug 2007
Posts: 5

PostPosted: Fri Jan 11, 2008 3:32 pm    Post subject: Re: Parsing Telnet Commands? Reply with quote

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
Back to top
View user's profile Send private message
pbd22



Joined: 08 Aug 2007
Posts: 5

PostPosted: Fri Jan 11, 2008 6:21 pm    Post subject: Re: Parsing Telnet Commands? Reply with quote

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();
}

Back to top
View user's profile Send private message
Display posts from previous:   
Related Topics:
Creating a Telnet form in Access I need help with creating a Telnet form in Access 2002. We currently use a telnet program to access data on our main host system. We have created an access data base work through accounts in this system, but we also have to have our telnet session up to

Help Displaying Telnet Session in a Form I need help displaying a telnet session in an Access Form. Now it has to be in a form within some sort of Text box or something but I just dont know the first place to start. If someone could please give me some sort of Sample code on just how to Connec

Connections and Commands I am creating a model for generic connections and commands, and at this level there doesnt seem any difference between a command wether its oracle, odbc, oledb or sql, can I just use the idb interfaces directly to access varying clients rather than accoma

AT Commands to GSM Modem I need to send "AT" Commands to a GSM Modem that is connected to my local machine vi a USB port. How is this done? Is there an interface in .NET that allows communicating to the USB Port? Sample code will be very helpful.. Thank you in advance

Adding PJL commands to GDI+ Printing I have an application that prints tiff images through standard GDI+ calls by writing to the graphics object. I would like to add a PJL command with a username so that the username can then be detected by a print auditing application. Is this possible, and
Post new topic   Reply to topic    MSDOTnet.org Forum Index -> C Sharp All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group