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 | |
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 |
pType |
PeripheralType
|
Type of the peripheral, defaults to
|
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 | |
__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'
|
name
|
str
|
Name of the CAN peripheral. |
''
|
pins
|
Dict[Any, Any]
|
Dictionary mapping pin names to their values.
Expected keys include |
{}
|
pType
|
PeripheralType
|
Peripheral type, defaults to
|
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 | |
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 | |
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 |
pType |
PeripheralType
|
Type of the peripheral, defaults to
|
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 | |
__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., |
''
|
name
|
str
|
Name of the I2C peripheral. |
''
|
pins
|
Dict[Any, Any]
|
Dictionary mapping pin names to their values.
Expected keys include |
{}
|
pType
|
PeripheralType
|
Peripheral type, defaults to
|
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 | |
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 | |
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 | |
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 |
pType |
PeripheralType
|
Type of the peripheral, defaults to
|
form_factor |
str
|
Module form factor, e.g., |
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., |
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 | |
__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 |
{}
|
pType
|
PeripheralType
|
Peripheral type, defaults to
|
SFP
|
form_factor
|
str
|
Module form factor ( |
'SFP'
|
wavelength
|
int
|
Optical wavelength in nanometers. Defaults to 850. |
850
|
media
|
str
|
Physical media type ( |
'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 | |
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 |
pType |
PeripheralType
|
Type of the peripheral, defaults to
|
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
|
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 | |
__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., |
''
|
name
|
str
|
Name of the SPI peripheral. |
''
|
pins
|
Dict[Any, Any]
|
Dictionary mapping pin names to their values.
Expected keys include |
{}
|
pType
|
PeripheralType
|
Peripheral type, defaults to
|
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'
|
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 | |
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 | |
__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 | |
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 | |
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 | |
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 | |
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 | |