Results 1 to 5 of 5

Thread: [C(++)] Project Programming Help

  1. #1
    Junior Member
    Join Date
    Jan 2010
    Location
    Canada
    Posts
    84

    Default [C(++)] Project Programming Help

    So about 70% into C++ Primer, I decided to tackle two pretty advanced topics at once, Sockets and Multithreading, well I spent three weeks or so (yes three) reading up on it, and my current project is this:

    Have a server on a Linux Machine, and clients on Windows, they connect, and I can send a variety of things to them from my linux machine. To be blunt Im making a reverse shell I have no desire to sent it out since well, if I need to ask for help, chances are id get caught

    Ive got the base coded, (and modules ), but im stuck on one crucial part, sending the data in a reliable way, since I need to use non blocking sockets, or at least blocking sockets with a very short time out. So before I go freaking out with fancy append calls and such, does anyone know of another reliable way to send large blocks of text ( think the size of a detailed nmap scan at max, ie a small essay ) over sockets? I cant seem to find a way that fits my needs and my rigid coding style :s

  2. #2
    Very good friend of the forum Virchanza's Avatar
    Join Date
    Jan 2010
    Posts
    863

    Default

    Which networking library are you using?

    There's probably a networking library out there that lets you send files by writing one line of code:

    SendFileHTTP(my_socket,my_file);
    Ask questions on the open forums, that way everybody benefits from the solution, and everybody can be corrected when they make mistakes. Don't send me private messages asking questions that should be asked on the open forums, I won't respond. I decline all "Friend Requests".

  3. #3
    Junior Member
    Join Date
    Jan 2010
    Location
    Canada
    Posts
    84

    Default

    Quote Originally Posted by Virchanza View Post
    Which networking library are you using?

    There's probably a networking library out there that lets you send files by writing one line of code:

    SendFileHTTP(my_socket,my_file);
    I am using winsock for the client, and the *nix sockets for linux. In other words, no special library.

    I dont need to send files however, I need to send commands to the client, and recieve the output at the server. If i use blocking sockets, theoretically seaking, one computer going down could crash the entire thing, because TCP has a painfully long timeout, if I use non blocking, the data could arrive in the wrong order.

    My idea was to (after the encoding) append --END-- to the string being sent, and have the server watching for the time when the last 6 characters match that, so to send the command... SYSEXC(what im using to represent system calls) ls, it would end up with something like:

    h45h57whj32825jh835II5HVHN3VHN58V--END--

    But im still not sure that will be 100% reliable (what if the buffer gets hit with the begginign of the next command like so:

    abbaguibav8vb8ivno--END--bufjbqaf

    Then my program would be wondering: what does "lsc" mean?

  4. #4
    Very good friend of the forum Virchanza's Avatar
    Join Date
    Jan 2010
    Posts
    863

    Default

    I've only ever done raw socket networking programming, I've never played around with TCP.

    I did a quick Google search though and found this:

    http://www.uio.no/studier/emner/matn...atacomm-03.ppt

    I dunno if it will help you or not, but I think it describes how to make a chat program. (I think your backdoor will basically be a chat program sending text back and forth).
    Ask questions on the open forums, that way everybody benefits from the solution, and everybody can be corrected when they make mistakes. Don't send me private messages asking questions that should be asked on the open forums, I won't respond. I decline all "Friend Requests".

  5. #5
    Junior Member
    Join Date
    Jan 2010
    Location
    Canada
    Posts
    84

    Default

    I think I figured it out, I decided to go with non blocking sockets and a recieve loop like so:

    while (1)
    {
    recieve:
    int status = recv(socketfd, *transmission_buffer, sizeof(transmission_buffer), 0);
    if (status == 0 || status == SOCKET_ERROR) { closesocket(socketfd); goto connect;}
    if (status == -1) {pause(30); goto recieve;}
    if (status > 0 )
    {
    int i = 0;
    while ( status >= i )
    {
    //Merge Array into String
    command_buffer == ("%s%c"command_buffer,transmission_buffer[i]);
    i++;
    }
    //Check for "--END" in string
    if ((command_buffer[(strlen(command_buffer))] == 'D')
    && (command_buffer[((strlen(command_buffer)) - 1)] == 'N')
    && (command_buffer[((strlen(command_buffer)) - 2)] == 'E')
    && (command_buffer[((strlen(command_buffer)) - 3)] == '-')
    && (command_buffer[((strlen(command_buffer)) - 4)] == '-'))
    {
    //Decode + Check Command
    command_buffer = decode(command_buffer);
    chckcommand(command_buffer);
    //Reset Buffers
    command_buffer = "";
    memset(&transmission_buffer, 0, sizeof(transmission_buffer));
    }
    goto recieve;
    }
    }
    Please ignore the function calls that decode it and such :P Those are private srs buizness

Posting Permissions

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