acageduser / DMA-Attack-Firmware-Customization

This cybersecurity guide provides a comprehensive approach to hardware obfuscation using LambdaConcept's PCIe Screamer Squirrel DMA board. It is intended for educational and research purposes only.
MIT License
17 stars 0 forks source link
arbor dma pcileech visual-studio xilinx-vivado

DMA-Attack-Firmware-Customization

Executive Overview

This guide provides a comprehensive approach to hardware obfuscation using LambdaConcept's PCIe Screamer Squirrel DMA board. The project involves simulating a DMA card to avoid detection by anti-cheat systems, disguising it as a Realtek RTL8111 PCIe ethernet network card. This technique is key in cybersecurity, offering innovative methods to protect high-value hardware from automated detection systems.

Key Skills Demonstrated

# #

Purpose

Strategic Rationale

Focusing on evading anti-cheat systems like BattleEye (BE) and Easy Anti-Cheat (EAC) mirrors the complexity and organization of sophisticated hacking groups. These systems are developed by intelligent professionals and are highly funded, making them ideal testing grounds for advanced evasion techniques. Successfully bypassing such strong detection mechanisms not only highlights technical expertise but also provides valuable insights that can be applied to broader cybersecurity applications. By tackling these challenges, this project demonstrates customization of DMA firmware, expertise in hardware manipulation, and advanced cybersecurity skills—highly valuable in the tech industry and relevant to defending against equally well-funded, malicious entities.

Software and Hardware List

Project Details

What is the project?

This project is a hardware obfuscation simulation. Hardware obfuscation is an effective cybersecurity technique that hides the true nature of high-priority hardware by disguising it as lower-priority hardware.

Why is hardware obfuscation effective in Cybersecurity?

Attackers often prioritize targeting high-value hardware. By disguising such hardware as low-value, the likelihood of detection is reduced, effectively stalling attackers.

Examples of High-Value Hardware:

Examples of Low-Value Hardware:

Advantages of Hardware Obfuscation:

Potential Applications:

# #

The Project

1. Introduction information:

35T

This project will be using a 35T: Squirrel device. 75T and 100T devices will be different!

Why RTL8111?

I will also be using the RTL8111 as a 'donor card'. A donor card refers to the physical device I'll pull legitimate IDs off of. The donor cards information will be put onto the DMA card. Using a real network card will ensure my IDs are all accurate.

I picked the RTL8111 because the drivers are all well documented. This is an important step to keep in mind when choosing the right donor card. Open source drivers are best. A list of open source drivers can be found on this wiki on the Comparison of Open-Source Wireless Drivers.

2. Donor Card IDs

Gathering the IDs off of the donor card is the first part of the project. I will be using MindShare's Arbor to get hardware IDs off my donor card. I will perform a PCI scan here:

image

We can identify the RTL8111 is on Bus 5 within the PCI Map tab:

image

Inside teh PCI Config tab, we can identify many values within the RTL8111 such as B:D:F, Class, Device Description, Device Type, Capabilities.

image

We can also identify the header for the RTL8111:

image

Nothing out of the ordinary on the RTL8111. We must collect some values from the RTL8111.

Base Registry Address (BAR)

Note the size for your base registry addresses (BARs) by clicking on BAR0 to BAR5. A BAR set to '00 00 00 00' is a special bar. The 0's indicate that this specific BAR is not used on the RTL8111.

image

BAR0 is 256 bytes.

image

BAR1 is not used.

image

BAR2 and BAR3 are a pair. Their size is 4KB.

image

BAR4 and BAR5 are a pair. Thier size is 16KB.

Device Serial Number (DSN) Capability Structure

image

Advanced Error Reporting (AER) Capability Structure

image

Power Management (PM) Capability Structure

image

MSI-X Capability Structure

image

Virtual Channel (VC) Capability Structure

image

Message Signaled Innterrupt (MSI) Capability Structure

image

3. Enabling Master Abort Handling for Enhanced Error Detection

Set the master abort flag to 1 in pcileech-fpga-4.15\PCIeSquirrel\src in the pcileech_pcie_cfg_a7.sv file because it helps catch invalid memory accesses during DMA transactions, which would otherwise go unnoticed if set to 0. This allows for easier debugging if there is an issue with the custom firmware. Detecting and addressing any misconfigurations or failed transactions later on (if there are any) will be easier to manage. Without this change, you risk missing critical errors that could compromise the DMA firmware functionality. This is a safeguard. Do not skip this step.

image

I found it quite easily with the CTRL + F function and the string 'master abort flag'. There is only 1 mention of this in the entire file. Make the line exactly as follows:

rw[20]      <= 1;                       //       CFGSPACE_STATUS_REGISTER_AUTO_CLEAR [master abort flag]

Read/Write (rw) rw[20] is the correct line.

4. Setting the DSN

In the same file, copy the DSN value into the rw[127:64] line. This line is for the cfg_dsn. There are 16 avalible characters in this section. Be sure to copy the Lower DW over top of the first 8 numbers and copy the Upper DW into the second 8 numbers like shown:

rw[127:64]  <= 64'h684CE00051140000;    // +008: cfg_dsn

684CE000 and 51140000 are our Lower and Upper DWs.

Save pcieleech_pcie_cfg_a7.sv.

5. Vivado

Open

Vivado is what I will be using to create my pcileech_squirrel.xpr file. Be sure to know exactly where your PCIeSquirrel folder is. Mine is in M:\CUSTOM FW\pcileech-fpga-4.15\PCIeSquirrel, so I will cd into that location and run source vivado_generate_project.tcl -notrace to build.

cd into your PCIeSquirrel: image

source vivado_generate_project.tcl -notrace

image

Ensure there are no errors when creating the .xpr file. Open the file i_pcie_7x_0 : pcie_7x_0 (pcie_7x_0.xci) within the Sources box. Expand pcileech_squirrel_top and i_pcileech_tlps128_dst64 : pcileech_tlps128_dst64 until you find i_pcie_7x_0 : pcie_7x_0 (pcie_7x_0.xci). Open i_pcie_7x_0 : pcie_7x_0 (pcie_7x_0.xci).

IDs

We will now write in the IDs we saved before into the tab IDs.

image

I've updated Vendor ID, Device ID, Revision ID, Subsystem Vendor ID, and Subsystem ID. No need to update any values in Class Code because the RTL8111 is already 02 00 00:

image

BARs

Navigate to the BARs tab. BARs 0 and 1 are each 32 bit BARs becasue they contain a single BAR each. BARs 2, and 4 are 64 bit BARs because they contain two total BARs each. I/O BARs are always 32 bit. Do not enable BARs 1, 3, and 5 because they are unused BARs. We know this because they are hard coded to all 0s. BAR 3 is part of BAR 2 so do not enable BAR 3. Likewise, BAR 5 is part of BAR 4 so do not enable BAR 5. All 64 bit BARs will carry into the next BAR, so do not enable the 2nd half of each 64 bit BAR. Update the BARs:

image

We should leave the other tabs alone because the DMA device needs to function as normal under the hood. Changing values in other tabs such as Power Management could over or under volt your DMA card. DO NOT change these tabs or you risk mechanical failure! Instead, click OK at the bottom of the screen, then click Generate without changing any default settings in the pop up box.

image # Locate inst : pcie_7x_0_core_top (pcie_7x_0_core_top.v) (2)

image

We will now manually edit these values. There is no friendly GUI to help us anymore like before. You (generally) read the parameter name by the <Capability Structure>_<Capability Name>_<Capability Description>. For example, MSI_CAP_64_BIT_ADDR_CAPABLE is in the MSI Structure, CAP (short for capabilities) is the name of the Capability, and 64_BIT_ADDR_CAPABLE is the name of the description. I've indcluded screenshots on how to read the MSI capability below. They love to abbreviate the names, so read over them carefully. I'm simply going to list out line numbers and values to change below:

Message Signaled Interrupt (Real Example)

image

Line 154:

parameter         MSI_CAP_64_BIT_ADDR_CAPABLE = "TRUE",

PCIe

image

Line 101:

parameter integer DEV_CAP_ENDPOINT_L0S_LATENCY = 3,

image

How to read: 3 is the value for the Endpoint L0s Latency at [8:6]

image

Line 102:

parameter integer DEV_CAP_ENDPOINT_L1_LATENCY = 6,

image

Line 103:

parameter         DEV_CAP_EXT_TAG_SUPPORTED = "TRUE",

image

Line 104:

parameter integer DEV_CAP_MAX_PAYLOAD_SUPPORTED = 2,

image

Line 105:

parameter integer DEV_CAP_PHANTOM_FUNCTIONS_SUPPORT = 0,

image

Line 134:

parameter [3:0]   LINK_CAP_MAX_LINK_SPEED = 4'h1,

image

Line 135:

parameter [5:0]   LINK_CAP_MAX_LINK_WIDTH = 6'h1,

image

Line 139:

parameter [3:0]   LINK_CTRL2_TARGET_LINK_SPEED = 4'h0,

image

Line 163:

parameter [3:0]   PCIE_CAP_DEVICE_PORT_TYPE = 4'h0,

How to read: 4' means the value is 4 bits wide. The assigned value here must fit within 4 bits. h indicates the base of the number. h stands for hex (base 16) 0 is the actual value assigned

4'h0 means it is a 4 bit hex value that is set to 0. We can see that 0000b is the value assigned for Device/Port Type. Checks out.

image

Line 267:

parameter         LINK_CAP_ASPM_SUPPORT = 3,

Power Management Capability Structure

image

Line 167:

parameter         PM_CAP_D1SUPPORT = "TRUE",

Line 168:

parameter         PM_CAP_D2SUPPORT = "FALSE",

image

Line 171:

parameter         PM_CSR_NOSOFTRST = "TRUE",

image

Line 310: parameter PM_CAP_AUXCURRENT = 4,

image

Line 315:

parameter         PM_CAP_VERSION = 3,

MSI-X Capability Structure

This part is slightly different.

  1. PCIE_BASE_PTR: Set to 0x40, which is where the PCI Express capability structure is located.

Line 292:

parameter [7:0]   PCIE_BASE_PTR = 8'h40,
  1. PCIE_CAP_NEXTPTR: Set to 0xC8, which is where the next capability, Power Management, is located.

Line 164:

parameter [7:0]   PCIE_CAP_NEXTPTR = 8'hC8,
  1. PM_BASE_PTR: Set to 0xC8, which is the offset for Power Management capability.

Line 309:

parameter [7:0]   PM_BASE_PTR = 8'hC8,
  1. PM_CAP_NEXTPTR: Set to 0xD0, pointing to the MSI-X structure at offset 0xD0.

Line 169:

parameter [7:0]   PM_CAP_NEXTPTR = 8'hD0,
  1. MSI_BASE_PTR: Set to 0xD0, the location of the MSI-X capability.

Line 280:

parameter [7:0]   MSI_BASE_PTR = 8'hD0,
  1. MSI_CAP_NEXTPTR: Set to 0x00, indicating the end of the capability chain.

Line 282:

parameter [7:0]   MSI_CAP_NEXTPTR = 8'h00,
  1. CAPABILITIES_PTR: The starting point of the capabilities list is set to 0x40, which is the offset for the PCIe capability

Line 359:

parameter [7:0]   CAPABILITIES_PTR = PCIE_BASE_PTR,

This will link the capability structures in the configuation space based on the offsets and pointers.

Save your work so far.

6. Building

This will take a while to run. It took around 10 minutes on my 10600KF + 3070 PC.

image

Run source vivado_build.tcl -notrace again in the console.

image

It will generate pchileech_squirrel_top.bin. Flash this onto your DMA Card. This project will not go over how to flash the firmware onto the DMA card as that is out of the scope of this project. This project is for building custom firmware only.

7. Testing

DMA Card Functionality Check

Connect your second PC (Attack PC) to the PC with the DMA Card installed.

insert pic of my DMA card plugged in

insert image of my Laptop plugged in

I can verify my firmware is working using Lone DMA Test Tool.

insert image of lone DMA test tool

8. Testing My Firmware Against BattleEye Anti Cheat

DMA cards are forbidden to be plugged into your computer when launching a game equiped with BattleEye Anti Cheat. You will be banned immediately along with your hardware IDs logged on a blacklist. Do not try this part of the guide unless your firmware's configuration space does NOT resemble your vanilla card. Do this next part at your own risk.

I will be testing on PlayerUnknown's Battlegrounds because it's a free online game that uses BattleEye anti cheat.

Firmware Pass Check

I have no issues logging into the game.

insert pic of me in training mode

#

Conclusion

This project was a success. I will keep the status of my firmware up to date here. When this method no longer works, I will update this section.

As of my last check, this method passes and works.

#

Documentation and Drivers Used

Documentation

Read Further

Glossary

Note

This project is for EDUCATIONAL PURPOSES ONLY. Using this project outside of a purely educational context is not allowed. This project is to teach me a Cybersecurity strategy for detection prevention only. Following this guide assumes you understand the risks involved as it includes rewriting critical firmware files that can brick your hardware. Any firmware manipulation can lead to bricking. Consider this a warning! Follow the steps as they appear ONLY.