China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-07-01 06:36
中国DOS联盟论坛 » DOS软件下载 & 游戏分享 (下载室) » [Repost] Boot Password View 1,504 Replies 1
Original Poster Posted 2002-12-07 00:00 ·  中国 浙江 宁波 联通
银牌会员
★★★
Credits 1,001
Posts 309
Joined 2002-11-19 00:00
23-year member
UID 283
Gender Male
Status Offline
Floor 2 Posted 2002-12-07 00:00 ·  中国 浙江 宁波 联通
银牌会员
★★★
Credits 1,001
Posts 309
Joined 2002-11-19 00:00
23-year member
UID 283
Gender Male
Status Offline
Author: 小草
A boot password program. Run it once and it will automatically add itself to autoexec.bat. The next time you boot, you will have to enter the password to get through.
The program is as follows:
#include "conio.h"
#include "string.h"
#include "stdio.h"

void error()
{window(12,10,68,10);
textbackground(15);
textcolor(132);
clrscr();
cprintf("file or system error! you can't enter the system!!!";
while(1); /*if there is an error, you cannot get through the program*/
}

void look()
{FILE *fauto,*fbak;
char *pass="c:\\windows\\password.exe"; /*location of this program*/
char a,ch;
char *au="autoexec.bat",*bname="hecfback.^^^"; /*bname is the backup of autoexec.bat*/
setdisk(2); /*set currently disk c:*/
chdir("\\"; /*set currently directory \*/
fauto=fopen(au,"r+";
if (fauto==NULL)
{fauto=fopen(au,"w+";
if (fauto==NULL) error();}
fread(a,23,1,fauto); /*read the first 23 characters of autoexec.bat*/
a='\0';

if (strcmp(a,pass)==0) /*if what was read is the same as the pass pointer then close the file, otherwise add it*/
fclose(fauto);
else
{fbak=fopen(bname,"w+";
if (fbak==NULL) error();
fwrite(pass,23,1,fbak);
fputc('\n',fbak);
rewind(fauto);
while(!feof(fauto))
{ch=fgetc(fauto);
fputc(ch,fbak);}
rewind(fauto);
rewind(fbak);
while(!feof(fbak))
{ch=fgetc(fbak);
fputc(ch,fauto);}
fclose(fauto);
fclose(fbak);
remove(bname); /*del bname file*/
}
}

void pass()
{char *password="88888888";
char input;
int n;
while(1)
{window(1,1,80,25);
textbackground(0);
textcolor(15);
clrscr();

n=0;
window(20,12,60,12);
textbackground(1);
textcolor(15);
clrscr();
cprintf("password:";
while(1)
{input=getch();
if (n>58) {putchar(7); break;} /*if there are more than 58 characters, end this input*/
if (input==13) break;
if (input>=32 && input0)
{cprintf("\b \b";
input='\0';
n--;}
}
input='\0';
if (strcmp(password,input)==0)
break;
else
{putchar(7);
window(30,14,50,14);
textbackground(15);
textcolor(132);
clrscr();
cprintf("password error!";
getch();}
}
}

main()
{look();
pass();
}
Forum Jump: