August 21st, 2003, 04:30 PM
function keys over telnet
The company I work for has a wireless network that we in part secure through mac address filtering. I'm writing a program to manage the list and automatically telnet into the access points and update on command. Managing the list was cake, and I found a component to handle most of the telnet work for me, but I'm having a bit of trouble sending function key commands. Basically, what I need to know is, what command would the operating system (Win2K or XP) send to a telnet program when you press the F1 key, the F3 key, or the down arrow. Like I said, I have a component that does a lot of the telnet work for me, so I don't need to know what to transmit to the server, or what the keyboard sends to the operating systyem, but what the operating system would send to the program so I can fake a function call to the telnet component. I'm using borland builder, and it uses virtual key codes for everything which are mostly just ascii, but the function keys are different.
August 21st, 2003, 06:41 PM
The basis of telnet is the idea of the Network Virtual Terminal (NVT). When a telnet session starts up, this NVT gets set up by the client and server as they send each other negotiation messages which state what features each wants the other to support and what each will and will not support. Part of that negotiation is how function keys will be handled.
On this web page, http://www.spectrum-worldresearch.co....facility.html , for RFC 1043, "TELNET Data Entry Terminal ", I found this subcommand relating to function keys:
I'm attaching a ZIP file containing my man-in-the-middle-type (MiM) utility, executable plus source plus Visual C++6 build environment. I had written it to capture the negotiation between the Windows telnet client and Linux telnet server, my test environment. It was one of my first sockets projects, so I'm apologizing in advance, but if it helps you then by all means use it. It's not the least bit brilliant or inventive, but I found it useful for seeing what's going on in a telnet session. Also, it's been quite a while since I've looked at it, so I hope that I gave you everything you need to build it.
You run MiM by telling it what port to listen on and what server to connect to, plus giving it an optional capture file. Then you connect to MiM with your client, whereupon it connects to the server. MiM relays all the characters from the client to the server and vice versa, and at the same time it dumps everything to the capture file. Then afterwards you can examine the capture file to see what exactly was sent.
Hope that helps you get started.
August 22nd, 2003, 09:01 AM
I already have a component that handles all of the telnet side, and worries about negotiating how to do all that for me. What I really need to know is what will windows send to that program?
August 22nd, 2003, 11:00 AM
Then capture the packets and look. If you have a packet sniffer already, then that should work too.
August 22nd, 2003, 11:52 AM
dont know if this helps, but from Stevens tcp/ip illustrated:
3 key escape seq:
the F1 key -> M [ ESC
the F2 key -> N [ ESC
August 22nd, 2003, 04:37 PM
I've got it now. Just needed to find the right string to send, after all. Program now functions to spec, it's just a matter of getting the script the program uses to know when to send what correct.