Skip to content

peripherals

Peripherals classes for Wintermute

This file contains the peripheral metaclass and the classes that inherit from it to give access to hardware peripherals and have more abstraction for automation and attacking.

Bluetooth

Bases: Peripheral

Class that defines the Bluetooth interface

Source code in wintermute/peripherals.py
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
class Bluetooth(Peripheral):
    """Class that defines the Bluetooth interface"""

    def __init__(
        self,
        device_path: str = "hci0",
        name: str = "",
        pins: Dict[Any, Any] = {},
        pType: PeripheralType = PeripheralType.Bluetooth,
        device_name: str = "",
        mac_address: str = "",
        paired_devices: list[str] = [],
        vulnerabilities: Optional[List[Vulnerability | dict[str, Any]]] = None,
    ) -> None:
        self.pType = pType
        self.device_name = device_name
        self.mac_address = mac_address
        self.paired_devices = paired_devices

        super().__init__(
            device_path, name, pins, pType, vulnerabilities=vulnerabilities
        )
        log.info(
            f"Initialized Bluetooth peripheral {name} with device name {device_name} and MAC {mac_address}"
        )

CAN

Bases: Peripheral

Class that defines the CAN (Controller Area Network) bus interface.

CAN is a robust, message-based, multi-master serial bus standard widely used in automotive, industrial, and embedded applications. It uses a differential pair (CAN_H / CAN_L) but most controllers expose digital TX / RX lines toward an external transceiver.

Examples:

>>> pins = {"can_tx": "P1", "can_rx": "P2", "gnd": "GND", "vcc": "VCC"}
>>> can = CAN(name="powertrain", pins=pins, baudrate=500000)
>>> print(can)
name='powertrain' pins={'can_tx': 'P1', 'can_rx': 'P2', 'gnd': 'GND', 'vcc': 'VCC'} pType=<PeripheralType.CAN: 13>
>>> print(can.baudrate, can.extended_id)
500000 False

Attributes:

Name Type Description
name str

Name of the peripheral.

pins Dict[Any, Any]

Dictionary of pin names to their values, expects keys can_tx and can_rx.

pType PeripheralType

Type of the peripheral, defaults to PeripheralType.CAN.

baudrate int

Bus bit rate in bits per second. Common values: 125000, 250000, 500000 (most common automotive), 1000000.

extended_id bool

Whether to use 29-bit extended identifiers (CAN 2.0B) instead of the 11-bit standard identifiers (CAN 2.0A). Defaults to False.

Source code in wintermute/peripherals.py
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
class CAN(Peripheral):
    """Class that defines the CAN (Controller Area Network) bus interface.

    CAN is a robust, message-based, multi-master serial bus standard widely
    used in automotive, industrial, and embedded applications. It uses a
    differential pair (CAN_H / CAN_L) but most controllers expose digital
    TX / RX lines toward an external transceiver.

    Examples:
        >>> pins = {"can_tx": "P1", "can_rx": "P2", "gnd": "GND", "vcc": "VCC"}
        >>> can = CAN(name="powertrain", pins=pins, baudrate=500000)
        >>> print(can)
        name='powertrain' pins={'can_tx': 'P1', 'can_rx': 'P2', 'gnd': 'GND', 'vcc': 'VCC'} pType=<PeripheralType.CAN: 13>
        >>> print(can.baudrate, can.extended_id)
        500000 False

    Attributes:
        name (str): Name of the peripheral.
        pins (Dict[Any, Any]): Dictionary of pin names to their values, expects
            keys ``can_tx`` and ``can_rx``.
        pType (PeripheralType): Type of the peripheral, defaults to
            ``PeripheralType.CAN``.
        baudrate (int): Bus bit rate in bits per second. Common values: 125000,
            250000, 500000 (most common automotive), 1000000.
        extended_id (bool): Whether to use 29-bit extended identifiers (CAN 2.0B)
            instead of the 11-bit standard identifiers (CAN 2.0A). Defaults to
            False.
    """

    def __init__(
        self,
        device_path: str = "can0",
        name: str = "",
        pins: Dict[Any, Any] = {},
        pType: PeripheralType = PeripheralType.CAN,
        baudrate: int = 500000,
        extended_id: bool = False,
        vulnerabilities: Optional[List[Vulnerability | dict[str, Any]]] = None,
    ) -> None:
        """Initialize a CAN peripheral.

        Args:
            device_path (str): Path or name of the CAN interface (e.g., ``can0``).
            name (str): Name of the CAN peripheral.
            pins (Dict[Any, Any]): Dictionary mapping pin names to their values.
                Expected keys include ``can_tx`` and ``can_rx``.
            pType (PeripheralType): Peripheral type, defaults to
                ``PeripheralType.CAN``.
            baudrate (int): Bus bit rate in bps. Defaults to 500000.
            extended_id (bool): Use 29-bit extended identifiers. Defaults to False.
            vulnerabilities: Optional list of known vulnerabilities.
        """
        self.pType = pType
        self.baudrate = baudrate
        self.extended_id = extended_id

        super().__init__(
            device_path, name, pins, pType, vulnerabilities=vulnerabilities
        )
        log.info(
            f"Initialized CAN peripheral {name} at {baudrate} bps (extended_id={extended_id})"
        )

__init__(device_path='can0', name='', pins={}, pType=PeripheralType.CAN, baudrate=500000, extended_id=False, vulnerabilities=None)

Initialize a CAN peripheral.

Parameters:

Name Type Description Default
device_path str

Path or name of the CAN interface (e.g., can0).

'can0'
name str

Name of the CAN peripheral.

''
pins Dict[Any, Any]

Dictionary mapping pin names to their values. Expected keys include can_tx and can_rx.

{}
pType PeripheralType

Peripheral type, defaults to PeripheralType.CAN.

CAN
baudrate int

Bus bit rate in bps. Defaults to 500000.

500000
extended_id bool

Use 29-bit extended identifiers. Defaults to False.

False
vulnerabilities Optional[List[Vulnerability | dict[str, Any]]]

Optional list of known vulnerabilities.

None
Source code in wintermute/peripherals.py
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
def __init__(
    self,
    device_path: str = "can0",
    name: str = "",
    pins: Dict[Any, Any] = {},
    pType: PeripheralType = PeripheralType.CAN,
    baudrate: int = 500000,
    extended_id: bool = False,
    vulnerabilities: Optional[List[Vulnerability | dict[str, Any]]] = None,
) -> None:
    """Initialize a CAN peripheral.

    Args:
        device_path (str): Path or name of the CAN interface (e.g., ``can0``).
        name (str): Name of the CAN peripheral.
        pins (Dict[Any, Any]): Dictionary mapping pin names to their values.
            Expected keys include ``can_tx`` and ``can_rx``.
        pType (PeripheralType): Peripheral type, defaults to
            ``PeripheralType.CAN``.
        baudrate (int): Bus bit rate in bps. Defaults to 500000.
        extended_id (bool): Use 29-bit extended identifiers. Defaults to False.
        vulnerabilities: Optional list of known vulnerabilities.
    """
    self.pType = pType
    self.baudrate = baudrate
    self.extended_id = extended_id

    super().__init__(
        device_path, name, pins, pType, vulnerabilities=vulnerabilities
    )
    log.info(
        f"Initialized CAN peripheral {name} at {baudrate} bps (extended_id={extended_id})"
    )

