74 lines
1.2 KiB
Markdown
Executable File
74 lines
1.2 KiB
Markdown
Executable File
# Let's All Love UART — Solution
|
|
|
|
**Difficulty:** Easy | **Category:** IoT | **Flag:** `ESPILON{LAIN_TrUsT_U4RT}`
|
|
|
|
## Overview
|
|
|
|
The challenge emulates a split UART interface on a Lain router:
|
|
|
|
- **TX (port 1111)**: Read only — device output
|
|
- **RX (port 2222)**: Write only — send commands
|
|
|
|
## Steps
|
|
|
|
1. Open two terminals:
|
|
|
|
```bash
|
|
# Terminal 1 — read device output
|
|
nc <host> 1111
|
|
|
|
# Terminal 2 — send commands
|
|
nc <host> 2222
|
|
```
|
|
|
|
1. On the RX terminal, send the `flag` command:
|
|
|
|
```text
|
|
flag
|
|
```
|
|
|
|
1. The flag prints on the TX terminal:
|
|
|
|
```text
|
|
ESPILON{LAIN_TrUsT_U4RT}
|
|
```
|
|
|
|
## Solver Script
|
|
|
|
```python
|
|
#!/usr/bin/env python3
|
|
import socket
|
|
import threading
|
|
|
|
HOST = "<host>"
|
|
TX_PORT = 1111
|
|
RX_PORT = 2222
|
|
|
|
def reader():
|
|
with socket.create_connection((HOST, TX_PORT)) as s:
|
|
while True:
|
|
data = s.recv(4096)
|
|
if not data:
|
|
break
|
|
out = data.decode(errors="replace")
|
|
print(out, end="")
|
|
if "ESPILON{" in out:
|
|
break
|
|
|
|
tx_thread = threading.Thread(target=reader, daemon=True)
|
|
tx_thread.start()
|
|
|
|
with socket.create_connection((HOST, RX_PORT)) as s:
|
|
s.sendall(b"flag\n")
|
|
|
|
tx_thread.join()
|
|
```
|
|
|
|
## Flag
|
|
|
|
`ESPILON{LAIN_TrUsT_U4RT}`
|
|
|
|
## Author
|
|
|
|
Eun0us
|