#1
  1. ASP.Net MVP
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Aug 2003
    Location
    WI
    Posts
    4,378
    Rep Power
    1510

    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.
    Primary Forum: .Net Development
    Holy cow, I'm now an ASP.Net MVP!

    [Moving to ASP.Net] | [.Net Dos and Don't for VB6 Programmers]

    http://twitter.com/jcoehoorn
  2. #2
  3. Contributing User
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jan 2003
    Location
    USA
    Posts
    7,145
    Rep Power
    2222
    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:
    MISCELLANEOUS

    IAC SB DET FUNCTION-KEY IAC

    subcommand code: 40

    This subcommand transmits a user entered function key code
    The parameter is one byte that identifies the
    function key entered. Function key values range
    0 to 255. This subcommand is used in conjunction with
    ENABLE-FUNCTION-KEY subcommand. Use of this
    requires facility negotiation; see the FORMAT-
    subcommand, Function-Key bit
    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.
    Attached Files
  4. #3
  5. ASP.Net MVP
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Aug 2003
    Location
    WI
    Posts
    4,378
    Rep Power
    1510
    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?
    Primary Forum: .Net Development
    Holy cow, I'm now an ASP.Net MVP!

    [Moving to ASP.Net] | [.Net Dos and Don't for VB6 Programmers]

    http://twitter.com/jcoehoorn
  6. #4
  7. Contributing User
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jan 2003
    Location
    USA
    Posts
    7,145
    Rep Power
    2222
    Originally posted by f'lar
    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?
    Then capture the packets and look. If you have a packet sniffer already, then that should work too.
  8. #5
  9. not a fan of fascism (n00b)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Feb 2003
    Location
    ct
    Posts
    2,756
    Rep Power
    95
    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
    etc...
  10. #6
  11. ASP.Net MVP
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Aug 2003
    Location
    WI
    Posts
    4,378
    Rep Power
    1510
    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.
    Primary Forum: .Net Development
    Holy cow, I'm now an ASP.Net MVP!

    [Moving to ASP.Net] | [.Net Dos and Don't for VB6 Programmers]

    http://twitter.com/jcoehoorn

IMN logo majestic logo threadwatch logo seochat tools logo