Anna Antonenko, who specializes in embedded systems development and also works on the BOSS (BEAM-based Operating System with Security) in her spare time, published the results of reverse engineering the Yamaha PSR-E433 synthesizer. During her 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 the synthesizer is connected via USB port. The insights gained from the reverse engineering regarding the chip and firmware, as well as code samples and debugging dumps, are available on GitHub.
Interest in reverse engineering arose a few years ago when Anna decided to clean the synthesizer's insides of dust and satisfy her curiosity by wanting to see the device's internals. The board contained the YAMAHA SWL01U chip, about which detailed information could not be found online. A couple of months ago, Anna came across a manual for a similar model of synthesizer that included the pinout for this chip. Anna disassembled the device once again and began experiments using the available pins on the board for the JTAG debugging interface and the UART port.

Using the OpenOCD debugger, connecting to JTAG, and conducting experiments revealed that the board uses a chip with an ARM7TDMI core. By studying the memory layout in the debugger, it was possible to dump the contents of the firmware stored in the ROM and Flash memory. After that, the firmware images were analyzed using the Ghidra reverse engineering tool.
Vaadates pĂŒsivara eraldatud tekstilisi andmeid, on mĂ€rgatud hulka stringe («help, «info», «ver», «logout» jne), mis meenutavad kĂ€surea kĂ€sku. Nende stringide viidatud uurimine vĂ”imaldas leida koodi, mis kutsub esile funktsioone kĂ€skude töötlemiseks, meenutades sisenemisliidest ja kĂ€surea liidest. Samuti leiti, et liidese aktiveerimiseks on ette nĂ€htud kĂ€sk «login», millele tuleb edastada parool «#0000». void shell_run_command(char* command_input) { if (shell_login_state == 0) { if (shell_compare_command(command_input, «login») == 0) { shell_ask_passwd(); // prindib «passwd? » shell_login_state = 1; } } else if (shell_login_state == 1) { if (shell_compare_command(command_input, «#0000») == 0) { shell_login_ok(); // prindib «login OK» shell_login_state = 2; } else { shell_print(«Passwd Error\r»); shell_login_state = 0; } } else { // teostage kĂ€sk } }
PĂŒsivara edasine uurimine nĂ€itas, et kĂ€ske töödeldakse pakettidena, mis algavad alati samade 8 baitide andmetega ja lĂ”ppevad koodiga 0xf7. Kuna vĂ€line suhtlemine sĂŒnteesijaga toimub ainult lĂ€bi MIDI ja MIDI spetsifikatsioonis on ette nĂ€htud eriline teenindustĂŒĂŒp SysEx sĂ”numite jaoks, arvati, et just seda vĂ”iks kasutada kĂ€skude edastamiseks. Oletust kinnitas ka see, et SysEx sĂ”numid ja liideses tĂ”lgitavad paketid algasid ĂŒhe koodiga 0xf0, millele jĂ€rgnes tootja identifikaator 0x43 (Yamaha).
HĂŒpoteesi testimiseks kirjutati Python-skript, mis tĂ”lkis sisendandmed MIDI protokolli pakettideks. Ja meetod töötas: 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 >
KĂ€sku «help» saates kuvatud vihkes, muu hulgas sisaldusid kĂ€sud mĂ€lusisule muutmiseks. Nende kĂ€skude abil oli vĂ”imalik laadida mĂ€lu suvaline kood ja edastada sellele juhtimine, asendades tagasikutsumise pĂ€rast kĂ€su tĂ€itmist stack'i kasutatava nĂ€idiku. Eksperimendi kĂ€igus paigutati kasutamata mĂ€lupiirkonda assamblee keeles kirjutatud lihtne rakendus, mis kuvab âHeloWrldâ 8-tĂ€helisel LCD-ekraanil. Programm oli vormistatud tavalise MIDI-failina, mille edastamine seadmesse oli piisav.

PĂ€rast seda algas töö graafika vĂ€ljundite uurimise kallal LCD-ekraanile, mille kulminatsiooniks oli koodi ettevalmistamine, mis kuvaks suvalist pikslisisut sĂŒnkroonselt koos Bad Apple video esitamisega vĂ€lisseadmest (demovideo).


Allikas: opennet.ru