Ethernet

Bases: Peripheral

Class that defines the Ethernet interface.

This class can be used to define the Ethernet peripheral of a device, including its MAC address, IP address, subnet mask, gateway, DNS server, speed, and duplex mode. Pins can also be defined for the peripheral. The usual pins found on ethernet connectors are: RXD0, RXD1, RXD2, RXD3, TXD0, TXD1, TXD2, TXD3, RX_DV, LED1, RX_CLK, TX_CLK, TXEN, MDIO, MDC.

Examples:

>>> pins = {
...     "RXD0": "P1",
...     "RXD1": "P2",
...     "RXD2": "P3",
...     "RXD3": "P4",
...     "TXD0": "P5",
...     "TXD1": "P6",
...     "TXD2": "P7",
...     "TXD3": "P8",
...     "RX_DV": "P9",
...     "LED1": "P10",
...     "RX_CLK": "P11",
...     "TX_CLK": "P12",
...     "TXEN": "P13",
...     "MDIO": "P14",
...     "MDC": "P15",
...     "GND": "GND",
...     "VCC": "VCC",
... }
>>> eth = ethernet(
...     name="eth0",
...     pins=pins,
...     mac_address="00:11:22:33:44:55",
...     ipaddress=""
...     subnet_mask=""
...     gateway=""
...     dns=""
...     speed="1Gbps"
...     duplex="full"
... )
>>> print(eth)
name='eth0' pins={'RXD0': 'P1', 'RXD1': 'P2', 'RXD2': 'P3', 'RXD3': 'P4', 'TXD0': 'P5', 'TXD1': 'P6',
'TXD2': 'P7', 'TXD3': 'P8', 'RX_DV': 'P9', 'LED1': 'P10', 'RX_CLK': 'P11', 'TX_CLK': 'P12', 'TXEN': 'P13',
'MDIO': 'P14', 'MDC': 'P15', 'GND': 'GND', 'VCC': 'VCC'} pType=<PeripheralType.Ethernet: 2>

Attributes:

Name Type Description
name str

Name of the peripheral

pins Dict[Any, Any]

Dictionary of pin names to their values

pType PeripheralType

Type of the peripheral

mac_address str

MAC address of the Ethernet interface

ipaddress IPv4Address | IPv6Address | None

IP address of the Ethernet interface

subnet_mask IPv4Address | IPv6Address | None

Subnet mask of the Ethernet interface

gateway IPv4Address | IPv6Address | None

Gateway of the Ethernet interface

dns IPv4Address | IPv6Address | None

DNS server of the Ethernet interface

speed str

Speed of the Ethernet interface (e.g., "10Mbps", "100Mbps", "1Gbps")

duplex str

Duplex mode of the Ethernet interface ("half" or "full")

Source code in wintermute/peripherals.py
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
class Ethernet(Peripheral):
    """Class that defines the Ethernet interface.

    This class can be used to define the Ethernet peripheral of a device, including
    its MAC address, IP address, subnet mask, gateway, DNS server, speed, and duplex mode.
    Pins can also be defined for the peripheral. The usual pins found on ethernet connectors are:
    RXD0, RXD1, RXD2, RXD3, TXD0, TXD1, TXD2, TXD3, RX_DV, LED1, RX_CLK, TX_CLK, TXEN, MDIO, MDC.

    Examples:
        >>> pins = {
        ...     "RXD0": "P1",
        ...     "RXD1": "P2",
        ...     "RXD2": "P3",
        ...     "RXD3": "P4",
        ...     "TXD0": "P5",
        ...     "TXD1": "P6",
        ...     "TXD2": "P7",
        ...     "TXD3": "P8",
        ...     "RX_DV": "P9",
        ...     "LED1": "P10",
        ...     "RX_CLK": "P11",
        ...     "TX_CLK": "P12",
        ...     "TXEN": "P13",
        ...     "MDIO": "P14",
        ...     "MDC": "P15",
        ...     "GND": "GND",
        ...     "VCC": "VCC",
        ... }
        >>> eth = ethernet(
        ...     name="eth0",
        ...     pins=pins,
        ...     mac_address="00:11:22:33:44:55",
        ...     ipaddress=""
        ...     subnet_mask=""
        ...     gateway=""
        ...     dns=""
        ...     speed="1Gbps"
        ...     duplex="full"
        ... )
        >>> print(eth)
        name='eth0' pins={'RXD0': 'P1', 'RXD1': 'P2', 'RXD2': 'P3', 'RXD3': 'P4', 'TXD0': 'P5', 'TXD1': 'P6',
        'TXD2': 'P7', 'TXD3': 'P8', 'RX_DV': 'P9', 'LED1': 'P10', 'RX_CLK': 'P11', 'TX_CLK': 'P12', 'TXEN': 'P13',
        'MDIO': 'P14', 'MDC': 'P15', 'GND': 'GND', 'VCC': 'VCC'} pType=<PeripheralType.Ethernet: 2>

    Attributes:
        name (str): Name of the peripheral
        pins (Dict[Any, Any]): Dictionary of pin names to their values
        pType (PeripheralType): Type of the peripheral
        mac_address (str): MAC address of the Ethernet interface
        ipaddress (ipaddress.IPv4Address | ipaddress.IPv6Address | None): IP address of the Ethernet interface
        subnet_mask (ipaddress.IPv4Address | ipaddress.IPv6Address | None): Subnet mask of the Ethernet interface
        gateway (ipaddress.IPv4Address | ipaddress.IPv6Address | None): Gateway of the Ethernet interface
        dns (ipaddress.IPv4Address | ipaddress.IPv6Address | None): DNS server of the Ethernet interface
        speed (str): Speed of the Ethernet interface (e.g., "10Mbps", "100Mbps", "1Gbps")
        duplex (str): Duplex mode of the Ethernet interface ("half" or "full")
    """

    def __init__(
        self,
        device_path: str = "eth0",
        name: str = "",
        pins: Dict[Any, Any] = {},
        pType: PeripheralType = PeripheralType.Ethernet,
        mac_address: str = "",
        ipaddress: str | ipaddress.IPv4Address | ipaddress.IPv6Address | None = None,
        subnet_mask: str | ipaddress.IPv4Network | ipaddress.IPv6Network | None = None,
        gateway: str | ipaddress.IPv4Address | ipaddress.IPv6Address | None = None,
        dns: str | ipaddress.IPv4Address | ipaddress.IPv6Address | None = None,
        speed: str = "1Gbps",
        duplex: str = "full",
        vulnerabilities: Optional[List[Vulnerability | dict[str, Any]]] = None,
    ) -> None:
        self.pType = pType
        self.mac_address = mac_address
        self.ipaddress = ipaddress
        self.subnet_mask = subnet_mask
        self.gateway = gateway
        self.dns = dns
        self.speed = speed
        self.duplex = duplex

        super().__init__(
            device_path, name, pins, pType, vulnerabilities=vulnerabilities
        )
        log.info(
            f"Initialized Ethernet peripheral {name} with MAC {mac_address} at IP {ipaddress}"
        )

