Results 1 to 12 of 12
  1. #1
    xephora's Avatar
    Join Date
    Mar 2010
    Gender
    male
    Posts
    45
    Reputation
    8
    Thanks
    3

    Remote Process Killing C++

    Good Day all,

    It's me again.. Yet again I am stumped as always. I am trying to create a remote process killer which in my infrastructure I gotta clean out some processes from some computers "out side the box". I thought if I can make a cool C++ program that accepts the ip or hostname, domain, userid and the process then proceeds to add the inputs into a system command I use very often to eliminate a suspicious process. I always seem to bump into an issue at the end. Remember I am a beginner so sorry for my bad syntax. I would really appreciate the assistance.

    Code:
    #include <cstdlib>
    #include <iostream>
    #include <windows.h>
    
    using namespace std;
    
    char pcname[256];
    char domain[256];
    char userid[256];
    char process[256];
    
    
    int main()
    {
        cout << "Remote Process Kill Utility \n";
        cout << "Please Provide target hostname \n ->";
        cin >> pcname;
        
        cout << "\nDomain \n ->";
        cin >> domain;
        
        cout << "\nUser id \n ->";
        cin >> userid;
        
        cout << "\nProcess name *Example explorer.exe \n ->";
        cin >> process;
        
        system("cls");
        system("Loading..");
        system("taskkill /s " + pcname + " /u " + domain + "\\" + userid + " /fi " "username ne nt*" "/im " + process + "");
        return 0;
    }






    Update..


    Oh man... So close... Can someone help me add quotes to a system command string. It like totally ignores the quotes.

    Code:
    #include <cstdlib>
    #include <iostream>
    #include <windows.h>
    
    using namespace std;
    
    static string pcname;
    static string domain;
    static string userid;
    static string process;
    
    
    int main()
    {
        cout << "Remote Process Kill Utility \n";
        cout << "------------------------------\n";
        cout << "Please Provide target hostname \n ->";
        cin >> pcname;
        
        cout << "\nDomain \n ->";
        cin >> domain;
        
        cout << "\nUser id \n ->";
        cin >> userid;
        
        cout << "\nProcess name *Example explorer.exe \n ->";
        cin >> process;
        
        system("cls");
        system("echo Loading..");
        system(("echo taskkill /s " + pcname + " /u " + domain + "\\" + userid + " /fi " + """username ne nt*""" + " /im " + process + "").c_str());
        system("pause");
        return 0;
    }
    output:

    Taskkill /s pcname /u domain\userid /fi "username ne nt*" /IM process

    I can't add the quotes between username and nt!! sooo close yet so far!!!
    Last edited by xephora; 07-28-2011 at 08:46 AM.

  2. #2
    258456's Avatar
    Join Date
    May 2010
    Gender
    male
    Location
    ghjghj
    Posts
    1,222
    Reputation
    18
    Thanks
    300
    My Mood
    Relaxed
    use sprintf to get everything into one string. For example:


    Code:
    char string[50];
    
    sprintf(string, "echo taskkill /s   %s  /u  %s \\  %s  /fi username ne nt*  /im  %s ", pcname, domain, process);
    
    system(string)
    This way you can make your string the way you want it. When you see the function sprintf above and look at "%s". This means that you are going to replace the %s with a string, and after the comma I put in order the strings like pcname and stuff that you wanted where it said %s.

  3. #3
    xephora's Avatar
    Join Date
    Mar 2010
    Gender
    male
    Posts
    45
    Reputation
    8
    Thanks
    3
    Sweet.. Would that accept quote marks? It's essential that the quotes is added otherwise the command won't work.

    Taskkill /s pcname /u domain\userid /fi "username ne nt*" /IM process

    Those quotes is what allows the command to go through successfully.
    Last edited by xephora; 07-28-2011 at 10:49 AM.

  4. #4
    Nico's Avatar
    Join Date
    Jan 2011
    Gender
    male
    Location
    Germany :D
    Posts
    15,918
    Reputation
    1121
    Thanks
    8,617
    Quotes are made like this:

    Code:
    char* string = "We got \"Quotes\"";

  5. #5
    xephora's Avatar
    Join Date
    Mar 2010
    Gender
    male
    Posts
    45
    Reputation
    8
    Thanks
    3
    "\" works!!!!! omg! SUCCESS!!!!! You guys are the best!


    Code:
    #include <windows.h>
    
    using namespace std;
    
    static string pcname;
    static string domain;
    static string userid;
    static string process;
    
    int main()
    {
        cout << "Remote Process Kill Utility \n";
        cout << "------------------------------\n";
        cout << "Please Provide target hostname \n->";
        cin >> pcname;
        
        cout << "\nDomain \n->";
        cin >> domain;
        
        cout << "\nUser id \n->";
        cin >> userid;
        
        cout << "\nProcess name *Example explorer.exe \n->";
        cin >> process;
        
        system("cls");
        system("echo Loading..");
        system(("taskkill /s " + pcname + " /u " + domain + "\\" + userid + " /fi " + "\"username ne nt*\"" + " /im " + process + "").c_str());
        system("exit");
        return 0;
    }
    Open sourced!! I love it! Remote Process Elimination! Now I think i can fit other sweet commands in this... You guys rock!
    Last edited by xephora; 07-28-2011 at 11:16 AM.

  6. #6
    258456's Avatar
    Join Date
    May 2010
    Gender
    male
    Location
    ghjghj
    Posts
    1,222
    Reputation
    18
    Thanks
    300
    My Mood
    Relaxed
    You are very welcome. It is good that you are doing programs like this because you are learning more and more and eventually you will make epic stuff. Good luck.

  7. #7
    xephora's Avatar
    Join Date
    Mar 2010
    Gender
    male
    Posts
    45
    Reputation
    8
    Thanks
    3
    I hope so! >.< I love it! I'm using it so much. I wish I can make a window application with this type of program instead of it being a bland cmd prompt. I also made a Remote Process Viewer which will record and log processes running in the background of a remote computer. I love it.

    Code:
    #include <cstdlib>
    #include <iostream>
    #include <windows.h>
    
    using namespace std;
    
    static string pcname;
    static string session;
    
    int main()
    {
        cout << "Please enter Session ID\n->";
        cin >> session;
        system("cls");
        cout << "Remote Process Viewer \n";
        cout << "------------------------\n";
        cout << "Please Provide Target Hostname\n->";
        cin >> pcname;
        
        system(("tasklist /s " + pcname + " /fo list >> Library\\Log_Session_" + session + ".log").c_str());
        system("cls");
        system("echo Please check Library for Results listed under your session id");
        system("pause");
        return EXIT_SUCCESS;
    You will need to create a folder called Library with Remote Process Viewer.
    Last edited by xephora; 07-29-2011 at 05:46 AM.

  8. #8
    xephora's Avatar
    Join Date
    Mar 2010
    Gender
    male
    Posts
    45
    Reputation
    8
    Thanks
    3
    Update!!

    I included a cool option side to either eliminate via process or pid. Gotta love this.

    Code:
    #include <cstdlib>
    #include <iostream>
    #include <windows.h>
    
    using namespace std;
    
    static string pcname;
    static string domain;
    static string userid;
    static string processh;
    static string pidn;
    static string doover;
    static string cnl;
    
    int pid()
    {
        cout << "Remote PID Kill Utility \n";
        cout << "------------------------------\n";
        cout << "Please Provide target hostname \n\n\n\n>";
        cin >> pcname;
        
        cout << "\nDomain \n->";
        cin >> domain;
        
        cout << "\nUser id \n->";
        cin >> userid;
        
        cout << "\nPID Number of Target process \n->";
        cin >> pidn;
        
        system("cls");
        system("echo Loading..");
        system(("taskkill /s " + pcname + " /u " + domain + "\\" + userid + " /fi " + "\"username ne nt*\"" + " /PID " + pidn + "").c_str());
        cout << "\necho Retry? Y / N";
        cin >> doover;
        if (doover == "Y" || doover == "y")
        {
                   system("cls");
                   pid();
        }
        else if (doover == "N" || doover == "n")
        {
             system("exit");
        }
    }
    
    int process()
    {
        cout << "Remote Process Kill Utility \n";
        cout << "------------------------------\n";
        cout << "Please Provide target hostname \n>";
        cin >> pcname;
        
        cout << "\nDomain \n->";
        cin >> domain;
        
        cout << "\nUser id \n->";
        cin >> userid;
        
        cout << "\nProcess name *Example explorer.exe \n->";
        cin >> processh;
        
        system("cls");
        system("echo Loading..");
        system(("taskkill /s " + pcname + " /u " + domain + "\\" + userid + " /fi " + "\"username ne nt*\"" + " /im " + processh + "").c_str());
        cout << "\nRetry? Y / N";
        cin >> doover;
        if (doover == "Y" || doover == "y")
        {
                   system("cls");
                   process();
        }
        else if (doover == "N" || doover == "n")
        {
                   system("exit");
        }
    }
    
    int main()
    {
        SetConsoleTitle("Remote Process Killer");
        system("cls");
        system("color 0f");
        system("echo Please Select your Method of Process Removal");
        cout << "\n\n";
        system("echo Type 1 for Process ID\n");
        system("echo Type 2 for PID");
        cout << "\n\n\n>";
        cin >> cnl;
        
        if (cnl == "1")
        {
                system("cls");
                process();
        }
        else if (cnl == "2")
        {
                system("cls");
                pid();
        }
        return 0;
    }
    Feel free to trim it up or add to it if you feel! I love this.



    OOOOh! I got an idea. Is there any way I can make this into an window application or is there any way I can turn the process viewer to show up in a separate window with the results of the processes instead of logs in a folder. I would like to minimize the amount of effort as possible.
    Last edited by xephora; 07-29-2011 at 11:24 AM.

  9. #9
    FailHacker's Avatar
    Join Date
    Sep 2010
    Gender
    male
    Posts
    444
    Reputation
    8
    Thanks
    49
    Quote Originally Posted by xephora View Post
    Update!!

    I included a cool option side to either eliminate via process or pid. Gotta love this.

    Code:
    #include <cstdlib>
    #include <iostream>
    #include <windows.h>
    
    using namespace std;
    
    static string pcname;
    static string domain;
    static string userid;
    static string processh;
    static string pidn;
    static string doover;
    static string cnl;
    
    int pid()
    {
        cout << "Remote PID Kill Utility \n";
        cout << "------------------------------\n";
        cout << "Please Provide target hostname \n\n\n\n>";
        cin >> pcname;
        
        cout << "\nDomain \n->";
        cin >> domain;
        
        cout << "\nUser id \n->";
        cin >> userid;
        
        cout << "\nPID Number of Target process \n->";
        cin >> pidn;
        
        system("cls");
        system("echo Loading..");
        system(("taskkill /s " + pcname + " /u " + domain + "\\" + userid + " /fi " + "\"username ne nt*\"" + " /PID " + pidn + "").c_str());
        cout << "\necho Retry? Y / N";
        cin >> doover;
        if (doover == "Y" || doover == "y")
        {
                   system("cls");
                   pid();
        }
        else if (doover == "N" || doover == "n")
        {
             system("exit");
        }
    }
    
    int process()
    {
        cout << "Remote Process Kill Utility \n";
        cout << "------------------------------\n";
        cout << "Please Provide target hostname \n>";
        cin >> pcname;
        
        cout << "\nDomain \n->";
        cin >> domain;
        
        cout << "\nUser id \n->";
        cin >> userid;
        
        cout << "\nProcess name *Example explorer.exe \n->";
        cin >> processh;
        
        system("cls");
        system("echo Loading..");
        system(("taskkill /s " + pcname + " /u " + domain + "\\" + userid + " /fi " + "\"username ne nt*\"" + " /im " + processh + "").c_str());
        cout << "\nRetry? Y / N";
        cin >> doover;
        if (doover == "Y" || doover == "y")
        {
                   system("cls");
                   process();
        }
        else if (doover == "N" || doover == "n")
        {
                   system("exit");
        }
    }
    
    int main()
    {
        SetConsoleTitle("Remote Process Killer");
        system("cls");
        system("color 0f");
        system("echo Please Select your Method of Process Removal");
        cout << "\n\n";
        system("echo Type 1 for Process ID\n");
        system("echo Type 2 for PID");
        cout << "\n\n\n>";
        cin >> cnl;
        
        if (cnl == "1")
        {
                system("cls");
                process();
        }
        else if (cnl == "2")
        {
                system("cls");
                pid();
        }
        return 0;
    }
    Feel free to trim it up or add to it if you feel! I love this.



    OOOOh! I got an idea. Is there any way I can make this into an window application or is there any way I can turn the process viewer to show up in a separate window with the results of the processes instead of logs in a folder. I would like to minimize the amount of effort as possible.

    Spend time on Win32
    Legen...wait for it...dary







  10. #10
    xephora's Avatar
    Join Date
    Mar 2010
    Gender
    male
    Posts
    45
    Reputation
    8
    Thanks
    3
    Any book recommendation or video tutorials that you learned from? I see a bunch in buy.com, however the books are for different platforms such as windows NT or windows 2000.

  11. #11
    Tekkn0logik's Avatar
    Join Date
    Sep 2010
    Gender
    male
    Posts
    37
    Reputation
    12
    Thanks
    52
    My Mood
    Amused
    Quote Originally Posted by xephora View Post
    Any book recommendation or video tutorials that you learned from? I see a bunch in buy.com, however the books are for different platforms such as windows NT or windows 2000.
    Google 'theforger win32 tutorial' -- that's a good online one. I'd link you directly, but it'd be a pain since I'm posting this from a phone.
    If you want an actual book, the definitive Windows API guide is "Programming Windows" by Charles Petzold. I have it, and it's great.
    Last edited by Tekkn0logik; 08-04-2011 at 10:51 PM.

  12. #12
    xephora's Avatar
    Join Date
    Mar 2010
    Gender
    male
    Posts
    45
    Reputation
    8
    Thanks
    3
    Thanks alot I will definitely check the tutorial out! If i find that book I shall buy it as well! Sorry for the late reply!
    Last edited by xephora; 08-14-2011 at 07:25 PM.

Similar Threads

  1. Process Kill
    By GameTrainerMaker in forum Combat Arms Hack Coding / Programming / Source Code
    Replies: 3
    Last Post: 07-15-2010, 08:11 AM
  2. Remote Kill
    By Peacemaker93 in forum Combat Arms Discussions
    Replies: 1
    Last Post: 03-06-2010, 01:13 PM
  3. How to kill a process?
    By ac1d_buRn in forum Visual Basic Programming
    Replies: 16
    Last Post: 11-27-2009, 08:20 AM
  4. [TUT] Get running processes and kill them ~~
    By Zoom in forum Visual Basic Programming
    Replies: 2
    Last Post: 11-09-2009, 08:34 AM
  5. Can't kill Avira Processes?
    By Th3KaNgSt3R in forum Suggestions, Requests & General Help
    Replies: 2
    Last Post: 09-17-2009, 06:42 PM