How to secure your console program with LOGIN

How to secure your console program with LOGIN

Post by -Th3V01d- on Wed Jan 25, 2012 9:26 am
([msg=63868]see How to secure your console program with LOGIN[/msg])

Hello,

I'm gonna show you how to secure your console program with LOGIN. So you need to enter a username and password to access the content of program. This is basic and very easy script that everyone can learn, when i say "basic" i mean it isn't hackable, you can hack this if you know how. But enough of talk lets move on coding!

I will post here full code of program and explain(I will use Classes to store functions in).
Code: Select all
#include <iostream>
#include <string> // You need this if you want to store more complex username and password.

using namespace std;

class Program
{
      public:
             void username_func()
             {
                  system("CLS");
                  system("TITLE Basic protection of program");
                  cout << "ACCESS DENIED! Please indentify yourself." << endl;
                  cout << "Enter username: ";
                  std::string username; // Username variable
                  cin >> username;
                  if (username == "-Th3V01D-") // If you want to store complex username like this, you will need string declaration
                  {
                               password_func();
                               }
                  else
                  {
                      username_func();
                      }
                  }
      protected:
                void password_func()
                {
                  system("CLS");
                  cout << "ACCESS DENIED! Please indentify yourself." << endl;
                  cout << "Enter username: *********" << endl;
                  cout << "Enter password: ";
                  std::string password; // Password variable
                  cin >> password;
                  if (password == "y0ucan'tst0pm3")
                  {
                               access_granted();
                               }
                  else
                  {
                      password_func();
                      }
                     }
      private:
              void access_granted()
              {
                   system("CLS");
                   system("COLOR A");
                   cout << "Welcome agent, -Th3V01D-" << endl;
                   cout << "Begin search database: ";
                   cin.get();
                   }
      };

int main()
{
    Program run;
    run.username_func();
    return 0;
    }


Pretty cool huh??? ;) with this code you can make you own database or password storage or ANYTHING YOU WANT!

Enjoy!
-Th3V01D- :ugeek:
ImageДа будет Революция
User avatar
-Th3V01d-
New User
New User
 
Posts: 11
Joined: Sun Jan 15, 2012 8:24 am
Blog: View Blog (0)


Re: How to secure your console program with LOGIN

Post by pretentious on Thu Jan 26, 2012 6:49 am
([msg=63889]see Re: How to secure your console program with LOGIN[/msg])

Thanks for sharing. Storing the password as a string literal isn't the best security measure, also I'm not a fan of using OO programming when it isn't totally necessary but that's just me stuck in my ways i guess.
Goatboy wrote:Oh, that's simple. All you need to do is dedicate many years of your life to studying security.

IF you feel like exchanging ASCII arrays, let me know ;)
pretentious wrote:Welcome to bat country
User avatar
pretentious
Contributor
Contributor
 
Posts: 701
Joined: Wed Mar 03, 2010 12:48 am
Blog: View Blog (0)


Re: How to secure your console program with LOGIN

Post by centip3de on Thu Jan 26, 2012 4:24 pm
([msg=63897]see Re: How to secure your console program with LOGIN[/msg])

pretentious wrote:Thanks for sharing. Storing the password as a string literal isn't the best security measure, also I'm not a fan of using OO programming when it isn't totally necessary but that's just me stuck in my ways i guess.


^ This.

Also, try using more portable commands for clearing the screen. Not everyone is on Windows, you know. Next, instead of
Code: Select all
                   cout << "Welcome agent, -Th3V01D-" << endl;
. Try;
Code: Select all
cout << "Welcome agent, " << username << endl;


That way if you change the username variable, it wouldn't still call you -Th3V01D- . And if you already stated that you're using namespace std, you don't need to use 'std::' in-front of all the strings. Just 'string' would suffice. Other than those, it looks like a pretty cool program for beginners. I like that you actually indent things in your code, makes it much more readable IMHO.

Keep it up!
~Cent
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. -Rick Cook
User avatar
centip3de
Moderator
Moderator
 
Posts: 1467
Joined: Fri Aug 20, 2010 5:46 pm
Blog: View Blog (0)


Re: How to secure your console program with LOGIN

Post by Jiffy on Fri Jan 27, 2012 3:36 am
([msg=63902]see Re: How to secure your console program with LOGIN[/msg])

I remember when I first learned to code...I'll be honest with you, this is pathetic. All you're doing is performing a conditional check on the user supplied input to see if it matches a predefined variable, do I hear "vulnerable as fuck"? Any scrub could crack this program using the most primitive of reversing techniques in about a few minutes.
Jiffy
New User
New User
 
Posts: 4
Joined: Wed Aug 10, 2011 1:55 am
Blog: View Blog (0)


Re: How to secure your console program with LOGIN

Post by -Th3V01d- on Fri Jan 27, 2012 6:35 am
([msg=63904]see Re: How to secure your console program with LOGIN[/msg])

Jiffy wrote:I remember when I first learned to code...I'll be honest with you, this is pathetic. All you're doing is performing a conditional check on the user supplied input to see if it matches a predefined variable, do I hear "vulnerable as fuck"? Any scrub could crack this program using the most primitive of reversing techniques in about a few minutes.

i told that already...... that is basic "protection" and its very easy to crack.. i can do more complex code to protect but for beginning this is enough.... i writted this code for beginners...

-- Fri Jan 27, 2012 6:44 am --

And if you already stated that you're using namespace std, you don't need to use 'std::' in-front of all the strings. Just 'string' would suffice.

