Ausnahme gefangen: SSL certificate problem: certificate is not yet valid ๐Ÿ“Œ Bootkit Disk Forensics - Part 3

๐Ÿ  Team IT Security News

TSecurity.de ist eine Online-Plattform, die sich auf die Bereitstellung von Informationen,alle 15 Minuten neuste Nachrichten, Bildungsressourcen und Dienstleistungen rund um das Thema IT-Sicherheit spezialisiert hat.
Ob es sich um aktuelle Nachrichten, Fachartikel, Blogbeitrรคge, Webinare, Tutorials, oder Tipps & Tricks handelt, TSecurity.de bietet seinen Nutzern einen umfassenden รœberblick รผber die wichtigsten Aspekte der IT-Sicherheit in einer sich stรคndig verรคndernden digitalen Welt.

16.12.2023 - TIP: Wer den Cookie Consent Banner akzeptiert, kann z.B. von Englisch nach Deutsch รผbersetzen, erst Englisch auswรคhlen dann wieder Deutsch!

Google Android Playstore Download Button fรผr Team IT Security



๐Ÿ“š Bootkit Disk Forensics - Part 3


๐Ÿ’ก Newskategorie: Video
๐Ÿ”— Quelle: malwaretech.com

Getting Original Pointers

XP is a little more complicated than newer systems due to the use of a single driver for both port and miniport; however, getting the original pointers is fairly straight forward depending on how you do it.

IRP_MJ_SCSI & DriverStartIo - Method 1 (Windows XP)
A common method is to programmatically disassemble the miniport's DriverEntry, looking for the code which initializes the driver's object, then you can extract and calculate the addresses from "mov [esi+30h], offset" and "mov [esi+74h], offset" for DriverStartIo and IRP_MJ_SCSI respectively. 
An example of code initializing the driver object (taken from atapi.sys)

The obvious problem with this method is the initialization code may not be in DriverEntry, but a sub function called from it (it may even be necessary to follow jumps). It's also not guaranteed that the instruction will use esi as the pointer to the driver object or an immediate for the function address, in fact you're probably going to have to account for quite a few different instructions.

IRP_MJ_SCSI & DriverStartIo - Method 2  (Windows XP)
In my tests, it was possible to simply call the DriverEntry of the miniport driver with the parameters from your own driver entry, thus having the miniport set up your driver's object as if it were its own. The only issue with this method is if the driver uses GsDriverEntry (it usually does), the entry point will be invalidated after the driver is initialized, so you cannot call it. To deal with GsDriverEntry you'd first need to load the original image from disk, then search until you reach an unconditional relative jump (this is the offset to real entry point and you can use it to calculate the same address within the loaded driver).

IRP_MJ_SCSI  (Windows Vista+)
On newer systems, things are wonderfully easier: There's no DriverStartIo field and you can initialize all the major functions in your DriverObject with a call to AtaPortInitialize, ScsiPortInitialize, or StorPortInitialize which are all exported from the relevant port drivers (ataport.sys, scsiport.sys, or storport.sys). 

Bypassing Inline Hooks

Although not many bootkits actually perform inline hooking on miniports, it's worth taking care of. You'll need to read a the original miniport or port driver's file into memory, then do a bit of pointer math to calculate the addresses of  IRP_MJ_SCSI or DriverStartIo within the clean image. I'm not too sure of the best way to call the clean functions, but here are 2 viable methods to chose from.

Trampoline
Usually a hook is placed within the first few bytes of a function, so you can simply read and relocate the first few bytes from the clean function into a buffer, then append it with a jump to the same offset within the real driver(this is the same way a hooking engine would call the unhooked version of a function).

Manual Mapping
A more difficult but effective method is to manually map a clean copy of the driver into memory, then relocate it so that all absolute instructions will reference the real driver, meaning you don't have to worry about initializing any global variables or such.

Creating a Clean Call Path

Due to the fact a lot of bootkits run persistence threads for replacing any driver object hooks which get removed, you don't want to unhook the real driver but instead create a parallel one, so you can maintain your own hook-free call path.