I2C

Bases: Peripheral

Class that defines the I2C (Inter-Integrated Circuit) interface.

I2C is a multi-master, multi-slave, packet-switched, single-ended, serial communication bus. It uses two bidirectional open-collector or open-drain lines, SDA (Serial Data) and SCL (Serial Clock), pulled up with resistors.

Examples:

>>> pins = {"sda": "P1", "scl": "P2", "gnd": "GND", "vcc": "VCC"}
>>> i2c = I2C(name="eeprom", pins=pins, address=0x50, clock_speed=400000)
>>> print(i2c)
name='eeprom' pins={'sda': 'P1', 'scl': 'P2', 'gnd': 'GND', 'vcc': 'VCC'} pType=<PeripheralType.I2C: 8>
>>> print(hex(i2c.address), i2c.clock_speed)
0x50 400000

Attributes:

Name Type Description
name str

Name of the peripheral.

pins Dict[Any, Any]

Dictionary of pin names to their values, expects keys sda and scl.

pType PeripheralType

Type of the peripheral, defaults to PeripheralType.I2C.

address int

7-bit (or 10-bit) I2C slave address of the target device. Defaults to 0.

clock_speed int

Bus clock frequency in Hz. Common values: 100000 (standard mode), 400000 (fast mode), 1000000 (fast-mode plus), 3400000 (high-speed mode). Defaults to 100000.

Source code in wintermute/peripherals.py
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
class I2C(Peripheral):
    """Class that defines the I2C (Inter-Integrated Circuit) interface.

    I2C is a multi-master, multi-slave, packet-switched, single-ended, serial
    communication bus. It uses two bidirectional open-collector or open-drain
    lines, SDA (Serial Data) and SCL (Serial Clock), pulled up with resistors.

    Examples:
        >>> pins = {"sda": "P1", "scl": "P2", "gnd": "GND", "vcc": "VCC"}
        >>> i2c = I2C(name="eeprom", pins=pins, address=0x50, clock_speed=400000)
        >>> print(i2c)
        name='eeprom' pins={'sda': 'P1', 'scl': 'P2', 'gnd': 'GND', 'vcc': 'VCC'} pType=<PeripheralType.I2C: 8>
        >>> print(hex(i2c.address), i2c.clock_speed)
        0x50 400000

    Attributes:
        name (str): Name of the peripheral.
        pins (Dict[Any, Any]): Dictionary of pin names to their values, expects
            keys ``sda`` and ``scl``.
        pType (PeripheralType): Type of the peripheral, defaults to
            ``PeripheralType.I2C``.
        address (int): 7-bit (or 10-bit) I2C slave address of the target device.
            Defaults to 0.
        clock_speed (int): Bus clock frequency in Hz. Common values: 100000
            (standard mode), 400000 (fast mode), 1000000 (fast-mode plus),
            3400000 (high-speed mode). Defaults to 100000.
    """

    def __init__(
        self,
        device_path: str = "",
        name: str = "",
        pins: Dict[Any, Any] = {},
        pType: PeripheralType = PeripheralType.I2C,
        address: int = 0,
        clock_speed: int = 100000,
        vulnerabilities: Optional[List[Vulnerability | dict[str, Any]]] = None,
    ) -> None:
        """Initialize an I2C peripheral.

        Args:
            device_path (str): Path to the I2C bus device (e.g., ``/dev/i2c-1``).
            name (str): Name of the I2C peripheral.
            pins (Dict[Any, Any]): Dictionary mapping pin names to their values.
                Expected keys include ``sda`` and ``scl``.
            pType (PeripheralType): Peripheral type, defaults to
                ``PeripheralType.I2C``.
            address (int): I2C slave address of the target device. Defaults to 0.
            clock_speed (int): Bus clock frequency in Hz. Defaults to 100000.
            vulnerabilities: Optional list of known vulnerabilities.
        """
        self.pType = pType
        self.address = address
        self.clock_speed = clock_speed

        super().__init__(
            device_path, name, pins, pType, vulnerabilities=vulnerabilities
        )
        log.info(
            f"Initialized I2C peripheral {name} at address {hex(address)} with clock {clock_speed} Hz"
        )

__init__(device_path='', name='', pins={}, pType=PeripheralType.I2C, address=0, clock_speed=100000, vulnerabilities=None)

Initialize an I2C peripheral.

Parameters:

Name Type Description Default
device_path str

Path to the I2C bus device (e.g., /dev/i2c-1).

''
name str

Name of the I2C peripheral.

''
pins Dict[Any, Any]

Dictionary mapping pin names to their values. Expected keys include sda and scl.

{}
pType PeripheralType

Peripheral type, defaults to PeripheralType.I2C.

I2C
address int

I2C slave address of the target device. Defaults to 0.

0
clock_speed int

Bus clock frequency in Hz. Defaults to 100000.

100000
vulnerabilities Optional[List[Vulnerability | dict[str, Any]]]

Optional list of known vulnerabilities.

None
Source code in wintermute/peripherals.py
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
def __init__(
    self,
    device_path: str = "",
    name: str = "",
    pins: Dict[Any, Any] = {},
    pType: PeripheralType = PeripheralType.I2C,
    address: int = 0,
    clock_speed: int = 100000,
    vulnerabilities: Optional[List[Vulnerability | dict[str, Any]]] = None,
) -> None:
    """Initialize an I2C peripheral.

    Args:
        device_path (str): Path to the I2C bus device (e.g., ``/dev/i2c-1``).
        name (str): Name of the I2C peripheral.
        pins (Dict[Any, Any]): Dictionary mapping pin names to their values.
            Expected keys include ``sda`` and ``scl``.
        pType (PeripheralType): Peripheral type, defaults to
            ``PeripheralType.I2C``.
        address (int): I2C slave address of the target device. Defaults to 0.
        clock_speed (int): Bus clock frequency in Hz. Defaults to 100000.
        vulnerabilities: Optional list of known vulnerabilities.
    """
    self.pType = pType
    self.address = address
    self.clock_speed = clock_speed

    super().__init__(
        device_path, name, pins, pType, vulnerabilities=vulnerabilities
    )
    log.info(
        f"Initialized I2C peripheral {name} at address {hex(address)} with clock {clock_speed} Hz"
    )

JTAG

Bases: Peripheral

Class that defines the JTAG interface

Examples:

>>> pins = {
...     "tck": "P1",
...     "tdi": "P2",
...     "tdo": "P3",
...     "tms": "P4",
...     "trst": "P5",
...     "gnd": "GND",
...     "vcc": "VCC",
... }
>>> j = JTAG(name="jtag1", pins=pins)
>>> print(j)
name='jtag1' pins={'tck': 'P1', 'tdi': 'P2', 'tdo': 'P3', 'tms': 'P4', 'trst': 'P5', 'gnd': 'GND', 'vcc': 'VCC'} pType=<PeripheralType.JTAG: 3>
>>> print(j.tck, j.tdi, j.tdo, j.tms, j.trst, j.gnd, j.vcc)
P1 P2 P3 P4 P5 GND VCC

