# BlackLotus-analysis-stage2-bootkit-rootkit-stage

BlackLotus stage 2 bootkit-rootkit analysis

Before we dive into this divine shit(belive me this is some divine shit as nobody can do this withouth GOD's Will(at least that's my opinion on this)) ,here's the hash for the bootkit file

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/56b4a81c-c4a3-4788-859a-9492d0a76bdb" alt="1"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2F5oYOjcXkewTeP6Tyth5b%2F1.PNG?alt=media&#x26;token=f493fbc9-ba3e-42fb-9209-19f5eb6f9583" alt=""><figcaption></figcaption></figure></div>

Frist things first this is how a healthy system looks like

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/763d7c19-79da-4c01-bc64-249bde695ba7" alt="1"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2FCThY1JlAnwNAzqbgL80P%2F1.PNG?alt=media&#x26;token=c286fd0a-d3e5-4486-b2b5-1d243b9304d7" alt=""><figcaption></figcaption></figure></div>

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/de67e159-9e15-430c-bfe4-2ab34f6b379c" alt="2"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2Fwy9hxhNcC71y6GvzI14O%2F1.PNG?alt=media&#x26;token=e65dbfd1-34fe-4e85-bd7c-3059072c3dc7" alt=""><figcaption></figcaption></figure></div>

```
C:\Windows\system32>BCDEdit

Windows Boot Manager
--------------------
identifier              {bootmgr}
device                  partition=\Device\HarddiskVolume9
path                    \EFI\MICROSOFT\BOOT\BOOTMGFW.EFI
description             Windows Boot Manager
locale                  en-US
inherit                 {globalsettings}
default                 {current}
resumeobject            {3f80ecd0-df10-11ed-bafc-80a84b2564bb}
displayorder            {current}
toolsdisplayorder       {memdiag}
timeout                 30

Windows Boot Loader
-------------------
identifier              {current}
device                  partition=C:
path                    \Windows\system32\winload.efi
description             Windows 10
locale                  en-US
inherit                 {bootloadersettings}
recoverysequence        {3f80ecd2-df10-11ed-bafc-80a84b2564bb}
displaymessageoverride  Recovery
recoveryenabled         Yes
isolatedcontext         Yes
allowedinmemorysettings 0x15000075
osdevice                partition=C:
systemroot              \Windows
resumeobject            {3f80ecd0-df10-11ed-bafc-80a84b2564bb}
nx                      OptIn
bootmenupolicy          Standard

```

Now on my analysis i never managed to infect my machine such i will use the example from the already referenced asian's researcher blog post which this is how it's supposed to look an infected one

```
    // Windows Boot Manager
    // --------------------
    // identifier              {9dea862c-5cdd-4e70-acc1-f32b344d4795}
    // description             Windows Boot Manager
    // locale                  en-US
    // inherit                 {7ea2e1ac-2e61-4728-aaa3-896d9d0a9f0e}
    // bootdebug               Yes
    // displayorder            {57e1b615-0355-11ec-abb0-005056c00008}
    // timeout                 30

    // Windows Boot Loader
    // -------------------
    // identifier              {57e1b615-0355-11ec-abb0-005056c00008}
    // device                  boot
    // path                    \system32\hvloader.efi
    // description             Hoy la disco se flota
    // locale                  en-US
    // inherit                 {6efb52bf-1766-41db-a6b3-0ee5eff72bd7}
    // truncatememory          0x10000000
    // avoidlowmemory          0x1000
    // nointegritychecks       Yes
    // testsigning             Yes
    // isolatedcontext         Yes
    // osdevice                boot
    // systemroot              \
    // ems                     Yes
```

\=============================================================================

\=============================================================================

Before we get started how does one setup the environment for the analysis of an efi module anyway ? Well courtesy goes to @MaverickMusic\_\_ , during a disscussion with him he handed me this( `https://zhuanlan-zhihu-com.translate.goog/p/343293521?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=en-GB` ). Now i didn't completly follow the stepts there so here's what exactly i did in order to have the environment up and running :

