Hidden shell in the Yamaha synthesizer that allowed code execution via MIDI

Anna Antonenko, who specializes in embedded system development and, in her spare time, is developing the BOSS (BEAM-based Operating System with Security) operating system, published the results of reverse engineering the Yamaha PSR-E433 synthesizer. During the work, an obfuscated shell interface was discovered in the synthesizer, allowing the execution of custom code at the firmware level. Access to the shell interface is achieved by sending MIDI packets with SysEx messages, which can be transmitted when connecting the synthesizer via USB. The information obtained during reverse engineering about the chip and firmware, along with code examples and debugging dumps, is available on GitHub.

Interest in reverse engineering arose a few years ago when Anna decided to clean the dust from the synthesizer's insides and satisfy her curiosity about the device's internal components. The board featured a YAMAHA SWL01U chip, about which she couldn't find detailed information online. A couple of months ago, Anna came across a guide for a similar synthesizer model that included the pinout for this chip. She disassembled the device again and started experiments, utilizing the available pins for the JTAG debugging interface and the UART port.

Hidden shell in the Yamaha synthesizer that allowed code execution via MIDI

Using the OpenOCD debugger, connections to JTAG, and experimentation, it was found that the board uses a chip with an ARM7TDMI processor core. By studying the memory layout in the debugger, she managed to dump the contents of the firmware located in the ROM and Flash memory. After that, the firmware images were analyzed in the reverse engineering package Ghidra.

A kiválasztott firmware-ből nyert szöveges adatok vizsgálata során észleltünk egy parancssora hasonlító karakterlánc halmazt (pl. „help”, „info”, „ver”, „logout” stb.), amely programozási felületek parancsaira emlékeztet. E karakterláncokra mutató hivatkozások tanulmányozása lehetővé tette egy kód megismerését, amely a parancsok feldolgozásáért felelős funkciókat hívja meg, hasonlóan a belépési felülethez és a parancssorhoz. Azt is megállapítottuk, hogy a parancssor aktiválásához a „login” parancs szükséges, amelyhez a „#0000” jelszót kell megadni.void shell_run_command(char* command_input) { if (shell_login_state == 0) { if (shell_compare_command(command_input, "login") == 0) { shell_ask_passwd(); // prints "passwd? " shell_login_state = 1; } } else if (shell_login_state == 1) { if (shell_compare_command(command_input, "#0000") == 0) { shell_login_ok(); // prints "login OK" shell_login_state = 2; } else { shell_print("Passwd Error\r"); shell_login_state = 0; } } else { // actually run the command } }

A firmware további vizsgálata megmutatta, hogy a parancsokat csomagokban dolgozzák fel, amelyek mindig azonos 8 bájt adatokkal kezdődnek és a 0xf7 kóddal zárulnak. Mivel a hangszerrel való külső kommunikáció csak MIDI-n keresztül történik, és a MIDI specifikációja szerint létezik egy SysEx nevű különleges üzenettípus, feltételeztük, hogy ez használható a parancsok továbbítására. Az elgondolást az is alátámasztotta, hogy a SysEx üzenetek és a parancssor által feldolgozott csomagok 0xf0 kóddal kezdődtek, ezt követően pedig a gyártói azonosító 0x43 (Yamaha) található.

A hipotézis ellenőrzésére írtunk egy Python szkriptet, amely az adatbevitel alapján MIDI protokoll csomagokká alakította az adatokat. A módszer működött:login passwd? #0000 login OK > help logout help ? info ver stack perf-on perf-off perf-disp d dp d xxxxx d/s xxxxx m ADDRESS DATA m/b ADDRESS DATA m/w ADDRESS DATA m/l ADDRESS DATA > info DevelopName PSR-E433 DevelopNumber #3341 Main DevelopNumber #3341 Make data & time MAY 16 2012 19:00:57 J/E Select English >

A parancs „help” küldésekor megjelenő javaslatban többek között a memória tartalmának megváltoztatására vonatkozó parancsok is szerepeltek. Ezekkel a parancsokkal szabadon választható kód tölthető be a memóriába, amelynek irányítását át lehetett adni, a parancs befejezését követő visszatérési mutató felülírásával a veremben. Kísérletként egy, az üres memória területén elhelyezett, assembler nyelven írt egyszerű alkalmazást készítettek, amely a „HeloWrld” szöveget megjelenítette egy 8 karakteres LCD kijelzőn. A program egy szokásos MIDI fájl formájában került elkészítésre, amelyet csak át kellett küldeni az eszközre.

Hidden shell in the Yamaha synthesizer that allowed code execution via MIDI

Ezt követően elindult a grafika kimenetének tanulmányozása az LCD kijelzőn, amelynek csúcspontja egy olyan kód elkészítése volt, amely véletlenszerű pixeltartalmat mutatott a karakter területen, szinkronban a Bad Apple videó lejátszásával egy külső eszközön (demonstrációs videóval).

Hidden shell in the Yamaha synthesizer that allowed code execution via MIDI
Videó lejátszása


Forrás: opennet.ru
Megbízható hosting vásárlása weboldalak számára, DDoS védelemmel, VPS VDS szerverek. 🔥 Megbízható webtárhely vásárlása DDoS védelemmel, VPS VDS szerverek | ProHoster