Attributes: name (str): Name of the peripheral pins (Dict[Any, Any]): Dictionary of pin names to their values pType (PeripheralType): Type of the peripheral

Source code in wintermute/peripherals.py
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
class JTAG(Peripheral):
    """Class that defines the JTAG interface

    Examples:
        >>> pins = {
        ...     "tck": "P1",
        ...     "tdi": "P2",
        ...     "tdo": "P3",
        ...     "tms": "P4",
        ...     "trst": "P5",
        ...     "gnd": "GND",
        ...     "vcc": "VCC",
        ... }
        >>> j = JTAG(name="jtag1", pins=pins)
        >>> print(j)
        name='jtag1' pins={'tck': 'P1', 'tdi': 'P2', 'tdo': 'P3', 'tms': 'P4', 'trst': 'P5', 'gnd': 'GND', 'vcc': 'VCC'} pType=<PeripheralType.JTAG: 3>
        >>> print(j.tck, j.tdi, j.tdo, j.tms, j.trst, j.gnd, j.vcc)
        P1 P2 P3 P4 P5 GND VCC
    Attributes:
        name (str): Name of the peripheral
        pins (Dict[Any, Any]): Dictionary of pin names to their values
        pType (PeripheralType): Type of the peripheral
    """

    def __init__(
        self,
        device_path: str = "",
        name: str = "",
        pins: Dict[Any, Any] = {},
        pType: PeripheralType = PeripheralType.JTAG,
        vulnerabilities: Optional[List[Vulnerability | dict[str, Any]]] = None,
    ) -> None:
        self.pType = pType
        self.name = name
        super().__init__(
            device_path, name, pins, pType, vulnerabilities=vulnerabilities
        )
        log.info(f"Initialized JTAG peripheral {name}")

PCIe

Bases: Peripheral

Class that defines the PCIe interface

Source code in wintermute/peripherals.py
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
class PCIe(Peripheral):
    """Class that defines the PCIe interface"""

    __schema__ = {
        "Processor": Processor,
        "Architecture": Architecture,
        "Memory": Memory,
    }
    __enums__ = {}

    def __init__(
        self,
        device_path: str = "",
        name: str = "",
        pins: Dict[Any, Any] = {},
        pType: PeripheralType = PeripheralType.PCIe,
        version: str = "4.0",
        lanes: int = 1,
        role: str = "endpoint",  # GPU, Co-Processor, Network Card, etc.
        processor: Processor
        | None = None,  # CPU or SoC connected via PCIe or in the PCIe device
        architecture: Architecture | None = None,
        memory: Memory | None = None,
        vulnerabilities: Optional[List[Vulnerability | dict[str, Any]]] = None,
    ) -> None:
        self.pType = pType
        self.version = version
        self.lanes = lanes
        self.role = role
        self.processor = processor
        self.architecture = architecture
        self.memory = memory

        super().__init__(
            device_path, name, pins, pType, vulnerabilities=vulnerabilities
        )
        log.info(
            f"Initialized PCIe peripheral {name} with version {version}, lanes {lanes}, role {role}"
        )

SFP

Bases: Peripheral

Class that defines an SFP (Small Form-factor Pluggable) transceiver.

SFP modules are hot-pluggable network interface transceivers used in Ethernet, Fibre Channel, and SONET/SDH equipment. They expose low-speed management signals (TX_FAULT, TX_DISABLE, MOD_DEF, RX_LOS) plus the high-speed differential data pairs.

Examples:

>>> pins = {
...     "tx_fault": "P1",
...     "tx_disable": "P2",
...     "mod_def": "P3",
...     "rx_los": "P4",
...     "gnd": "GND",
...     "vcc": "VCC",
... }
>>> sfp = SFP(
...     name="uplink0",
...     pins=pins,
...     form_factor="SFP+",
...     wavelength=1310,
...     media="fiber",
... )
>>> print(sfp)
name='uplink0' pins={'tx_fault': 'P1', 'tx_disable': 'P2', 'mod_def': 'P3', 'rx_los': 'P4', 'gnd': 'GND', 'vcc': 'VCC'} pType=<PeripheralType.SFP: 14>
>>> print(sfp.form_factor, sfp.wavelength, sfp.media)
SFP+ 1310 fiber

Attributes:

Name Type Description
name str

Name of the peripheral.

pins Dict[Any, Any]

Dictionary of pin names to their values, expects keys tx_fault, tx_disable, mod_def, and rx_los.

pType PeripheralType

Type of the peripheral, defaults to PeripheralType.SFP.

form_factor str

Module form factor, e.g., "SFP", "SFP+", "QSFP", "QSFP+", "QSFP28".

wavelength int

Optical wavelength in nanometers (e.g., 850, 1310, 1550). Use 0 for copper / direct attach modules.

media str

Physical media type, e.g., "fiber" or "copper".

Source code in wintermute/peripherals.py
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
class SFP(Peripheral):
    """Class that defines an SFP (Small Form-factor Pluggable) transceiver.

    SFP modules are hot-pluggable network interface transceivers used in
    Ethernet, Fibre Channel, and SONET/SDH equipment. They expose low-speed
    management signals (TX_FAULT, TX_DISABLE, MOD_DEF, RX_LOS) plus the
    high-speed differential data pairs.

    Examples:
        >>> pins = {
        ...     "tx_fault": "P1",
        ...     "tx_disable": "P2",
        ...     "mod_def": "P3",
        ...     "rx_los": "P4",
        ...     "gnd": "GND",
        ...     "vcc": "VCC",
        ... }
        >>> sfp = SFP(
        ...     name="uplink0",
        ...     pins=pins,
        ...     form_factor="SFP+",
        ...     wavelength=1310,
        ...     media="fiber",
        ... )
        >>> print(sfp)
        name='uplink0' pins={'tx_fault': 'P1', 'tx_disable': 'P2', 'mod_def': 'P3', 'rx_los': 'P4', 'gnd': 'GND', 'vcc': 'VCC'} pType=<PeripheralType.SFP: 14>
        >>> print(sfp.form_factor, sfp.wavelength, sfp.media)
        SFP+ 1310 fiber

    Attributes:
        name (str): Name of the peripheral.
        pins (Dict[Any, Any]): Dictionary of pin names to their values, expects
            keys ``tx_fault``, ``tx_disable``, ``mod_def``, and ``rx_los``.
        pType (PeripheralType): Type of the peripheral, defaults to
            ``PeripheralType.SFP``.
        form_factor (str): Module form factor, e.g., ``"SFP"``, ``"SFP+"``,
            ``"QSFP"``, ``"QSFP+"``, ``"QSFP28"``.
        wavelength (int): Optical wavelength in nanometers (e.g., 850, 1310,
            1550). Use 0 for copper / direct attach modules.
        media (str): Physical media type, e.g., ``"fiber"`` or ``"copper"``.
    """

    def __init__(
        self,
        device_path: str = "",
        name: str = "",
        pins: Dict[Any, Any] = {},
        pType: PeripheralType = PeripheralType.SFP,
        form_factor: str = "SFP",
        wavelength: int = 850,
        media: str = "fiber",
        vulnerabilities: Optional[List[Vulnerability | dict[str, Any]]] = None,
    ) -> None:
        """Initialize an SFP peripheral.

        Args:
            device_path (str): Path or identifier of the SFP cage / interface.
            name (str): Name of the SFP peripheral.
            pins (Dict[Any, Any]): Dictionary mapping pin names to their values.
                Expected keys include ``tx_fault``, ``tx_disable``, ``mod_def``,
                and ``rx_los``.
            pType (PeripheralType): Peripheral type, defaults to
                ``PeripheralType.SFP``.
            form_factor (str): Module form factor (``"SFP"``, ``"SFP+"``,
                ``"QSFP"``, etc.). Defaults to ``"SFP"``.
            wavelength (int): Optical wavelength in nanometers. Defaults to 850.
            media (str): Physical media type (``"fiber"`` or ``"copper"``).
                Defaults to ``"fiber"``.
            vulnerabilities: Optional list of known vulnerabilities.
        """
        self.pType = pType
        self.form_factor = form_factor
        self.wavelength = wavelength
        self.media = media

        super().__init__(
            device_path, name, pins, pType, vulnerabilities=vulnerabilities
        )
        log.info(
            f"Initialized SFP peripheral {name} ({form_factor}, {wavelength}nm, {media})"
        )

