Thread: C++ Telnet

  1. #1
    Code Injector Gaming's Avatar
    Join Date
    Mar 2008
    Posts
    19

    Talking C++ Telnet

    I found out how to execute dos commands in C++ and get output in the console window. I connected to a telnet server but I couldn't call telnet commands by doing system(telnetcommand.c_str()); , is there a way to call telnet commands in C++?
    #WriteProcessMemory

  2. #2
    Registered User
    Join Date
    Aug 2004
    Location
    San Diego, CA
    Posts
    313
    Short answer: No.

    Long answer: Nope.

    Longer answer: No, because when you do the system() call that you're doing, you are just spawning another application process. Unless the application that is spawned has a method for inter-process communication (and you fork it - not just make a system call) then there's no way for your app to do anything with it.

    In example, a piece of code that calls system("pause"); won't have execution returned to it until the pause process completes. Your code isn't even running while the process that system() called is done.



    Edited to add: Also, using system() is inherantly dangerous. What happens when I replace telnet with an application that has viral code strewn throughout it? You just infected your system, but you won't know what caused it.

  3. #3
    Code Injector Gaming's Avatar
    Join Date
    Mar 2008
    Posts
    19

    Talking

    So there are no ways to do a telnet command in C++? are there any libraries for this? any at all?
    #WriteProcessMemory

  4. #4
    Registered User
    Join Date
    Aug 2004
    Location
    San Diego, CA
    Posts
    313
    Quote Originally Posted by Gaming View Post
    So there are no ways to do a telnet command in C++? are there any libraries for this? any at all?
    You would have to write your own telnet-style application. To do this, you'd want to start learning about WinSock, and how to emulate different terminal types if you're going to emulate that functionality - like telnet can.

    If you're talking about using the stock telnet application in your OS of choice and making system() calls, then no. It's just not possible, let alone not being adviseable or even remotely sane.

  5. #5
    Code Injector Gaming's Avatar
    Join Date
    Mar 2008
    Posts
    19
    Thanks for the WinSock tutorial!

    EDIT: What language is it? C or C++?
    Last edited by Gaming; 05-07-2008 at 07:44 PM.
    #WriteProcessMemory

  6. #6
    Registered User
    Join Date
    Apr 2008
    Posts
    890
    Try libwww. It has support for telnet.

  7. #7
    Banned
    Join Date
    Nov 2007
    Posts
    678
    it is certainly possible, and not that difficult either.
    i have not tested, but, it should work:

    - open a pipe for the telnet program
    - write telnet commands to the stdin of telnet

    good luck!

  8. #8
    Registered User
    Join Date
    Oct 2007
    Posts
    66
    When I was learning WinSock I found the MSDN step-by-step walk through to be by far the most valuable resource I had. (In fact I ditched all of the tutorials I had even thought of reading because none of them were as good as that MSDN walk through) I'd provide a link but sadly I can't find it ;( (It's a real shame, it was a _really_ good step-by-step.)
    "When your work speaks for itself - don't interrupt!"

    -Samantha Ingraham.

  9. #9
    Registered User
    Join Date
    Nov 2006
    Posts
    85
    Quote Originally Posted by tjpanda View Post
    When I was learning WinSock I found the MSDN step-by-step walk through to be by far the most valuable resource I had. (In fact I ditched all of the tutorials I had even thought of reading because none of them were as good as that MSDN walk through) I'd provide a link but sadly I can't find it ;( (It's a real shame, it was a _really_ good step-by-step.)

    I know exactly what your talking about. When I first tried learning winsock MSDN was by far the most helpfull resource.

    I think this was it: msdn.microsoft.com/en-us/library/ms738545(VS.85).aspx

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help with telnet and tcp
    By hoAx in forum Windows Programming
    Replies: 11
    Last Post: 03-11-2008, 02:03 PM
  2. C Function Telnet Email
    By karcheee in forum C Programming
    Replies: 3
    Last Post: 07-25-2005, 11:39 AM
  3. C Execl Telnet
    By karcheee in forum C Programming
    Replies: 1
    Last Post: 04-26-2005, 02:31 PM
  4. telnet!!
    By bigB8210 in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 08-13-2003, 05:09 PM
  5. Most Secure (SSH) Telnet Client for Programming
    By kuphryn in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 02-14-2002, 08:49 PM