473,761 Members | 5,578 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 8788
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.co m

"pbd22" <du*****@gmail. comwrote in message
news:f9******** *************** ***********@v29 g2000hsf.google groups.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
"TheConnectionH andler()" 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(IPA ddress.Any,
23);

listener.Start( );
while( true)
{

socket = listener.Accept TcpClient();
connectionQueue .Enqueue( socket);

Thread workingthread = new Thread( new
ThreadStart(The ConnectionHandl er));
workingthread.S tart();

}
public void TheConnectionHa ndler()
{

System.Net.Sock ets.TcpClient socket =
(System.Net.Soc kets.TcpClient) connectionQueue .Dequeue();
}
Jan 11 '08 #6

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

Similar topics

1
3839
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 to write a telnet server ( residing on the box) listening on some specific port where it can listen to telnet requests from clients and provide them an interactive command line session. I tried using the python's async_chat module but it is very...
3
8664
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 seems to freeze after a couple of command. I did a simplify script that reproduce the problem each time (I'm using 2.3.4 on W2K):
5
33879
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 shouldn't be too complicated, I thought... I have yet to find any examples of being able to do this.
7
14098
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 Telnet client. I just need to send a telnet request to a local IP address on a LAN issue a "c" then a "b" and stream back the text for internal use. The "c" changes sub-menus and the "b" is a switch to dump the status of a firewall. I need to issue...
2
2107
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 (?<Commands>)|(?<Spaces>)|(?<Text>+) on my sample text of \tOne\ncar red \fcar\a blue car\r\n \r\n does not work as indetended. Specially, the spaces are grouped as commands and the Text grouping ends up grouping words delimited by spaces. Here is the sample...
2
15782
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 no luck. I've created a script (suprisingly) similar to the on found an old post from 2001...
4
2869
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. So, I need to prompt the user for input and then capture that imput, parse it into a form that is readable (strings in
2
2374
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# telnet clients which i have no hope of integrating into my project .Can anyone tell me where i can get a free telnet client that can load scripts without user input or a way to achive the above without a massive telnet client ? thanks
1
5631
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 output of "ls" is not coming in $a. a is having the status of the ls command it is not having results .a is having 0 or 1. ouput is not coming in a
0
9975
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9909
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8794
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7342
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5241
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5384
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3889
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3481
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2765
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.