__init__(device_path='', name='', pins={}, pType=PeripheralType.SFP, form_factor='SFP', wavelength=850, media='fiber', vulnerabilities=None)

Initialize an SFP peripheral.

Parameters:

Name Type Description Default
device_path str

Path or identifier of the SFP cage / interface.

''
name str

Name of the SFP peripheral.

''
pins Dict[Any, Any]

Dictionary mapping pin names to their values. Expected keys include tx_fault, tx_disable, mod_def, and rx_los.

{}
pType PeripheralType

Peripheral type, defaults to PeripheralType.SFP.

SFP
form_factor str

Module form factor ("SFP", "SFP+", "QSFP", etc.). Defaults to "SFP".

'SFP'
wavelength int

Optical wavelength in nanometers. Defaults to 850.

850
media str

Physical media type ("fiber" or "copper"). Defaults to "fiber".

'fiber'
vulnerabilities Optional[List[Vulnerability | dict[str, Any]]]

Optional list of known vulnerabilities.

None
Source code in wintermute/peripherals.py
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
def __init__(
    self,
    device_path: str = "",
    name: str = "",
    pins: Dict[Any, Any] = {},
    pType: PeripheralType = PeripheralType.SFP,
    form_factor: str = "SFP",
    wavelength: int = 850,
    media: str = "fiber",
    vulnerabilities: Optional[List[Vulnerability | dict[str, Any]]] = None,
) -> None:
    """Initialize an SFP peripheral.

    Args:
        device_path (str): Path or identifier of the SFP cage / interface.
        name (str): Name of the SFP peripheral.
        pins (Dict[Any, Any]): Dictionary mapping pin names to their values.
            Expected keys include ``tx_fault``, ``tx_disable``, ``mod_def``,
            and ``rx_los``.
        pType (PeripheralType): Peripheral type, defaults to
            ``PeripheralType.SFP``.
        form_factor (str): Module form factor (``"SFP"``, ``"SFP+"``,
            ``"QSFP"``, etc.). Defaults to ``"SFP"``.
        wavelength (int): Optical wavelength in nanometers. Defaults to 850.
        media (str): Physical media type (``"fiber"`` or ``"copper"``).
            Defaults to ``"fiber"``.
        vulnerabilities: Optional list of known vulnerabilities.
    """
    self.pType = pType
    self.form_factor = form_factor
    self.wavelength = wavelength
    self.media = media

    super().__init__(
        device_path, name, pins, pType, vulnerabilities=vulnerabilities
    )
    log.info(
        f"Initialized SFP peripheral {name} ({form_factor}, {wavelength}nm, {media})"
    )

SPI

Bases: Peripheral

Class that defines the SPI (Serial Peripheral Interface) interface.

SPI is a synchronous, full-duplex, master-slave-based serial communication bus. It uses four signals: MISO (Master In Slave Out), MOSI (Master Out Slave In), SCLK (Serial Clock), and CS (Chip Select / Slave Select).

Examples:

>>> pins = {
...     "miso": "P1",
...     "mosi": "P2",
...     "sclk": "P3",
...     "cs": "P4",
...     "gnd": "GND",
...     "vcc": "VCC",
... }
>>> spi = SPI(name="flash", pins=pins, mode=0, clock_speed=10000000)
>>> print(spi)
name='flash' pins={'miso': 'P1', 'mosi': 'P2', 'sclk': 'P3', 'cs': 'P4', 'gnd': 'GND', 'vcc': 'VCC'} pType=<PeripheralType.SPI: 9>
>>> print(spi.mode, spi.clock_speed, spi.bit_order)
0 10000000 MSB

Attributes:

Name Type Description
name str

Name of the peripheral.

pins Dict[Any, Any]

Dictionary of pin names to their values, expects keys miso, mosi, sclk, and cs.

pType PeripheralType

Type of the peripheral, defaults to PeripheralType.SPI.

mode int

SPI mode, an integer in the range 0-3 selecting the clock polarity (CPOL) and clock phase (CPHA) combination.

clock_speed int

Bus clock frequency in Hz.

bit_order Literal['MSB', 'LSB']

Bit transmission order, either "MSB" (most significant bit first) or "LSB" (least significant bit first). Defaults to "MSB".

