-1

To go more indepth i have a program where I want to prompt the user to type their given username and password (Given from me) and make them type it in, if it is correct it will run a check on the hostname to see if the password matches their hostname that they told me. So basicaly make something like this:

cout << "Type in your username: ";
cin >> username;
cout << "Type in your password: ";
cin >> password;
if (username == "Example" && password == "Example") { /* Checks if correct   
combination.*/
cout << "Correct combination, running Hostname scan\n";
// Than scan hostname and assign it to this string "hostname"
if (hostname == "Example's Computer") {
    cout << "Access granted\n";
    system("cls"); // And clear the screan!
}   

This is so if I were to sell a program and than give him his Username and Password, and than he gives me his hostname so he cant just give the hack away for free, since he has given me his computers name!

i_am_jorf
  • 53,608
  • 15
  • 131
  • 222
Yami
  • 29
  • 1
  • 6
  • Which system? Under Linux run `hostname` and pipe the output. – qwerty_so Feb 23 '15 at 20:36
  • 2
    That last sentence makes no sense. – Biffen Feb 23 '15 at 20:37
  • 2
    The trouble with hostnames is that a user can set them to whatever they want.. – Collin Feb 23 '15 at 20:38
  • Sorry guys if the last part of my text didn't make sense, English is not my native language! System is for windows, sorry if i was not specific enough! :) @ThomasKilian. – Yami Feb 23 '15 at 20:41
  • One computer can have more than one User. My home PC has one account for each family member. My work PC has one account for each I.T. person (plus me). – Thomas Matthews Feb 23 '15 at 20:54
  • What happens if the User wants to switch computers, such as Laptop vs. Desktop? How will you manage that? – Thomas Matthews Feb 23 '15 at 20:55
  • @ThomasMatthews This is a hack, if the user wants to change PC, i will remove his old Hostname and replace it. This is how most of the hacks nowadays are done (If they are made without using some sort of database for storing stuff that is:P). And if he has confirmed it i can always add an else if. And to answer your first question, it is meant for one user. Only the person that buys it. – Yami Feb 23 '15 at 21:09
  • You're going to make a custom build of your software for each customer? That seems a little ridiculous. This won't be worth the effort; there are too many easy ways to bypass this security check. – i_am_jorf Feb 23 '15 at 21:19

1 Answers1

0

If you want to get the hostname for the local computer on Windows, you can just call gethostname(), or one of the related winsock functions, depending on your needs.

i_am_jorf
  • 53,608
  • 15
  • 131
  • 222
  • Thanks for this answer. I got help on another site before you answered. But thanks! :) – Yami Feb 23 '15 at 21:29