i know, but this is my first time using Dev-C++, im writing std:: because thats im gonna need in Visual C++ 2010 with "namespace" declaration, in Dev-C++ it doesn't need... :shock:
ImageДа будет Революция
User avatar
-Th3V01d-
New User
New User
 
Posts: 11
Joined: Sun Jan 15, 2012 8:24 am
Blog: View Blog (0)


Re: How to secure your console program with LOGIN

Post by Comperz91 on Fri Jan 27, 2012 7:05 am
([msg=63909]see Re: How to secure your console program with LOGIN[/msg])

-Th3V01d- wrote:
Jiffy wrote:I remember when I first learned to code...I'll be honest with you, this is pathetic. All you're doing is performing a conditional check on the user supplied input to see if it matches a predefined variable, do I hear "vulnerable as fuck"? Any scrub could crack this program using the most primitive of reversing techniques in about a few minutes.

i told that already...... that is basic "protection" and its very easy to crack.. i can do more complex code to protect but for beginning this is enough.... i writted this code for beginners...

-- Fri Jan 27, 2012 6:44 am --

And if you already stated that you're using namespace std, you don't need to use 'std::' in-front of all the strings. Just 'string' would suffice.

i know, but this is my first time using Dev-C++, im writing std:: because thats im gonna need in Visual C++ 2010 with "namespace" declaration, in Dev-C++ it doesn't need... :shock:



Give the kid a breaK? ^^
he have done great :D

Thx for sharing! =D
I wanna be the very best Like no one ever was,
To know it all is my real test To master it, is my cause

programming, gotta know 'em all
User avatar
Comperz91
New User
New User
 
Posts: 35
Joined: Fri Jan 27, 2012 6:24 am
Location: Sweden
Blog: View Blog (0)


Re: How to secure your console program with LOGIN

Post by centip3de on Fri Jan 27, 2012 3:29 pm
([msg=63918]see Re: How to secure your console program with LOGIN[/msg])

Jiffy wrote:I remember when I first learned to code...I'll be honest with you, this is pathetic. All you're doing is performing a conditional check on the user supplied input to see if it matches a predefined variable, do I hear "vulnerable as fuck"? Any scrub could crack this program using the most primitive of reversing techniques in about a few minutes.


So? This is a _beginning_ program. I highly doubt that when you began programming you could do much better. I mean, the fact that he is using OOP (while in the completely wrong context) shows that he at least understands a semi-advanced topic. Next time you feel like improving your self-esteem by degrading someone who just started, don't. You just wind up looking like an insensitive prick.
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. -Rick Cook
User avatar
centip3de
Moderator
Moderator
 
Posts: 1467
Joined: Fri Aug 20, 2010 5:46 pm
Blog: View Blog (0)


Re: How to secure your console program with LOGIN

Post by Comperz91 on Sat Jan 28, 2012 9:23 am
([msg=63937]see Re: How to secure your console program with LOGIN[/msg])

centip3de wrote:
Jiffy wrote:I remember when I first learned to code...I'll be honest with you, this is pathetic. All you're doing is performing a conditional check on the user supplied input to see if it matches a predefined variable, do I hear "vulnerable as fuck"? Any scrub could crack this program using the most primitive of reversing techniques in about a few minutes.


So? This is a _beginning_ program. I highly doubt that when you began programming you could do much better. I mean, the fact that he is using OOP (while in the completely wrong context) shows that he at least understands a semi-advanced topic. Next time you feel like improving your self-esteem by degrading someone who just started, don't. You just wind up looking like an insensitive prick.


Word! 8-)
I wanna be the very best Like no one ever was,
To know it all is my real test To master it, is my cause

programming, gotta know 'em all
User avatar
Comperz91
New User
New User
 
Posts: 35
Joined: Fri Jan 27, 2012 6:24 am
Location: Sweden
Blog: View Blog (0)


Re: How to secure your console program with LOGIN

Post by LoGiCaL__ on Sun Jan 29, 2012 3:04 am
([msg=63962]see Re: How to secure your console program with LOGIN[/msg])

Jiffy wrote:I remember when I first learned to code...I'll be honest with you, this is pathetic. All you're doing is performing a conditional check on the user supplied input to see if it matches a predefined variable, do I hear "vulnerable as fuck"? Any scrub could crack this program using the most primitive of reversing techniques in about a few minutes.


Instead of responding with what can be basically summed up as an insult for no reason, respond with better code and teach the ones that are willing to learn.
User avatar
LoGiCaL__
Addict
Addict
 
Posts: 1063
Joined: Sun May 30, 2010 12:33 pm
Blog: View Blog (0)


Re: How to secure your console program with LOGIN

Post by MNP_Hikaru on Sun Jan 29, 2012 3:12 pm
([msg=63977]see Re: How to secure your console program with LOGIN[/msg])

LoGiCaL__ wrote:
Jiffy wrote:I remember when I first learned to code...I'll be honest with you, this is pathetic. All you're doing is performing a conditional check on the user supplied input to see if it matches a predefined variable, do I hear "vulnerable as fuck"? Any scrub could crack this program using the most primitive of reversing techniques in about a few minutes.


Instead of responding with what can be basically summed up as an insult for no reason, respond with better code and teach the ones that are willing to learn.


Word. And come on, he's actively posting content in the forums. We need more members like that. I say +1 to him, keep up the good work!
One of these days there's gonna be a real profound quote down here.
User avatar
MNP_Hikaru
Experienced User
Experienced User
 
Posts: 70
Joined: Tue Oct 05, 2010 9:22 pm
Blog: View Blog (0)



Return to C and C++

Who is online

Users browsing this forum: No registered users and 0 guests