当年,我的IBM笔记本密码忘记了,于是在网上找到一个开源的破解程序(电脑版),于是移植到51单片机上破解了密码。
单片机源程序如下:
- #include "reg51.h"
- #include "intrins.h"
- typedef unsigned char uint8;
- typedef unsigned int uint16;
- typedef unsigned long uint32;
- uint8 IIC_Buffer[17];
- uint8 PASSWORD_Buffer[8];
- void Disp_Logo();
- sbit KEY=P3^2;
- sbit BEEP=P2^5;
- uint8 bak,uit;
- uint8 const code PASSWORDTAB[]=
- {
- 0x00,'1','2','3','4','5','6','7','8','9','0',0x00,0x00,0x00,0x00,0x00,'Q','W','E','R','T','Y','U','I','O','P',
- 0x00,0x00,0x00,0x00,'A','S','D','F','G','H','J','K','L',0x00,0x00,0x00,0x00,0x00,'Z',
- 'X','C','V','B','N','M',',','.',0x00,0x00,0x00,0x00,' ',0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,'/','*','7','8','9','-','4','5','6','+','1','2','3','0','.',0x00
- };
- sbit LCD_RS = P2^0;
- sbit LCD_RW = P2^1;
- sbit LCD_EN = P2^2;
- #define LCD_DataPort P0
- #define COMMAND 0
- #define DATA 1
- bit LCD_Check_Busy()
- {
- bit result;
- LCD_RS=0;
- LCD_RW=1;
- LCD_EN=1;
- _nop_();_nop_();_nop_();_nop_();
- result=(bit)(LCD_DataPort&0x80);
- LCD_EN=0;
- return result;
- }
- void LCD_Write(uint8 dat,uint8 type)
- {
- while(LCD_Check_Busy());
- LCD_RS=type;
- LCD_RW=0;
- LCD_EN=0;
- _nop_();_nop_(); _nop_();_nop_();
- LCD_DataPort=dat;
- _nop_();_nop_();_nop_();_nop_();
- LCD_EN=1;
- _nop_();_nop_();_nop_();_nop_();
- LCD_EN=0;
- }
- void LCD_Prints(uint8 *dat,uint8 addr)
- {
- LCD_Write(addr|0x80,COMMAND);
- while((*dat!='\0')||(*dat!=0x00))LCD_Write(*(dat++),DATA);
- }
- void PASS_Prints(uint8 *dat,uint8 addr)
- {
- LCD_Write(addr|0x80,COMMAND);
- LCD_Write('[',DATA);
- while(*dat!=0x00)LCD_Write(*(dat++),DATA);
- LCD_Write(']',DATA);
- }
-
- void LCD_Initialize()
- {
- LCD_Write(0x06,COMMAND);
- LCD_Write(0x38,COMMAND);
- LCD_Write(0x0c,COMMAND);
- LCD_Write(0x01,COMMAND);
- }
- sbit IIC_SCK = P2^3;
- sbit IIC_SDA = P2^4;
- #define IIC_WRITE_MODE 0xa0
- #define IIC_READ_MODE 0xa1
- void IIC_Delay()
- {
- _nop_();
- _nop_();
- }
- void IIC_Delayms(uint8 ms)
- {
- uint8 i;
- while(ms--)
- {
- for(i=0;i<120;i++);
- }
- }
- void IIC_Start_Byte()
- {
- IIC_SDA=1;
- IIC_SCK=1;
- IIC_Delay();
- IIC_SDA=0;
- IIC_Delay();
- IIC_SCK=0;
- }
- void IIC_Stop_Byte()
- {
- IIC_SDA=0;
- IIC_Delay();
- IIC_SCK=1;
- IIC_Delay();
- IIC_SDA=1;
- }
- uint8 IIC_Read_Byte()
- {
- uint8 i,dat;
- for(i=0;i<8;i++)
- {
- IIC_SCK=1;
- dat<<=1;
- dat|=(uint8)IIC_SDA;
- IIC_SCK=0;
- }
- return dat;
- }
- bit IIC_Write_Byte(uint8 dat)
- {
- uint8 i;
- bit ack;
- for(i=0;i<8;i++)
- {
- IIC_SDA=(bit)(dat&0x80);
- IIC_Delay();
- IIC_SCK=1;
- IIC_Delay();
- IIC_SCK=0;
- dat<<=1;
- }
- IIC_SDA=1;
- IIC_Delay();
- IIC_SCK=1;
- IIC_Delay();
- IIC_Delay();
- ack=IIC_SDA;
- IIC_SCK=0;
- return ack;
- }
- void IIC_Write_Data(uint8 addr,uint8 dat)
- {
- IIC_Start_Byte();
- IIC_Write_Byte(IIC_WRITE_MODE);
- IIC_Write_Byte(addr);
- IIC_Write_Byte(dat);
- IIC_Stop_Byte();
- IIC_Delayms(10);
- }
- uint8 IIC_Read_Current()
- {
- uint8 dat;
- IIC_Start_Byte();
- IIC_Write_Byte(IIC_READ_MODE);
- dat=IIC_Read_Byte();
- IIC_Stop_Byte();
- return dat;
- }
- uint8 IIC_Read_Data(uint8 addr)
- {
- IIC_Start_Byte();
- IIC_Write_Byte(IIC_WRITE_MODE);
- IIC_Write_Byte(addr);
- return IIC_Read_Current();
- }
- void GOTO_LOGO() interrupt 1 using 1
- {
- bak++;
- if(bak==0x39){Disp_Logo();TR0=0;bak=0;uit=0;}
- }
- void Beep_Int() interrupt 3 using 2
- {
- TH1=1200;
- TL1=1200;
- BEEP=~BEEP;
- }
- void Password_Read() interrupt 0 using 0
- {
- uint8 i;
- while(!KEY);
- EX0=1;
- if(uit==1)goto exit;
- uit++;
- bak=0;
- TH0=0xfe;
- TL0=0xff;
- TR0=1;
- LCD_Write(0x01,COMMAND);
- for(i=0;i<7;i++)
- {
- PASSWORD_Buffer[i]=PASSWORDTAB[IIC_Read_Data(0x38+i)];
- }
- for(i=0;i<16;i++)
- {
- IIC_Buffer[i]=IIC_Read_Data(0x70+i);
- }
- IIC_Buffer[16]='\0';
- PASS_Prints(PASSWORD_Buffer,0x40);
- LCD_Prints(IIC_Buffer,0);
- goto exit1;
- exit: Disp_Logo();
- uit=0;
- exit1: i=0;
- }
- void Disp_Logo()
- {
- LCD_Prints("WelCome Use IBM",0);
- LCD_Prints(" Password Read ",0x40);
- }
- void main()
- {
- uint8 i;
- IIC_SDA = 1;
- IIC_SCK = 1;
- LCD_Initialize();
- TMOD=0x01;
- EA=1;
- EX0=1;
- ET0=1;
- Disp_Logo();
- while(1);
- }
复制代码
所有资料51hei提供下载:
IBMPASSWORD.rar
(71.16 KB, 下载次数: 13)
|