Source code in wintermute/peripherals.py
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
class SPI(Peripheral):
    """Class that defines the SPI (Serial Peripheral Interface) interface.

    SPI is a synchronous, full-duplex, master-slave-based serial communication
    bus. It uses four signals: MISO (Master In Slave Out), MOSI (Master Out
    Slave In), SCLK (Serial Clock), and CS (Chip Select / Slave Select).

    Examples:
        >>> pins = {
        ...     "miso": "P1",
        ...     "mosi": "P2",
        ...     "sclk": "P3",
        ...     "cs": "P4",
        ...     "gnd": "GND",
        ...     "vcc": "VCC",
        ... }
        >>> spi = SPI(name="flash", pins=pins, mode=0, clock_speed=10000000)
        >>> print(spi)
        name='flash' pins={'miso': 'P1', 'mosi': 'P2', 'sclk': 'P3', 'cs': 'P4', 'gnd': 'GND', 'vcc': 'VCC'} pType=<PeripheralType.SPI: 9>
        >>> print(spi.mode, spi.clock_speed, spi.bit_order)
        0 10000000 MSB

    Attributes:
        name (str): Name of the peripheral.
        pins (Dict[Any, Any]): Dictionary of pin names to their values, expects
            keys ``miso``, ``mosi``, ``sclk``, and ``cs``.
        pType (PeripheralType): Type of the peripheral, defaults to
            ``PeripheralType.SPI``.
        mode (int): SPI mode, an integer in the range 0-3 selecting the clock
            polarity (CPOL) and clock phase (CPHA) combination.
        clock_speed (int): Bus clock frequency in Hz.
        bit_order (Literal["MSB", "LSB"]): Bit transmission order, either
            ``"MSB"`` (most significant bit first) or ``"LSB"`` (least
            significant bit first). Defaults to ``"MSB"``.
    """

    def __init__(
        self,
        device_path: str = "",
        name: str = "",
        pins: Dict[Any, Any] = {},
        pType: PeripheralType = PeripheralType.SPI,
        mode: int = 0,
        clock_speed: int = 1000000,
        bit_order: Literal["MSB", "LSB"] = "MSB",
        vulnerabilities: Optional[List[Vulnerability | dict[str, Any]]] = None,
    ) -> None:
        """Initialize an SPI peripheral.

        Args:
            device_path (str): Path to the SPI bus device (e.g., ``/dev/spidev0.0``).
            name (str): Name of the SPI peripheral.
            pins (Dict[Any, Any]): Dictionary mapping pin names to their values.
                Expected keys include ``miso``, ``mosi``, ``sclk``, and ``cs``.
            pType (PeripheralType): Peripheral type, defaults to
                ``PeripheralType.SPI``.
            mode (int): SPI mode (0-3). Defaults to 0.
            clock_speed (int): Bus clock frequency in Hz. Defaults to 1000000.
            bit_order (Literal["MSB", "LSB"]): Bit transmission order. Defaults
                to ``"MSB"``.
            vulnerabilities: Optional list of known vulnerabilities.
        """
        self.pType = pType
        self.mode = mode
        self.clock_speed = clock_speed
        self.bit_order = bit_order

        super().__init__(
            device_path, name, pins, pType, vulnerabilities=vulnerabilities
        )
        log.info(
            f"Initialized SPI peripheral {name} in mode {mode} with clock {clock_speed} Hz, bit order {bit_order}"
        )

__init__(device_path='', name='', pins={}, pType=PeripheralType.SPI, mode=0, clock_speed=1000000, bit_order='MSB', vulnerabilities=None)

Initialize an SPI peripheral.

Parameters:

Name Type Description Default
device_path str

Path to the SPI bus device (e.g., /dev/spidev0.0).

''
name str

Name of the SPI peripheral.

''
pins Dict[Any, Any]

Dictionary mapping pin names to their values. Expected keys include miso, mosi, sclk, and cs.

{}
pType PeripheralType

Peripheral type, defaults to PeripheralType.SPI.

SPI
mode int

SPI mode (0-3). Defaults to 0.

0
clock_speed int

Bus clock frequency in Hz. Defaults to 1000000.

1000000
bit_order Literal['MSB', 'LSB']

Bit transmission order. Defaults to "MSB".

'MSB'
vulnerabilities Optional[List[Vulnerability | dict[str, Any]]]

Optional list of known vulnerabilities.

None
Source code in wintermute/peripherals.py
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
def __init__(
    self,
    device_path: str = "",
    name: str = "",
    pins: Dict[Any, Any] = {},
    pType: PeripheralType = PeripheralType.SPI,
    mode: int = 0,
    clock_speed: int = 1000000,
    bit_order: Literal["MSB", "LSB"] = "MSB",
    vulnerabilities: Optional[List[Vulnerability | dict[str, Any]]] = None,
) -> None:
    """Initialize an SPI peripheral.

    Args:
        device_path (str): Path to the SPI bus device (e.g., ``/dev/spidev0.0``).
        name (str): Name of the SPI peripheral.
        pins (Dict[Any, Any]): Dictionary mapping pin names to their values.
            Expected keys include ``miso``, ``mosi``, ``sclk``, and ``cs``.
        pType (PeripheralType): Peripheral type, defaults to
            ``PeripheralType.SPI``.
        mode (int): SPI mode (0-3). Defaults to 0.
        clock_speed (int): Bus clock frequency in Hz. Defaults to 1000000.
        bit_order (Literal["MSB", "LSB"]): Bit transmission order. Defaults
            to ``"MSB"``.
        vulnerabilities: Optional list of known vulnerabilities.
    """
    self.pType = pType
    self.mode = mode
    self.clock_speed = clock_speed
    self.bit_order = bit_order

    super().__init__(
        device_path, name, pins, pType, vulnerabilities=vulnerabilities
    )
    log.info(
        f"Initialized SPI peripheral {name} in mode {mode} with clock {clock_speed} Hz, bit order {bit_order}"
    )

TPM

Bases: Peripheral

Class that defines a TPM peripheral with version-aware payload builders.

Examples:

>>> pins = {
...     "mosi": "P1",
...     "miso": "P2",
...     "sclk": "P3",
...     "gnd": "GND",
...     "cs": "P4",
...     "rst": "P5",
...     "pirq": "P6",
...     "vcc": "VCC",
... }
>>> tpm = TPM(name="tpm1", pins=pins)
>>> print(tpm)
name='tpm1' pins={'mosi': 'P1', 'miso': 'P2', 'sclk': 'P3', 'gnd': 'GND', 'cs': 'P4', 'rst': 'P5', 'pirq': 'P6', 'vcc': 'VCC'} pType=<PeripheralType.TPM: 10>
>>> print(
...     tpm.mosi,
...     tpm.miso,
...     tpm.sclk,
...     tpm.gnd,
...     tpm.cs,
...     tpm.rst,
...     tpm.pirq,
...     tpm.vcc,
... )
P1 P2 P3 GND P4 P5 P6 VCC

Attributes:

Name Type Description
name str

Name of the peripheral

pins Dict[Any, Any]

Dictionary of pin names to their values

pType PeripheralType

Type of the peripheral

version Literal['1.2', '2.0']

TPM specification version targeted