Step 1 (XP & Vista)
  1. Get the device object for the boot disk miniport, this is usually \Device\Harddisk0\Dr0
  2. Use the size field of the device object to allocate some non paged memory and copy the entire object (this is your clean miniport).
  3. Set the DriverObject field to point to your own driver's object, in which you've set the IRP_MJ_SCSI and DriverStartIo field appropriately (DriverStartIo can be skipped on Vista+).

Step 2 (XP Only)
  1. Set the DeviceExtension field of your clean miniport device object to point to directly after its device object (DeviceObject + sizeof(DEVICE_OBJECT)).
  2. Get the address stored at offset 0x5C into your clean miniport's device extension and check it's valid (this is the address of the corresponding port's device extension).
  3. Read the addresses stored at offset 0x0C into the port's device extension (this is the address of the port's device object).
  4. Use the size field of the port's device object to allocate some non paged memory and copy the entire object (this is your clean port).
  5. Set the DeviceExtension field of your clean port's device object to point to directly after its device object (DeviceObject + sizeof(DEVICE_OBJECT)).
  6. Set the DriverObject field of your clean port's device object to point to your own driver's object, in which you've set the IRP_MJ_SCSI field appropriately.
  7. Change offset 0x5C into your clean miniport's device extension to contain the address of the clean port's device extension.
  8. Set offset 0x0C into the clean port's device extension to contain the address of the clean port's device object.

Using the Clean Path

You're going to need to build a raw SCSI request which is pretty complicated; however, the Chinese are already a step ahead, so you can look to this example for help (This request can be issued by passing the clean miniport device object and the IRP to IofCallDriver).

It's important to note that miniport drivers are PnP, so if you don't create any devices (IoCreateDevice): the driver will be unloaded as soon as DriverEntry returns, if you do: the driver can't be unloaded at all. Although it's not recommended, you can set the driver back to a legacy driver by setting the AddDevice pointer within the driver's extension to 0, allowing the driver to be unloaded normally.

Conclusion

This concludes my 3 part series, any feedback in the comments would be greatly appreciated and will be taken into consideration when I create a whitepaper version of the series in a few weeks. 

Other resources of note

...













๐Ÿ“Œ Awesome Forensics Resources. Almost 300 open source forensics tools, and 600 blog posts about forensics.


๐Ÿ“ˆ 41.66 Punkte

๐Ÿ“Œ How to Install Spaceview Disk Space Analyzer (Disk Utility) in Ubuntu โ€“ A Best Disk Usage Indicator for Linux


๐Ÿ“ˆ 30.43 Punkte

๐Ÿ“Œ Full Tutorial : How to Clone a Smaller Boot Disk onto a Larger Disk for Free with Clonezilla & Delete Disk Partition


๐Ÿ“ˆ 30.43 Punkte

๐Ÿ“Œ CAINE 10.0 - GNU/Linux Live Distribution For Digital Forensics Project, Windows Side Forensics And Incident Response


๐Ÿ“ˆ 27.78 Punkte

๐Ÿ“Œ Imago Forensics - Image Forensics Tutorial


๐Ÿ“ˆ 27.78 Punkte

๐Ÿ“Œ Imago Forensics - Image Forensics Tutorial


๐Ÿ“ˆ 27.78 Punkte

๐Ÿ“Œ Survey Now Open: 2021 SANS Digital Forensics Survey: Digital Forensics Essentials and Why Foundations Matter


๐Ÿ“ˆ 27.78 Punkte

๐Ÿ“Œ ICS-Forensics-Tools - Microsoft ICS Forensics Framework


๐Ÿ“ˆ 27.78 Punkte

๐Ÿ“Œ CAINE 10.0 - GNU/Linux Live Distribution For Digital Forensics Project, Windows Side Forensics And Incident Response


๐Ÿ“ˆ 27.78 Punkte

๐Ÿ“Œ CAINE 11 - GNU/Linux Live Distribution For Digital Forensics Project, Windows Side Forensics And Incident Response


