Skip to content

anonymous /highlyInsecure.cpp

How (NOT!) to lock a folder with password without software
//source from http://ansblog.com/2009/12/how-to-lock-a-folder-with-password-without-software/
//Indentation mistakes may have occurred during transcription, as the original was not indented
//Empty lines, likewise, were inserted haphazardly, as the original did not have any
#include<iostream.h>
#include<fstream.h>
#include<conio.h>
#include<string.h>
#include<dos.h>
#include<stdlib.h>
int main()
{
int ch;
char pass[4]=”aaa”,passcon[20],passw[20],pass1[20],conpass[20],dn[20]=”md x:\\locker”,dr;
char com1[100]=”ren x:\\locker explorer.{20D04FE0-3AEA-1069-A2D8-08002B30309D}”,com2[100]=”attrib +r +h +s x:\\explorer.{20D04FE0-3AEA-1069-A2D8-08002B30309D}”;
char com3[100]=”attrib -r -h -s x:\\explorer.{20D04FE0-3AEA-1069-A2D8-08002B30309D}”,com4[100]=”ren x:\\explorer.{20D04FE0-3AEA-1069-A2D8-08002B30309D} locker”;
char tet[50]=”c:\\windows\\inf\\pass.txt”,tet1[50]=”c:\\windows\\inf\\dr.txt”;
do
{
cout<<”\n\t\t1.Make Locker\n”;
cout<<”\n\t\t2.Lock\n”;
cout<<”\n\t\t3.Unlock\n”;
cout<<”\n\t\t4.Reset Password\n”;
cout<<”\n\t\t5.Exit\n”;
cout<<”\n\t\tEnter Choice : “;
cin>>ch;
if(ch==1)
{
cout<<”Enter a valid drive letter to create locker (ex. c)\t:”;
cin>>dn[3];
system(dn);
ofstream finp;
finp.open(tet);
finp<<pass;
ofstream finr;
finr.open(tet1);
finr<<dn[3];
finp.close();
finr.close();
cout<<”LOCKER CREATED SUCCESSFULLY”;
cout<<”\nPress any key to return to menu…”;
getch();
system(“cls”);
}
else if(ch==2)
{ifstream finp;
ifstream finr;
finp.open(tet);
finr.open(tet1);
finp>>pass1;
finr>>dr;
finp.close();
finr.close();
if(strcmp(pass1,”aaa”)==0)
{ do
{
cout<<”\nEnter password\t:”;
cin>>pass;
cout<<”\nConfirm password\t:”;
cin>>passcon;}
while(strcmp(pass,passcon)!=0);
ofstream fout;
fout.open(tet);
fout<<pass;
fout.close();
cout<<”\nPASSWORD SET”;
com1[4]=dr;
com2[16]=dr;
system(com1);
system(com2);
cout<<”\nLOCKER LOCKED SUCCESSFULLY”;
cout<<”\nPress any key to return to menu…\n”;
getch();
system(“cls”);
}
else
{cout<<”\nEnter password\t:”;
cin>>passw;
ifstream finp;
ifstream finr;
finp.open(tet);
finr.open(tet1);
finp>>pass1;
finr>>dr;
finr.close();
finp.close();
if(strcmp(passw,pass1)==0)
{com1[4]=dr;
com2[16]=dr;
system(com1);
system(com2);
cout<<”\nLOCKER LOCKED SUCCESSFULLY”;
cout<<”\nPress any key to return to menu…\n”;
getch();
system(“cls”);}
else
{cout<<”\nWRONG PASSWORD”;
cout<<”\nPress any key to return to menu…\n”;
getch();}
system(“cls”);
} }
else if(ch==3)
{cout<<”\nEnter password\t:”;
cin>>conpass;
ifstream finp;
ifstream finr;
finp.open(tet);
finr.open(tet1);
finp>>pass1;
finr>>dr;
finr.close();
finp.close();
if(strcmp(conpass,pass1)==0)
{com4[4]=dr;
com3[16]=dr;
system(com3);
system(com4);
cout<<”\nLOCKER UNLOCKED SUCCESSFULLY”;
cout<<”\nPress any key to return to menu…\n”;
getch();}
else
{cout<<”\nWRONG PASSWORD!!!”;
cout<<”\nPress any key to return to menu…\n”;
getch();}
system(“cls”);
}
else if(ch==4)
{cout<<”\nEnter old password\t:”;
cin>>passw;
ifstream finp;
ifstream finr;
finp.open(tet);
finr.open(tet1);
finp>>pass1;
finr>>dr;
finr.close();
finp.close();
if(strcmp(pass1,passw)==0)
{cout<<”\nEnter new password”;
cin>>pass1;
ofstream finp;
finp.open(tet);
finp<<pass1;
finp.close(); }
else
{cout<<”WRONG PASSWORD!!!”;}
cout<<”\nPress any key to return to menu…”;
getch();
system(“cls”);
}
else
{cout<<”\n\t\tWrong Choice\n”;system(“cls”);}
}while(ch!=5);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.