SitePoint Sponsor

User Tag List

Results 1 to 11 of 11
  1. #1
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,071
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)

    Communicating with a Telnet Program

    I am wanting to write a php script that will communicate with a telnet script.

    What happens is when access a telnet server you are asked for a userid and pin number, I want to be able to use PHP to enter that data, along with other data.

    Does anyone have any experience at this?
    -Matt
    Be sure to congratulate Patche on earning July's Member of the Month
    Go ahead and blame me, I still won't lose any sleep over it
    My Blog | My Technical Notes

  2. #2
    SitePoint Zealot
    Join Date
    Aug 2003
    Location
    Brisbane, QLD
    Posts
    101
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you should be able to accomplish that using just sockets (which is what telnet essentially does, more or less)

    http://php.net/fsockopen

  3. #3
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,071
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by soapsud
    you should be able to accomplish that using just sockets (which is what telnet essentially does, more or less)

    http://php.net/fsockopen
    I have used fsockopen, but not to communicate with a console program. Is there anything I need to look out for? I am guessing that fgets will grab the output prompt from the telnet script, and fputs will send it the user input?

    Okay, I have successfully grabbed the prompt but how do I send it information, then receive the new prompt, etc?

    -Matt
    Last edited by cpradio; Oct 4, 2003 at 12:05.

  4. #4
    SitePoint Zealot
    Join Date
    Aug 2003
    Location
    Brisbane, QLD
    Posts
    101
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yep, you should be able to just fputs anything and fgets it back, and continue on and on until the socket is closed... if you're having trouble just post some code, and perhaps a bit of info as to what happens in a typical telnet session

  5. #5
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,071
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    http://cpradio.net/telnet.phps

    I know very little about the telnet script that is being executed. I am in a class called Secure E-commerce, and we are supposed to develop techniques of cracking a 4 digit pin and discovering the other's 10 digit id numbers.

    Since I am more comfortable in PHP, than I am in Java, I decided to give it ago using PHP, I have learned a bit of Java (only enough to write a RSA encryption technique for the class), but I know even less about talking to a telnet socket.

    -Matt

  6. #6
    ********* Victim lastcraft's Avatar
    Join Date
    Apr 2003
    Location
    London
    Posts
    2,423
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Hi.

    You want RFC854. To play with it get a terminal program (not telnet) and connect to the telnet port of your machine. You will have to install a telnet server and disable any extra protection it might have (Kerberos) and allow the appropriate port (21 I think) through the firewall. Once you have finished playing I would then disable it again as Telnet has been obsoleted by ssh because of security concerns.

    yours, Marcus.

    p.s. There is a text version of the RFC here, but I would find a more explanatory version:
    http://www.ietf.org/rfc/rfc0854.txt
    Marcus Baker
    Testing: SimpleTest, Cgreen, Fakemail
    Other: Phemto dependency injector
    Books: PHP in Action, 97 things

  7. #7
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,071
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    What is RFC854?? I went to the link you posted but that sounds like it was written by a legal team and it is just too confusing.

    Can someone summarize what RFC854 is and why I supposedly want that?

    Whenever I access the telnet server of the school project, it automatically runs a script seeking a userid and pin number.....I cannot see how a telnet program will help me with this.

  8. #8
    ********* Victim lastcraft's Avatar
    Join Date
    Apr 2003
    Location
    London
    Posts
    2,423
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Hi.

    It's the definition of the Telnet protocol.

    I was thinking you could understand what was going on my manually sending commands to the telnet server. Now I am confused. Is it that you are on the server side already and trying to communicate with the script that handles the Telnet connection? Or are you trying to communicate via Telnet to a system? If the latter then you will have to write code to handle the protocol if you are using a raw socket connection.

    yours, Marcus
    Marcus Baker
    Testing: SimpleTest, Cgreen, Fakemail
    Other: Phemto dependency injector
    Books: PHP in Action, 97 things

  9. #9
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,071
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    Okay, here is what I have to do.

    I use putty, or konsole to connect to ecommerce.cis.utulsa.edu.

    As soon as it establishes the connection it asks for a userid and pin number, now I have my own userid and pin number but the point of the project is to do pin cracking to develop other user's 4-digit pin numbers.

    I have no idea what methods can be used to do pin cracking, I was hoping I could just run a loop using PHP, but it seems a bit more complex than that considering I do not know the variables names the script is looking for.

    Does this make more sense now?
    -Matt

  10. #10
    SitePoint Zealot
    Join Date
    Aug 2003
    Location
    Brisbane, QLD
    Posts
    101
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yep, so what's the problem? essentially, you should be able to fsockopen to connect, then trade off fputs and fgets to send and receive commands until you're done.

    just remember when your script stops so does your connection.

  11. #11
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,071
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    Okay, here is my problem.
    http://cpradio.net/telnet.phps -- source code
    http://cpradio.net/telnet.php -- add ?start= to the address to start the process

    I send it my 10 digit ID but all I get in return is the same prompt, "login (account number): "

    Is there something I am missing?


Bookmarks

Posting Permissions

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