获取主板BIOS的信息 [转]

获取主板BIOS的信息
1、读取主板序列号
2、AWard Bios密码读取
3、读取BIOS信息
4、获取BIOS日期信息

=========================================
1、读取主板序列号

uses SHA1, Base64;

 function GetHashedBiosInfo: string;
 var
   SHA1Context: TSHA1Context;
   SHA1Digest: TSHA1Digest;
 begin
   // Get the BIOS data
   SetString(Result, PChar(Ptr($F0000)), $10000);
   // Hash the string
   SHA1Init(SHA1Context);
   SHA1Update(SHA1Context, PChar(Result), Length(Result));
   SHA1Final(SHA1Context, SHA1Digest);
   SetString(Result, PChar(@SHA1Digest), sizeof(SHA1Digest));
   // Return the hash string encoded in printable characters
   Result := B64Encode(Result);
 end;


 function GetBiosInfoAsText: string;
 var
   p, q: pchar;
 begin
   q := nil;
   p := PChar(Ptr($FE000));
   repeat
     if q <> nil then begin
       if not (p^ in [#10, #13, #32..#126, #169, #184]) then begin
         if (p^ = #0) and (p - q >= 8) then begin
           Result := Result + TrimRight(String(q)) + #13#10;
         end;
         q := nil;
       end;
     end else
       if p^ in [#33..#126, #169, #184] then
         q := p;
     inc(p);
   until p > PChar(Ptr($FFFFF));
   Result := TrimRight(Result);
 end;

 procedure TForm1.FormCreate(Sender: TObject);
 begin
   Memo1.Lines.Text := GetBiosInfoAsText;
 end;

==========================================
2、AWard Bios密码读取(应该是jingtao的文章,但是ID没有记录)
Unit AwardBiosPas;
//Write by lovejingtao
//http://www.138soft.com
interface
uses windows,SysUtils;

function My_GetBiosPassword:String;
implementation

function CalcPossiblePassword(PasswordValue: WORD): string;
var
 I: BYTE;
 C: CHAR;
 S: string[8];

begin
 I := 0;
 while PasswordValue <> 0 do
   begin
     Inc(I);
     if $263 > PasswordValue then
       begin
         if $80 > PasswordValue then
           S[I] := CHAR(PasswordValue)
         else if $B0 > PasswordValue then
           S[I] := CHAR(PasswordValue and $77)
         else if $11D > PasswordValue then
           S[I] := CHAR($30 or (PasswordValue and $0F))
         else if $114 > PasswordValue then
           begin
             S[I] := CHAR($64 or (PasswordValue and $0F));
             if '0' > S[I] then
               S[I] := CHAR(BYTE(S[I]) + 8);
           end
         else if $1C2 > PasswordValue then
           S[I] := CHAR($70 or (PasswordValue and $03))
         else if $1E4 > PasswordValue then
           S[I] := CHAR($30 or (PasswordValue and $03))
         else
           begin
             S[I] := CHAR($70 or (PasswordValue and $0F));
             if 'z' < S[I] then
               S[I] := CHAR(BYTE(S[I]) - 8);
           end;
       end
     else
       S[I] := CHAR($30 or (PasswordValue and $3));
     PasswordValue := (PasswordValue - BYTE(S[I])) shr 2;
   end;

 S[0] := CHAR(I);
 PasswordValue := I shr 1;
 while PasswordValue < I do
   begin {this is to do because award starts calculating with the last letter}

     C := S[BYTE(S[0]) - I + 1];
     S[BYTE(S[0]) - I + 1] := S[I];
     S[I] := C;
     Dec(I);
   end;
 CalcPossiblePassword := S;
end;

function readcmos(off: byte): byte;
var
 value: byte;
begin
 asm
     xor ax, ax
     mov al, off
     out 70h, al
     in  al, 71h
     mov value, al
 end;
 readcmos := value;
end;
function My_GetBiosPassword:String;
var
 superpw, userpw: word;
 S:String;
begin
if Win32Platform <> VER_PLATFORM_WIN32_NT then //不是NT
begin
 pchar(@superpw)[0] := char(readcmos($1C));
 pchar(@superpw)[1] := char(readcmos($1D));
 pchar(@userpw)[0] := char(readcmos($64));
 pchar(@userpw)[1] := char(readcmos($65));
 S:='超级用户密码为:'+CalcPossiblePassword(superpw)+#13+'用户密码为:'+CalcPossiblePassword(userpw);
 Result:=S;
 end
 else
 Result:='用户系统为NT,无法获取BISO密码!';
 end;
end.

=======================================

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值