ããªããšã®é·ãäŒæ©ã®åŸãç§ãšUEFIã®å éšãæãäžããŸãã ä»åã¯ãäžéšã®HPã©ãããããã®ãã¡ãŒã ãŠã§ã¢ãå€æŽããä¿è·ããããã«èšèšããããå€ããŠäººæ°ã®ããPEIã¢ãžã¥ãŒã«SecureUpdatingã䜿çšããŠãå®è¡å¯èœãªUEFIã³ã³ããŒãã³ãã®ãªããŒã¹ãšãããã°ãç°¡çŽ åããããã€ãã®ææ³ã瀺ãããšã«ããŸããã
èæ¯ã¯ããã§ãïŒããå€ããã©ã«ãŒã·ã®ããç¥ãããã©ãããããã®ä¿®çå·¥ãç§ã«æçŽãæžããŠãVideoBIOSã亀æããã©ãããããã次ã«åããã®ã§æ£åžžã«èµ·åããã®ã«ãªãèµ·åããªãã®ããå°ããŸããã çãã¯è¡šé¢ã«ããããšãå€æããŸãã-å€æŽåŸã«èµ·åããªãã£ãã©ãããããã«ã¯ãUEFIã®æ°ããããŒãžã§ã³ããããHPã®åªç§ãªäººã ãDXEããªã¥ãŒã ã®å€æŽã«å¯Ÿããä¿è·ãçµ±åããŸããïŒãããŠãUEFIã³ãŒãã®80ïŒ ãšãšãã«å¿ èŠãªVideoBIOSãèŠã€ãããŸãïŒãæªæã®ãªããŠãŒã¶ãŒã¯ã誀ã£ãŠããã§äœããå£ããŸããã§ããã ãã®åŸãå€ãUEFIããŒãžã§ã³ããæ°ããããŒãžã§ã³ã«SecureUpdating PEIã¢ãžã¥ãŒã«ã転éããããšã§åé¡ã¯è§£æ±ºããŸãããã2é±éåŸãåã人ãåã³åããå€ããŸãããä»åã¯åæ§ã®ã©ãããããã§å€ãããŒãžã§ã³ã®ã¢ãžã¥ãŒã«ãæ©èœããªããªããç§ã®å©ããåã³å¿ èŠã«ãªããŸããã
éã¢ã»ã³ãã©ãŒãšãããããããã©ã³ãžã·ã§ã³ã䜿çšããUEFI PEIã¢ãžã¥ãŒã«ã®äžçã§ã®ç§ã®ãããªãåéºã«èå³ããããªããcatã«ããããã
æè²ããã°ã©ã ãžã®ãªã³ã¯ã®ã«ããã«
ããªããã»ãšãã©äœãç解ããŠããªãå Žå-ããã¯å€§äžå€«ã§ããç§ã¯çšèªã説æããããã€ãã®èšäºãæã£ãŠããŸãïŒ 1ã2ã3 ãèªãã§æ»ã£ãŠãã ããã ãªãªãžãã«ã®ããã¥ã¡ã³ãã®ãã¡ã³ã®ããã«ã UEFI PI ä»æ§ã¯åžžã«å©çšå¯èœã§ãããã¹ãŠããã詳现ã«æžãããŠããŸããå¿ èŠãªãã¡ã€ã«ãšããŒã«
äžèšã®ãã¡ãŒã ãŠã§ã¢ãå解ããã«ã¯ã次ã®ãã®ãå¿ èŠã§ãã- å®éã«ãã¡ãŒã ãŠã§ã¢ãå«ããã¡ã€ã«ã ããã¯ç§ã«éãããŸãã ã
- UEFIã€ã¡ãŒãžãæäœããããã®ãŠãŒãã£ãªãã£ã¯ãã¹ãŠUEFIToolãäœæè ãšããŠäœ¿çšããŸããã uefi-firmware-parserãPhoenixToolãªã©ã奜ã¿ã«å¿ããŠäœ¿çšã§ããŸããããã¯éèŠã§ã¯ãããŸããã
- ã奜ã¿ã®16é²ãšãã£ã¿ã HxDã䜿çšããŸã ã
- PE32ãã¡ã€ã«ããµããŒãããéã¢ã»ã³ãã©ãŒãããã§ã¯IDA 6.6ãã¢ãçæ³çã§ãã ã»ãšãã©ã®å ŽåãPEIã¢ãžã¥ãŒã«ã¯32ãããã§ããããã¢ããŒãžã§ã³ã®å¶éã¯ããã»ã©å®³ã«ãªããŸããã 芪æãªãxvilkaãradare2ã® Cãã¡ã€ã«ããæ§é ãããŒãããæ¹æ³ã瀺ãããšãã§ããã°ã次ã®modãäœæããããšããŸãããä»ã®ãšãããIDAããã¹ãŠã§ãã
- efi-utilsãã³ãã«ã«ã¯ ãUEFIã§äœ¿çšãããã»ãŒãã¹ãŠã®å¯èœãªããŒã¿æ§é ã®å®çŸ©ãå«ãå€é¡ã®behemoth.hãã¡ã€ã«ãå¿ èŠã§ãã ç§ãã¡ã®å Žåãå¿ èŠãªã®ã¯ãããã®ãã¡ã®æ°åã ãã§ãã
åºçºç¹
ä¿®çæ åœè ã®èšèããã次ã®ããšãããããŸããDXEããªã¥ãŒã ã®å€æŽã¯ãCaps Lockã§ã©ãããããã®ç¹æ» ãåŒãèµ·ãããç»åã®ä»ã®éšåã®å€æŽã¯ãã®ãããªçµæã«ã¯ãªããŸããã ããã¯ããã§ãã¯ãµã ãŸãã¯EDSã®ãããããæ ŒçŽãããPEIã¢ãžã¥ãŒã«ã®ããããã®ã³ãŒãã«ãã£ãŠãã§ãã¯ãããåæããå Žåãå¶åŸ¡ã¯DXEãã§ãŒãºã«è»¢éãããããã§ãªãå Žåã¯ãã©ãã«ã転éãããªãããšãæå³ããŸãããããã次ã®ããšã確èªããå¿ èŠããããŸãã
- CS / EDSã¯æ£ç¢ºã«ã©ãã«ä¿åãããŸããïŒ
- 誰ã圌女ããã§ãã¯ããŠããŸããïŒ
- ãããŠãæãéèŠãªããšã¯ãæ€èšŒãåžžã«æ£åžžã«çµäºããããšã確èªããæ¹æ³ã§ããïŒ
è¡ããïŒ
äžåºŠãã£ãŠãã ããïŒ
UEFIToolã®ãã¡ãŒã ãŠã§ã¢ã§ãã¡ã€ã«ãéãã泚ææ·±ãèŠãŠãã ããïŒUEFIããªã¥ãŒã ã®1ã€ã®ç©ºãé åå ã«ãä»æ§ã«ããã°ããã«ããã¹ãã§ã¯ãªãããŒã¿ããã£ããšããã¡ãã»ãŒãžãé€ããŠãç°åžžãªããšã¯ãªãããã§ãã ããã¯ãïŒä»æ§ãå®éã«ä¿¡ããŠããªã人ã®ïŒã¡ãŒã«ãŒãéåžžããã§ãã¯ãµã ãŸãã¯ããžã¿ã«çœ²åãé ãæ¹æ³ã§ãã ã¡ãã»ãŒãžãããã«ã¯ãªãã¯ããŠããããã®åãããŒã¿ãèŠã€ãã£ãããªã¥ãŒã ãéžæãããã®å šäœãåæã®ããã«dxe.volãã¡ã€ã«ã«æœåºããŸãã UEFIToolã¯éããå¿ èŠã¯ãããŸãã-ãŸã 䟿å©ã§ãã
çµæã®ãã¡ã€ã«ã16é²ãšãã£ã¿ã§éããããªã¥ãŒã ã®ç©ºãé åã¯ããã«ããååšã§ããªããããæåŸããæ€èšããŸãã
ãŸãããµã€ãº100hïŒèµ€ã§ããŒã¯ïŒã®éåžžã«çãããããŒã¿ãããããã®åŸãã«çœ²å$ SIG ããã¡ãŒã ãŠã§ã¢ããŒãžã§ã³F.50ããã³ãã©ãããã©ãŒã ã³ãŒãå68CPKããããŸãã ãããã£ãŠãæåã®è³ªåã«å¯Ÿããçãã¯ããããåãåãããŸãã
äºåããïŒ
2çªç®ã«çããã«ã¯ããã®ããŒã¿ãããã¯ã«ã¢ã¯ã»ã¹ããPEIã¢ãžã¥ãŒã«ãæ¢ãå¿ èŠããããŸãã ããã¯ç°¡åã§ã¯ãªããå€ãã®å Žåãããã€ãã®ãªãã·ã§ã³ãè©Šãå¿ èŠããããŸãã æãç°¡åãªæ¹æ³ã¯ã$ SIGã·ã°ããã£ã®ä»ã®åºçŸãæ¢ãããšã§ããããã®å Žåãããã«å€±æããŸã-ç»åå ã«ãã®ãããªè¡ã®ä»ã®åºçŸã¯ãããŸããã ãã ãããããã¯ã眲åã§æ€çŽ¢ãããªãå Žåã¯ããªãã»ãããŸãã¯çµ¶å¯Ÿã¢ãã¬ã¹ã§æ€çŽ¢ãããŸãã ããªã¥ãŒã å ã®ãªãã»ããã¯12FEE0hã§ãã UEFIToolã«åãæ¿ããŠãããããŒãèæ ®ããã«16é²ãã¿ãŒã³E0FF12ãæ€çŽ¢ããŸãïŒIntelããã»ããµãŒã¯ãŸã LittleEndianãªã®ã§ããã€ãé ãå€æŽããå¿ èŠããããŸããïŒãIiii ... BINGOã2ã€ã®ãšã³ããªã®ã¿ãããã³äž¡æ¹ãææãªååSecureUpdatingãæã€åãPEIã¢ãžã¥ãŒã«ã«ãããŸãã ããã«åæããããã«ã su.binãã¡ã€ã«ã«ããããŒãªãã§ãããåãåºããŸãã
ãããã£ãŠãããããã2çªç®ã®è³ªåã«å¯Ÿããåçãåä¿¡ãããŸãã
ïŒã€ãã£ãŠïŒ
第äžã«å¯ŸåŠããããã«æ®ã£ãŠããŸãã ãããè¡ãã«ã¯ãéã¢ã»ã³ãã©ãããã€ã¹ã®PEIã¢ãžã¥ãŒã«ã«é¢ããç¥èãå°ãå¿ èŠãå¿èåãå¿ èŠã§ãã IDAãèµ·åãããã¢ã¢ãŒãã®æ¡ä»¶ã«åæããŠã以åã«åä¿¡ãããã¡ã€ã«ãéããŸãã[ãªãã·ã§ã³]-> [ã³ã³ãã€ã©]ã«ç§»åãã次ã®ããã«èšå®ããŸãã
次ã«ã [ãã¡ã€ã«]-> [ãã¡ã€ã«ã®èªã¿èŸŒã¿]-> [CããããŒãã¡ã€ã«ã®è§£æ]ã«ç§»åããå¿ èŠãªãã¡ã€ã«ã®ãªã¹ãã«ããäžèšã®behemoth.hãã¡ã€ã«ãUEFIæ§é ã®å®çŸ©ãšãšãã«èªã¿èŸŒã¿ãŸãã
解æãšã©ãŒã«æ³šæãæã䟡å€ã¯ãããŸããããã®å Žåããšã©ãŒã¯çºçããŸããã
[æ§é ]ã¿ããéãã[ ç·šé ] -> [æ§é ã¿ã€ãã®è¿œå ... ]ã«ç§»åãïŒãŸãã¯[æ¿å ¥]ãã¯ãªãã¯ãããšé«éã«ãªããŸãïŒã[ æšæºæ§é ãè¿œå ] ãã¯ãªãã¯ããŸãã
åæã«ãEFI_GUIDãšEFI_FFS_FILE_HEADERãè¿œå ããŸã-䟿å©ã§ãã
EFI_PEI_SERVICESæ§é äœïŒçµ¶å¯Ÿã«æ£ç¢ºãªå ŽåãPEIã«ãŒãã«ã«ãã£ãŠäœæãããã€ã³ã¹ã¿ã³ã¹ãžã®ããã«ãã€ã³ã¿ãŒïŒã¯ããã©ã¡ãŒã¿ãŒãšããŠåPEIã¢ãžã¥ãŒã«ã®ãšã³ããªãã€ã³ããšãã®ã»ãŒãã¹ãŠã®é¢æ°ã«æž¡ãããŸãã ããã¯ãPEIã®äžéšããã©ãã·ã¥ã¡ã¢ãªããçŽæ¥å®è¡ãããããšã匷å¶ãããŠããããã§ãããã©ãã·ã¥ã¡ã¢ãªã¯ãã®æç¹ã§ã¯èªã¿åãå°çšã§ããããããã®ãããªPEIã¢ãžã¥ãŒã«ã®ã°ããŒãã«å€æ°ã¯äœ¿çšã§ããããã¹ãŠãæã¡æ©ãå¿ èŠããããŸãã ããã¯ããã°ã©ããŒã«ãšã£ãŠäžå¿«ãªå¶éã§ããã次ã®ããã«PEIã¢ãžã¥ãŒã«ã®èª¿æ»ãšãããã°ã«åœ¹ç«ã¡ãŸãã ããã«ãã€ã³ã¿ãŒã®éåç §ã¯ãéåžžã®ã³ãŒãã§ã¯ããŸãäžè¬çãªæé ã§ã¯ãªããããPEIãµãŒãã¹ãžã®åŒã³åºãã®ã»ãšãã©ã¯ããªã¹ãããçŽæ¥è¿œè·¡ã§ããŸãã ãã®ãããããã«æ»ããŸãããæåã«PEIã¢ãžã¥ãŒã«ãžã®ãšã³ããªãã€ã³ããã©ã®ãããªãã®ããæãåºããŸãïŒãŸãã¯èª¿ã¹ãŸãïŒã ã°ãŒã°ã«ã«æ¥ããªãã§ãã ãããããã¯æ¬¡ã®ããã«ãªããŸãïŒ
EFI_STATUS EFIAPI PeimEntry( IN EFI_FFS_FILE_HEADER *FfsFileHeader, IN EFI_PEI_SERVICES **PeiServices );
EFI_STATUSã¯unsigned intã®typedefãEFIAPIã¯stdcallã®typedefã§ããæåã®ãã©ã¡ãŒã¿ãŒã¯ãåŒã³åºãããPEIã¢ãžã¥ãŒã«ãé 眮ãããŠããFFSãã¡ã€ã«ã瀺ããŸãïŒã¢ãžã¥ãŒã«ãããŒã¿ãè¿ãã«ä¿åããã¢ã¯ã»ã¹ããå¿ èŠãããå ŽåïŒ ïŒãããã³2çªç®ã¯ãæ¢ã«äžèšã§èª¬æããPEIãµãŒãã¹ããŒãã«ãžã®ããã«ãã€ã³ã¿ãŒã§ãã ãã®ç¥èãæŠåšã«ãéå§é¢æ°ã®ã¿ã€ãã倧èã«å€æŽãïŒåŒ·èª¿è¡šç€ºããŠYããŒãæŒãïŒã次ã®ããã«ãªããŸãã
çŸåšããªã¹ãã«ã¯æ¬¡ã®ããšã瀺ãããŠããŸãããŸããPeiServicesãäžèŠãªäžé£ã®é¢æ°åŒã³åºãããããŸãã ã»ãšãã©ã®å Žåããããã¯IOããŒããšä»ã®ãã®çš®ã®éæ³ãšã®éã§å ¥åºåãè¡ã£ãŠããŸããæåã«é çªã«ç§»åããŠãã®ä»®å®ãæ€èšŒããŸãã
å®éãé¢æ°ã¯ããŒã24Ehãžã®ããŒã¿åºåãå®è¡ããŸãã 次ã®ããã€ãïŒãããã¯éåžžã«ãã䌌ããèªã¿æžãIOããŒãïŒãçç¥ããPeiServicesããŸã 䜿çšããŠãããã®ã«é²ã¿ãŸãã
1ã€ç®ã¯ç°¡åã§ãPeiServicesãã°ããŒãã«å€æ°ã«ä¿åããã ãã§ãïŒPEIã¢ãžã¥ãŒã«ãæ¢ã«RAMããå®è¡ãããŠããããšã瀺ããŸãããå°é家ã®éãç®ã¯UEFIToolã®PEãã¡ã€ã«ã«é¢ããæ å ±ããããã«æ°ã¥ããã§ãããïŒã
ç¹ã«æ£ãããã©ã¡ãŒã¿ãŒãèšå®ãããã®å€ã®ã¿ã€ããè¿ãå Žåã以äžã¯ãã§ã«ã¯ããã«å€§ãããã¯ããã«èå³æ·±ããã®ã§ãã
ããããŒã°ãšããŒã«ã«å€æ°ã®ãŒãåã®çŽåŸã«èµ€ã§åŒ·èª¿è¡šç€ºããããã©ã°ã¡ã³ãã¯ãäžèšã§èª¬æããããã«ãã€ã³ã¿ãŒã®éåç §ãšåãé¡èãªãã¿ãŒã³ã§ãã ã©ã®ãããªçš®é¡ã®PEIãµãŒãã¹ãåŒã³åºãããããç解ããã«ã¯ãæ§é äœã®åšãã§ããããã¹ãŠã®ãã³ã¹ãå¿ èŠã§ããã[eax + 28h]ã«ã«ãŒãœã«ã眮ãã TãæŒããŠè¡šç€ºããããŠã£ã³ããŠã§EFI_PEI_SERVICES.GetBootModeãéžæããŸãïŒ
ãã®ã·ã°ããã£ãèŠããšãvar_134ã¯å®éã«ã¯ã¹ã¿ãã¯äžã®å€æ°ã§ãããçŸåšã®ããŒãã¢ãŒãã®å€ãæžã蟌ãŸãããšçµè«ä»ããããšãã§ããŸãã 次ã«ããã®å€ã¯11hãšæ¯èŒãããçãããªãå Žåãèšç®ã¯ããã«é²ã¿ãŸããããŸã çããå Žåãeaxã«ãŒããå ¥ããŠæ»ããŸãã ãã®å Žåã®11hã¯BOOT_ON_S3_RESUME ãã€ãŸã ã·ã¹ãã ãACPIã¹ãªãŒãã¢ãŒãããèµ·åãããšãé¢æ°ã¯åžžã«0ãè¿ããŸãïŒããã¯ããŒã«ã«ã®æ¹èšEFI_SUCCESSã«ãããŸãïŒã ã·ã¹ãã ãå¥ã®ç¶æ ããèµ·åãããšãå®è¡ãç¶ç¶ããçµæãšããŠãã®èå³æ·±ãå ŽæãééããŸãã
ããå€ãåéïŒ ãã®ã¢ãžã¥ãŒã«ãèŠã€ããã®ãšåã12FEE0hã®åºçŸã ãããŠãæåã«ãCopyMemé¢æ°ã䜿çšããŠããã®çãããCS / EDSããããã¡ãŒã«ã³ããŒãããå ã®å ŽæãFFhãã€ãã§äžæžããããŸããããã¯ãæåã«DXEããªã¥ãŒã ã®ç©ºãã¹ããŒã¹ãåããããã«äœ¿çšããã次ã«ãã®CS / EDSããã§ãã¯ããé¢æ°ãåŒã³åºãããŸã
ãã¡ãããä»ããæ¢çŽ¢ãéå§ã§ããŸãããã·ã¹ãã ãS3ãããŠã§ã€ã¯ã¢ããããå Žåãã³ãŒãã®ãã®éšåã¯ãŸã£ããå®è¡ãããŸããïŒS3ã®DXEããªã¥ãŒã ã«ã¯äœãå¿ èŠãªããããã§ããã ãæ©ããŠã§ã€ã¯ã¢ããããå¿ èŠããããããè«ççã§ãïŒããŸãæ©èœããªãã®ã§ããŸãå§ãã«ããã®ç¹å®ã®PEIã¢ãžã¥ãŒã«ã«ãæ°žé ã®å€ããããåžžã«S3_RESUMEããããšèãããããã§ãã¯ãã¹ãããããŸãã
ãããè¡ãã«ã¯ãcmp [ebp + BootMode]ã11hãxor eaxãeaxã«å€æŽããã ãã§ã次ã®jnzã¯å®è¡ãããŸããããå®äºããªãå Žåã¯ãé·ç§»èªäœãããã€ãã®NOPã«çœ®ãæããæ¹ãç°¡åã§ãã
Hexãšãã£ã¿ãŒã§éžæãããã©ã°ã¡ã³ãã90 90ã«å€æŽããŠå®äºã§ãã
UPD
çªç¶ãããã€ãã®æ°ããç¶æ³ãçŸããŸããã ãã®ãå€ããããŒãžã§ã³ã®ä¿è·ã«ã¯ãã·ã¹ãã ãPEIããªã¥ãŒã ã®å ã®ç¶æ ã埩å ããããã«äœ¿çšã§ããPEIããªã¥ãŒã ã®ã³ããŒããããŸãããã®ã³ããŒã§ã¯ãSecureUpdatingã¢ãžã¥ãŒã«ãããããé©çšãããã®ãšäº€æããå¿ èŠããããŸãã ã³ããŒã¯ãã¿ã€ãRAWã®GUID 05B3AFFD-F7CC-4C0A-A19A-A9774E2675D7ã®ãã¡ã€ã«ã«ä¿åãããããããã®ãã¡ã€ã«ã®å 容ã¯UEFIToolã®çŸåšã®ããŒãžã§ã³ã§ã¯è¡šç€ºãããŸããã
å®éãããã¯ã¿ã€ãFreeformã®ãã¡ã€ã«ã§ããããã®ã³ã³ãã³ãã«ã¢ã¯ã»ã¹ããã«ã¯ã Extractãããã®ãŸãŸæœåºããå¿ èŠããããŸã... ã æœåºããããã¡ã€ã«ã®ãªãã»ãã12hïŒãã¡ã€ã«ã¿ã€ãïŒã®ãã€ãã01ãã02ã«çœ®ãæããReplaceãä»ããŠå ã®ãã¡ã€ã«ã®ä»£ããã«çµæãã¡ã€ã«ãæ¿å ¥ããŸããã®ãŸãŸ... ïŒ
ãã®ãã¡ã€ã«å ã«ã¯ãPEIããªã¥ãŒã ã®ã³ããŒãå«ãå§çž®ã»ã¯ã·ã§ã³ããããŸãããããã«ã¯SecureUpdatingã®å¥ã®ã€ã³ã¹ã¿ã³ã¹ãããããããããããå¿ èŠã§ãã ä»ã§ã¯ã以åã¯æãã§ããªãã£ãå Žæã§ããã¹ãŠã確å®ã«æ©èœããŸãã
ãããã«
ããã«æè¡ã®åé¡ã§ãã Replace Body ...å ã®PE32ã»ã¯ã·ã§ã³ã®å 容ãå€æŽããããã¡ã€ã«ã§çœ®ãæã ãDXEããªã¥ãŒã ã«å¿ èŠãªå€æŽãå ããå€æŽãä¿åããããã°ã©ããŒã«çµæã®ã€ã¡ãŒãžããã©ãã·ã¥ããŸãã ç§ã¯ãã®ã©ããããããæã£ãŠããªãã£ãã®ã§ãä¿®æ£ããŠçµæããµããªã«ã³ãã«éä¿¡ããŸããã æ°æéåŸããããããšãããã¹ãŠãæ©èœããã¯ã©ã€ã¢ã³ãã¯æºè¶³ããŠããŸãããšããçããè¿ã£ãŠããŸãããç§ã¯ããªããèªãã ã°ããã®èšäºãæžãããã«æ確ãªè¯å¿ããã£ãŠè¡ããŸããã
ãæž èŽããããšãããããŸããã