Source code in wintermute/peripherals.py
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
class TPM(Peripheral):
    """Class that defines a TPM peripheral with version-aware payload builders.

    Examples:
        >>> pins = {
        ...     "mosi": "P1",
        ...     "miso": "P2",
        ...     "sclk": "P3",
        ...     "gnd": "GND",
        ...     "cs": "P4",
        ...     "rst": "P5",
        ...     "pirq": "P6",
        ...     "vcc": "VCC",
        ... }
        >>> tpm = TPM(name="tpm1", pins=pins)
        >>> print(tpm)
        name='tpm1' pins={'mosi': 'P1', 'miso': 'P2', 'sclk': 'P3', 'gnd': 'GND', 'cs': 'P4', 'rst': 'P5', 'pirq': 'P6', 'vcc': 'VCC'} pType=<PeripheralType.TPM: 10>
        >>> print(
        ...     tpm.mosi,
        ...     tpm.miso,
        ...     tpm.sclk,
        ...     tpm.gnd,
        ...     tpm.cs,
        ...     tpm.rst,
        ...     tpm.pirq,
        ...     tpm.vcc,
        ... )
        P1 P2 P3 GND P4 P5 P6 VCC

    Attributes:
        name (str): Name of the peripheral
        pins (Dict[Any, Any]): Dictionary of pin names to their values
        pType (PeripheralType): Type of the peripheral
        version (Literal["1.2", "2.0"]): TPM specification version targeted
    """

    def __init__(
        self,
        device_path: str = "/dev/tpm0",
        name: str = "",
        pins: Dict[Any, Any] = {},
        pType: PeripheralType = PeripheralType.TPM,
        version: Literal["1.2", "2.0"] = "2.0",
        vulnerabilities: Optional[List[Vulnerability | dict[str, Any]]] = None,
    ) -> None:
        """Initialize TPM peripheral with pin mappings, version, and type.

        Args:
            device_path (str): Path to the TPM device file.
            name (str): Name of the TPM peripheral.
            pins (Dict[Any, Any]): Dictionary mapping pin names to their values.
            pType (PeripheralType): Type of the peripheral, defaults to PeripheralType.TPM.
            version (Literal["1.2", "2.0"]): TPM spec version, defaults to "2.0".
            vulnerabilities: Optional list of known vulnerabilities.
        """
        self.version: Literal["1.2", "2.0"] = version
        super().__init__(
            device_path, name, pins, pType, vulnerabilities=vulnerabilities
        )
        log.info(f"Initialized TPM {version} peripheral {name} at {device_path}")

    def _require_version(self, required: str) -> None:
        """Raise NotImplementedError if the TPM version does not match."""
        if self.version != required:
            raise NotImplementedError(
                f"This operation requires TPM {required}, "
                f"but this peripheral is configured for TPM {self.version}"
            )

    # -------------------------------------------------
    # Common header helpers (version-agnostic framing)
    # -------------------------------------------------

    def _tpm_input_header(self, tag: int, len: int, code: int) -> bytes:
        """10 byte header that will prepend every command sent from the host to the TPM"""
        return struct.pack(">HII", tag, len, code)

    def _tpm_output_header(self, tag: int, len: int, code: int) -> bytes:
        """10 byte header that will prepend every command sent from the TPM to the host"""
        return struct.pack(">HII", tag, len, code)

    # -------------------------------------------------
    # TPM 1.2 payload builders
    # -------------------------------------------------

    def _tpm12_pcr_read_req_body(self, pcr_index: int = 0) -> bytes:
        """Build a TPM 1.2 PCR_Read request body (SHA-1 / 20-byte digests)."""
        self._require_version("1.2")
        return struct.pack(">I", pcr_index)

    def _tpm12_pcr_read_resp_body(self, out_digest: bytes) -> bytes:
        """Parse helper for a TPM 1.2 PCR_Read response body."""
        self._require_version("1.2")
        return struct.pack(">20s", out_digest)

    def _tpm12_pcr_extend_req_body(self, pcr_index: int, in_digest: bytes) -> bytes:
        """Build a TPM 1.2 PCR_Extend request body."""
        self._require_version("1.2")
        return struct.pack(">I20s", pcr_index, in_digest)

    def _tpm12_pcr_extend_resp_body(self, out_digest: bytes) -> bytes:
        """Parse helper for a TPM 1.2 PCR_Extend response body."""
        self._require_version("1.2")
        return struct.pack(">20s", out_digest)

    def _tpm12_get_rnd_req_body(self, num_bytes: int) -> bytes:
        """Build a TPM 1.2 GetRandom request body."""
        self._require_version("1.2")
        return struct.pack(">I", num_bytes)

    def _tpm12_get_rnd_resp_body(
        self, random_bytes_size: int, random_bytes: bytes
    ) -> bytes:
        """Parse helper for a TPM 1.2 GetRandom response body."""
        self._require_version("1.2")
        return struct.pack(">I128s", random_bytes_size, random_bytes)

    def _tpm12_op_auth_req_body(self, operator_auth: bytes) -> bytes:
        """Build a TPM 1.2 SetOperatorAuth request body."""
        self._require_version("1.2")
        return struct.pack(">20s", operator_auth)

    # -------------------------------------------------
    # Version-dispatching wrappers (backwards compat)
    # -------------------------------------------------

    def _tpm_pcr_read_req_body(self, pcr_index: int = 0) -> bytes:
        if self.version == "2.0":
            raise NotImplementedError(
                "TPM 2.0 PCR_Read uses the tpm20 cartridge; "
                "these helpers target TPM 1.2 wire format only"
            )
        return self._tpm12_pcr_read_req_body(pcr_index)

    def _tpm_pcr_read_resp_body(self, out_digest: bytes) -> bytes:
        if self.version == "2.0":
            raise NotImplementedError("TPM 2.0 PCR_Read uses the tpm20 cartridge")
        return self._tpm12_pcr_read_resp_body(out_digest)

    def _tpm_pcr_extend_req_body(self, pcr_index: int, in_digest: bytes) -> bytes:
        if self.version == "2.0":
            raise NotImplementedError("TPM 2.0 PCR_Extend uses the tpm20 cartridge")
        return self._tpm12_pcr_extend_req_body(pcr_index, in_digest)

    def _tpm_pcr_extend_resp_body(self, out_digest: bytes) -> bytes:
        if self.version == "2.0":
            raise NotImplementedError("TPM 2.0 PCR_Extend uses the tpm20 cartridge")
        return self._tpm12_pcr_extend_resp_body(out_digest)

    def _tpm_get_rnd_req_body(self, num_bytes: int) -> bytes:
        if self.version == "2.0":
            raise NotImplementedError("TPM 2.0 GetRandom uses the tpm20 cartridge")
        return self._tpm12_get_rnd_req_body(num_bytes)

    def _tpm_get_rnd_resp_body(
        self, random_bytes_size: int, random_bytes: bytes
    ) -> bytes:
        if self.version == "2.0":
            raise NotImplementedError("TPM 2.0 GetRandom uses the tpm20 cartridge")
        return self._tpm12_get_rnd_resp_body(random_bytes_size, random_bytes)

    def _tpm_op_auth_req_body(self, operator_auth: bytes) -> bytes:
        if self.version == "2.0":
            raise NotImplementedError("TPM 2.0 auth uses the tpm20 cartridge")
        return self._tpm12_op_auth_req_body(operator_auth)

__init__(device_path='/dev/tpm0', name='', pins={}, pType=PeripheralType.TPM, version='2.0', vulnerabilities=None)

Initialize TPM peripheral with pin mappings, version, and type.

Parameters:

Name Type Description Default
device_path str

Path to the TPM device file.

'/dev/tpm0'
name str

Name of the TPM peripheral.

''
pins Dict[Any, Any]

Dictionary mapping pin names to their values.

{}
pType PeripheralType

Type of the peripheral, defaults to PeripheralType.TPM.

TPM
version Literal['1.2', '2.0']

TPM spec version, defaults to "2.0".

'2.0'
vulnerabilities Optional[List[Vulnerability | dict[str, Any]]]

Optional list of known vulnerabilities.

None
Source code in wintermute/peripherals.py
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
def __init__(
    self,
    device_path: str = "/dev/tpm0",
    name: str = "",
    pins: Dict[Any, Any] = {},
    pType: PeripheralType = PeripheralType.TPM,
    version: Literal["1.2", "2.0"] = "2.0",
    vulnerabilities: Optional[List[Vulnerability | dict[str, Any]]] = None,
) -> None:
    """Initialize TPM peripheral with pin mappings, version, and type.

    Args:
        device_path (str): Path to the TPM device file.
        name (str): Name of the TPM peripheral.
        pins (Dict[Any, Any]): Dictionary mapping pin names to their values.
        pType (PeripheralType): Type of the peripheral, defaults to PeripheralType.TPM.
        version (Literal["1.2", "2.0"]): TPM spec version, defaults to "2.0".
        vulnerabilities: Optional list of known vulnerabilities.
    """
    self.version: Literal["1.2", "2.0"] = version
    super().__init__(
        device_path, name, pins, pType, vulnerabilities=vulnerabilities
    )
    log.info(f"Initialized TPM {version} peripheral {name} at {device_path}")

