-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprint_serial.py
51 lines (40 loc) · 1.21 KB
/
print_serial.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# @file list_tool.py
# @author Frederich Stine
# @brief host tool for listing installed components
# @date 2024
#
# This source file is part of an example system for MITRE's 2024 Embedded CTF (eCTF).
# This code is being provided only for educational purposes for the 2024 MITRE eCTF
# competition, and may not meet MITRE standards for quality. Use this code at your
# own risk!
#
# @copyright Copyright (c) 2024 The MITRE Corporation
import argparse
import serial
# List function
def listen(args):
ser = serial.Serial(
port=args.application_processor,
baudrate=115200,
parity=serial.PARITY_NONE,
stopbits=serial.STOPBITS_ONE,
bytesize=serial.EIGHTBITS,
)
# Receive messages until done
while True:
byte = ser.read()
char = byte.decode("utf-8")
print(char, end='')
# Main function
def main():
parser = argparse.ArgumentParser(
prog="eCTF List Host Tool",
description="List the components connected to the medical device",
)
parser.add_argument(
"-a", "--application-processor", required=True, help="Serial device of the AP"
)
args = parser.parse_args()
listen(args)
if __name__ == "__main__":
main()