How do you make this program?

Status
Not open for further replies.

HiJackThis1.99

Posts: 91   +0
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
 
You use the system() function to make the OS run something.

Does Firefox actually work when the executable is not in its proper directory?
 
Nodsu said:
You use the system() function to make the OS run something.

Does Firefox actually work when the executable is not in its proper directory?
How?
Can you please rewrite the code for me by changing my last line.
 
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 :)
 
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:
14:14 D:\Files\Untitled2.cpp [Warning] unknown escape sequence '\W'
14:14 D:\Files\Untitled2.cpp [Warning] unknown escape sequence '\s'
14:14 D:\Files\Untitled2.cpp [Warning] unknown escape sequence '\c'

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.
 
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/.."
 
Nodsu said:
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/.."
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.
 
Status
Not open for further replies.
Back