๐Ÿ“ˆ 27.78 Punkte

๐Ÿ“Œ Bootkit ransomware baddy hops down BadRabbit hole in Japan


๐Ÿ“ˆ 20.99 Punkte

๐Ÿ“Œ Chinese hacker group spotted using a UEFI bootkit in the wild


๐Ÿ“ˆ 20.99 Punkte

๐Ÿ“Œ Rare Bootkit Malware Targets North Korea-Linked Diplomats


๐Ÿ“ˆ 20.99 Punkte

๐Ÿ“Œ Hacker gehen mit UEFI-Bootkit gegen europรคische NGOs vor


๐Ÿ“ˆ 20.99 Punkte

๐Ÿ“Œ New 'MosaicRegressor' UEFI Bootkit Malware Found Active in the Wild


๐Ÿ“ˆ 20.99 Punkte

๐Ÿ“Œ Hacker gehen mit UEFI-Bootkit gegen europรคische NGOs vor


๐Ÿ“ˆ 20.99 Punkte

๐Ÿ“Œ MalwareTech SBK - A Bootkit Capable of Surviving Reformat


๐Ÿ“ˆ 20.99 Punkte

๐Ÿ“Œ Kaspersky enttarnt UEFI-BIOS-"Bootkit" auf zwei Computern


๐Ÿ“ˆ 20.99 Punkte

๐Ÿ“Œ Kaspersky enttarnt UEFI-BIOS-"Bootkit" auf zwei Computern


๐Ÿ“ˆ 20.99 Punkte

๐Ÿ“Œ Spionageprogramm mit Firmware-Bootkit


๐Ÿ“ˆ 20.99 Punkte

๐Ÿ“Œ Spionageprogramm mit Firmware-Bootkit


๐Ÿ“ˆ 20.99 Punkte

๐Ÿ“Œ MalwareTech SBK - A Bootkit Capable of Surviving Reformat


๐Ÿ“ˆ 20.99 Punkte

๐Ÿ“Œ 10 Years Since Stuxnet, Rare Bootkit Discovered, & Thin Client Vulnerabilities - PSW #669


๐Ÿ“ˆ 20.99 Punkte

๐Ÿ“Œ TrickBot Malware Gets UEFI/BIOS Bootkit Feature to Remain Undetected


๐Ÿ“ˆ 20.99 Punkte

๐Ÿ“Œ Meet MBR-ONI, Bootkit Ransomware Used as a Targeted Wiper


๐Ÿ“ˆ 20.99 Punkte

๐Ÿ“Œ TrickBot Returns with a Vengeance, Sporting Rare Bootkit Functions


๐Ÿ“ˆ 20.99 Punkte

๐Ÿ“Œ ESET Research Podcast: UEFI in crosshairs of ESPecter bootkit


๐Ÿ“ˆ 20.99 Punkte

๐Ÿ“Œ ESPecter Bootkit โ€“ neue Bedrohung in der EFIโ€‘Systempartition


๐Ÿ“ˆ 20.99 Punkte

๐Ÿ“Œ Malware dev claims to sell new BlackLotus Windows UEFI bootkit


๐Ÿ“ˆ 20.99 Punkte

๐Ÿ“Œ BlackLotus UEFI Bootkit โ€“ First Known Malware to Bypass Secure Boot Defenses


๐Ÿ“ˆ 20.99 Punkte

๐Ÿ“Œ Windows 11: Angreifer umgehen mit UEFI-Bootkit BlackLotus Secure Boot


๐Ÿ“ˆ 20.99 Punkte

๐Ÿ“Œ BlackLotus Becomes First UEFI Bootkit Malware to Bypass Secure Boot on Windows 11


๐Ÿ“ˆ 20.99 Punkte

๐Ÿ“Œ BlackLotus UEFI bootkit: Myth confirmed


๐Ÿ“ˆ 20.99 Punkte

๐Ÿ“Œ BlackLotus UEFI Bootkit ist kein Mythos mehr


๐Ÿ“ˆ 20.99 Punkte

matomo