TPM12_Commands

Bases: Enum

TPM 1.2 command ordinals used by the hardware interposer.

Source code in wintermute/peripherals.py
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
class TPM12_Commands(Enum):
    """TPM 1.2 command ordinals used by the hardware interposer."""

    TPM_ORD_OIAP = 0x0A
    TPM_ORD_OSAP = 0x0B
    TPM_ORD_TakeOwnership = 0x0D
    TPM_ORD_Extend = 0x14
    TPM_ORD_PcrRead = 0x15
    TPM_ORD_GetRandom = 0x46
    TPM_ORD_SelfTest = 0x50
    TPM_ORD_ContinueSelfTest = 0x53
    TPM_ORD_OwnerClear = 0x5B
    TPM_ORD_GetCapability = 0x65
    TPM_ORD_GetCapabilityOwner = 0x66
    TPM_ORD_OwnerSetDisable = 0x6E
    TPM_ORD_PhysicalEnable = 0x6F
    TPM_ORD_SetOwnerInstall = 0x71
    TPM_ORD_PhysicalSetDeactivated = 0x72
    TPM_ORD_SetOperatorAuth = 0x74
    TPM_ORD_ReadPubek = 0x7C
    TPM_ORD_OwnerReadInternalPub = 0x81
    TPM_ORD_Startup = 0x99
    TPM_ORD_FlushSpecific = 0xBA
    TPM_ORD_NV_ReadValue = 0xCF
    TSC_ORD_PhysicalPresence = 0x4000000A

UART

Bases: Peripheral

Class that defines the UART interface

Examples:

>>> pins = {"tx": "P1", "rx": "P2", "gnd": "GND"}
>>> u = UART(name="dbg", pins=pins, comPort="/dev/ttyUSB0")
>>> print(u)
name='dbg' pins={'tx': 'P1', 'rx': 'P2', 'gnd': 'GND'} pType=<PeripheralType.UART: 1>
>>> print(u.tx, u.rx, u.gnd)
P1 P2 GND
>>> print(u.baudrate, u.bytesize, u.parity, u.stopbits)
9600 8 N 1

Attributes:

Name Type Description
name str

Name of the peripheral

pins Dict[Any, Any]

Dictionary of pin names to their values

pType PeripheralType

Type of the peripheral

tx str

Pin name for TX

rx str

Pin name for RX

gnd str

Pin name for GND

baudrate int

Baud rate for UART communication

bytesize int

Number of data bits

parity str

Parity bit setting ('N', 'E', 'O')

stopbits int

Number of stop bits

com_port str

Port connected to the user's device to speak to the UART

Source code in wintermute/peripherals.py
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
class UART(Peripheral):
    """Class that defines the UART interface

    Examples:
        >>> pins = {"tx": "P1", "rx": "P2", "gnd": "GND"}
        >>> u = UART(name="dbg", pins=pins, comPort="/dev/ttyUSB0")
        >>> print(u)
        name='dbg' pins={'tx': 'P1', 'rx': 'P2', 'gnd': 'GND'} pType=<PeripheralType.UART: 1>
        >>> print(u.tx, u.rx, u.gnd)
        P1 P2 GND
        >>> print(u.baudrate, u.bytesize, u.parity, u.stopbits)
        9600 8 N 1

    Attributes:
        name (str): Name of the peripheral
        pins (Dict[Any, Any]): Dictionary of pin names to their values
        pType (PeripheralType): Type of the peripheral
        tx (str): Pin name for TX
        rx (str): Pin name for RX
        gnd (str): Pin name for GND
        baudrate (int): Baud rate for UART communication
        bytesize (int): Number of data bits
        parity (str): Parity bit setting ('N', 'E', 'O')
        stopbits (int): Number of stop bits
        com_port (str): Port connected to the user's device to speak to the UART

    """

    def __init__(
        self,
        device_path: str = "",
        name: str = "",
        pins: Dict[Any, Any] = {},
        pType: PeripheralType = PeripheralType.UART,
        baudrate: int = 9600,
        bytesize: int = 8,
        parity: str = "N",
        stopbits: int = 1,
        comPort: str = "",
        vulnerabilities: Optional[List[Vulnerability | dict[str, Any]]] = None,
    ) -> None:
        self.baudrate = baudrate
        self.bytesize = bytesize
        self.parity = parity
        self.stopbits = stopbits
        self.pType = pType
        self.com_port = (
            device_path or comPort
        )  # Port connected to the user's device to speak to the UART

        super().__init__(
            device_path=self.com_port,
            name=name,
            pins=pins,
            pType=pType,
            vulnerabilities=vulnerabilities,
        )
        log.info(
            f"Initialized UART peripheral {name} on port {self.com_port} with baudrate {baudrate}"
        )

USB

Bases: Peripheral

Class that defines the USB interface

Source code in wintermute/peripherals.py
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
class USB(Peripheral):
    """Class that defines the USB interface"""

    def __init__(
        self,
        device_path: str = "",
        name: str = "",
        pins: Dict[Any, Any] = {},
        pType: PeripheralType = PeripheralType.USB,
        version: str = "2.0",
        speed: str = "480Mbps",
        role: str = "host",
        vulnerabilities: Optional[List[Vulnerability | dict[str, Any]]] = None,
    ) -> None:
        self.pType = pType
        self.version = version
        self.speed = speed
        self.role = role

        super().__init__(
            device_path, name, pins, pType, vulnerabilities=vulnerabilities
        )
        log.info(
            f"Initialized USB peripheral {name} with version {version}, speed {speed}, role {role}"
        )

Wifi

Bases: Peripheral

Class that defines the Wifi interface

Source code in wintermute/peripherals.py
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
class Wifi(Peripheral):
    """Class that defines the Wifi interface"""

    def __init__(
        self,
        device_path: str = "wlan0",
        name: str = "",
        pins: Dict[Any, Any] = {},
        pType: PeripheralType = PeripheralType.Wifi,
        SSID: str = "",
        password: str = "",
        encryption: str = "WPA2",
        band: str = "2.4GHz",
        ipaddress: str
        | ipaddress.IPv4Address
        | ipaddress.IPv6Address
        | None = "127.0.0.1",
        vulnerabilities: Optional[List[Vulnerability | dict[str, Any]]] = None,
    ) -> None:
        self.pType = pType
        self.SSID = SSID
        self.password = password
        self.encryption = encryption
        self.band = band
        self.ipaddress = ipaddress

        super().__init__(
            device_path, name, pins, pType, vulnerabilities=vulnerabilities
        )
        log.info(f"Initialized Wifi peripheral {name} with SSID {SSID} on band {band}")