建立 AWS UEFI 安全開機的二進位 Blob - Amazon Elastic Compute Cloud

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

建立 AWS UEFI 安全開機的二進位 Blob

您可以使用以下步驟在 AMI 建立過程中自定義 UEFI 安全開機變數。在這些步驟中使用的 KEK 截至 2021 年 9 月都是最新的。如果 Microsoft 更新 KEK,則您必須使用最新的 KEK。

建立 AWS 二進位 Blob
  1. 建立一個空白的 PK 簽章清單。

    touch empty_key.crt cert-to-efi-sig-list empty_key.crt PK.esl
  2. 下載 KEK 憑證。

    https://go.microsoft.com/fwlink/?LinkId=321185
  3. 將 KEK 憑證包裝在 UEFI 簽章清單中 (siglist)。

    sbsiglist --owner 77fa9abd-0359-4d32-bd60-28f4e78f784b --type x509 --output MS_Win_KEK.esl MicCorKEKCA2011_2011-06-24.crt
  4. 下載 Microsoft 的 db 憑證。

    https://www.microsoft.com/pkiops/certs/MicWinProPCA2011_2011-10-19.crt https://www.microsoft.com/pkiops/certs/MicCorUEFCA2011_2011-06-27.crt
  5. 產生 db 簽章清單。

    sbsiglist --owner 77fa9abd-0359-4d32-bd60-28f4e78f784b --type x509 --output MS_Win_db.esl MicWinProPCA2011_2011-10-19.crt sbsiglist --owner 77fa9abd-0359-4d32-bd60-28f4e78f784b --type x509 --output MS_UEFI_db.esl MicCorUEFCA2011_2011-06-27.crt cat MS_Win_db.esl MS_UEFI_db.esl > MS_db.esl
  6. 統一可擴展韌體界面論壇不再提供 DBX 檔案。它們現在由 Microsoft 在 GitHub 上提供。從位於 https://https://github.com/microsoft/secureboot_objects 的 Microsoft 安全開機更新儲存庫下載最新的 DBX 更新。

  7. 解壓縮已簽署的 update-binary。

    SplitDbxContent.ps1 使用以下指令碼內容建立 。或者,您可以使用 從 PowerShell Gallery 安裝指令碼Install-Script -Name SplitDbxContent

    <#PSScriptInfo .VERSION 1.0 .GUID ec45a3fc-5e87-4d90-b55e-bdea083f732d .AUTHOR Microsoft Secure Boot Team .COMPANYNAME Microsoft .COPYRIGHT Microsoft .TAGS Windows Security .LICENSEURI .PROJECTURI .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS .EXTERNALSCRIPTDEPENDENCIES .RELEASENOTES Version 1.0: Original published version. #> <# .DESCRIPTION Splits a DBX update package into the new DBX variable contents and the signature authorizing the change. To apply an update using the output files of this script, try: Set-SecureBootUefi -Name dbx -ContentFilePath .\content.bin -SignedFilePath .\signature.p7 -Time 2010-03-06T19:17:21Z -AppendWrite' .EXAMPLE .\SplitDbxAuthInfo.ps1 DbxUpdate_x64.bin #> # Get file from script input $file = Get-Content -Encoding Byte $args[0] # Identify file signature $chop = $file[40..($file.Length - 1)] if (($chop[0] -ne 0x30) -or ($chop[1] -ne 0x82 )) { Write-Error "Cannot find signature" exit 1 } # Signature is known to be ASN size plus header of 4 bytes $sig_length = ($chop[2] * 256) + $chop[3] + 4 $sig = $chop[0..($sig_length - 1)] if ($sig_length -gt ($file.Length + 40)) { Write-Error "Signature longer than file size!" exit 1 } # Content is everything else $content = $file[0..39] + $chop[$sig_length..($chop.Length - 1)] # Write signature and content to files Set-Content -Encoding Byte signature.p7 $sig Set-Content -Encoding Byte content.bin $content

    使用指令碼來解壓縮已簽章的 DBX 檔案。

    PS C:\Windows\system32> SplitDbxContent.ps1 .\dbx.bin

    這會產生兩個檔案 — signature.p7content.bin。在下一個步驟content.bin中使用 。

  8. 使用 uefivars.py 指令碼建置 UEFI 變數存放區。

    ./uefivars.py -i none -o aws -O uefiblob-microsoft-keys-empty-pk.bin -P ~/PK.esl -K ~/MS_Win_KEK.esl --db ~/MS_db.esl --dbx ~/content.bin
  9. 檢查二進位 blob 和 UEFI 變數存放區。

    ./uefivars.py -i aws -I uefiblob-microsoft-keys-empty-pk.bin -o json | less
  10. 您可以透過再次將 blob 傳遞給同一工具來更新 Blob。

    ./uefivars.py -i aws -I uefiblob-microsoft-keys-empty-pk.bin -o aws -O uefiblob-microsoft-keys-empty-pk.bin -P ~/PK.esl -K ~/MS_Win_KEK.esl --db ~/MS_db.esl --dbx ~/content.bin

    預期的輸出結果

    Replacing PK Replacing KEK Replacing db Replacing dbx