TechSpot

How do you make this program?

By HiJackThis1.99
May 29, 2006
  1. I want to create a program when you click on firefox icon on desktop a DOS window pops up asking for the code. If correct Mozilla firefox is loaded if not program terminates.

    This is my theory (Windows XP)
    ---------------
    1)Rename firefox.exe to for example sdefrag.exe by hexadecimal editing it otherwise program would not work.

    2)Hide this file in a random location on the computer. For example C:\WINDOWS\system32\sdefrag.exe

    3)Thus, to load firefox all you need to execute is the program step 2.

    4)Create a program in C++, say password is 12345:
    Code:
    #include <iostream>
    
    int main ()
    {
       std::cout<<"What is password/n";
       int password;
       std::cin>>password;
       if (password != 12345)
       std::cout<<"Invalid passord/n";
       if (password ==12345)
       load C:\WINDOWS\system32\sdefrag.exe
    
       return 0;
    }   
    
    Problem is with last line,
    "load C:\WINDOWS\system32\sdefrag.exe"
    I have no idea how to make such a command via C++.

    So it is not really a password block it is actually just loading a program from a hidden random location on the computer which the other user cannot know where it is

    5)Now call this program firefox.exe, thus when the user click on the Icon on desktop or finds this in C:\Program Files\Firefox\firefox.exe this black screen would appear.

    Muhahaha
     
  2. Nodsu

    Nodsu TS Rookie Posts: 5,837   +6

    You use the system() function to make the OS run something.

    Does Firefox actually work when the executable is not in its proper directory?
     
  3. HiJackThis1.99

    HiJackThis1.99 TS Enthusiast Topic Starter Posts: 92

    How?
    Can you please rewrite the code for me by changing my last line.
     
  4. Spike

    Spike TS Evangelist Posts: 2,168

  5. HiJackThis1.99

    HiJackThis1.99 TS Enthusiast Topic Starter Posts: 92

    Thanks but I do not understand, I am only starting to learn C++, thus if you can please change the code that I gave so that it would work I would really appreciate it.
     
  6. Nodsu

    Nodsu TS Rookie Posts: 5,837   +6

    Code:
    #include <iostream>
    
    int main ()
    {
       int password;
    
       std::cout << "What is password/n";
       std::cin >> password;
    
       if (password != 12345)
          std::cout << "Invalid passord/n";
    
       if (password == 12345)
          system("C:\WINDOWS\system32\sdefrag.exe");
    
       return 0;
    }
    Note how much more readable this is with some whitespace and newlines. We have plenty of disk space and big monitors nowadays, so there is no reason to squeeze your code into as little space as possible :)
     
  7. HiJackThis1.99

    HiJackThis1.99 TS Enthusiast Topic Starter Posts: 92

    Thank you SO much man. I try to be more open about how I compile.

    I was using BloodShed-Dev C++ compiler something cool happened.

    I did
    Code:
    #include <iostream>
    
    int main ()
    {
       int password;
    
       std::cout << "What is password\n";
       std::cin >> password;
    
       if (password != 12345)
          std::cout << "Invalid passord\n";
    
       if (password == 12345)
          system("C:\WINDOWS\system32\calc.exe");
    
       return 0;
    } 
    
    And it gave an error:
    I then tried,
    Code:
    #include <iostream>
    
    int main ()
    {
       int password;
    
       std::cout << "What is password\n";
       std::cin >> password;
    
       if (password != 12345)
          std::cout << "Invalid passord\n";
    
       if (password == 12345)
          system("calc.exe");
    
       return 0;
    }
    
    And it works!

    After trying,
    Code:
    system(firefox.exe)
    
    Nothing worked.

    I assumed it is only able to run those program that ARE EXECUTABLE in CMD. I tested my idea with,
    Code:
    system(regedit)
    
    And as I guessed it worked.

    Since firefox.exe is not a programmed command in CMD it is not executable. Thus there are two options. Make firefox.exe (or sdefrag.exe) an executable command though CMD or change the coding somehow.

    Thanks again.
     
  8. Nodsu

    Nodsu TS Rookie Posts: 5,837   +6

    The system() function passes the parameter string directly to Windows. You can run calc and regedit directly because they are in the Windows folder and that's one of the places Windows automatically looks for programs.

    The firefox command failed, because the \ character is treated specially. Try with "C:\\windows\\system32..." instead or maybe "c:/windows/system32/.."
     
  9. HiJackThis1.99

    HiJackThis1.99 TS Enthusiast Topic Starter Posts: 92

    It works!!
    Now I hope I can complete my program. I think you were right that firefox does not load from a different folder. I think I can find a way around it.

    I noticed one interesting thing, at first I tried.
    Code:
    #include <iostream>
    
    int main ()
    {
       int password;
    
       std::cout << "What is password\n";
       std::cin >> password;
    
       if (password != 12345)
          std::cout << "Invalid passord\n";
    
       if (password == 12345)
          system("C:/Program Files/Mozilla Firefox/firefox.exe");
    
       return 0;
    }
    
    Nothing happened.

    I then typed,
    Code:
    int main ()
    {
       int password;
    
       std::cout << "What is password\n";
       std::cin >> password;
    
       if (password != 12345)
          std::cout << "Invalid passord\n";
    
       if (password == 12345)
          system("C:/Progra~1/Mozill~1/firefox.exe");
    
       return 0;
    } 
    
    And it worked, the reason why I did that is that in DOS commands (not MS-DOS) there is no such thing as,
    Code:
    C:\Program Files\Mozilla Firefox\firefox.exe
    
    Becuase it is too longggg. The proper why to write this in DOS commands is,
    Code:
    C:\Progra~1\Mozill~1\firefox.exe
    
    Anyway, thank you for you help cuz I am a n00b in C++ hoping to learn it.

    Is there a rep system here? I gladly give you as much as I can.
     
  10. Nodsu

    Nodsu TS Rookie Posts: 5,837   +6

    You already did :)

    Positive feedback is all we need.
     
Topic Status:
Not open for further replies.

Similar Topics

Add New Comment

You need to be a member to leave a comment. Join thousands of tech enthusiasts and participate.
TechSpot Account You may also...