-First i installed edk2(<https://github.com/tianocore/tianocore.github.io/wiki/Windows-systems>)

-Second i have configured my ovmf as debug not realease(this will help us later). Here is the command `build -a X64 -t VS2019 -b DEBUG -p OvmfPkg/OvmfPkgX64.dsc`

-Third i had to configure my windbg. How tf did i do this ? I downloaded everything from this link(`git clone https://github.com/microsoft/WinDbg-Samples`). Than i compiled ExdiGdbSrv.sln. Thank i followed everything from this link(<https://learn.microsoft.com/en-us/windows-hardware/drivers/debugger/setting-up-qemu-kernel-mode-debugging-using-exdi>), from whevere it said `Use regsvr32 to register the DLL in an Administrator command prompt.` till `PS>.\Start-ExdiDebugger.ps1 -ExdiTarget "QEMU" -GdbPort 1234 -Architecture x64 -ExdiDropPath "C:\path\to\built\exdi\files"`. Confusing i know but please wait patiencly as i will defently make a video where i will explain every step! Cool so now that we have a setup environment for debugging how tf do we debug the code ? So we start qemu in my case i did it by executing `qemu-system-x86_64.exe -L . -bios OVMF.fd -hdd dos.img -debugcon file:debug.log -global isa-debugcon.iobase=0x402` . Once i ran qemu commmand i instantly went and selected compat\_monitor0 from view menu of qemu. It should look like that when you do that.&#x20;

<figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2FUfQB0dWpCr52QmmdlK59%2F1.PNG?alt=media&#x26;token=211da6fc-3dd4-426d-9455-c6a3251d41dc" alt=""><figcaption></figcaption></figure>

also after selecting this you should input gdbserver to start a remeote instance of gdb debuggin to which we will attach with windbg using this command `.\Start-ExdiDebugger.ps1 -ExdiTarget "QEMU" -GdbPort 1234 -Architecture x64` Cool so once we connect to it will look like this

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/3047fb82-60d2-496f-8957-add54549d3ca" alt="1"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2FD3W2ngvxTYHCWkN9Jilr%2F1.PNG?alt=media&#x26;token=b07abf32-465e-4540-94e1-c4d92db1aeed" alt=""><figcaption></figcaption></figure></div>

```
So how do we set up a breakpoint in order to debug the bootkit? Well that's we we compiled the ovmf image as debug rather than release. If you specifically start qemu with that command you'll have qemu run and debug messages will be logged in a file called debug.log , which looks like this 
```

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/7e5cd8f4-3638-43bc-9646-9b037c3e8096" alt="1"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2FDWrCuCofoNJzC3iueJne%2F1.PNG?alt=media&#x26;token=8abea6b7-5d83-4057-aedf-51a0b4f74b5b" alt=""><figcaption></figcaption></figure></div>

So cool now to make sense of this output, for our case the only relevant line is `EntryPoint=0x000062C9A8C` which is like the preffered loaded address whenever we run the bootkit. Specifically for the bootkit it varies between `0x62C4A8C or 0x62C9A8C`. Now we can rebase the program in ida and do our normal work :) . Enojoy the rest of the blog!

\=============================================================================

Bindiffing the original winload.efi with the one dropped by the blacklotus

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/a5beeebe-6d7e-47ed-92ce-72767242a3cc" alt="1"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2F11fz67ey7IBaZkTqMrdG%2F1.PNG?alt=media&#x26;token=4494808f-5bc1-4a13-b9f3-e86ad14b2a10" alt=""><figcaption></figcaption></figure></div>

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/af1f2da2-cb15-430f-8809-d9c8c10e6e12" alt="2"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2F58SpwaSYiN0M6x4fTHkR%2F1.PNG?alt=media&#x26;token=8bbe868a-3c3d-4bbc-b24b-55ccd77f8977" alt=""><figcaption></figcaption></figure></div>

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/3866f2f6-9a7b-4338-b303-1d1b470b71fe" alt="3"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2Fob5Svc2uBaAMVLCUAWNL%2F1.PNG?alt=media&#x26;token=edd2cb96-3512-4166-bd54-558f4d2bfc16" alt=""><figcaption></figcaption></figure></div>

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/76aeb4af-f423-41eb-bbf6-0d08aed2433e" alt="4"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2FUb3eS3CCsomcJQtK7oFJ%2F1.PNG?alt=media&#x26;token=bedcc7e6-57ff-44d1-818d-ff2657f1cd2a" alt=""><figcaption></figcaption></figure></div>

We see some similarities but also some discepancies, but nothing usefull,anywayy....

\=============================================================================

Cool so let's get this party started.

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/77afbc0d-1616-4af8-a8bb-4eaa5682a82b" alt="1"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2FaR04l0ZCtJpoAQwqQgK2%2F1.PNG?alt=media&#x26;token=e522c571-84b1-400f-ab17-7a934281e9b2" alt=""><figcaption></figcaption></figure></div>

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/756ca67e-baf3-4e83-bb9c-77cfd1c62c63" alt="1"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2FV4GAtzqCqf0GfcmPtlE8%2F1.PNG?alt=media&#x26;token=ec487a61-a7fe-4961-8618-bd780ae4df9c" alt=""><figcaption></figcaption></figure></div>

Cool so let's start dissecating. So first we see that we have a function which gets called. Cool so what about it ? well

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/0f71f792-7a68-4e45-981e-2ac803606dc6" alt="1"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2FSJazGMuqtkxaNc40d54z%2F1.PNG?alt=media&#x26;token=81104a80-0858-4113-82b2-a6e3d04f021d" alt=""><figcaption></figcaption></figure></div>

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/89940f3b-2ac1-44a5-8376-9b5fad73bdb8" alt="2"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2FgVLmRU9LnySJvkZXBFJL%2F1.PNG?alt=media&#x26;token=d1338198-6d01-4980-a0e8-ff82547eb6a3" alt=""><figcaption></figcaption></figure></div>

Cool another function . Not quite... Notice something familiary ?

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/7c5d8662-72b8-4e7c-8a04-04992e4f1d2d" alt="1"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2FCpaxyLslc0K1O4Irc2aH%2F1.PNG?alt=media&#x26;token=10c519e6-dcd9-4911-86b8-9ee4698aa68e" alt=""><figcaption></figcaption></figure></div>

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/72419316-2945-4187-8112-3976d210e7ab" alt="2"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2FX2gjnEyssaMwAZe40H2m%2F1.PNG?alt=media&#x26;token=809fa36d-35e0-467d-a032-253388a142c8" alt=""><figcaption></figcaption></figure></div>

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/00ceebe5-fe73-4a28-a4c5-235cabe8786e" alt="3"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2FKWpy3To7EKw733gP2Pjf%2F1.PNG?alt=media&#x26;token=78c47911-e972-4b53-ae8f-ac0da2de8876" alt=""><figcaption></figcaption></figure></div>

![4](https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/b675edcc-b7ec-4737-afb3-5cf327bffd83)

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/1795ebdd-6e83-49b3-93bf-6b1911c2af89" alt="5"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2FCNiREsxAwCLcjm8PxkF0%2F1.PNG?alt=media&#x26;token=afb47ca6-9aea-49b0-9862-e44a067af8cb" alt=""><figcaption></figcaption></figure></div>

Nothing yet???

No problemo maybe now

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/2becee86-c848-4505-b522-b9ff9969edf0" alt="1"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2FYO3NZItauZkjDbctUYsY%2F1.PNG?alt=media&#x26;token=a31ae741-9ccd-4217-a57d-f027bd80c7a2" alt=""><figcaption></figcaption></figure></div>

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/eb196e09-90bf-41a1-9df6-ace8585cb6ab" alt="2"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2FhkCnH7SBc2aYPpYV8eZJ%2F2.PNG?alt=media&#x26;token=f645ebae-f5ed-41d2-ae35-59e54dfac6d9" alt=""><figcaption></figcaption></figure></div>

Same demangle function! Hi there old friend :)))

Cool but what about `return (*(a1 + 88))(v2, &unk_62CEABC, 3i64);` ?? Well honestly idk what to say just soley from a static perspective so let's try to use the debugger to understand it :))

So when we demangle the string we get

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/071d7748-85e0-4d69-b466-f77048d9b66e" alt="1"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2FIslEP5lqB76QlBWvUBpw%2F1.PNG?alt=media&#x26;token=e4b78341-b15f-45f6-9b4c-d5ef53444f6f" alt=""><figcaption></figcaption></figure></div>

So next when we end up to the call instruction

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/93c01e2a-86b0-4ba6-ae7c-899fb7aba5ac" alt="1"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2FrCO5K5yKvVVfqQPcW1IY%2F2.PNG?alt=media&#x26;token=f892fc3e-3d9d-41c5-b82d-ee509229ffb9" alt=""><figcaption></figcaption></figure></div>

and we get no info.... great, but why is that ? bc we don't have a .pdb file so we can get debug symbols.... Cool at least ida is helpfull here. So we know that the "grand" function takes as input SystemTable->RuntimeServices, which is of type EFI\_SYSTEM\_TABLE. Cool if we inspect it this is a `A pointer to the EFI Runtime Services Table.` . if we search around googler we come around a bunch of docs but one crucial doc we come around is <https://uefi.org/sites/default/files/resources/UEFI\\_Spec\\_2\\_1\\_D.pdf> . there is says

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/6802517e-b815-40f5-88cd-3df8899baf0a" alt="1"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2F1q2KDvY4AkwKjUwBiqA7%2F1.PNG?alt=media&#x26;token=50df2bf3-6a83-49cb-82c3-302761e6ccc1" alt=""><figcaption></figcaption></figure></div>

Cool so a struct with bunch of pointers, ye, but let's zoom in more.

So first it demangles VbsPolicyDisable, if we search google we come around eset analysis which states `that this variable is evaluated by the Windows OS loader during boot and if defined, the core VBS features, such as HVCI and Credential Guard will not be initialized.` , so basically this variable is responsible for current "security" at boot level. Cool next we have the function which takes that variable and

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/61d0e73f-8f7c-4eff-8f70-4d259bd5beb6" alt="1"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2FgD72tzu8KHYbhNs5SoD2%2F2.PNG?alt=media&#x26;token=1c1c72e1-e63e-4bbd-88b5-400aa615ab33" alt=""><figcaption></figcaption></figure></div>

and so we can come to the conclusion that this must be a function which changes somehow the state of that variable. Cool so what are some possible function that could do this ? there's only one such function in EFI\_SYSTEM\_TABLE which EFI\_SET\_VARIABLE SetVariable;

So we conclude that this function simply take VbsPolicyDisable and sets it to

