Results 1 to 9 of 9

Thread: keystrokes via telnet

  1. #1
    Funking Prink! Raz316's Avatar
    Join Date
    Jul 2003
    Location
    Deal, Kent, UK
    Posts
    2,978
    Thanks
    130
    Thanked
    62 times in 52 posts

    keystrokes via telnet

    Is it possible to send, lets say a right cursor press, via a telnet script?
    Code:
    (sleep 1;
    echo "open 192.168.0.1";
    sleep 1;
    echo "speshul";
    sleep 1;
    echo "hacker";
    sleep 1;
    echo "/usr/pro50/pro SYS";
    sleep 1;
    ***
    ) | telnet
    *** at this point I need to send a right cursor keystroke, any idea how I would go about doing this?

    Cheers

  2. #2
    Agent of the System ikonia's Avatar
    Join Date
    May 2004
    Location
    South West UK (Bath)
    Posts
    3,736
    Thanks
    39
    Thanked
    75 times in 56 posts
    telnets a tough one to send key sequences to.

    You need to look at the ASCII charecter for -> (right cusor move)

    The best way I did this a long time ago was to echo what I wanted to the tty I was using to connect to the remote machine

    eg: echo "hello" > /dev/ttya would send "hello" to ttya and thus to telnet.

    echoing asci characters may be a little tougher as you'll have to echo the escape sequence, then the ascii number then drop out of special char mode.

    Have a play with sending input to the tty and see what results you get.
    It is Inevitable.....


  3. #3
    Funking Prink! Raz316's Avatar
    Join Date
    Jul 2003
    Location
    Deal, Kent, UK
    Posts
    2,978
    Thanks
    130
    Thanked
    62 times in 52 posts
    Oo cheers, i'll look into that I did move onto trying to work with escape characters but couldnt see a way of specifying '^]]C' (I think) and then sending it.

    Ill try when I get into work tomorrow, thanks

  4. #4
    Agent of the System ikonia's Avatar
    Join Date
    May 2004
    Location
    South West UK (Bath)
    Posts
    3,736
    Thanks
    39
    Thanked
    75 times in 56 posts
    if you want to send special charecters direct, and easy way is to set -o vi

    then use ctrl+v (sets it into special char mode) then do ctrl+$yourkey
    It is Inevitable.....


  5. #5
    Funking Prink! Raz316's Avatar
    Join Date
    Jul 2003
    Location
    Deal, Kent, UK
    Posts
    2,978
    Thanks
    130
    Thanked
    62 times in 52 posts
    thats certainly doing something, though I have to use /dev/pts/0 instead. Im struggling to echo the keystroke across though on both the client and the server ctrl-v and ctrl-keystroke gives ^[0C but when I echo it to > /dev/pts/0 it places a 'C' on the current line, then goes down to the next at the same cursor position

  6. #6
    Agent of the System ikonia's Avatar
    Join Date
    May 2004
    Location
    South West UK (Bath)
    Posts
    3,736
    Thanks
    39
    Thanked
    75 times in 56 posts
    ok - thats interesting.

    No problem that your using pts, pts is just psudo terminals (bad spelling).

    If you ctrl+v + ctrl $char and you get say ^U what your saying is it acutally sends ^C even though you echo ^U ?

    I remember a problem with ctrl+v ctrl+M == ^J instead of ^M

    When I looked into it it was a termcap issue, but I'm guessing your running linux and linux has pretty basic termcaps. for arguments sake and assuming your running linux, try setting TERM=linux (export it) and see if that makes a difference.

    Other suggestions are to look at searching for echoing ascii char mappings.

    Its been a while scince I looked at feeding stuff into terminals remotley. I'll try take a look / have a play with this tonight.
    It is Inevitable.....


  7. #7
    Funking Prink! Raz316's Avatar
    Join Date
    Jul 2003
    Location
    Deal, Kent, UK
    Posts
    2,978
    Thanks
    130
    Thanked
    62 times in 52 posts
    I'll give it a go cheers

    and "echoing ascii char mappings" why the hell couldn't I word it like that!

  8. #8
    Commander Keen
    Join Date
    Nov 2003
    Location
    217.27.240.214
    Posts
    624
    Thanks
    0
    Thanked
    0 times in 0 posts
    Erm... How about this.

    Why don't you get your client to send a character or a word to represent the keystroke you are after. Then get the server to look for that. This is how I got round this type of thing. When developing apps that work like telnet YOU define the commands you want to implement.

    OR have I just misunderstood you ? Are you trying to use standard telnet daemons/clients... If thats the case. My bad. Sorry

    [EDITS]
    Ah.. you are script accessing it, or 'terming' in. I will shut my mouth and clean out my eyes

  9. #9
    Funking Prink! Raz316's Avatar
    Join Date
    Jul 2003
    Location
    Deal, Kent, UK
    Posts
    2,978
    Thanks
    130
    Thanked
    62 times in 52 posts
    Yeah its a really shoddy way of accessing it, I know, but the program on the server has no command line interface so you have to manually open the program and navigate through using the cursor keys :/

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. VBA - Telnet
    By Raz316 in forum Software
    Replies: 0
    Last Post: 13-04-2004, 11:13 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •