291 Commits

Author SHA1 Message Date
Nicolas Iooss 9a0f04e2a1 Import modules traceback and errno when they are needed
When loading the kernel module fails on Linux, `chipsec_util.py`
raises an error in

    logger().log_debug(traceback.format_exc())

because `traceback` was not imported.

Fix this issue by importing the missing modules `traceback` and `errno`.
While at it, import `traceback` too in other files where it was missing.

Signed-off-by: Nicolas Iooss <nicolas.iooss_git@polytechnique.org>
2023-09-06 16:37:59 -07:00
Nathaniel Mitchell 89f4be530f Update sgx_check and vbox_crash_apicbase
Signed-off-by: Nathaniel Mitchell <nathaniel.p.mitchell@intel.com>
2023-08-15 16:39:01 -07:00
Dan Scott b3d974b51a Update modules and utils to match config parsing update
Signed-off-by: Dan Scott <dan.scott@intel.com>
2023-07-28 09:34:00 -07:00
Nathaniel Mitchell a6ec8e0dd3 Update remap.py for when IBECC is enabled (EHL)
Signed-off-by: Nathaniel Mitchell <nathaniel.p.mitchell@intel.com>
2023-07-05 16:37:36 -07:00
Sara Batllori 318b361621 WIP: Add return codes changes to module_common and testcase plus remap support
Signed-off-by: Sara Batllori <sara.batllori@intel.com>
2023-06-27 17:47:46 -07:00
Nicolas Iooss e8d41ab9ee Replace binascii.hexlify with bytes.hex
Python 3.5 introduced `bytes.hex` to represent bytes in hexadecimal:
https://docs.python.org/3.5/library/stdtypes.html#bytes.hex

This function directly returns a string, contrary to `binascii.hexlify`
which returns bytes. Using `binascii.hexlify` without transforming the
output to string actually produced buggy output. For example:

    $ ./chipsec_util.py spidesc spi_rom.bin
    ...
    + 0x0000 Reserved : 0xb'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF'

This `b'` is not desired. Using `bytes.hex` fixes this issue and makes
the code simpler.

Signed-off-by: Nicolas Iooss <nicolas.iooss_git@polytechnique.org>
2023-06-05 16:43:15 -07:00
Nicolas Iooss 9be66dadbd Replace print_buffer(bytestostring(data)) with print_buffer_bytes
`print_buffer_bytes` can directly handle bytes, instead of converting
them to a string.

While at it, replace buggy calls to `print_buffer(buffer)` (when
`buffer` uses type `bytes`) with `print_buffer_bytes(buffer)`.
This fixes `./chipsec_util.py idt 0`. Before it failed with:

    [CHIPSEC] Dumping IDT of 8 CPU threads
    [cpu0] Physical Address: 0x000000036639E000
    [cpu0] # of entries    : 256
    [cpu0] Contents (4 entries):
    Traceback (most recent call last):
      File "./chipsec_util.py", line 210, in <module>
        sys.exit(main())
      File "./chipsec_util.py", line 205, in main
        return chipsecMain.main()
      File "./chipsec_util.py", line 190, in main
        comm.run()
      File "chipsec/utilcmd/desc_cmd.py", line 84, in run
        self.cs.msr.IDT_all(4)
      File "chipsec/hal/msr.py", line 166, in IDT_all
        self.IDT(tid, num_entries)
      File "chipsec/hal/msr.py", line 158, in IDT
        return self.dump_Descriptor_Table(cpu_thread_id, DESCRIPTOR_TABLE_CODE_IDTR, num_entries)
      File "chipsec/hal/msr.py", line 144, in dump_Descriptor_Table
        print_buffer(dt)
      File "chipsec/logger.py", line 493, in print_buffer
        prt_str = bytes2string(arr, length)
      File "chipsec/logger.py", line 466, in bytes2string
        num_string += [f'{ord(c):02X} ']
    TypeError: ord() expected string of length 1, but int found

There was another bug in `hal/msr.py` where `ord(dt[...])` was used
instead of `dt`.

Signed-off-by: Nicolas Iooss <nicolas.iooss_git@polytechnique.org>
2023-05-31 16:39:35 -07:00
Nathaniel Mitchell 0016b0c14c Clean up oshelper
Signed-off-by: Nathaniel Mitchell <nathaniel.p.mitchell@intel.com>
2023-05-26 18:32:51 -07:00
nstarke 61fcd60637 Fixing broken 'intelsecurity.com' link with wayback link 2023-05-08 09:05:13 -07:00
Sara Batllori 25a50ac8cc f'string updates to vmm subfolders in tools
Signed-off-by: Sara Batllori <sara.batllori@intel.com>
2023-04-25 15:26:15 -07:00
Sara Batllori 31b7edb884 f'string updates to cpuid
Signed-off-by: Sara Batllori <sara.batllori@intel.com>
2023-04-25 08:32:10 -07:00
Sara Batllori a981fbbd1d f'string updates to msr_fuzz, pcie_fuzz and pcie_overlap_fuzz
Signed-off-by: Sara Batllori <sara.batllori@intel.com>
2023-04-25 08:31:53 -07:00
Nathaniel Mitchell 1ea833bbc0 Clean up memconfig
Signed-off-by: Nathaniel Mitchell <nathaniel.p.mitchell@intel.com>
2023-04-25 08:31:11 -07:00
Sara Batllori 152a8c44ec f'string updates to vmm hv folder in tools
Signed-off-by: Sara Batllori <sara.batllori@intel.com>
2023-04-24 14:03:39 -07:00
Nathaniel Mitchell d209262ff6 Add type hinting and f'
Signed-off-by: Nathaniel Mitchell <nathaniel.p.mitchell@intel.com>
2023-04-24 14:03:19 -07:00
Nathaniel Mitchell b74183824d Update uefi variable test to not require dbx
Signed-off-by: Nathaniel Mitchell <nathaniel.p.mitchell@intel.com>
2023-04-24 14:03:19 -07:00
Dan Scott 54a81b8a78 Add flush method, typehints, fstrings to common.py
Signed-off-by: Dan Scott <dan.scott@intel.com>
2023-04-20 10:26:48 -07:00
Sara Batllori 86ecd5f087 f-string updates for cpu, secureboot and smm folders in tools
Signed-off-by: Sara Batllori <sara.batllori@intel.com>
2023-04-12 09:09:58 -07:00
Sara Batllori 36ca280c8a f-string updates for uefi folder in tools
Signed-off-by: Sara Batllori <sara.batllori@intel.com>
2023-04-12 09:09:05 -07:00
Nathaniel Mitchell 47bc4b2198 Fix issue with modifying variables in variables.py
Signed-off-by: Nathaniel Mitchell <nathaniel.p.mitchell@intel.com>
2023-01-18 17:42:42 -08:00
brentholtsclaw 7af173a43c Module and command changes to work with hal
Signed-off-by: brentholtsclaw <brent.holtsclaw@intel.com>
2022-12-05 16:34:48 -08:00
Frinzell, Aaron c4f8aa95c2 Removed deprecated logger functions
Signed-off-by: Frinzell, Aaron <aaron.frinzell@intel.com>
2022-12-05 17:41:00 -06:00
Nathaniel Mitchell d6b78e24ac Add fw bleed vuln to scan_blocked tool
Signed-off-by: Nathaniel Mitchell <nathaniel.p.mitchell@intel.com>
2022-09-30 14:54:17 -07:00
Frinzell, Aaron 0326a20d15 Remove broken link from smm_dma.py
Signed-off-by: Frinzell, Aaron <aaron.frinzell@intel.com>
2022-08-26 09:45:26 -07:00
Frinzell, Aaron 62af364780 Better docstring formatting in smm_dma.py
Signed-off-by: Frinzell, Aaron <aaron.frinzell@intel.com>
2022-08-26 09:45:26 -07:00
Frinzell, Aaron 3ad040e4ec Update is_supported() in memconfig.py
Signed-off-by: Frinzell, Aaron <aaron.frinzell@intel.com>
2022-08-24 16:50:07 -07:00
Frinzell, Aaron a7ca74c120 Clean up py2 class object
Signed-off-by: Frinzell, Aaron <aaron.frinzell@intel.com>
2022-08-24 13:28:16 -07:00
Nathaniel Mitchell 291632c0ee Apply flake8 code formatting rules against repo
Signed-off-by: Nathaniel Mitchell <nathaniel.p.mitchell@intel.com>
2022-07-28 09:17:10 -07:00
Sara Batllori 89cc29a194 Improve skipped messaging
Signed-off-by: Sara Batllori <sara.batllori@intel.com>
2022-07-25 17:05:29 -07:00
Sara Batllori 344043b37d Remove sphinx warnings
Signed-off-by: Sara Batllori <sara.batllori@intel.com>
2022-07-25 17:05:19 -07:00
Frinzell, Aaron d7349fad14 Move wsmt.py to tools
Signed-off-by: Frinzell, Aaron <aaron.frinzell@intel.com>
2022-07-25 17:03:23 -07:00
Frinzell, Aaron e5af018eb4 Update log_verbose() in bios_ts.py and sgx_check.py
Signed-off-by: Frinzell, Aaron <aaron.frinzell@intel.com>
2022-06-30 10:53:31 -07:00
Frinzell, Aaron 41ce05ef25 Clean up ia_untrusted.py code
Signed-off-by: Frinzell, Aaron <aaron.frinzell@intel.com>
2022-06-30 10:52:33 -07:00
Frinzell, Aaron 644035beb0 Update logger.error() in modules
Signed-off-by: Frinzell, Aaron <aaron.frinzell@intel.com>
2022-06-30 10:43:22 -07:00
Frinzell, Aaron 119f1287d5 Fix typo in xsa188.py docstring
Signed-off-by: Frinzell, Aaron <aaron.frinzell@intel.com>
2022-06-22 15:11:18 -07:00
Frinzell, Aaron 2ebd5a7909 Update usage documentation to hypercallfuzz.py
Signed-off-by: Frinzell, Aaron <aaron.frinzell@intel.com>
2022-06-21 08:53:07 -07:00
Nathaniel Mitchell 500152632e Fix byte buffer prints in hal and tool modules
Signed-off-by: Nathaniel Mitchell <nathaniel.p.mitchell@intel.com>
2022-06-16 16:14:32 -07:00
Frinzell, Aaron 1f5279ec80 Update usage documentation in sinkhole.py
Signed-off-by: Frinzell, Aaron <aaron.frinzell@intel.com>
2022-06-16 16:01:06 -07:00
Frinzell, Aaron 25e7b691cb Update usage documentation to vmbusfuzz.py
Signed-off-by: Frinzell, Aaron <aaron.frinzell@intel.com>
2022-06-16 15:45:58 -07:00
Frinzell, Aaron 831f718306 Add usage documentation to xsa188.py
Signed-off-by: Frinzell, Aaron <aaron.frinzell@intel.com>
2022-06-16 15:29:08 -07:00
Frinzell, Aaron ad7c222721 Minor usage documentation updates to cpuid_fuzz.py
Signed-off-by: Frinzell, Aaron <aaron.frinzell@intel.com>
2022-06-16 15:28:08 -07:00
Frinzell, Aaron 34544639ba Add usage documentation to pcie_overlap_fuzz.py
Signed-off-by: Frinzell, Aaron <aaron.frinzell@intel.com>
2022-06-16 15:26:27 -07:00
Frinzell, Aaron 242137360d Add usage documentation to hypercallfuzz.py
Signed-off-by: Frinzell, Aaron <aaron.frinzell@intel.com>
2022-06-16 15:25:07 -07:00
Frinzell, Aaron 3215046ef4 Add usage documentation to venom.py
Signed-off-by: Frinzell, Aaron <aaron.frinzell@intel.com>
2022-06-16 14:58:11 -07:00
Frinzell, Aaron bbaea2bc11 Add usage documentation to pcie_fuzz.py
Signed-off-by: Frinzell, Aaron <aaron.frinzell@intel.com>
2022-06-16 14:53:46 -07:00
Frinzell, Aaron 38d8884707 Add usage documentation to msr_fuzz.py
Signed-off-by: Frinzell, Aaron <aaron.frinzell@intel.com>
2022-06-16 14:50:40 -07:00
Frinzell, Aaron fa02974daf Add usage documentation to ept_finder.py
Signed-off-by: Frinzell, Aaron <aaron.frinzell@intel.com>
2022-06-16 14:50:21 -07:00
Frinzell, Aaron b8240440f1 Add usage documentation to iofuzz.py
Signed-off-by: Frinzell, Aaron <aaron.frinzell@intel.com>
2022-06-16 14:50:04 -07:00
Frinzell, Aaron 255b4cfb41 Add additional verboseness to spi_access.py
Signed-off-by: Frinzell, Aaron <aaron.frinzell@intel.com>
2022-05-23 12:07:05 -07:00
Frinzell, Aaron 4e569427b2 add alternate url
Signed-off-by: Frinzell, Aaron <aaron.frinzell@intel.com>
2022-05-23 12:06:31 -07:00