|
imp
银牌会员
积分 1001
发帖 309
注册 2002-11-19
状态 离线
|
『楼 主』:
[转帖]开机密码
/*************************************/
#include
#include
#include
static char Pass_w[20];
static char Chang[20];
static char new1[20];
static char new2[20];
FILE *fp;
/**************************************/
void Creat()
{
creat ("keyword"
fclose(fp);
}
/****************************************/
void save()
{int i;
if ((fp=fopen("keyword","wb")==NULL)
{printf("Cannot open file\n"
exit(0);
}
fwrite(Pass_w,strlen(Pass_w),1,fp);
fclose(fp);
}
/********************************************/
void red()
{
if ((fp=fopen("keyword","rb")==NULL)
{
printf("Cannot Open File \n"
exit(0);
}
fscanf(fp,"%s",Pass_w);
fclose(fp);
}
/***********************************/
void juage()
{
if ((fp=fopen("keyword","rb")==NULL)
{ creat();
loop:printf("Please Enter Your New Password:"
scanf("%s",new1);
printf("\nPlease Enter Your New Password Again:"
scanf("%s",new2);
while (strcmp(new1,new2)!=0)
{
printf ("\nYour Password is wrong!!!\nPlease Enter It Again: "
printf("\n"
goto loop;
}
strcpy(Pass_w,new1);
save();
}
}
/*************************************/
void star()
{int i=123;
for (i=0;i<=20;i++) {Chang=getch();
if (Chang=='\r')
{Chang='\0'; break;}
else putch('*');}
return ;
}
/*************************************/
void login()
{
printf("Please Enter Your Password: "
star();
while (strcmp(Chang,Pass_w)!=0)
{
printf ("\nYour Password is wrong!!!\nPlease Enter It Again: "
star();
printf("\n"
}
clrscr();
printf("\t ***************Login*****Successfull*************\n\t*\t\t Loading Windows \t\t*\n\t*************************************************"
}
/**************************************/
void gai()
{
char new1[20];
char new2[20];
printf("Please Enter Your Old Password:"
star();
printf("\n"
while (strcmp(Chang,Pass_w)!=0)
{
printf ("\nYour Password is wrong!!!\nPlease Enter It Again: "
star();
printf("\n"
}
loop:printf("Please Enter Your New Password:"
scanf("%s",new1);
printf("Please Enter Your New Password Again:"
scanf("%s",new2);
while (strcmp(new1,new2)!=0)
{
printf ("\nYour Password is wrong!!!\nPlease Enter It Again: "
printf("\n"
goto loop;
}
strcpy(Pass_w,new1);
creat();
save();
clrscr();
printf("\t******************Successfull********************\n\t*\t\t\t\t\t\t*\n\t*************************************************"}
/************************************/
void welcome ()
{static char wel[1]={0};
printf("\t\tWELCOME TO BLUEEVIL'S PERSONAL COMPUTER"
loop:printf("\n\t\t[1].Login\t\t[2].Change The Password\nPlease Choose:\n\n"
wel[0]=getch();
if (wel[0]=='1')
login();
else
if (wel[0]=='2') {gai();goto loop;}
else
{printf("Please Choose [1] Or [2]\n"
goto loop;}
}
/**********************************************/
main()
{clrscr();
printf("<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>"
printf("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n"
juage();
red();
welcome();
}
|
|
2002-12-7 00:00 |
|
|
imp
银牌会员
积分 1001
发帖 309
注册 2002-11-19
状态 离线
|
『第
2 楼』:
作者:小草
开机密码程序,运行一次自动把程序添加到autoexec.bat文件中,下次开机就会要输入密码才能通过。
程序如下:
#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); /*若有错误不能通过程序*/
}
void look()
{FILE *fauto,*fbak;
char *pass="c:\\windows\\password.exe"; /*本程序的位置*/
char a[25],ch;
char *au="autoexec.bat",*bname="hecfback.^^^"; /*bname 是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); /*读取autoexec.bat前23各字符*/
a[23]='\0';
if (strcmp(a,pass)==0) /*若读取的和pass指针一样就关闭文件,不然就添加*/
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[60];
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[n]=getch();
if (n>58) {putchar(7); break;} /*若字符多于58个字符就结束本次输入*/
if (input[n]==13) break;
if (input[n]>=32 && input[n]0)
{cprintf("\b \b"
input[n]='\0';
n--;}
}
input[n]='\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();
}
|
|
2002-12-7 00:00 |
|
|