```
db  77h ; w
.data:0000000180005034                 db  59h ; Y
.data:0000000180005035                 db    3
.data:0000000180005036                 db  32h ; 2
.data:0000000180005037                 db  4Dh ; M
.data:0000000180005038                 db 0BDh ; ½
.data:0000000180005039                 db  60h ; `
.data:000000018000503A                 db  28h ; (
.data:000000018000503B                 db 0F4h ; ô
.data:000000018000503C                 db 0E7h ; ç
.data:000000018000503D                 db  8Fh
.data:000000018000503E                 db  78h ; x
.data:000000018000503F                 db  4Bh ; K.
```

Now is there anything important about these bytes ? well yes, if you by chance have read the first part of the blacklotus analysis you'll know that i referenced an asian's researcher work. Well that researcher was kind enough to also analyse the dropped bootkit . Please check it out(<https://www.cnblogs.com/DirWang/p/17294545.html#autoid-3-2-1>) , so in his analysis he was kind enough to give us that info. He points us to <https://github.com/Mattiwatti/EfiGuard/blob/master/EfiGuardDxe/PatchWinload.c> . there we see a similar line

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/cb4aeaeb-44a0-46c5-a192-acf75ac5ecc5" alt="1"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2FpRCForIXyTnq9ZQeXOJe%2F1.PNG?alt=media&#x26;token=89a1ab34-d712-46ef-816f-6e5ce97104c3" alt=""><figcaption></figcaption></figure></div>

Is there a specific reason behind this , honestly i don't know it's my first time analysing a bootkit . Please do let me know or make a pr/pull request to edit this document if you have more experience than i do :) in this area

\=============================================================================

Cool next, fortune favours us and the pseudo code from ida is simillar with assebmly

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/823b3ab5-5b15-4324-98ce-e01792b49cfb" alt="1"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2FYCyd1FmCptyhOPQqmnnK%2F2.PNG?alt=media&#x26;token=7d4c451c-58b8-4ebb-9171-bd110d0a66ad" alt=""><figcaption></figcaption></figure></div>

so what i guess happens here is normal initialisation of EFI\_SYSTEM\_TABLE which basically i guess initializes which process to continue the boot process. and than we have the function call PatchBootManager

\=============================================================================

PatchBootManager

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/531e8380-ea15-4882-9006-7506f6f823ef" alt="1"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2FnIhdvyOhZ3O9WRMUdo58%2F1.PNG?alt=media&#x26;token=42cd7dd1-d1e0-405a-9c8d-3bc27559ef65" alt=""><figcaption></figcaption></figure></div>

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/4ad8b398-cb66-4549-ae29-3c0ca87c8ab6" alt="2"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2F4mu04Xl8ZB4n8BOrB2JK%2F2.PNG?alt=media&#x26;token=d78ebc0b-fbb2-4cf0-aa75-2258f2ff1cfb" alt=""><figcaption></figcaption></figure></div>

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/107e0158-d958-403b-b691-ed7e90836a5c" alt="3"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2F3jdEVs8PyX9XMTbttpdh%2F1.PNG?alt=media&#x26;token=71f88b57-1503-45df-8f0c-40a6718deabc" alt=""><figcaption></figcaption></figure></div>

And from pseudo code

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/34213178-a799-4af8-87e5-3ebb70e9c49c" alt="1"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2FLOPRE8e6R13ggG9PvS8H%2F1.PNG?alt=media&#x26;token=0e49ff9a-b471-4c36-abe8-32bd6036987f" alt=""><figcaption></figcaption></figure></div>

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/0748de2e-cead-4525-990b-87ca1a8ecfa3" alt="2"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2FL0N363HyCGzzoAtG71Wf%2F2.PNG?alt=media&#x26;token=1b7588ca-50d6-4703-85f7-dbf38d8ac2ff" alt=""><figcaption></figcaption></figure></div>

Coll so first function call we see it does is HandleProtocol. So what the code does it do ? Luckly we stumble upong this when doing a quick google search (<https://tianocore-docs.github.io/edk2-ModuleWriteGuide/draft/5\\_uefi\\_drivers/54\\_communication\\_between\\_uefi\\_drivers.html>) and we see that it `retrieve protocols`. Cool nothign rlly that can i make sense. Ye i gotcha' fam. So basically this retrives communication informationmethods used by other UEFI drivers. Cool some more digging. we see the second parameter is

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/4dcc9941-76b3-4c5a-94c3-3f74e6a71185" alt="1"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2F0XLvh6j28P2LhgVLwhVa%2F1.PNG?alt=media&#x26;token=2d3d19c1-33fe-4f8e-9929-464bb5226e9c" alt=""><figcaption></figcaption></figure></div>

If we search for that specifc bytes we come across this

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/8356ae68-043b-450a-b549-ee471b93483c" alt="1"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2FJ7uGjaa0eR9tZJ8WBMVT%2F2.PNG?alt=media&#x26;token=ca4fd3e3-dd0b-4d9a-8d47-0d5990f8440e" alt=""><figcaption></figcaption></figure></div>

so wtf does EFI\_LOADED\_IMAGE\_PROTOCOL\_GUID do ? quoting from(<https://uefi.org/specs/UEFI/2.10/09\\_Protocols\\_EFI\\_Loaded\\_Image.html>) `Can be used on any image handle to obtain information about the loaded image.` , what type of info ? \`\`\`This section defines EFI\_LOADED\_IMAGE\_PROTOCOL and the EFI\_LOADED\_IMAGE\_DEVICE\_PATH\_PROTOCOL. Respectively, these protocols describe an Image that has been loaded into memory and specifies the device path used when a PE/COFF image was loaded through the EFI Boot Service LoadImage(). These descriptions include the source from which the image was loaded, the current location of the image in memory, the type of memory allocated for the image, and the parameters passed to the image when it was invoked.\`\`\`\`

So in our case grabs info about the bootkit. Now there's a problem we can't rlly inspect the resut of the function bc we have no debug symbols :/ but we can presume. and i tend to presume that the structure(result from previous function call)will be in rbx.

<figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2FDxb1JsjpJalRGKmM7U2S%2F1.PNG?alt=media&#x26;token=00110fab-cdaf-4572-b107-dd9cbca7306c" alt=""><figcaption></figcaption></figure>

Next we call demangle string

<figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2FGGwYWmSVYOFTV3tbSZyo%2F2.PNG?alt=media&#x26;token=b743bc17-7fcc-4e5f-ac74-5d5006f67d67" alt=""><figcaption></figcaption></figure>

which gets us

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/77ac1280-d7de-4f0e-956c-a6f6f7aeedd6" alt="1"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2FTJn0kOnURHSpAAP7Al25%2F1.PNG?alt=media&#x26;token=0bea5ebc-57c9-4127-a753-29c270dc6e34" alt=""><figcaption></figcaption></figure></div>

and than we call

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/4f66b2c5-a3c3-457d-88f2-fde4e55a1b7f" alt="1"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2Fn3fcp2776NWXksD4YcAd%2F1.PNG?alt=media&#x26;token=68e4a7f0-7c72-4fc0-8cab-09dce6eb3702" alt=""><figcaption></figcaption></figure></div>

\=============================================================================

sub\_180002B14

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/4b229ff9-43d3-4e22-90e9-628c8121b27b" alt="1"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2FRpnMw7xr8cruLks9cHk5%2F1.PNG?alt=media&#x26;token=011c9b8b-79b0-4e72-8d69-2b302607a7bc" alt=""><figcaption></figcaption></figure></div>

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/8d84f664-a402-4e78-b17d-55aa31b24cb7" alt="2"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2FZLQjk9sWZ0ZWSGnOG5gr%2F2.PNG?alt=media&#x26;token=6091927c-b1dc-41d9-a818-1f157fc5bc20" alt=""><figcaption></figcaption></figure></div>

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/096bf634-bf22-49ad-b034-909215dc9ecc" alt="3"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2Fs399Cr11yCxCpa3irAY9%2F3.PNG?alt=media&#x26;token=db60f195-8111-42ee-bdff-948730de524d" alt=""><figcaption></figcaption></figure></div>

and pseudo code

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/327d9ae9-7813-436b-8cec-c1351dd30ec2" alt="1"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2FLlyc1OveNwkvDDAa8y2B%2F1.PNG?alt=media&#x26;token=963b0e6d-837e-4cce-a421-fa718346066f" alt=""><figcaption></figcaption></figure></div>

Cool so until the if everythin's self explanatory,now what about the if? We see again it does a call with unk\_180005010 as parameters which is an array of bytes again, upon further inspection it looks like this

<figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2Fm0dyY06OzgezuknVVtzE%2F1.PNG?alt=media&#x26;token=9fe976c4-52ea-4950-86ff-3bce9689a036" alt=""><figcaption></figcaption></figure>

Now if we inspect the first bytes again and do a quick search we come around this (<https://github.com/theopolis/uefi-firmware-parser/blob/master/uefi\\_firmware/guids/efiguids\\_ami.py>) more precisely this `'EFI_DEVICE_PATH_PROTOCOL_GUID': [0x09576e91, 0x6d3f, 0x11d2, 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b]` .

If we go again on uefi's spec page we see that `Can be used on any device handle to obtain generic path/location information concerning the physical device or logical device.`. Coon we also se more like this `The device path describes the location of the device the handle is for`. OK cool and if we scroll just a little we see a function called \_EFI\_DEVICE\_PATH\_PROTOCOL. Ok so to conclude we know this this has ti di with EFI\_DEVICE\_PATH\_PROTOCOL\_GUID but our function is of type EFI\_BOOT\_SERVICES. So is there any function in EFI\_BOOT\_SERVICES which could do something like handling a protocol ? yes there is . If we inspect <https://www.intel.com/content/dam/doc/product-specification/efi-v1-10-specification.pdf> section 4.4 we see

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/dbcbb1a1-9ce7-46b8-abe2-18cc9da0b5fc" alt="1"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2FRovv4kb204oJjlSURdGp%2F1.PNG?alt=media&#x26;token=606d9991-9eae-4291-b2df-5242472667e5" alt=""><figcaption></figcaption></figure></div>

more precisely it has a function to which we are familiar(HandleProtocol). Cool

Next we see another function call unkow this time to us. Let's see what arguments it takes, So it take 2,than len of passed string as unicode , and ptr to a variable

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/2db35acb-9e5b-49ba-903c-0d46ad77dbe5" alt="2"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2FBal5UcVa9VGuMuLhidh0%2F1.PNG?alt=media&#x26;token=1db46d79-7d80-4840-98f2-d962bf49c49e" alt=""><figcaption></figcaption></figure></div>

Now if we inspect this in a debugger

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/0fa822bc-c19b-494c-a63c-3c6e6f39317c" alt="1"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2FdgNojQRzJUZDfjylmOLH%2F1.PNG?alt=media&#x26;token=e962c381-73fd-44e1-807f-bcac75a189a9" alt=""><figcaption></figcaption></figure></div>

we see a weird thing rcx has a debug string which AllocatePool, which comes after a function call so we conclude that this was possible a call to AllocatePool, funny enough if you also inspect the specs you'll see that boot\_services also has a ptr to AllocatePool which only makes our assumption stronger.

Cool so if we manage to allocate enough space(the check if >= 0 is to check if we succesed to allocate bc if EFI\_OUT\_OF\_RESOURCES is implemented as

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/a4e16a3b-57ff-44e4-b6a0-86a971f8b429" alt="1"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2FRpkPWpZHXWh4HZCsFdAU%2F1.PNG?alt=media&#x26;token=c6d45b10-ec44-4ab3-b7fd-a9e4110abc0c" alt=""><figcaption></figcaption></figure></div>

it's only safe to assume

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/6b4cb668-f835-474a-9ceb-0fcc8599790b" alt="1"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2FFtlptfUIRBMguilHXA6M%2F2.PNG?alt=media&#x26;token=2f707b5a-eb06-4b38-8379-499165a31aeb" alt=""><figcaption></figcaption></figure></div>

is used for success allocation)

One interesting fact is that the buffer after allocating it is not zero but rather it has these bytes in it. If anyone knows more abut this please make a pr request to edit this document

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/36c1351c-ad7d-43e4-9792-58ceea64963e" alt="1"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2FmeNeHV4Ua7y59evj4KKD%2F1.PNG?alt=media&#x26;token=fb48047b-73b4-4939-b162-e652f19be2b5" alt=""><figcaption></figcaption></figure></div>

So yeah anyway we end up calling memcpy after the call our buffer looks like this

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/fa69388b-1cca-403e-a073-4ce8331900d7" alt="1"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2F1nnz1YTgFsirhLdKqmgx%2F1.PNG?alt=media&#x26;token=ac2634fe-e385-41e8-9cdc-707a27a37b43" alt=""><figcaption></figcaption></figure></div>

We than append some bytes to get the buffer to look like this

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/85b5591b-9ea5-4b0a-8c23-1bcfdad7a0c5" alt="1"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2FJAK7wWaZGB5gZv6VEOy8%2F2.PNG?alt=media&#x26;token=5e053dac-3d1b-4d9b-b2f1-b1f40f889624" alt=""><figcaption></figcaption></figure></div>

And than call a function called FileDevicePath\_call which looks about like this&#x20;

<figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2FvvzqW6qbUD62pvW24HKx%2F1.PNG?alt=media&#x26;token=6140ce06-709f-477a-81d8-7beb7da7a283" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2F7dZlOOZpCFREhTR3ucBm%2F3.PNG?alt=media&#x26;token=9dd1ce5b-3fc8-4461-bd83-a2d575fd7a1f" alt=""><figcaption></figcaption></figure>

And translates to this

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/d33dca2e-e5d8-456c-a846-1e7d9d968680" alt="2"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2FD45oQPCRHMgLjv82G1BM%2F2.PNG?alt=media&#x26;token=434b64c5-f3b1-402a-98b5-f558f06316fa" alt=""><figcaption></figcaption></figure></div>

Cool but this don make no sense if not explained so....

first we have a custom implementation of strlen which we won't dissecc cause it's usless :) But here's the result

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/4bddf53d-cd3a-4ee4-897d-e325a74ed1e9" alt="1"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2FKITEdzDDS3rZgE2LVSyB%2F1.PNG?alt=media&#x26;token=d0619541-7ea7-498f-adf0-05d169d55be0" alt=""><figcaption></figcaption></figure></div>

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/c36d8166-1f74-428b-b710-47524702ce52" alt="2"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2FLaRhRdAN1L4gHlYpdFuy%2F2.PNG?alt=media&#x26;token=0ff5b89e-0be4-49ae-97b8-e4a5d61d0e1d" alt=""><figcaption></figcaption></figure></div>

32 chars from len(of(str)+"\x00" and than the last 4 bytes appended before the function call 0x4FF7F

Next we call what i also used from the asian's research blog post PxepDevicePathInstanceCount, which is simply strlen, cause it simply counts each letter and has a counter. as seen here

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/7c91b17e-3fda-4e96-bbfa-ff66af3e0f29" alt="1"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2FIKzOFIivYqPVCXhozGim%2F1.PNG?alt=media&#x26;token=d25df3e6-b628-4682-9f45-04531b533121" alt=""><figcaption></figcaption></figure></div>

So yeah we see pop rbx and after call we see rbx=0x48

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/204da595-ad18-4a15-8056-a88b32e34d97" alt="1"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2F180EFhU3slSGMsNh1DUx%2F2.PNG?alt=media&#x26;token=5a806587-90f4-4112-b2a0-4a444fad7fe5" alt=""><figcaption></figcaption></figure></div>

we than call against strlen again on the same string , i guess this is just bc on next line precisly , `v6 + v4 * v5;` we do v4\*v5 which is like i guess some way of having unicode strings i guess

Anyway an than we allocate memory again using gEfiBootServices + 64 which we previously enocuntered which solved to AllocatePool.

So here we also see something nice which is

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/c6d60d0e-954e-4e6d-9ab3-98e63b8259f9" alt="1"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2FlcgYo9I69RGp15zq8yoO%2F1.PNG?alt=media&#x26;token=36daf076-4d81-4129-8ae6-44993a01de3c" alt=""><figcaption></figcaption></figure></div>

the fact that here the memory block has the pattern afafafaf in it .

So what happens next is that we get two buffer which look like this after the main loop executes

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/08238484-8e74-4220-aa7f-7f54771f58d1" alt="1"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2FVvYfakKdQVtXsVFnl9gl%2F2.PNG?alt=media&#x26;token=71c6ba60-7112-4f86-acbc-768405205091" alt=""><figcaption></figcaption></figure></div>

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/897d6022-3cd1-4142-b610-b7674012f8ef" alt="2"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2FoXqy5vQyhABR8QMm4MRk%2F3.PNG?alt=media&#x26;token=76cc0833-caef-49fb-b228-f494cc419c72" alt=""><figcaption></figcaption></figure></div>

And truelly speaking we are interested in only the first one because that's what get's returned, so we can conclude this simply i guess copies the device path and clear some garbabe from buffer. :))

Now after we finish with this we check to see if the device path in our case is already i guess initialised and free the pool if not we return the clearer buffer from the previous mentioned function .

Before we finish with this function i would like to point another interesting fact , this is how it looks in memory the bootservice table :) it looks like according to the specs with the begging header just figured it might be interesting to let here for anyone who wanna do feature work and find themselves finding this string BOOTSERVF in a dump, this is deffno bootservice table

\=============================================================================

Right so what happens next ??? well we check to see if we managed to locate the winload.efi file and we load it into memory. this is the pseudo code :)

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/c8dbffda-1779-4f26-9780-e6e1d1039193" alt="1"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2F5F8bZ02TBId5tcTlKFuh%2F1.PNG?alt=media&#x26;token=8c988ec2-5c77-40e5-9757-acd4a909d09e" alt=""><figcaption></figcaption></figure></div>

And this is how it looks into memory

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/318b0fa6-62cd-42fc-8a00-748cca29885f" alt="1"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2F0QCVkEYHgqFzFgWExwpL%2F2.PNG?alt=media&#x26;token=77a733a6-ef08-4edd-b934-2ed82a1d0260" alt=""><figcaption></figcaption></figure></div>

what is rax? rax is a handle to the image :) don't be dumb like me when i first tought that it is a memory zone :)

Cool before we head in for some more let me quickly explain wtf is winload.efi. So, `with the development of computers, the traditional BIOS boot is outdated, and the security confrontation about UEFI boot has started. From the flow chart below, we can see that MBR and VBR no longer exist in UEFI, but UEFI itself is responsible for loading bootmgr, which also means safer and faster`

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/8962e54d-2017-4b69-aede-0d17ad938b18" alt="1"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2FDA20vleXHswBfUR3ic4p%2F1.PNG?alt=media&#x26;token=17fe8018-bdc9-4723-a3e8-817ae83abf18" alt=""><figcaption></figcaption></figure></div>

So how does a normal windows pc boots ? After BDS, the UEFI firmware code stored in SPI has completed the work, then the UEFI firmware boot manager first queries the NVRAM UEFI variable to find the ESP, and finds the OS-specific boot manager bootmgfw\.efi to call its entry function (DXE driver).

This function will first call the EfiInitCreateInputParametersEx function, which is mainly used to convert the EfiEntry parameter into the parameter format expected by bootmgfw\.efi.

The Windows Boot Manager entry point BmMain function is then called.

In this function, BmFwInitializeBootDirectoryPath is called to initialize the startup application (BootDirectory) path (\EFI\Microsoft\Boot).

Then BootMgr will read the system boot configuration letter (BCD), if there are multiple boot options, it will call BmDisplayGetBootMenuStatus to display the boot menu.

Then it will call the BmpLaunchBootEntry function to start the application (winload.efi).

Of course, bootmgfw\.efi does more than that, as well as boot policy verification code integrity and initialization of secure boot components, so I won’t go into details.

In the final stage of Windows Boot Manager (BootMgr), the BmpLaunchBootEntry function will select the correct boot entry according to the previous BCD value. If full volume encryption (BitLocker) is enabled, the system partition will be decrypted first, and then the control can be transferred to winload.efi.

Next, the BmTransferExecution function is called, the startup options are checked and the execution flow is passed to the BlImgStartBootApplication function.

Then the BlImgStartBootApplication function will call the ImgFwStartBootApplication function, and finally call the ImgArchStartBootApplication function. In it, the memory protection mode of winload.efi will be initialized, Then call the BlpArchTransferTo64BitApplication function, BlpArchTransferTo64BitApplication calls The Archpx64TransferTo64BitApplicationAsm function finally hands over control to winload.efi.

This function will enable the new GDT and IDT, and then completely hand over the control to winload.efi. At this point, BootMgr completes its mission and Winload starts to work. -End of quotes stolen from a chinese website which talks about this(please review this for more content <https://bbs.kanxue.com/thread-268267.htm> )

And from there winload.efi does it job which is to load windows and do some more hw work before it hands control to kernel .

Now after this sort briefing as we were saying

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/5cd88999-9608-46bc-98e4-04505fb32cfc" alt="1"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2FPjOppkvzehkXDM8OjzXu%2F2.PNG?alt=media&#x26;token=e7f02fa3-b243-4d1f-801b-84c3d4afb213" alt=""><figcaption></figcaption></figure></div>

we further check to see if loading it into memory successeded and than we do a function called ati\_analysis\_rdtsc\_aia\_cu\_4e1f to which you should be familiar if you have already read the first part of this analysis.

Now for the fun lets pretend we fail to analyse that function and we get detected.Let's see how sub\_180002A08 looks like.

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/e1cc8282-62be-4da8-8cb3-c7409161f10e" alt="1"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2F2BJdtOK0WFrHxVP8PBN4%2F1.PNG?alt=media&#x26;token=bda9d8ff-dac1-4515-8cf9-b346f38557fd" alt=""><figcaption></figcaption></figure></div>

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/3daa1149-b650-4eb0-a761-4bf13f909d41" alt="2"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2FXk8DKKjTY81gMB9ctR7q%2F2.PNG?alt=media&#x26;token=00bc34c2-b2dd-404f-a7d4-f79aa337a267" alt=""><figcaption></figcaption></figure></div>

we see again gEfiSystemTable + 64 which we actually don't know this time because it's of different type it's not of type bootservices this time is of type efisystemtable than memcpy and another 3 function call which we don't know now if we run until the loop begins

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/1b920157-282c-4a9f-9f0c-523aa964ad41" alt="2"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2FcaDiVpI3NEPJRSw0ZGbN%2F1.PNG?alt=media&#x26;token=582936e0-19f7-45fe-8e34-5eadbfc21f92" alt=""><figcaption></figcaption></figure></div>

and if we inspect previous paramets to memcpy

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/0d7ad630-8ea9-49a0-9ec9-6a9d125c4a59" alt="2"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2FlWZdfj5ntftuF1QVPgve%2F2.PNG?alt=media&#x26;token=2f4c7a7b-8b81-4e4e-b944-5d813032fe7f" alt=""><figcaption></figcaption></figure></div>

and we inspect the output image of qemu we get

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/65c8621c-ae99-437e-8699-95ea317f7dfe" alt="1"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2FitVp5lCSh0K5NsE856cv%2F1.PNG?alt=media&#x26;token=73384e68-eb14-4852-899e-a5673c4dbb8e" alt=""><figcaption></figcaption></figure></div>

Cool so let's make some sense of this ,i'll refear again to the asian's research blogpost cause honestly i'm lost here

So on his blog he says that the two functions were actually

```
ConOut->ClearScreen(ConOut);
ConOut->OutputString(ConOut, String);
```

Ok but wtf is conOut? well also he says that conout is of type EFI\_SIMPLE\_TEXT\_OUTPUT\_PROTOCOL and that conout is obtained by `ConOut = gEfiSystemTable->ConOut;` . ok so what in the code does this mean ??

Ok so let's digg in

the deffinition

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/b44929f9-fc5a-49da-92f2-3e593a51bb47" alt="1"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2FeVQejUETniYil2eW2b8g%2F1.PNG?alt=media&#x26;token=d108d1bf-2566-40ed-9767-ce9b7e775eda" alt=""><figcaption></figcaption></figure></div>

and the guid

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/6061184e-c695-44a5-b088-c691985edd15" alt="2"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2FGsXoM3q9Ol3zA3xqTMIo%2F2.PNG?alt=media&#x26;token=1e971929-0b6e-4873-add7-20a1124c397b" alt=""><figcaption></figcaption></figure></div>

Now my smart ass forgot to actually capture this in a debugger because first when i anaylsed this i confused the data type between efisystemtable and bootservices and i tought this is actually allocatepool.

Now what thoese function do?

Well ClearScreen should be pretty self explanatory and so should OutputString too. How could the researcher come to the conclusion that that variable is of type EFI\_SIMPLE\_TEXT\_OUTPUT\_PROTOCOL? well probably he saw the guid bytes in the debugger.

Now what about the last function ?

well in his blogpost he says that last function is gEfiBootServices->Stall ? so wtf this this do ? . From uefi specs `The Stall() function stalls execution on the processor for at least the requested number of microseconds. Execution of the processor is not yielded for the duration of the stall.`

So basically is makes our cpu freze. cool for how long 0x1C9C380 seconds. a shit tone of time if you ask me. which is again pun in an infite loop so yeah we fucked :)))

And this is how it looks in a debugger

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/cd8367c5-05b5-4534-866a-801745111602" alt="1"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2FkeqvvaM4J9y7SXt4x81S%2F1.PNG?alt=media&#x26;token=dbadce83-7270-4a2c-a31c-5401493179da" alt=""><figcaption></figcaption></figure></div>

Now continuing with our main function

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/618666f5-3cd1-4758-8dc1-b20048088b5c" alt="1"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2FgZHhHt7NFJ9yDTHXl4fU%2F2.PNG?alt=media&#x26;token=42f56856-fb3e-4a5c-b7a5-3cf6f86217a1" alt=""><figcaption></figcaption></figure></div>

if we manage to load the bootmgfrw\.efi(bc winload.efi here is the actual windows bootloader) we call sub\_180002538

\============================================================================= sub\_180002538

From a graph perspective

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/5aa56df4-9041-4caa-b664-240c45cdeb2d" alt="1"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2F4cgULbY7DoLA7q8Iaey4%2F1.PNG?alt=media&#x26;token=ce77c18e-f068-4741-b6f1-9822cfa58a9e" alt=""><figcaption></figcaption></figure></div>

From asm perspective

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/d2b372eb-dae2-4d82-9f3d-c797832a7003" alt="2"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2FyRsVkIkD9SdpzBnFujkP%2F1.PNG?alt=media&#x26;token=f789bb49-f314-4998-a0e3-541ffc93327d" alt=""><figcaption></figcaption></figure></div>

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/5bbc71cf-21fb-4f1b-8aa3-a27a41424030" alt="3"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2F3vuRF39jRxIQE9ma2Mj1%2F2.PNG?alt=media&#x26;token=3c649a79-de3c-42e2-bb77-fc053a8afba1" alt=""><figcaption></figcaption></figure></div>

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/47b347ec-d704-4a7a-8b5e-b292fa96fc38" alt="4"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2Fy14NoFSBoyQaDeqTvhHn%2F3.PNG?alt=media&#x26;token=44f4c918-6a99-493d-8ac8-f000d70544b9" alt=""><figcaption></figcaption></figure></div>

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/a8e64fa1-494f-46d4-b430-293330699055" alt="5"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2FOlKVmsgCy2nt2JEop7q5%2F4.PNG?alt=media&#x26;token=54f59bcd-6818-4add-8680-682a90958d59" alt=""><figcaption></figcaption></figure></div>

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/575c62d6-e496-47ec-8d6e-5b12b0581a14" alt="6"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2FJXpdP58UBMvkG9JslTpE%2F5.PNG?alt=media&#x26;token=adbcbe46-764b-4f1c-9ad1-25c33e58d405" alt=""><figcaption></figcaption></figure></div>

Anything ringing a bell yet ? nah well give it a minute it will sinc it , in the meantime take a lookt at pseudo code pov

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/7925bb02-d783-40f0-948e-49abef678d24" alt="1"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2F4BYYKfTlYIe2lT7dVu0f%2F1.PNG?alt=media&#x26;token=649f95fb-67b3-4522-afa7-8d3d42b0b9d4" alt=""><figcaption></figcaption></figure></div>

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/453760be-f468-462e-a3db-eb462468264c" alt="2"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2Fo4p0jzn54TB06QIYF003%2F2.PNG?alt=media&#x26;token=56cb4892-6d3e-4436-a90d-61a9eb0da349" alt=""><figcaption></figcaption></figure></div>

we see some parsing of an exe :) now idk how much it will be the same as the one from previous part(part1) but let's see :)

so we compare our in memory version of the binary(bootmgfrw\.efi) with classical mz header(0x5A4D), as you can see

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/800e0d4e-1faf-43a0-b04d-b6c73f9abd8e" alt="1"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2FsMVaVyUX3RJqdq6m0LWE%2F1.PNG?alt=media&#x26;token=67b29464-c662-431d-bedc-5576a8ad70a8" alt=""><figcaption></figcaption></figure></div>

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/dc1996fc-1b71-41bd-9a29-eb4e1d15d0fc" alt="1"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2Fx38PaG2kg9mnKx0efO0Y%2F2.PNG?alt=media&#x26;token=366de9eb-afc4-4b8d-a402-6b076c8d7b49" alt=""><figcaption></figcaption></figure></div>

ok next we do another classic check which is if we can find pe header

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/4058d60e-acc1-4411-a2db-3017c36427af" alt="1"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2FokMzGIdBlKwjCgBZt81u%2F1.PNG?alt=media&#x26;token=f15c50c5-6b6b-4695-904c-25e14b0366a5" alt=""><figcaption></figcaption></figure></div>

Cool next we call sub\_1800024C4() which looks like this

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/fb118a05-9ad3-4854-8405-37f289ffd607" alt="1"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2F34nBvncRFypbNLMPZP9n%2F2.PNG?alt=media&#x26;token=05c2d045-a200-4653-a33d-f6a9db47965b" alt=""><figcaption></figcaption></figure></div>

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/db63719a-d764-462a-b42c-e2e32624cb9c" alt="2"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2FeC5KeXboItOnRBJnm4zE%2F1.PNG?alt=media&#x26;token=14a0c4f4-93f7-442a-b4b5-6e806b4ad978" alt=""><figcaption></figcaption></figure></div>

Cool so what happens here is that we locate certain values in memory and if we found them we return them. Please reffer to sub\_180002538.py.py for the emulation.

Anyhow here's sub\_180002464

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/06588bc7-c043-436b-a6fb-5ca40580fd18" alt="1"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2FSd5Xq710uEoKSDhfAjKO%2F1.PNG?alt=media&#x26;token=31036690-d3f0-4e64-8d81-d79e8ef68d9a" alt=""><figcaption></figcaption></figure></div>

If we successfully execute sub\_1800024C4 we return in the bigger function and follow a few more checks , cool beans let's mase some sense of these

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/99a2be43-6ae7-48ea-a199-1d26fc612239" alt="1"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2FevFLdpqTF8T0CjFcTU8F%2F1.PNG?alt=media&#x26;token=63ffd849-9403-4d4a-b6e5-58d4f3a2bbe5" alt=""><figcaption></figcaption></figure></div>

Cool so we further compare whatever is at rax+0xe with 0x64 hmm cool interesting , inspecting rax+0xe

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/7b5f3e08-81b6-463b-8c17-294b2fff4183" alt="1"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2FsKpROElDGLaBFZYhKcDh%2F1.PNG?alt=media&#x26;token=d97bd558-58b1-4b0c-9e3b-7d16052e667d" alt=""><figcaption></figcaption></figure></div>

Any special reason behind this specific check? honestly idk? it might be if you know please make a pull request and edit this document

we do some more addition and than a comparison

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/7bd6b38b-6772-4163-a10e-f74ca8b043af" alt="1"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2FC17XIsFn4wQL1NVysX4e%2F1.PNG?alt=media&#x26;token=d92532e3-df3c-47a5-aa22-e37c6d72056b" alt=""><figcaption></figcaption></figure></div>

I wanna stop here for a minute and reference again the previous source of inspiration for this article whenever i got lost, so in his blog he renamed the function which compared values to RtlpImageDirectoryEntryToDataEx, which if we search we got no results but there's something close enough to his names and that is RtlImageDirectoryEntryToData , which basically does this `Given the base address of a kernel module and the index of an entry in the data directory, RtlImageDirectoryEntryToData() returns the virtual address and the size of the directory entry`(<https://codemachine.com/articles/top\\_ten\\_kernel\\_apis.html>) in our case since we are in an efi/uefi app we can consider that the 50 we see is the size of bytes/mb idk here of our root partition in this case and that that address which is in rax is an entry in our directory.

Before we further proceed there's one more interesting detail to be explained. In his research he converts the output of RtlImageDirectoryEntryToData to this structure

```
 typedef struct _IMAGE_RESOURCE_DIRECTORY_ENTRY {
               union {
                   struct {
                       DWORD NameOffset : 31;
                       DWORD NameIsString : 1;
                   };
                   DWORD   Name;
                   WORD    Id;
               };
               union {
                   DWORD   OffsetToData;
                   struct {
                       DWORD   OffsetToDirectory : 31;
                       DWORD   DataIsDirectory : 1;
                   };
               };
           } IMAGE_RESOURCE_DIRECTORY_ENTRY, *PIMAGE_RESOURCE_DIRECTORY_ENTRY;
```

Now wtf about this structure ?

well doing a quick search about that structure gets us here(<http://www.brokenthorn.com/Resources/OSDevPE.html>) which tells us that `Parsing resources is a bit more complex then the other directory types, however. Like the other sections, there is a base IMAGE_RESOURCE_DIRECTORY structure that can be obtained from the DataDirectory member of the optional header: blah blah` and also that \`\`\`This structure doesnt have much of any interesting fields, except the last three.

If you have worked with Win32 resources, you might know that resources can be idenitified by ID or name. Two of the members in this structure will let us know the number of these entries, and the total amount of entries (NumberOfNamedEntries + NumberOfIdEntries), which is useful in looping through all of the entries. As you can probably guess, the entries are in the DirectoryEntries array. DirectoryEntries consists of an array of IMAGE\_RESOURCE\_DIRECTORY\_ENTRY structures, which follow the format:\`\`\`

so basically this shit is used internally for parsing stuff internally and for us makes sense in the context of the fact that we work with a directory which has resources in it, cool.

More please!

So up next

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/533ff6f9-cf2d-4b6b-ac79-d7a6f8ec12a5" alt="1"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2FGUlSqtWZyYi8WElo8YRh%2F2.PNG?alt=media&#x26;token=2cfb5d29-744d-43d4-a858-d97b7d62157f" alt=""><figcaption></figcaption></figure></div>

what dis to is that basically iterate over every resource from directory and checks to see if it's of type string

ngl i don't know why he would so if i'm wrong sorry if i'm not cheers!

next

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/8ebdca15-08da-47d9-b0f8-70639e7b8731" alt="1"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2FLEdeezDwmkqNBv8kGHMn%2F1.PNG?alt=media&#x26;token=716c25d4-4ae5-4927-bf08-59a94735eb2c" alt=""><figcaption></figcaption></figure></div>

so what happens here is that we add some offsets and end up to what the chinese researcher says it's second resource table, as you can see

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/211f6b1d-9be2-4dc5-8e6d-122761b24363" alt="1"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2FZqMt9Nq7XqTdHzELnLTB%2F1.PNG?alt=media&#x26;token=a12ac394-7431-4a12-a6e6-cd061769427c" alt=""><figcaption></figcaption></figure></div>

and than we repeat same process to get some offsets

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/ce012c6a-a660-4ee0-80c1-c68df17f4406" alt="2"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2FWKBeaa4yQirKTkb5EFm1%2F2.PNG?alt=media&#x26;token=70c302f8-bbc3-4782-a92d-bd1b0ee1d6d1" alt=""><figcaption></figcaption></figure></div>

and repeat same process this time we check for type VS\_VERSION\_INFO

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/2745ecfc-f8c7-4b27-8a3c-0c3654813e06" alt="1"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2FYwIBAZUUigPeOuoQX31p%2F2.PNG?alt=media&#x26;token=92b0e5ed-7f5f-4ba8-9a75-dd834c4992c4" alt=""><figcaption></figcaption></figure></div>

so wtf is VS\_VERSION\_INFO? well microsoft(<https://learn.microsoft.com/en-us/windows/win32/menurc/versioninfo-resource>) says that `Defines a version-information resource`, eg i belive is simply says the version of bootmgfrw\.ef

and finally if we found VS\_VERSION\_INFO we repeat same algorithm

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/714cdc22-c053-4ae0-9223-73738a19f7d6" alt="1"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2FguKiAcazWe2e7NRvCGAE%2F1.PNG?alt=media&#x26;token=23b01da0-3d05-4cbb-ba17-8894250e745b" alt=""><figcaption></figcaption></figure></div>

this time with a twist, the twist being that we return the build id :) as we can see

So as a conclusion wtf happened here actually ? well based on the name the chinese researcher used(GetPeFileVersionInfo\_BuildNumber\_) we can conclude that we actauly get build number for bootload as can be seen from the first image

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/66145dae-6a99-48cf-bc88-8f111f217333" alt="1"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2FzRvfW7mcK5HjkBJX5SR4%2F1.PNG?alt=media&#x26;token=9926370f-ceb5-4dc1-86e7-2ab988afbb01" alt=""><figcaption></figcaption></figure></div>

where here we see the loade bootload in memory

in second image we see

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/d9b2b790-0603-44c2-8330-0504a39adf92" alt="2"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2FH8VB8eEVAcTvKY28WEOn%2F1.PNG?alt=media&#x26;token=90e37c0e-9f57-413a-9d6d-2dc685677206" alt=""><figcaption></figcaption></figure></div>

an integer in rcx which could either be build nr or pefileversion

and 3rd image

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/dd3366d9-53ac-43e1-8f84-732f94a47590" alt="3"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2FAU3dgoC7eCvqd6HiOBig%2F1.PNG?alt=media&#x26;token=d3d64cb5-632b-433c-94b4-f00ab4f5e2fa" alt=""><figcaption></figcaption></figure></div>

what we could speculate to be build number as ebx will be moved into rax :)

So as a last note on this function, wow amazing engineering

\=============================================================================

Now onto next challenge :) based on the output from previous stage we either set v10 to sub\_180001D80 or sub\_180001D48, as seen

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/296f9f02-3e33-468d-9fd0-a7e0e75bfd92" alt="1"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2FyruiMe8GnB3SbUaVZUvs%2F2.PNG?alt=media&#x26;token=a792d3f6-52d0-46bb-bbde-f0f44011c534" alt=""><figcaption></figcaption></figure></div>

and in our case v10=sub\_180001D80

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/343d24c7-f05c-4766-a397-357a8973453d" alt="1"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2FkhsQcAoLBzxls6btNxjA%2F1.PNG?alt=media&#x26;token=f8e7cc09-08cd-4a36-b12c-f15183b0df9b" alt=""><figcaption></figcaption></figure></div>

\=============================================================================

We than do a strcmp between our bootloade manager and that array of bytes

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/58c2af3a-ee6d-4214-a372-5ad3d1b65584" alt="1"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2FEBOY2PYJu4A9BPmPlZMv%2F1.PNG?alt=media&#x26;token=5ef57c0d-f259-4003-85e3-088a7bc9ba73" alt=""><figcaption></figcaption></figure></div>

I wanna stop here for a brief short period of time , as you might have guest it i saw something interesting in the chineses researcher blog post. he called the array of btyes SigImgArchStartBootApplication. so wtf is SigImgArchStartBootApplication and to who it belong and why the hack is that array called that way(migos) . So if we search on google(gulugulu) for SigImgArchStartBootApplication we get nothing. Now give that the current context we use the bootloader manager of windows let's open it in IDA. We go to C:\Windows\Boot\EFI, open the binary in ida an search SigImgArchStartBootApplication, nothing. We search for ImgArchStartBootApplication and we are met with

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/3c7a8ed4-8c01-4dcd-8d16-481cac5ffbf3" alt="1"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2FeRvHx1LVaCLuVLl5lYgI%2F2.PNG?alt=media&#x26;token=2c49fcef-5818-4c22-b819-32d266d0f4c7" alt=""><figcaption></figcaption></figure></div>

So ImgArchStartBootApplication .... what the dog doin... !? Well amm...hh I will steal this from `@_xeroxz`(go follow him, wtf you doing if you not following his work....) so basically in an article he says that `bootmgfw.ImgArchStartBootApplication between windows versions 2004-1709 is invoked to start winload.efi` as we can see also from his image(<https://guidedhacking.com/threads/hyper-v-hacking-framework-works-on-every-version-of-windows-10-2004-1511-amd-intel.16251/>)

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/05243b3f-20d2-4db2-bd7f-1717f3d481cd" alt="1603213912596"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2FhPCpuKTkc4W837uVbF2c%2F1603213912596.jpg?alt=media&#x26;token=49346668-ef6e-485a-b1b6-2da2b31ba3cf" alt=""><figcaption></figcaption></figure></div>

If that was not clear enougn on an article() we see that `ImgArchStartBootApplication to catch the moment when the Windows OS loader (winload.efi) is loaded in the memory but still has not been executed`(<https://rustrepo.com/repo/rusty-bootkit--uefi-bootkit-in-rust>)

Cool so wtf does strcmp have to do with ImgArchStartBootApplication? well let's take a closer look at ida and we will soon be reveal with the answear, if we search in bootloader code for bytes 41 b8 09 we are soon meet with the coolprit

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/342cab9b-d37f-4598-8b16-9d68b84da7ec" alt="1"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2FzMEUGcJtA1RJ0kbZcAch%2F1.PNG?alt=media&#x26;token=d69beff4-4382-48b7-bacf-4f1b75d97d67" alt=""><figcaption></figcaption></figure></div>

And in case we match our in memory image bytes of bootloade with the signature of bytes we execute sub\_180002398

And surely as can be seen we located the pattern we got returned in eax the memory zone where the bytes are and we safely proceed to run sub\_180002398

\=============================================================================

sub\_180002398

"Assembly perspective"

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/4260bf70-a0a8-4b72-aeaa-9526ffb01963" alt="1"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2FwFkdVYhs6IOxNqOtqNe1%2F1.PNG?alt=media&#x26;token=220acf1a-8e7d-468b-af61-4c38cfca4318" alt=""><figcaption></figcaption></figure></div>

<figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2FZ871enbo2hDBKV3cxWbj%2F2.PNG?alt=media&#x26;token=e3d791b2-b714-4459-a77d-d8831239e6a4" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2Fu71Yo6TW9jWMilB7yjvi%2F3.PNG?alt=media&#x26;token=4c070244-aa92-455a-9274-12ac26375e0b" alt=""><figcaption></figcaption></figure>

"Pseudo-code perspective"

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/b21d4c73-a63f-4b43-8522-35cf143e3b8b" alt="3"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2FGMEC989PCZGbbgWBUu71%2F1.PNG?alt=media&#x26;token=df86f18b-4854-4bb3-af4c-7635fb90420b" alt=""><figcaption></figcaption></figure></div>

<figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2Fb1jtFwEKRaXtSp7QCBNn%2F2.PNG?alt=media&#x26;token=58594c06-976a-4cab-8a25-32c817006f9f" alt=""><figcaption></figcaption></figure>

So what the dog doing ? honestly it does some calculation and some additions substractions and nothing rlly important ? why because it's not that interesting . What we interested in is what happens after we return from the function. We see rax

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/b24699a1-99cd-468e-8118-a5a3b8dd9d36" alt="1"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2Febxl0cR89Zey195KlmN1%2F1.PNG?alt=media&#x26;token=b27e13bc-a23e-4999-8dfe-ac1cc44adfd5" alt=""><figcaption></figcaption></figure></div>

ok cool so i still don't get it . Well rax = 0x5eec108 which points to 0x48c48b48 , ok and what ? well i was as confused as you were so i returned once again to the chinese blog. So what that researcher describes it happens here is this: it goes back to the beginning of the ImgArchStartBootApplication function. But how tf did he come up with this ? well as mention earlier rax =\
0x48c48b48 and if we inspect the booloadermnfr.efi we see

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/03a07352-58a9-4b37-b262-06fb7b3931d9" alt="1"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2FLwh67FvdCF52knqpUkiU%2F1.PNG?alt=media&#x26;token=f556611c-7778-4673-8542-9c55fed72860" alt=""><figcaption></figcaption></figure></div>

which is exactly the same sequence of bytes in 0x5eec108. ok now that's cool :)

Please reffer to sub\_180002398.py to see my failed attempt to emulate this behaviour :)

\=============================================================================

Cool next ?

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/24c004c6-0c0f-43aa-b6d0-efdeed935c26" alt="1"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2FIEa0ausqRHNIXISN30cr%2F1.PNG?alt=media&#x26;token=5a9ab996-0cb8-4299-a1aa-58b888bb4bd2" alt=""><figcaption></figcaption></figure></div>

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/28cc6ac2-26ee-4af9-9a2e-734258340b68" alt="1"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2F0cWTkHkGVnEf1MQdd5Yp%2F2.PNG?alt=media&#x26;token=7aa5ef8d-e78b-46ca-896b-7d0e683bf123" alt=""><figcaption></figcaption></figure></div>

So what happens next is RaiseTPL . ok so what this do ? Raises the priority of the currently executing task and returns its previous priority level. In our case it will be run as highest execution privillages.

Next we call what i called patch\_something which looks like this

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/1a44fc35-c772-49fd-bec3-6e4a48369e34" alt="1"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2FXhMJO7rNDDh27SdYPFbM%2F1.PNG?alt=media&#x26;token=2ba63494-79c5-4fda-bc75-bd265fe2db60" alt=""><figcaption></figcaption></figure></div>

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/f279ed31-d5dd-49f7-9940-63d0594d9154" alt="2"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2FZerunoIYo9WcLvatTdfN%2F1.PNG?alt=media&#x26;token=7968cdcc-5d9f-4ba1-a090-5875f235e517" alt=""><figcaption></figcaption></figure></div>

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/7aaf35f1-5a1e-456d-a834-2c8892c25930" alt="1"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2Fl1UDiOZ2mgm9LPOkv3vn%2F1.PNG?alt=media&#x26;token=3e4ce372-ba4f-4f19-9e1b-9be930d25ffe" alt=""><figcaption></figcaption></figure></div>

So from statical analysis we can see this is what it's known as hooking. :) so basically it patches the bytes of ImgArchStartBootApplication to point to sub\_180001D80 and saves original function of ImgArchStartBootApplication to byte\_180015C78

as as we can see it change to exactly sub\_180001D80

<div><img src="https://github.com/SpiralBL0CK/BlackLotus-analysis-stage2-bootkit-rootkit-stage/assets/25670930/390e7158-74f3-4a19-8644-218020113efa" alt="1"> <figure><img src="https://3871051723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FExAgvBA8vDyWgBzUA8r6%2Fuploads%2F2r77XAaPpp08Sqweu4Xr%2F1.PNG?alt=media&#x26;token=cb4a73fb-25a1-4765-99c2-24fea479204b" alt=""><figcaption></figcaption></figure></div>

next we reset the privilleges and from there we hand the control to boomgrfw\.efi :)

So this officially marks the first half of the analysis done :) next part we will learn how to further debug sub\_180001D80 and boomgrfw\.efi(in our case winload.efi) So please sit thight till i learn how to prepare the environment for the second part of the analysis

\=============================================================================

Now for the second half of the analysis.... How to do we debug boomgrfw\.efi ?
