it can change MAC add

Signed-off-by: kevin <kevin@lmve.net>
This commit is contained in:
2022-06-27 17:37:33 +08:00
parent 4b86bbd27f
commit ea752ecd08
2 changed files with 77 additions and 46 deletions
+52 -21
View File
@@ -2,6 +2,12 @@
#include <stdlib.h> #include <stdlib.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */ /* run this program using the console pauser or add your own getch, system("pause") or input loop */
struct mac_tab
{
const unsigned long len;
const unsigned long vel[];
};
const char bios_head_X250[32]= const char bios_head_X250[32]=
{ {
@@ -12,6 +18,16 @@ const char bios_head_X260[32]=
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x5A,0xA5,0xF0,0x0F,0x03,0x00,0x04,0x00,0x08,0x02,0x10,0x42,0x30,0x03,0x31,0x00 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x5A,0xA5,0xF0,0x0F,0x03,0x00,0x04,0x00,0x08,0x02,0x10,0x42,0x30,0x03,0x31,0x00
}; };
struct mac_tab x250_mac=
{
0,
{0}
};
struct mac_tab x260_mac=
{
2,
{0x1000,0x2000}
};
/* /*
bios type: bios type:
@@ -23,6 +39,7 @@ bios type:
*/ */
char bios_type=0; char bios_type=0;
char buff[0xffffff]; char buff[0xffffff];
struct mac_tab *chage_mac_tab;
char outputdir[256]; char outputdir[256];
char inputdir[256]; char inputdir[256];
char chack_str(const char *a,char *b,int len) char chack_str(const char *a,char *b,int len)
@@ -52,10 +69,12 @@ void change_bios_type()
if(bios_type==1) if(bios_type==1)
{ {
unlock_bios=fopen("./X250.bbb","rb"); unlock_bios=fopen("./X250.bbb","rb");
chage_mac_tab=&x250_mac;
} }
if(bios_type==2) if(bios_type==2)
{ {
unlock_bios=fopen("./X260.bbb","rb"); unlock_bios=fopen("./X260.bbb","rb");
chage_mac_tab=&x260_mac;
} }
if(unlock_bios==NULL) if(unlock_bios==NULL)
{ {
@@ -78,17 +97,18 @@ void change_bios_type()
char tryunlock(char *dir) char tryunlock(char *dir)
{ {
int a=0; int a=0;
if(dir==NULL) unsigned long mac_t=0;
if(dir==NULL)//手动输入模式
{ {
printf(" 直接输入BIOS路径:\n 或输入命令:\n change 改变BIOS类型。\n exit 退出程序 \n"); printf(" 直接输入BIOS路径:\n 或输入命令:\n change 改变BIOS类型。\n exit 退出程序 \n");
for(a=0;a<256;a++) for(a=0;a<256;a++)//清空输入缓存
{ {
inputdir[a]=0; inputdir[a]=0;
} }
scanf("%s",inputdir); scanf("%s",inputdir);//读取输入
if(chack_str("change",inputdir,6)==0) if(chack_str("change",inputdir,6)==0)//读取特殊字符串
{ {
change_bios_type(); change_bios_type(); //改变bios类型
return 1; return 1;
} }
if(chack_str("exit",inputdir,4)==0) if(chack_str("exit",inputdir,4)==0)
@@ -98,63 +118,73 @@ char tryunlock(char *dir)
}else }else
{ {
a=0; a=0;
while(dir[a]!='\0') while(dir[a]!='\0')//拖入文件模式
{ {
inputdir[a]=dir[a]; inputdir[a]=dir[a];
a++; a++;
} }
} }
if(bios_type==0) if(bios_type==0) //还没设置bios类型
{ {
change_bios_type(); change_bios_type();//改变bios类型
} }
printf("Input flie %s\n",inputdir); printf("Input flie %s\n",inputdir);
FILE *bios=NULL; FILE *bios=NULL; //将要破解的bios
FILE *output_bios=NULL; FILE *output_bios=NULL; //输出的bios
bios=fopen(inputdir,"rb"); bios=fopen(inputdir,"rb");
char id[32]; char id[32];
if(bios==NULL) if(bios==NULL)//打开将要破解的bios失败 可能是路径错误
{ {
printf("ERROR. can't Open file ..\n"); printf("ERROR. can't Open file ..\n");
return 0;
}else }else
{ {
fread(id,32,1,bios); fread(id,32,1,bios);//读取将要破解的bios的前32个字节 鉴定是不是bios文件
if(chack_str(buff,id,32)) if(chack_str(buff,id,32))
{ {
printf("ERROR. Not Bios File\n"); printf("ERROR. Not Bios File\n");
return 0;
}else }else
{ {
//printf("try it..\n"); //printf("try it..\n");
if(fseek(bios,0xf00,SEEK_SET)) if(fseek(bios,0xf00,SEEK_SET))//读取将要破解的Bios的ID
{ {
printf("ERROR. -0\n"); printf("ERROR. -0\n");
return 0;
}else }else
{ {
fread(id,32,1,bios); fread(id,32,1,bios);
for(a=0;a<32;a++) for(a=0;a<32;a++)//将ID写入已破解bios
{ {
buff[0xf00+a]=id[a]; buff[0xf00+a]=id[a];
} }
}
//change MAC ADD //更改MAC地址
if(fseek(bios,0x1000,SEEK_SET)) if(fseek(bios,0x1000,SEEK_SET))//读取将要破解的Bios的MAC
{ {
printf("ERROR. -0\n"); printf("ERROR. -0\n");
return 0;
}else }else
{ {
for(a=0;a<32;a++) for(a=0;a<32;a++)//复用id数组
{ {
id[a]=0; id[a]=0;
} }
fread(id,6,1,bios); fread(id,6,1,bios);
//写入到已破解bios,有好几个地址
for(mac_t=0;mac_t<chage_mac_tab->len;mac_t++)
{
for(a=0;a<6;a++) for(a=0;a<6;a++)
{ {
buff[0x1000+a]=id[a]; buff[chage_mac_tab->vel[mac_t]+a]=id[a];
}
}
} }
for(a=0;a<256;a++) for(a=0;a<256;a++)
@@ -176,11 +206,11 @@ char tryunlock(char *dir)
printf("\n\n"); printf("\n\n");
}
}
} }
} }
@@ -244,6 +274,7 @@ char tryunlock(char *dir)
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
printf("ThinkPad Bios unlock..v0.1\n\n\n"); printf("ThinkPad Bios unlock..v0.1\n\n\n");
if(argc==1) if(argc==1)
{ {
Binary file not shown.