473,385 Members | 2,069 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Parsing Telnet Commands?

Hi.

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

Thanks!
Jan 9 '08 #1
5 8723
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]
- mv*@spam.guard.caspershouse.com

"pbd22" <du*****@gmail.comwrote in message
news:f9**********************************@v29g2000 hsf.googlegroups.com...
Hi.

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

Thanks!

Jan 9 '08 #2
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?
Jan 10 '08 #3
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<bytefor
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/
Jan 10 '08 #4
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
Jan 11 '08 #5
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.Dequ eue();
}
Jan 11 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: kumar | last post by:
Hi all, I want to write a telnet server for an embedded linux box using python.The problem is that it doesn't give a shell ( just a limited CLI commands for configuring it . )My requirement is...
3
by: Yannick Turgeon | last post by:
Hello all, I'm currently trying to pass commands to a telnet session and get the texte generated (stdin + stdout) by the session. The problem I get is that the Telnet.read_until() function...
5
by: Greg Martz | last post by:
I'd like to do the following in C# and prefer using tcpclient rather than raw sockets... Connect to a unix box Login run date +%H%M%S retrieve the response. That's it, nothing more. This...
7
by: Rex Winn | last post by:
I've Googled until my eyes hurt looking for a way to issue Telnet commands from C# and cannot find anything but $300 libraries that encapsulate it for you. I don't want to be able to create a...
2
by: JaythePCguy | last post by:
Hi, I am trying to write a text parser to group all nonprintable and control characters, spaces and space delimited words in different groups using Regex class. Using a parsing of...
2
by: b00x | last post by:
Hi, I'm trying to develop a script that I can reuse to run remote commands on multiple UNIX servers via telnet. I've tried various php scripts after googling for a good 5 or so hours, but found...
4
by: pbd22 | last post by:
Hi I am making my way through a windows service that accepts custom telnet commands as strings and then parses the string and redirects it. This would be a custom string sent via telnet. ...
2
by: HTCGuy | last post by:
Hi, im building an application that has to run a series of simple telnet commands . login wget some links chmod some files exit The only thing Ive found sofar are massive fully function c#...
1
by: jeetendra G | last post by:
use Net::telnet telnet->open($host); telnet->logint("rrot","rut" $a=telnet->cmd("ls"); using telnet i am running this command to remote machine its is connecting to remote machine. but the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.