16 KiB
UART
{% hint style="success" %}
Learn & practice AWS Hacking:HackTricks Training AWS Red Team Expert (ARTE)
Learn & practice GCP Hacking: HackTricks Training GCP Red Team Expert (GRTE)
Support HackTricks
- Check the subscription plans!
- Join the ð¬ Discord group or the telegram group or follow us on Twitter ðŠ @hacktricks_live.
- Share hacking tricks by submitting PRs to the HackTricks and HackTricks Cloud github repos.
åºæ¬æ å ±
UARTã¯ã·ãªã¢ã«ãããã³ã«ã§ãããã³ã³ããŒãã³ãéã§ããŒã¿ã1ããããã€è»¢éããŸããå¯Ÿç §çã«ã䞊åéä¿¡ãããã³ã«ã¯è€æ°ã®ãã£ãã«ãéããŠããŒã¿ãåæã«éä¿¡ããŸããäžè¬çãªã·ãªã¢ã«ãããã³ã«ã«ã¯ãRS-232ãI2CãSPIãCANãEthernetãHDMIãPCI Expressãããã³USBããããŸãã
äžè¬çã«ãUARTãã¢ã€ãã«ç¶æ ã®ãšããã©ã€ã³ã¯é«ãç¶æ ïŒè«ç1å€ïŒã«ä¿ãããŸãã次ã«ãããŒã¿è»¢éã®éå§ã瀺ãããã«ãéä¿¡è ã¯åä¿¡è ã«ã¹ã¿ãŒãããããéä¿¡ãããã®éãä¿¡å·ã¯äœãç¶æ ïŒè«ç0å€ïŒã«ä¿ãããŸãã次ã«ãéä¿¡è ã¯å®éã®ã¡ãã»ãŒãžãå«ã5ã8ãããã®ããŒã¿ãéä¿¡ãããªãã·ã§ã³ã®ããªãã£ããããš1ãŸãã¯2ã®ã¹ããããããïŒè«ç1å€ïŒãç¶ããŸãããšã©ãŒãã§ãã¯ã«äœ¿çšãããããªãã£ãããã¯ãå®éã«ã¯ã»ãšãã©èŠãããŸãããã¹ããããããïŒãŸãã¯ãããïŒã¯ãéä¿¡ã®çµäºã瀺ããŸãã
æãäžè¬çãªæ§æã8N1ãšåŒã³ãŸãïŒ8ãããã®ããŒã¿ãããªãã£ãªãã1ã€ã®ã¹ãããããããããšãã°ãCãšããæåããŸãã¯ASCIIã§0x43ã8N1 UARTæ§æã§éä¿¡ãããå Žåã次ã®ããããéä¿¡ããŸãïŒ0ïŒã¹ã¿ãŒããããïŒïŒ0ã1ã0ã0ã0ã0ã1ã1ïŒ0x43ã®ãã€ããªå€ïŒãããã³0ïŒã¹ããããããïŒã
UARTãšéä¿¡ããããã®ããŒããŠã§ã¢ããŒã«ïŒ
- USB-to-serialã¢ããã¿
- CP2102ãŸãã¯PL2303ããããæèŒããã¢ããã¿
- Bus PirateãAdafruit FT232HãShikraããŸãã¯Attify Badgeãªã©ã®å€ç®çããŒã«
UARTããŒãã®ç¹å®
UARTã«ã¯4ã€ã®ããŒãããããŸãïŒTXïŒéä¿¡ïŒãRXïŒåä¿¡ïŒãVccïŒé»å§ïŒãããã³GNDïŒæ¥å°ïŒãPCBã«**TX
ããã³RX
ã®æåãæžãããŠãã4ã€ã®ããŒããèŠã€ããããšãã§ãããããããŸããããããã衚瀺ããªãå Žåã¯ããã«ãã¡ãŒã¿ãŒãããžãã¯ã¢ãã©ã€ã¶ãŒ**ã䜿çšããŠèªåã§èŠã€ããå¿
èŠããããããããŸããã
ãã«ãã¡ãŒã¿ãŒã䜿çšããããã€ã¹ã®é»æºãåã£ãç¶æ ã§ïŒ
- GNDãã³ãç¹å®ããã«ã¯ãé£ç¶æ§ãã¹ãã¢ãŒãã䜿çšããããã¯ãªãŒããæ¥å°ã«çœ®ããèµ€ããªãŒãã§ãã¹ãããŸãããã«ãã¡ãŒã¿ãŒããé³ãèããããŸã§ç¶ããŸããPCBã«ã¯è€æ°ã®GNDãã³ããããããUARTã«å±ãããã®ãèŠã€ãããã©ããã¯ããããŸããã
- VCCããŒããç¹å®ããã«ã¯ãDCé»å§ã¢ãŒããèšå®ãã20Vã®é»å§ã«èšå®ããŸããé»ããããŒããæ¥å°ã«ãèµ€ããããŒãããã³ã«æ¥ç¶ããŸããããã€ã¹ã®é»æºãå ¥ããŸãããã«ãã¡ãŒã¿ãŒã3.3VãŸãã¯5Vã®äžå®ã®é»å§ã枬å®ããå ŽåãVccãã³ãèŠã€ããããšã«ãªããŸããä»ã®é»å§ãåŸãããå Žåã¯ãä»ã®ããŒãã§åè©Šè¡ããŸãã
- TX ããŒããç¹å®ããã«ã¯ãDCé»å§ã¢ãŒãã20Vã®é»å§ã«èšå®ããé»ããããŒããæ¥å°ã«ãèµ€ããããŒãããã³ã«æ¥ç¶ããããã€ã¹ã®é»æºãå ¥ããŸããé»å§ãæ°ç§éå€åãããã®åŸVccå€ã§å®å®ããå ŽåãTXããŒããèŠã€ããå¯èœæ§ãé«ãã§ããããã¯ãé»æºãå ¥ãããšãããã°ããŒã¿ãéä¿¡ãããããã§ãã
- RXããŒãã¯ä»ã®3ã€ã«æãè¿ããé»å§ã®å€åãæãå°ãªãããã¹ãŠã®UARTãã³ã®äžã§æãäœãå šäœçãªå€ãæã£ãŠããŸãã
TXããŒããšRXããŒããæ··åããŠãäœãèµ·ãããŸããããGNDããŒããšVCCããŒããæ··åãããšåè·¯ãå£ããå¯èœæ§ããããŸãã
äžéšã®ã¿ãŒã²ããããã€ã¹ã§ã¯ã補é å ã«ãã£ãŠRXãŸãã¯TXããŸãã¯äž¡æ¹ãç¡å¹ã«ãããŠããå ŽåããããŸãããã®å Žåãåè·¯åºæ¿å ã®æ¥ç¶ã远跡ãããã¬ãŒã¯ã¢ãŠããã€ã³ããèŠã€ããããšã圹ç«ã¡ãŸããUARTã®æ€åºã確èªã§ãããåè·¯ãå£ããŠããããšã確èªãã匷ãæãããã¯ãããã€ã¹ã®ä¿èšŒã確èªããããšã§ããããã€ã¹ãä¿èšŒä»ãã§åºè·ãããŠããå Žåã補é å ã¯ãããã°ã€ã³ã¿ãŒãã§ãŒã¹ïŒãã®å Žåã¯UARTïŒãæ®ããŠããããããã£ãŠUARTãåæãããããã°äžã«åæ¥ç¶ããå¿ èŠããããŸãããããã®ãã¬ãŒã¯ã¢ãŠããã³ã¯ãã¯ãã ä»ããŸãã¯ãžã£ã³ããŒã¯ã€ã€ãŒã§æ¥ç¶ã§ããŸãã
UARTããŒã¬ãŒãã®ç¹å®
æ£ããããŒã¬ãŒããç¹å®ããæãç°¡åãªæ¹æ³ã¯ãTXãã³ã®åºåãèŠãŠããŒã¿ãèªã¿åãããšã§ããåä¿¡ããããŒã¿ãèªã¿åããªãå Žåã¯ã次ã®å¯èœãªããŒã¬ãŒãã«åãæ¿ããŠãããŒã¿ãèªã¿åããããã«ãªããŸã§ç¶ããŸãããããè¡ãã«ã¯ãUSB-to-serialã¢ããã¿ãBus Pirateã®ãããªå€ç®çããã€ã¹ã䜿çšããbaudrate.pyã®ãããªãã«ããŒã¹ã¯ãªãããšçµã¿åãããããšãã§ããŸããæãäžè¬çãªããŒã¬ãŒãã¯9600ã38400ã19200ã57600ãããã³115200ã§ãã
{% hint style="danger" %} ãã®ãããã³ã«ã§ã¯ã1ã€ã®ããã€ã¹ã®TXãä»ã®ããã€ã¹ã®RXã«æ¥ç¶ããå¿ èŠãããããšã«æ³šæããŠãã ããïŒ {% endhint %}
CP210X UART to TTYã¢ããã¿
CP210Xãããã¯ãNodeMCUïŒesp8266æèŒïŒãªã©ã®å€ãã®ãããã¿ã€ãã³ã°ããŒãã§ã·ãªã¢ã«éä¿¡ã«äœ¿çšãããŸãããããã®ã¢ããã¿ã¯æ¯èŒçå®äŸ¡ã§ãã¿ãŒã²ããã®UARTã€ã³ã¿ãŒãã§ãŒã¹ã«æ¥ç¶ããããã«äœ¿çšã§ããŸããããã€ã¹ã«ã¯5ã€ã®ãã³ããããŸãïŒ5VãGNDãRXDãTXDã3.3Vãã¿ãŒã²ããããµããŒãããé»å§ã«æ¥ç¶ããŠãæå·ãé¿ããããã«ããŠãã ãããæåŸã«ãã¢ããã¿ã®RXDãã³ãã¿ãŒã²ããã®TXDã«ãã¢ããã¿ã®TXDãã³ãã¿ãŒã²ããã®RXDã«æ¥ç¶ããŸãã
ã¢ããã¿ãæ€åºãããªãå Žåã¯ããã¹ãã·ã¹ãã ã«CP210Xãã©ã€ããã€ã³ã¹ããŒã«ãããŠããããšã確èªããŠãã ãããã¢ããã¿ãæ€åºãããŠæ¥ç¶ããããšãpicocomãminicomããŸãã¯screenãªã©ã®ããŒã«ã䜿çšã§ããŸãã
Linux/MacOSã·ã¹ãã ã«æ¥ç¶ãããŠããããã€ã¹ããªã¹ãããã«ã¯ïŒ
ls /dev/
UARTã€ã³ã¿ãŒãã§ãŒã¹ãšã®åºæ¬çãªã€ã³ã¿ã©ã¯ã·ã§ã³ã«ã¯ã次ã®ã³ãã³ãã䜿çšããŸãïŒ
picocom /dev/<adapter> --baud <baudrate>
minicomã®èšå®ã«ã¯ã次ã®ã³ãã³ãã䜿çšããŸãïŒ
minicom -s
èšå®ã§ããŒã¬ãŒããããã€ã¹åãSerial port setup
ãªãã·ã§ã³ã§æ§æããŸãã
æ§æåŸãminicom
ã³ãã³ãã䜿çšããŠUARTã³ã³ãœãŒã«ãèµ·åããŸãã
Arduino UNO R3ãä»ããUARTïŒåãå€ãå¯èœãªAtmel 328pãããããŒãïŒ
UARTã·ãªã¢ã«ããUSBã¢ããã¿ãå©çšã§ããªãå ŽåãArduino UNO R3ã䜿ã£ãŠç°¡åã«ããã¯ã§ããŸããArduino UNO R3ã¯éåžžã©ãã§ãå ¥æå¯èœãªãããããã«ããå€ãã®æéãç¯çŽã§ããŸãã
Arduino UNO R3ã«ã¯ãããŒãèªäœã«USBããã·ãªã¢ã«ãžã®ã¢ããã¿ãçµã¿èŸŒãŸããŠããŸããUARTæ¥ç¶ãåŸãã«ã¯ãããŒãããAtmel 328pãã€ã¯ãã³ã³ãããŒã©ãŒããããæãåºãã ãã§ãããã®ããã¯ã¯ãAtmel 328pãããŒãã«ãã³ãä»ããããŠããªãArduino UNO R3ã®ããªã¢ã³ãïŒSMDããŒãžã§ã³ã䜿çšãããŠããŸãïŒã§æ©èœããŸããArduinoã®RXãã³ïŒããžã¿ã«ãã³0ïŒãUARTã€ã³ã¿ãŒãã§ãŒã¹ã®TXãã³ã«æ¥ç¶ããArduinoã®TXãã³ïŒããžã¿ã«ãã³1ïŒãUARTã€ã³ã¿ãŒãã§ãŒã¹ã®RXãã³ã«æ¥ç¶ããŸãã
æåŸã«ãã·ãªã¢ã«ã³ã³ãœãŒã«ãååŸããããã«Arduino IDEã䜿çšããããšããå§ãããŸããã¡ãã¥ãŒã®tools
ã»ã¯ã·ã§ã³ã§Serial Console
ãªãã·ã§ã³ãéžæããUARTã€ã³ã¿ãŒãã§ãŒã¹ã«å¿ããŠããŒã¬ãŒããèšå®ããŸãã
Bus Pirate
ãã®ã·ããªãªã§ã¯ãããã°ã©ã ã®ãã¹ãŠã®åºåãã·ãªã¢ã«ã¢ãã¿ãŒã«éä¿¡ããŠããArduinoã®UARTéä¿¡ãã¹ãããã£ã³ã°ããŸãã
# Check the modes
UART>m
1. HiZ
2. 1-WIRE
3. UART
4. I2C
5. SPI
6. 2WIRE
7. 3WIRE
8. KEYB
9. LCD
10. PIC
11. DIO
x. exit(without change)
# Select UART
(1)>3
Set serial port speed: (bps)
1. 300
2. 1200
3. 2400
4. 4800
5. 9600
6. 19200
7. 38400
8. 57600
9. 115200
10. BRG raw value
# Select the speed the communication is occurring on (you BF all this until you find readable things)
# Or you could later use the macro (4) to try to find the speed
(1)>5
Data bits and parity:
1. 8, NONE *default
2. 8, EVEN
3. 8, ODD
4. 9, NONE
# From now on pulse enter for default
(1)>
Stop bits:
1. 1 *default
2. 2
(1)>
Receive polarity:
1. Idle 1 *default
2. Idle 0
(1)>
Select output type:
1. Open drain (H=Hi-Z, L=GND)
2. Normal (H=3.3V, L=GND)
(1)>
Clutch disengaged!!!
To finish setup, start up the power supplies with command 'W'
Ready
# Start
UART>W
POWER SUPPLIES ON
Clutch engaged!!!
# Use macro (2) to read the data of the bus (live monitor)
UART>(2)
Raw UART input
Any key to exit
Escritura inicial completada:
AAA Hi Dreg! AAA
waiting a few secs to repeat....
UARTã³ã³ãœãŒã«ã䜿çšãããã¡ãŒã ãŠã§ã¢ã®ãã³ã
UARTã³ã³ãœãŒã«ã¯ãã©ã³ã¿ã€ã ç°å¢ã§åºç€ãšãªããã¡ãŒã ãŠã§ã¢ãæäœããããã®åªããæ¹æ³ãæäŸããŸããããããUARTã³ã³ãœãŒã«ã®ã¢ã¯ã»ã¹ãèªã¿åãå°çšã®å Žåãå€ãã®å¶çŽãçããå¯èœæ§ããããŸããå€ãã®çµã¿èŸŒã¿ããã€ã¹ã§ã¯ããã¡ãŒã ãŠã§ã¢ã¯EEPROMã«ä¿åãããæ®çºæ§ã¡ã¢ãªãæã€ããã»ããµã§å®è¡ãããŸãããããã£ãŠãå ã®ãã¡ãŒã ãŠã§ã¢ã補é æã«EEPROMèªäœã«ããããããã¡ãŒã ãŠã§ã¢ã¯èªã¿åãå°çšã®ãŸãŸä¿æãããæ°ãããã¡ã€ã«ã¯æ®çºæ§ã¡ã¢ãªã®ããã«å€±ãããããšã«ãªããŸãããããã£ãŠãçµã¿èŸŒã¿ãã¡ãŒã ãŠã§ã¢ãæ±ãéã«ãã¡ãŒã ãŠã§ã¢ããã³ãããããšã¯è²Žéãªåªåã§ãã
ãããè¡ãæ¹æ³ã¯ãããããããSPIã»ã¯ã·ã§ã³ã§ã¯ããŸããŸãªããã€ã¹ã䜿çšããŠEEPROMããçŽæ¥ãã¡ãŒã ãŠã§ã¢ãæœåºããæ¹æ³ã説æããŠããŸãããã ããç©çããã€ã¹ãå€éšã€ã³ã¿ã©ã¯ã·ã§ã³ã䜿çšããŠãã¡ãŒã ãŠã§ã¢ããã³ãããããšã¯ãªã¹ã¯ããããããæåã«UARTã䜿çšããŠãã¡ãŒã ãŠã§ã¢ããã³ãããããšããå§ãããŸãã
UARTã³ã³ãœãŒã«ãããã¡ãŒã ãŠã§ã¢ããã³ãããã«ã¯ããŸãããŒãããŒããŒã«ã¢ã¯ã»ã¹ããå¿ èŠããããŸããå€ãã®äººæ°ãã³ããŒã¯ãLinuxãããŒãããããã®ããŒãããŒããŒãšããŠubootïŒãŠãããŒãµã«ããŒãããŒããŒïŒã䜿çšããŠããŸãããããã£ãŠãubootã«ã¢ã¯ã»ã¹ããããšãå¿ èŠã§ãã
ããŒãããŒããŒã«ã¢ã¯ã»ã¹ããã«ã¯ãUARTããŒããã³ã³ãã¥ãŒã¿ã«æ¥ç¶ããä»»æã®ã·ãªã¢ã«ã³ã³ãœãŒã«ããŒã«ã䜿çšããããã€ã¹ãžã®é»æºäŸçµŠãåæããŠãããŸããã»ããã¢ãããå®äºããããEnterããŒãæŒããŠä¿æããŸããæåŸã«ãããã€ã¹ã«é»æºãæ¥ç¶ããããŒããããŸãã
ãããè¡ããšãubootã®ããŒããäžæãããã¡ãã¥ãŒã衚瀺ãããŸããubootã³ãã³ããç解ãããã«ãã¡ãã¥ãŒã䜿çšããŠãããããªã¹ãããããšããå§ãããŸãããããhelp
ã³ãã³ãã§ããå¯èœæ§ããããŸããç°ãªããã³ããŒãç°ãªãæ§æã䜿çšããŠããããããããããåå¥ã«ç解ããããšãå¿
èŠã§ãã
éåžžããã¡ãŒã ãŠã§ã¢ããã³ãããããã®ã³ãã³ãã¯æ¬¡ã®ãšããã§ãïŒ
md
ããã¯ãã¡ã¢ãªãã³ãããæå³ããŸããããã«ãããã¡ã¢ãªïŒEEPROMã³ã³ãã³ãïŒãç»é¢ã«ãã³ããããŸããã¡ã¢ãªãã³ãããã£ããã£ããããã«ãæé ãéå§ããåã«ã·ãªã¢ã«ã³ã³ãœãŒã«ã®åºåããã°ã«èšé²ããããšããå§ãããŸãã
æåŸã«ããã°ãã¡ã€ã«ããäžèŠãªããŒã¿ããã¹ãŠåé€ãããã¡ã€ã«ã filename.rom
ãšããŠä¿åããbinwalkã䜿çšããŠå
容ãæœåºããŸãïŒ
binwalk -e <filename.rom>
ããã¯ã16é²æ°ãã¡ã€ã«ã«èŠã€ãã£ã眲åã«åºã¥ããŠãEEPROMããã®å¯èœãªå 容ããªã¹ãããŸãã
ãã ãã䜿çšãããŠããå Žåã§ããubootãåžžã«ããã¯è§£é€ãããŠããããã§ã¯ãªãããšã«æ³šæããå¿ èŠããããŸããEnterããŒãäœãåå¿ããªãå Žåã¯ãã¹ããŒã¹ããŒãªã©ã®ç°ãªãããŒã確èªããŠãã ãããããŒãããŒããŒãããã¯ãããŠããŠäžæãããªãå Žåããã®æ¹æ³ã¯æ©èœããŸãããããã€ã¹ã®ããŒãããŒããŒãubootã§ãããã©ããã確èªããã«ã¯ãããã€ã¹ã®ããŒãäžã«UARTã³ã³ãœãŒã«ã®åºåã確èªããŠãã ãããããŒãäžã«ubootãšè¡šç€ºããããããããŸããã
{% hint style="success" %}
AWSãããã³ã°ãåŠã³ãç·Žç¿ããïŒHackTricks Training AWS Red Team Expert (ARTE)
GCPãããã³ã°ãåŠã³ãç·Žç¿ããïŒHackTricks Training GCP Red Team Expert (GRTE)
HackTricksããµããŒããã
- ãµãã¹ã¯ãªãã·ã§ã³ãã©ã³ã確èªããŠãã ããïŒ
- **ð¬ Discordã°ã«ãŒããŸãã¯ãã¬ã°ã©ã ã°ã«ãŒãã«åå ããããTwitter ðŠ @hacktricks_liveããã©ããŒããŠãã ããã
- HackTricksããã³HackTricks Cloudã®githubãªããžããªã«PRãæåºããŠãããã³ã°ããªãã¯ãå ±æããŠãã ããã