SlideShare a Scribd company logo
SHALL WE PLAY
A GAME?
Hacking and weaponizing
the NES Classic Mini
SHALL WE PLAY A GAME?
‣ Ross (@HypnInfosec) and Dale (@dale_nunns)
‣ like retro computing and consoles
‣ also like hacking/breaking/making/fixing stuff
Who we are:
SHALL WE PLAY A GAME?
Why this talk:
‣ combination of the stuff we like
‣ good way to explore embedded device hacking
‣ relatively affordable & easily accessible
‣ fun to play with ¯_(ツ)_/¯
SHALL WE PLAY A GAME?
About the 

NES mini
SHALL WE PLAY A GAME?
About the NES Classic mini:
‣ modern remake of the NES-001 gaming console
SHALL WE PLAY A GAME?
The NES Classic mini is NOT:
‣ able to play original cartridges
‣ hard to find (available at many online retailers)
‣ "just a Raspberry Pi" (eg: RetroPie)
‣ meant to be modified/customized
SHALL WE PLAY A GAME?
About the NES Classic mini:
‣ USB powered
‣ HDMI output
‣ various models
SHALL WE PLAY A GAME?
About the NES Classic mini:
‣ comes with 30 games (roms)
‣ has a UI for selecting games to play
‣ uses custom emulator "kachikachi" to play NES ROMs
‣ coded with SDL and other open source tools
‣ see https://www.nintendo.co.jp/support/oss/
SHALL WE PLAY A GAME?
SHALL WE PLAY A GAME?
Software Hack
SHALL WE PLAY A GAME?
The "hakchi" mod/hack:
‣ initially written by "madmonkey"
‣ now on it's 3rd version: "Community Edition"
SHALL WE PLAY A GAME?
hakchi by madmonkey
SHALL WE PLAY A GAME?
hakchi2 by ClusterM
SHALL WE PLAY A GAME?
hakchi Community Edition
SHALL WE PLAY A GAME?
The "hakchi" mod/hack:
‣ changes the firmware
‣ changes startup scripts (eg: for mods)
‣ remaps paths (eg: symlinks ROM location)
‣ allows custom NES roms
SHALL WE PLAY A GAME?
allows custom NES roms
SHALL WE PLAY A GAME?
The "hakchi" mod/hack:
‣ adds some USB support via USB Host OTG adapters
‣ "90 degree" adapter seems to work well
‣ prevents Hakchi from communicating with your console
WRONG!

(left from power)
Correct

(right from power)
SHALL WE PLAY A GAME?
The "hakchi" mod/hack:
‣ USB storage - allowing more games (and emulators)
‣ formatting as NTFS seems to work best
‣ use https://github.com/swingflip/Hakchi-USB-tools
‣ not all flash drives work - but the "SanDisk 

Cruzer Blade" flash drives seem to
‣ mounts to "/media"
SHALL WE PLAY A GAME?
‣ enables ftp + ssh (login "root" with no password)
‣ host-networking on ip: 169.254.13.37 (ports 21 or 22)

(when not using OTG USB!)
The "hakchi" mod/hack:
login as: root
hakchi v1.0.4-122 by madmonkey
Special thanks to all of the contributors including: potyl, mistydemeo,

skogaby, DanTheMan827, KMFDManic, Mugi, princess_daphie, xorloser, ghoost82,

thomas-alrek, ClusterM, zigg, thomascrha and anyone else I may have forgotten
root@madmonkey:~#
SHALL WE PLAY A GAME?
Root?
"Big F*ing deal, what can you do with it"

https://twitter.com/officialmcafee/status/1025009808968171521
SHALL WE PLAY A GAME?
So What

Can We Do?
SHALL WE PLAY A GAME?
So what can we do?
‣ very few commands/tools
‣ mostly just busybox widgets
‣ let's see how far bash + busybox can take us!
SHALL WE PLAY A GAME?
‣ memory map of "kachikachi" (emulator)
Getting access to process memory
root@madmonkey:~# pgrep kachikachi

1869
root@madmonkey:~# cat /proc/1869/maps

00010000-00073000 r-xp 00000000 fe:00 292 /usr/bin/kachikachi

00083000-0008d000 rw-p 00063000 fe:00 292 /usr/bin/kachikachi

0008d000-0009d000 rw-p 00000000 00:00 0

00ebc000-00f8f000 rw-p 00000000 00:00 0 [heap]

b1e40000-b2200000 rw-s 11420000 00:05 398 /dev/mali

b5717000-b5718000 ---p 00000000 00:00 0

[...]

b5718000-b5f17000 rwxp 00000000 00:00 0 [stack:1902]

b5f17000-b5fec000 r-xp 00000000 fe:00 365 /usr/lib/libasound.so.2.0.0

b5fec000-b5ffc000 ---p 000d5000 fe:00 365 /usr/lib/libasound.so.2.0.0

b5ffc000-b6000000 rw-p 000d5000 fe:00 365 /usr/lib/libasound.so.2.0.0
SHALL WE PLAY A GAME?
Dumping heap (memory)
#!/bin/bash



# Dumps the full memory heap to disk



PID=`pgrep kachikachi`



HEAP=`cat /proc/$PID/smaps | grep heap | awk -F"-" '{print $1}'`

END=`cat /proc/$PID/smaps | grep heap | awk -F"[- ]" '{print $2}'`

HEAP_DEC=`printf "%d" 0x$HEAP` 

END_DEC=`printf "%d" 0x$END` 



COUNT=$(($END_DEC - $HEAP_DEC))



if [[ "$#" -ne 1 ]]; then

OUTPUT="/tmp/heap.bin"

else

OUTPUT=$1

fi



dd if=/proc/$PID/mem bs=1 skip=$HEAP_DEC count=$COUNT 2>/dev/null > $OUTPUT



echo "Dumped heap to: $OUTPUT (`stat -c "%s" $OUTPUT`)"
SHALL WE PLAY A GAME?
Reading bytes
#!/bin/bash



# Reads a byte from a given address



PID=`pgrep kachikachi`



if [ $PID ] then

HEAP=`cat /proc/$PID/smaps | grep heap | awk -F"-" '{print $1}'`

if [ $HEAP ] then

BASE=`printf "%d" 0x$HEAP`

OFFSET=`printf "%d" $1`

ADDRESS=$(($BASE + $OFFSET))



dd if=/proc/$PID/mem bs=1 skip=$ADDRESS count=1 2>/dev/null | 

xxd -p | awk '{print $1}'

else

exit 1

fi

else

exit 1

fi
SHALL WE PLAY A GAME?
Writing bytes
#!/bin/bash



# Writes a byte to a given address



PID=`pgrep kachikachi`



if [ $PID ] then

HEAP=`cat /proc/$PID/smaps | grep heap | awk -F"-" '{print $1}'`

if [ $HEAP ] then

BASE=`printf "%d" 0x$HEAP`

OFFSET=`printf "%d" $1`

ADDRESS=$(($BASE + $OFFSET))

BYTE=`echo -ne "x${2/0x/}"`



echo -n $BYTE | dd of=/proc/$PID/mem bs=1 seek=$ADDRESS conv=notrunc count=1

else

exit 1

fi

else

exit 1

fi
SHALL WE PLAY A GAME?
Using a mod...
‣ made by CompCom
‣ https://github.com/CompCom/OptionsMenu
‣ listens for key combo
‣ displays custom, configurable, menu
SHALL WE PLAY A GAME?
Extract game state from memory
SHALL WE PLAY A GAME?
Trigger events based on in-game activity
SHALL WE PLAY A GAME?
Manipulate memory / apply Game Genie codes
SHALL WE PLAY A GAME?
The Hardware
SHALL WE PLAY A GAME?
Hardware
‣ SoC: Allwinner R16 (4-core ARMv7)
‣ RAM: Ask NT5CC128M16IP-DI (256MB)
‣ NAND: Macronix MX30LF4G18AC-TI (512MB)
‣ PMU(Power Management Unit): X-POWER AXP223
‣ HDMI Transmitter: EPMI EP952
SHALL WE PLAY A GAME?
Hardware
‣ can put the console into FEL (recovery) mode (a type of
recovery mode) and get low-level access
‣ micro-usb port normally used for power
‣ with correct drivers enabled in the kernel can use of
RNDIS to establish a network connection with host PC
‣ usb port is OTG - client and usb host mode
SHALL WE PLAY A GAME?
Internal Photos - SNES Classic
SHALL WE PLAY A GAME?
Internal Photos - SNES Classic
SHALL WE PLAY A GAME?
Internal Photos - SNES Classic
SHALL WE PLAY A GAME?
SoC Allwinner R16
SHALL WE PLAY A GAME?
Hardware connections
SHALL WE PLAY A GAME?
UART / Serial
SHALL WE PLAY A GAME?
UART (Serial)
‣ hidden on the board
‣ gives access to uboot console and linux boot messages
‣ baudrate is 115200 and is 3.3v
‣ requires USB to Serial adapter (FTDI / CH430 etc)
SHALL WE PLAY A GAME?
UART pins marked on back of board
SHALL WE PLAY A GAME?
UART (Serial) - boot messages:
U-Boot 2011.09-rc1 (May 11 2017 - 16:32:31) Allwinner Technology 

[ 0.220]version: 1.1.

[ 0.223]uboot commit : eb2b275e0877fc98b3ba6d3b7bab225ebecb993a

ready
no battery, limit to dc

no key input

dram_para_set start

dram_para_set end



Using default environment



In: Out: Err: 

Uncompressing Linux... done, booting the kernel.

ion: failed to create debug files.

<4sunxi_leds_fetch_sysconfig_para script_parser_fetch "leds_para" leds_used = -1067179912
[ audio ] err:try to get audio_pa_ctrl failed!
[I2S1]sunxi-i2s1 cannot find any using configuration for controllers, return directly!

[I2S]sndi2s1 cannot find any using configuration for controllers, return directly

ths_fetch_sysconfig_para: type err device_used = 1.

fetch C0_LV_count from sysconfig failed



SHALL WE PLAY A GAME?
UART (Serial) - boot messages (hakchi):
hakchi init script version: 1.0.2



loading hakchi



waiting for usbhost ... 0

usbMode: device

overmounting /bin

overmounting /etc

overmounting /root

overmounting /etc/init.d/S92rndis on /etc/init.d/S90usb-gadget

menu code: 000



Welcome to CLOVER dp-sneseur-nerd release-v2.0.7-0-geb2b275BuildId final.cis.cis-d9-
clvrel0.20170511164229CEST



madmonkey login:
SHALL WE PLAY A GAME?
FEL Mode
SHALL WE PLAY A GAME?
FEL mode
‣ hold "reset" for 5 seconds while powering on
‣ a low-level USB programming and recovery mode in Boot
ROM of Allwinner System-on-Chip
‣ FEL commands are chip, not device, specific
‣ read & write memory and execute code
‣ dump or write kernel and firmware
SHALL WE PLAY A GAME?
FEL mode - clean boot
[ 0.213]



U-Boot 2011.09-rc1 (May 11 2017 - 16:32:31) Allwinner Technology 



[ 0.221]version: 1.1.0

[ 0.223]uboot commit : eb2b275e0877fc98b3ba6d3b7bab225ebecb993a



ready

no battery, limit to dc
SHALL WE PLAY A GAME?
FEL mode - upload fes1.bin
sunxi-fel write 0x2000 fes1.bin
FEL mode - execute fes1.bin
sunxi-fel exec 0x2000
SHALL WE PLAY A GAME?
FEL mode - Initialising DRAM and switch to FES
fes commit : fc3061df4dbd4153819b2d2f141d82b88fea51cf



begin to init dram

DRAM DRIVE INFO: V1.7

DRAM Type =3 (2:DDR2,3:DDR3,6:LPDDR2,7:LPDDR3)

DRAM zq value: 00003bbbDRAM CLK =600 MHZ

ID CHECK VERSION: V0.1

using ic R16

USE PLL DDR1

USE PLL NORMAL

PLL FREQUENCE = 1200 MHZ

DRAM PLL DDR1 frequency extend open !

...

DRAM PHY INTERFACE PARA = 02040102

DRAM VTC is disable

DRAM dynamic DQS/DQ ODT is on

DRAM DQS gate is PD mode.

DRAM one rank training is on,the value is 91003587

DRAM work mode register value = 004318d4

DRAM SIZE =256 M

set one rank ODTMAP

DRAM simple test OK.

init dram ok
SHALL WE PLAY A GAME?
FES mode - upload uboot.bin
sunxi-fel write 0x47000000 uboot.bin
FES mode - command to run instead of kernel
sunxi_flash phy_read 47400000 30 20;efex_test
FES mode - kernel dump boot command
sunxi-fel write 0x470604ff kernel_dump_bootcmd
SHALL WE PLAY A GAME?
FES mode - uboot booting
[ 194.359]



U-Boot 2011.09-rc1-00000-g1352b18-dirty (Jan 02 2017 - 10:46:29) Allwinner Technology 



[ 194.368]version: 1.1.0

[ 194.371]uboot commit : fc3061df4dbd4153819b2d2f141d82b88fea51cf



ready
no battery, limit to dc

no key input

dram_para_set start

dram_para_set end

Using default environment



In: Out: Err: 

Ph
SHALL WE PLAY A GAME?
Dump kernel to file
sunxi-fel read 0x47400030 0x600000 kernel.dump
(can then use additional tools to extract the "keyfile" from it to decrypt the
NAND flash storage)
SHALL WE PLAY A GAME?
Weaponizing
SHALL WE PLAY A GAME?
Weaponizing:
‣ Connectivity
‣ Tools
‣ Backdooring
SHALL WE PLAY A GAME?
Adding WiFi:
‣ "WPA Supplication" (wifi) hmod
‣ correct OTG cable/adapter
‣ compatible network dongle (RTL8188 seems to work)
‣ SSH in, run "wifi-wpa-setup", restart with 

OTG & wifi plugged in, hope for the best
‣ no visual indicator it works :/
SHALL WE PLAY A GAME?
wifi-wpa-setup mod:
SHALL WE PLAY A GAME?
wifi-wpa-setup mod:
login as: root
hakchi v1.0.4-122 by madmonkey
Special thanks to all of the contributors including: potyl, mistydemeo,

skogaby, DanTheMan827, KMFDManic, Mugi, princess_daphie, xorloser, ghoost82,

thomas-alrek, ClusterM, zigg, thomascrha and anyone else I may have forgotten
root@madmonkey:~#










SHALL WE PLAY A GAME?
wifi-wpa-setup mod:
login as: root
hakchi v1.0.4-122 by madmonkey
Special thanks to all of the contributors including: potyl, mistydemeo,

skogaby, DanTheMan827, KMFDManic, Mugi, princess_daphie, xorloser, ghoost82,

thomas-alrek, ClusterM, zigg, thomascrha and anyone else I may have forgotten
root@madmonkey:~# wifi-wpa-setup










SHALL WE PLAY A GAME?
wifi-wpa-setup mod:
login as: root
hakchi v1.0.4-122 by madmonkey
Special thanks to all of the contributors including: potyl, mistydemeo,

skogaby, DanTheMan827, KMFDManic, Mugi, princess_daphie, xorloser, ghoost82,

thomas-alrek, ClusterM, zigg, thomascrha and anyone else I may have forgotten
root@madmonkey:~# wifi-wpa-setup
Enter your SSID (Your SSID must not include spaces):

D-Link
Enter your Wi-Fi password:

hunter2
Details entered. You can reset your console now. Make sure that only your wifi

adapter is connected on first boot. When your console boots, you need to turn

off and reconnect your OTG hub and USB drive (if applicable). Failure to do so

will mean you will have to restart the process.
SHALL WE PLAY A GAME?
Adding tools:
‣ via mods (eg: wireless tools, gdb)
‣ see HakchiResources.com "Experimental" mods
‣ or... add our own
SHALL WE PLAY A GAME?
(url/dns brute forcer for webapps)
‣ git clone and compile with static flags:
‣ output of "file":
Porting GoBuster:
CGO_ENABLED=0 GOOS=linux GOARM=7 GOARCH=arm go build -a 

-ldflags '-extldflags "-static"' .
gobuster: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), 

statically linked, not stripped
SHALL WE PLAY A GAME?
SHALL WE PLAY A GAME?
‣ Kali is available for "ARMHF"
‣ can be run on a Raspberry Pi
‣ comes bundled with tools :D
‣ output of "file":
Porting Nmap:
/usr/bin/nmap: ELF 32-bit LSB pie executable ARM, EABI5 version 1 (SYSV),
dynamically linked, interpreter /lib/ld-linux.so.3, for GNU/Linux 3.2.0
SHALL WE PLAY A GAME?
‣ output of "ldd":
Porting Nmap:
libpcre.so.3 => /lib/arm-linux-gnueabi/libpcre.so.3 (0xb6c37000)

libssh2.so.1 => /lib/arm-linux-gnueabi/libssh2.so.1 (0xb6c02000)

libssl.so.1.1 => /lib/arm-linux-gnueabi/libssl.so.1.1 (0xb6ba1000)

libcrypto.so.1.1 => /lib/arm-linux-gnueabi/libcrypto.so.1.1 (0xb69cc000)

libz.so.1 => /lib/arm-linux-gnueabi/libz.so.1 (0xb69a2000)

liblua5.3.so.0 => /lib/arm-linux-gnueabi/liblua5.3.so.0 (0xb6964000)

liblinear.so.3 => /lib/arm-linux-gnueabi/liblinear.so.3 (0xb6944000)

libstdc++.so.6 => /lib/arm-linux-gnueabi/libstdc++.so.6 (0xb67fe000)

libm.so.6 => /lib/arm-linux-gnueabi/libm.so.6 (0xb673b000)

libgcc_s.so.1 => /lib/arm-linux-gnueabi/libgcc_s.so.1 (0xb670c000)

libc.so.6 => /lib/arm-linux-gnueabi/libc.so.6 (0xb65b9000)

/lib/ld-linux.so.3 (0xb6fc8000)

libpthread.so.0 => /lib/arm-linux-gnueabi/libpthread.so.0 (0xb658e000)

libgcrypt.so.20 => /lib/arm-linux-gnueabi/libgcrypt.so.20 (0xb64c1000)

libdl.so.2 => /lib/arm-linux-gnueabi/libdl.so.2 (0xb64ae000)

libblas.so.3 => /lib/arm-linux-gnueabi/libblas.so.3 (0xb6416000)

libgpg-error.so.0 => /lib/arm-linux-gnueabi/libgpg-error.so.0 (0xb63ec000)

libgfortran.so.5 => /lib/arm-linux-gnueabi/libgfortran.so.5 (0xb630b000)
SHALL WE PLAY A GAME?
‣ copy binary + files + dependencies to NES Classic
‣ use "LD_LIBRARY_PATH" to load dependencies when
running
Porting Nmap:
LD_LIBRARY_PATH=. ./nmap <target> <options>
SHALL WE PLAY A GAME?
SHALL WE PLAY A GAME?
‣ In Ubuntu 16.04
Porting socat:
sudo apt install gcc-4.8-arm-linux-gnueabihf
# download and extract socat .tar.get:

# http://www.dest-unreach.org/socat/download/socat-1.7.3.2.tar.gz
./configure LDFLAGS="-static"

sed -i 's/gcc/arm-linux-gnueabihf-gcc/g' Makefile

make
file ./socat

=> ELF 32-bit LSB executable, ARM, EABI5 version 1 (GNU/Linux),
statically linked, for GNU/Linux 3.2.0
‣ Output of "file":
SHALL WE PLAY A GAME?
‣ using a Raspberry Pi + Kali ARMHF
Compiling sources:
gcc slideshow.c -o slideshow --static

=> ELF 32-bit LSB executable, ARM, EABI5 version 1 (...), statically linked, for GNU/Linux 3.2.0
‣ use GCC cross compilation
arm-linux-gnueabihf-gcc slideshow.c -o slideshow --static

=> ELF 32-bit LSB executable, ARM, EABI5 version 1 (...), statically linked, for GNU/Linux 3.2.0
✓
✓
‣ using DockCross (dockcross-linux-armv7)
./dockcross-linux-armv7 bash -c '$CC slideshow.c -o slideshow --static'

=> ELF 32-bit LSB executable, ARM, EABI5 version 1 (...), statically linked, for GNU/Linux 4.10.8
✗
("for Linux 4.10.8", gives a "FATAL: kernel too old" error)
SHALL WE PLAY A GAME?
These Slides!
SHALL WE PLAY A GAME?
Interacting with the hardware:
‣ FrameBuffer is used for video: /dev/fb0
‣ have to pause UI/emulator to write to it
kill -STOP `pgrep kachikachi`

kill -STOP `pgrep ReedPlayer-Clover`
‣ controller events can be read from /dev/inputs/joystick
‣ events have a timestamp, value, type and number
‣ there's a "/dev/inputs/event4" for reset button event
SHALL WE PLAY A GAME?
Interacting with the hardware:
‣ "read_event" loop
‣ if left/right/A/B button
‣ next/previous slide
‣ check if video or image file exists
‣ output using "ffmpeg" or "decodepng" to frame buffer
‣ these slides are (hopefully) being played from our
custom slideshow app :D/
SHALL WE PLAY A GAME?
Other stuff
SHALL WE PLAY A GAME?
Misc stuff:
‣ hakchi .hmod (mods) are just tar files:

tar -czvf "../MyMod.hmod" *
‣ Can have multiple firmwares on a single device and swap
between them (eg: NES on SNES)
‣ Active community on Reddit and Discord
‣ Wolf3D (and other games) ported across!
‣ Theres a "FBVNC" (FrameBuffer VNC) but

frame rate is low with tearing
SHALL WE PLAY A GAME?
Misc stuff:
‣ "reset" button sends an event to "/dev/inputs/event4"
‣ input events have "time", "value", "type" and number"
‣ can capture + replay "reset" event:

cat /dev/inputs/event4 > reset.bin

cat reset.bin > /dev/inputs/event4
‣ was not able to automate/replay joystick

inputs (was hoping to make a Mario bot)
SHALL WE PLAY A GAME?
RetroArch:
‣ RetroArch emulator adds supports from many more
platforms:
* snes9x2010 (Super Famicom/Super Nintendo)

* gambatte_libretro (Game Boy, Game Boy Color)

* mgba (Game Boy Advance)

* genesis_plus_gx (Sega Master System, Genesis/Mega Drive, Game Gear)

* stella (Atari 2600)

* mednafen_pce_fast (PC Engine/Turbografx 16)

* fb_alpha and fb_alpha_cps2 (various arcade machines)

* picodrive (Sega Master System, Genesis/Mega Drive, Game Gear, Sega)

* dosbox and more: http://buildbot.libretro.com/nightly/linux/armhf/
SHALL WE PLAY A GAME?
Stuff that sucked:
‣ Trying to get an OTG adapter (had to order online)
‣ getting USB and wifi working is mostly blind
‣ "just" use BuildRoot - https://hakchi.net/hakchi/sdk/
‣ "just" use GCC <= 4.9 (good luck if you need zlib)
‣ compiling stuff for SDL is a major pain
‣ relatively easy to crash to console
SHALL WE PLAY A GAME?
‣ eBay OTG adapter
‣ Amazon OTG adapter
‣ Hakchi Community Edition
‣ HakchiResources (mods + Discord Channel)
Links
SHALL WE PLAY A GAME?
‣ https://www.xor.co.za/talks/shall_we_play/ (Dale)
‣ https://www.hypn.za.net/blog/?p=1272 (Ross)
Our notes + more info:
Thanks!

More Related Content

What's hot

Console design AGAIN
Console design AGAINConsole design AGAIN
Console design AGAINKyle Fielding
 
Computer Package
Computer PackageComputer Package
Computer Package
educ28
 
Partes piezas mayo
Partes piezas mayoPartes piezas mayo
Partes piezas mayo
Henry Nazir Triforia
 
Brosur mnc purwokerto
Brosur mnc purwokertoBrosur mnc purwokerto
Brosur mnc purwokertoDhan junkie
 
Console comparsions
Console comparsionsConsole comparsions
Console comparsionscopelandadam
 
Console development
Console developmentConsole development
Console development
spartasoft
 
Console design template
Console design templateConsole design template
Console design templateLewisB2013
 
Galactus
GalactusGalactus
Harga Komputer
Harga KomputerHarga Komputer
Harga Komputer
komputer laptop
 
Hp prodesk
Hp prodeskHp prodesk
Hp prodesk
itstorepro
 
Pandaboard
PandaboardPandaboard
Pandaboard
Sagar Patel
 
Installing and deploying ubuntu server box
Installing and deploying ubuntu server boxInstalling and deploying ubuntu server box
Installing and deploying ubuntu server box
Juan Carlos Pérez Pardo
 
10 laptop untuk game termahal 2020
10 laptop untuk game termahal 202010 laptop untuk game termahal 2020
10 laptop untuk game termahal 2020
eryhs94
 
Wynn's Independent Trading
Wynn's Independent TradingWynn's Independent Trading
Wynn's Independent Trading
benwynn
 

What's hot (16)

Console design AGAIN
Console design AGAINConsole design AGAIN
Console design AGAIN
 
Faq
FaqFaq
Faq
 
Computer Package
Computer PackageComputer Package
Computer Package
 
Partes piezas mayo
Partes piezas mayoPartes piezas mayo
Partes piezas mayo
 
Brosur mnc purwokerto
Brosur mnc purwokertoBrosur mnc purwokerto
Brosur mnc purwokerto
 
Console comparsions
Console comparsionsConsole comparsions
Console comparsions
 
Console development
Console developmentConsole development
Console development
 
Console design template
Console design templateConsole design template
Console design template
 
Galactus
GalactusGalactus
Galactus
 
Harga Komputer
Harga KomputerHarga Komputer
Harga Komputer
 
Presentación notebook
Presentación notebookPresentación notebook
Presentación notebook
 
Hp prodesk
Hp prodeskHp prodesk
Hp prodesk
 
Pandaboard
PandaboardPandaboard
Pandaboard
 
Installing and deploying ubuntu server box
Installing and deploying ubuntu server boxInstalling and deploying ubuntu server box
Installing and deploying ubuntu server box
 
10 laptop untuk game termahal 2020
10 laptop untuk game termahal 202010 laptop untuk game termahal 2020
10 laptop untuk game termahal 2020
 
Wynn's Independent Trading
Wynn's Independent TradingWynn's Independent Trading
Wynn's Independent Trading
 

Similar to Shall We Play A Game - BSides Cape Town 2018

The Ultimate Gaming
The Ultimate GamingThe Ultimate Gaming
The Ultimate Gamingkoolshreeram
 
[HUN] Hackersuli - Console and arcade game hacking – history, present, future
[HUN] Hackersuli - Console and arcade game hacking – history, present, future[HUN] Hackersuli - Console and arcade game hacking – history, present, future
[HUN] Hackersuli - Console and arcade game hacking – history, present, future
hackersuli
 
How to Hack Edison
How to Hack EdisonHow to Hack Edison
How to Hack Edison
Shotaro Uchida
 
Managing server secrets at scale with SaltStack and a vaultless password manager
Managing server secrets at scale with SaltStack and a vaultless password managerManaging server secrets at scale with SaltStack and a vaultless password manager
Managing server secrets at scale with SaltStack and a vaultless password manager
Ignat Korchagin
 
Starting Raspberry Pi
Starting Raspberry PiStarting Raspberry Pi
Starting Raspberry Pi
LloydMoore
 
Let's begin io t with $10
Let's begin io t with $10Let's begin io t with $10
Let's begin io t with $10
Makoto Takahashi
 
Manual - ED64 Plus - Nintendo 64 - Everdrive Flashcart
Manual - ED64 Plus - Nintendo 64 - Everdrive FlashcartManual - ED64 Plus - Nintendo 64 - Everdrive Flashcart
Manual - ED64 Plus - Nintendo 64 - Everdrive Flashcart
VICIOGAME Retro Games
 
Hacking with x86 Windows Tablet and mobile devices on Debian #debconf18
Hacking with x86 Windows Tablet and mobile devices on Debian  #debconf18Hacking with x86 Windows Tablet and mobile devices on Debian  #debconf18
Hacking with x86 Windows Tablet and mobile devices on Debian #debconf18
Netwalker lab kapper
 
Running Linux Desktop on Sony Playstation 4
Running Linux Desktop  on Sony Playstation 4Running Linux Desktop  on Sony Playstation 4
Running Linux Desktop on Sony Playstation 4
Iwan Tahari
 
Linux as a gaming platform - Errata
Linux as a gaming platform - ErrataLinux as a gaming platform - Errata
Linux as a gaming platform - Errata
Leszek Godlewski
 
DEF CON 23 - Phil Polstra - one device to pwn them all
DEF CON 23 - Phil Polstra - one device to pwn them allDEF CON 23 - Phil Polstra - one device to pwn them all
DEF CON 23 - Phil Polstra - one device to pwn them all
Felipe Prado
 
Game mintia
Game mintiaGame mintia
Game mintia
NehalNadaf
 
Linux as a gaming platform, ideology aside
Linux as a gaming platform, ideology asideLinux as a gaming platform, ideology aside
Linux as a gaming platform, ideology aside
Leszek Godlewski
 
XS Boston 2008 Self IO Emulation
XS Boston 2008 Self IO EmulationXS Boston 2008 Self IO Emulation
XS Boston 2008 Self IO Emulation
The Linux Foundation
 
Mainline kernel on ARM Tegra20 devices that are left behind on 2.6 kernels
Mainline kernel on ARM Tegra20 devices that are left behind on 2.6 kernelsMainline kernel on ARM Tegra20 devices that are left behind on 2.6 kernels
Mainline kernel on ARM Tegra20 devices that are left behind on 2.6 kernels
Dobrica Pavlinušić
 
Hardware Discovery Commands
Hardware Discovery CommandsHardware Discovery Commands
Hardware Discovery Commands
Kevin OBrien
 
Akshay-UNIT 20-LO-1,2,3&4-FINAL
Akshay-UNIT 20-LO-1,2,3&4-FINALAkshay-UNIT 20-LO-1,2,3&4-FINAL
Akshay-UNIT 20-LO-1,2,3&4-FINAL
Akshay
 
ChromePad - Chromium OS for ThinkPad
ChromePad - Chromium OS for ThinkPadChromePad - Chromium OS for ThinkPad
ChromePad - Chromium OS for ThinkPad
AndrewWright224
 
How to build Open Hardware self-navigating car robot
How to build Open Hardware self-navigating car robotHow to build Open Hardware self-navigating car robot
How to build Open Hardware self-navigating car robot
Tomáš Jukin
 
A2 Video Streamer
A2 Video StreamerA2 Video Streamer
A2 Video Streamer
Andrew Roughan
 

Similar to Shall We Play A Game - BSides Cape Town 2018 (20)

The Ultimate Gaming
The Ultimate GamingThe Ultimate Gaming
The Ultimate Gaming
 
[HUN] Hackersuli - Console and arcade game hacking – history, present, future
[HUN] Hackersuli - Console and arcade game hacking – history, present, future[HUN] Hackersuli - Console and arcade game hacking – history, present, future
[HUN] Hackersuli - Console and arcade game hacking – history, present, future
 
How to Hack Edison
How to Hack EdisonHow to Hack Edison
How to Hack Edison
 
Managing server secrets at scale with SaltStack and a vaultless password manager
Managing server secrets at scale with SaltStack and a vaultless password managerManaging server secrets at scale with SaltStack and a vaultless password manager
Managing server secrets at scale with SaltStack and a vaultless password manager
 
Starting Raspberry Pi
Starting Raspberry PiStarting Raspberry Pi
Starting Raspberry Pi
 
Let's begin io t with $10
Let's begin io t with $10Let's begin io t with $10
Let's begin io t with $10
 
Manual - ED64 Plus - Nintendo 64 - Everdrive Flashcart
Manual - ED64 Plus - Nintendo 64 - Everdrive FlashcartManual - ED64 Plus - Nintendo 64 - Everdrive Flashcart
Manual - ED64 Plus - Nintendo 64 - Everdrive Flashcart
 
Hacking with x86 Windows Tablet and mobile devices on Debian #debconf18
Hacking with x86 Windows Tablet and mobile devices on Debian  #debconf18Hacking with x86 Windows Tablet and mobile devices on Debian  #debconf18
Hacking with x86 Windows Tablet and mobile devices on Debian #debconf18
 
Running Linux Desktop on Sony Playstation 4
Running Linux Desktop  on Sony Playstation 4Running Linux Desktop  on Sony Playstation 4
Running Linux Desktop on Sony Playstation 4
 
Linux as a gaming platform - Errata
Linux as a gaming platform - ErrataLinux as a gaming platform - Errata
Linux as a gaming platform - Errata
 
DEF CON 23 - Phil Polstra - one device to pwn them all
DEF CON 23 - Phil Polstra - one device to pwn them allDEF CON 23 - Phil Polstra - one device to pwn them all
DEF CON 23 - Phil Polstra - one device to pwn them all
 
Game mintia
Game mintiaGame mintia
Game mintia
 
Linux as a gaming platform, ideology aside
Linux as a gaming platform, ideology asideLinux as a gaming platform, ideology aside
Linux as a gaming platform, ideology aside
 
XS Boston 2008 Self IO Emulation
XS Boston 2008 Self IO EmulationXS Boston 2008 Self IO Emulation
XS Boston 2008 Self IO Emulation
 
Mainline kernel on ARM Tegra20 devices that are left behind on 2.6 kernels
Mainline kernel on ARM Tegra20 devices that are left behind on 2.6 kernelsMainline kernel on ARM Tegra20 devices that are left behind on 2.6 kernels
Mainline kernel on ARM Tegra20 devices that are left behind on 2.6 kernels
 
Hardware Discovery Commands
Hardware Discovery CommandsHardware Discovery Commands
Hardware Discovery Commands
 
Akshay-UNIT 20-LO-1,2,3&4-FINAL
Akshay-UNIT 20-LO-1,2,3&4-FINALAkshay-UNIT 20-LO-1,2,3&4-FINAL
Akshay-UNIT 20-LO-1,2,3&4-FINAL
 
ChromePad - Chromium OS for ThinkPad
ChromePad - Chromium OS for ThinkPadChromePad - Chromium OS for ThinkPad
ChromePad - Chromium OS for ThinkPad
 
How to build Open Hardware self-navigating car robot
How to build Open Hardware self-navigating car robotHow to build Open Hardware self-navigating car robot
How to build Open Hardware self-navigating car robot
 
A2 Video Streamer
A2 Video StreamerA2 Video Streamer
A2 Video Streamer
 

Recently uploaded

ER(Entity Relationship) Diagram for online shopping - TAE
ER(Entity Relationship) Diagram for online shopping - TAEER(Entity Relationship) Diagram for online shopping - TAE
ER(Entity Relationship) Diagram for online shopping - TAE
Himani415946
 
How to Use Contact Form 7 Like a Pro.pptx
How to Use Contact Form 7 Like a Pro.pptxHow to Use Contact Form 7 Like a Pro.pptx
How to Use Contact Form 7 Like a Pro.pptx
Gal Baras
 
This 7-second Brain Wave Ritual Attracts Money To You.!
This 7-second Brain Wave Ritual Attracts Money To You.!This 7-second Brain Wave Ritual Attracts Money To You.!
This 7-second Brain Wave Ritual Attracts Money To You.!
nirahealhty
 
History+of+E-commerce+Development+in+China-www.cfye-commerce.shop
History+of+E-commerce+Development+in+China-www.cfye-commerce.shopHistory+of+E-commerce+Development+in+China-www.cfye-commerce.shop
History+of+E-commerce+Development+in+China-www.cfye-commerce.shop
laozhuseo02
 
Multi-cluster Kubernetes Networking- Patterns, Projects and Guidelines
Multi-cluster Kubernetes Networking- Patterns, Projects and GuidelinesMulti-cluster Kubernetes Networking- Patterns, Projects and Guidelines
Multi-cluster Kubernetes Networking- Patterns, Projects and Guidelines
Sanjeev Rampal
 
BASIC C++ lecture NOTE C++ lecture 3.pptx
BASIC C++ lecture NOTE C++ lecture 3.pptxBASIC C++ lecture NOTE C++ lecture 3.pptx
BASIC C++ lecture NOTE C++ lecture 3.pptx
natyesu
 
Latest trends in computer networking.pptx
Latest trends in computer networking.pptxLatest trends in computer networking.pptx
Latest trends in computer networking.pptx
JungkooksNonexistent
 
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
3ipehhoa
 
test test test test testtest test testtest test testtest test testtest test ...
test test  test test testtest test testtest test testtest test testtest test ...test test  test test testtest test testtest test testtest test testtest test ...
test test test test testtest test testtest test testtest test testtest test ...
Arif0071
 
The+Prospects+of+E-Commerce+in+China.pptx
The+Prospects+of+E-Commerce+in+China.pptxThe+Prospects+of+E-Commerce+in+China.pptx
The+Prospects+of+E-Commerce+in+China.pptx
laozhuseo02
 
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
3ipehhoa
 
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
3ipehhoa
 
Output determination SAP S4 HANA SAP SD CC
Output determination SAP S4 HANA SAP SD CCOutput determination SAP S4 HANA SAP SD CC
Output determination SAP S4 HANA SAP SD CC
ShahulHameed54211
 
Living-in-IT-era-Module-7-Imaging-and-Design-for-Social-Impact.pptx
Living-in-IT-era-Module-7-Imaging-and-Design-for-Social-Impact.pptxLiving-in-IT-era-Module-7-Imaging-and-Design-for-Social-Impact.pptx
Living-in-IT-era-Module-7-Imaging-and-Design-for-Social-Impact.pptx
TristanJasperRamos
 
guildmasters guide to ravnica Dungeons & Dragons 5...
guildmasters guide to ravnica Dungeons & Dragons 5...guildmasters guide to ravnica Dungeons & Dragons 5...
guildmasters guide to ravnica Dungeons & Dragons 5...
Rogerio Filho
 
1.Wireless Communication System_Wireless communication is a broad term that i...
1.Wireless Communication System_Wireless communication is a broad term that i...1.Wireless Communication System_Wireless communication is a broad term that i...
1.Wireless Communication System_Wireless communication is a broad term that i...
JeyaPerumal1
 

Recently uploaded (16)

ER(Entity Relationship) Diagram for online shopping - TAE
ER(Entity Relationship) Diagram for online shopping - TAEER(Entity Relationship) Diagram for online shopping - TAE
ER(Entity Relationship) Diagram for online shopping - TAE
 
How to Use Contact Form 7 Like a Pro.pptx
How to Use Contact Form 7 Like a Pro.pptxHow to Use Contact Form 7 Like a Pro.pptx
How to Use Contact Form 7 Like a Pro.pptx
 
This 7-second Brain Wave Ritual Attracts Money To You.!
This 7-second Brain Wave Ritual Attracts Money To You.!This 7-second Brain Wave Ritual Attracts Money To You.!
This 7-second Brain Wave Ritual Attracts Money To You.!
 
History+of+E-commerce+Development+in+China-www.cfye-commerce.shop
History+of+E-commerce+Development+in+China-www.cfye-commerce.shopHistory+of+E-commerce+Development+in+China-www.cfye-commerce.shop
History+of+E-commerce+Development+in+China-www.cfye-commerce.shop
 
Multi-cluster Kubernetes Networking- Patterns, Projects and Guidelines
Multi-cluster Kubernetes Networking- Patterns, Projects and GuidelinesMulti-cluster Kubernetes Networking- Patterns, Projects and Guidelines
Multi-cluster Kubernetes Networking- Patterns, Projects and Guidelines
 
BASIC C++ lecture NOTE C++ lecture 3.pptx
BASIC C++ lecture NOTE C++ lecture 3.pptxBASIC C++ lecture NOTE C++ lecture 3.pptx
BASIC C++ lecture NOTE C++ lecture 3.pptx
 
Latest trends in computer networking.pptx
Latest trends in computer networking.pptxLatest trends in computer networking.pptx
Latest trends in computer networking.pptx
 
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
 
test test test test testtest test testtest test testtest test testtest test ...
test test  test test testtest test testtest test testtest test testtest test ...test test  test test testtest test testtest test testtest test testtest test ...
test test test test testtest test testtest test testtest test testtest test ...
 
The+Prospects+of+E-Commerce+in+China.pptx
The+Prospects+of+E-Commerce+in+China.pptxThe+Prospects+of+E-Commerce+in+China.pptx
The+Prospects+of+E-Commerce+in+China.pptx
 
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
 
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
 
Output determination SAP S4 HANA SAP SD CC
Output determination SAP S4 HANA SAP SD CCOutput determination SAP S4 HANA SAP SD CC
Output determination SAP S4 HANA SAP SD CC
 
Living-in-IT-era-Module-7-Imaging-and-Design-for-Social-Impact.pptx
Living-in-IT-era-Module-7-Imaging-and-Design-for-Social-Impact.pptxLiving-in-IT-era-Module-7-Imaging-and-Design-for-Social-Impact.pptx
Living-in-IT-era-Module-7-Imaging-and-Design-for-Social-Impact.pptx
 
guildmasters guide to ravnica Dungeons & Dragons 5...
guildmasters guide to ravnica Dungeons & Dragons 5...guildmasters guide to ravnica Dungeons & Dragons 5...
guildmasters guide to ravnica Dungeons & Dragons 5...
 
1.Wireless Communication System_Wireless communication is a broad term that i...
1.Wireless Communication System_Wireless communication is a broad term that i...1.Wireless Communication System_Wireless communication is a broad term that i...
1.Wireless Communication System_Wireless communication is a broad term that i...
 

Shall We Play A Game - BSides Cape Town 2018

  • 1. SHALL WE PLAY A GAME? Hacking and weaponizing the NES Classic Mini
  • 2. SHALL WE PLAY A GAME? ‣ Ross (@HypnInfosec) and Dale (@dale_nunns) ‣ like retro computing and consoles ‣ also like hacking/breaking/making/fixing stuff Who we are:
  • 3. SHALL WE PLAY A GAME? Why this talk: ‣ combination of the stuff we like ‣ good way to explore embedded device hacking ‣ relatively affordable & easily accessible ‣ fun to play with ¯_(ツ)_/¯
  • 4. SHALL WE PLAY A GAME? About the 
 NES mini
  • 5. SHALL WE PLAY A GAME? About the NES Classic mini: ‣ modern remake of the NES-001 gaming console
  • 6. SHALL WE PLAY A GAME? The NES Classic mini is NOT: ‣ able to play original cartridges ‣ hard to find (available at many online retailers) ‣ "just a Raspberry Pi" (eg: RetroPie) ‣ meant to be modified/customized
  • 7. SHALL WE PLAY A GAME? About the NES Classic mini: ‣ USB powered ‣ HDMI output ‣ various models
  • 8. SHALL WE PLAY A GAME? About the NES Classic mini: ‣ comes with 30 games (roms) ‣ has a UI for selecting games to play ‣ uses custom emulator "kachikachi" to play NES ROMs ‣ coded with SDL and other open source tools ‣ see https://www.nintendo.co.jp/support/oss/
  • 9. SHALL WE PLAY A GAME?
  • 10. SHALL WE PLAY A GAME? Software Hack
  • 11. SHALL WE PLAY A GAME? The "hakchi" mod/hack: ‣ initially written by "madmonkey" ‣ now on it's 3rd version: "Community Edition"
  • 12. SHALL WE PLAY A GAME? hakchi by madmonkey
  • 13. SHALL WE PLAY A GAME? hakchi2 by ClusterM
  • 14. SHALL WE PLAY A GAME? hakchi Community Edition
  • 15. SHALL WE PLAY A GAME? The "hakchi" mod/hack: ‣ changes the firmware ‣ changes startup scripts (eg: for mods) ‣ remaps paths (eg: symlinks ROM location) ‣ allows custom NES roms
  • 16. SHALL WE PLAY A GAME? allows custom NES roms
  • 17. SHALL WE PLAY A GAME? The "hakchi" mod/hack: ‣ adds some USB support via USB Host OTG adapters ‣ "90 degree" adapter seems to work well ‣ prevents Hakchi from communicating with your console WRONG!
 (left from power) Correct
 (right from power)
  • 18. SHALL WE PLAY A GAME? The "hakchi" mod/hack: ‣ USB storage - allowing more games (and emulators) ‣ formatting as NTFS seems to work best ‣ use https://github.com/swingflip/Hakchi-USB-tools ‣ not all flash drives work - but the "SanDisk 
 Cruzer Blade" flash drives seem to ‣ mounts to "/media"
  • 19. SHALL WE PLAY A GAME? ‣ enables ftp + ssh (login "root" with no password) ‣ host-networking on ip: 169.254.13.37 (ports 21 or 22)
 (when not using OTG USB!) The "hakchi" mod/hack: login as: root hakchi v1.0.4-122 by madmonkey Special thanks to all of the contributors including: potyl, mistydemeo,
 skogaby, DanTheMan827, KMFDManic, Mugi, princess_daphie, xorloser, ghoost82,
 thomas-alrek, ClusterM, zigg, thomascrha and anyone else I may have forgotten root@madmonkey:~#
  • 20. SHALL WE PLAY A GAME? Root? "Big F*ing deal, what can you do with it"
 https://twitter.com/officialmcafee/status/1025009808968171521
  • 21. SHALL WE PLAY A GAME? So What
 Can We Do?
  • 22. SHALL WE PLAY A GAME? So what can we do? ‣ very few commands/tools ‣ mostly just busybox widgets ‣ let's see how far bash + busybox can take us!
  • 23. SHALL WE PLAY A GAME? ‣ memory map of "kachikachi" (emulator) Getting access to process memory root@madmonkey:~# pgrep kachikachi
 1869 root@madmonkey:~# cat /proc/1869/maps
 00010000-00073000 r-xp 00000000 fe:00 292 /usr/bin/kachikachi
 00083000-0008d000 rw-p 00063000 fe:00 292 /usr/bin/kachikachi
 0008d000-0009d000 rw-p 00000000 00:00 0
 00ebc000-00f8f000 rw-p 00000000 00:00 0 [heap]
 b1e40000-b2200000 rw-s 11420000 00:05 398 /dev/mali
 b5717000-b5718000 ---p 00000000 00:00 0
 [...]
 b5718000-b5f17000 rwxp 00000000 00:00 0 [stack:1902]
 b5f17000-b5fec000 r-xp 00000000 fe:00 365 /usr/lib/libasound.so.2.0.0
 b5fec000-b5ffc000 ---p 000d5000 fe:00 365 /usr/lib/libasound.so.2.0.0
 b5ffc000-b6000000 rw-p 000d5000 fe:00 365 /usr/lib/libasound.so.2.0.0
  • 24. SHALL WE PLAY A GAME? Dumping heap (memory) #!/bin/bash
 
 # Dumps the full memory heap to disk
 
 PID=`pgrep kachikachi`
 
 HEAP=`cat /proc/$PID/smaps | grep heap | awk -F"-" '{print $1}'`
 END=`cat /proc/$PID/smaps | grep heap | awk -F"[- ]" '{print $2}'`
 HEAP_DEC=`printf "%d" 0x$HEAP` 
 END_DEC=`printf "%d" 0x$END` 
 
 COUNT=$(($END_DEC - $HEAP_DEC))
 
 if [[ "$#" -ne 1 ]]; then
 OUTPUT="/tmp/heap.bin"
 else
 OUTPUT=$1
 fi
 
 dd if=/proc/$PID/mem bs=1 skip=$HEAP_DEC count=$COUNT 2>/dev/null > $OUTPUT
 
 echo "Dumped heap to: $OUTPUT (`stat -c "%s" $OUTPUT`)"
  • 25. SHALL WE PLAY A GAME? Reading bytes #!/bin/bash
 
 # Reads a byte from a given address
 
 PID=`pgrep kachikachi`
 
 if [ $PID ] then
 HEAP=`cat /proc/$PID/smaps | grep heap | awk -F"-" '{print $1}'`
 if [ $HEAP ] then
 BASE=`printf "%d" 0x$HEAP`
 OFFSET=`printf "%d" $1`
 ADDRESS=$(($BASE + $OFFSET))
 
 dd if=/proc/$PID/mem bs=1 skip=$ADDRESS count=1 2>/dev/null | 
 xxd -p | awk '{print $1}'
 else
 exit 1
 fi
 else
 exit 1
 fi
  • 26. SHALL WE PLAY A GAME? Writing bytes #!/bin/bash
 
 # Writes a byte to a given address
 
 PID=`pgrep kachikachi`
 
 if [ $PID ] then
 HEAP=`cat /proc/$PID/smaps | grep heap | awk -F"-" '{print $1}'`
 if [ $HEAP ] then
 BASE=`printf "%d" 0x$HEAP`
 OFFSET=`printf "%d" $1`
 ADDRESS=$(($BASE + $OFFSET))
 BYTE=`echo -ne "x${2/0x/}"`
 
 echo -n $BYTE | dd of=/proc/$PID/mem bs=1 seek=$ADDRESS conv=notrunc count=1
 else
 exit 1
 fi
 else
 exit 1
 fi
  • 27. SHALL WE PLAY A GAME? Using a mod... ‣ made by CompCom ‣ https://github.com/CompCom/OptionsMenu ‣ listens for key combo ‣ displays custom, configurable, menu
  • 28. SHALL WE PLAY A GAME? Extract game state from memory
  • 29. SHALL WE PLAY A GAME? Trigger events based on in-game activity
  • 30. SHALL WE PLAY A GAME? Manipulate memory / apply Game Genie codes
  • 31. SHALL WE PLAY A GAME? The Hardware
  • 32. SHALL WE PLAY A GAME? Hardware ‣ SoC: Allwinner R16 (4-core ARMv7) ‣ RAM: Ask NT5CC128M16IP-DI (256MB) ‣ NAND: Macronix MX30LF4G18AC-TI (512MB) ‣ PMU(Power Management Unit): X-POWER AXP223 ‣ HDMI Transmitter: EPMI EP952
  • 33. SHALL WE PLAY A GAME? Hardware ‣ can put the console into FEL (recovery) mode (a type of recovery mode) and get low-level access ‣ micro-usb port normally used for power ‣ with correct drivers enabled in the kernel can use of RNDIS to establish a network connection with host PC ‣ usb port is OTG - client and usb host mode
  • 34. SHALL WE PLAY A GAME? Internal Photos - SNES Classic
  • 35. SHALL WE PLAY A GAME? Internal Photos - SNES Classic
  • 36. SHALL WE PLAY A GAME? Internal Photos - SNES Classic
  • 37. SHALL WE PLAY A GAME? SoC Allwinner R16
  • 38. SHALL WE PLAY A GAME? Hardware connections
  • 39. SHALL WE PLAY A GAME? UART / Serial
  • 40. SHALL WE PLAY A GAME? UART (Serial) ‣ hidden on the board ‣ gives access to uboot console and linux boot messages ‣ baudrate is 115200 and is 3.3v ‣ requires USB to Serial adapter (FTDI / CH430 etc)
  • 41. SHALL WE PLAY A GAME? UART pins marked on back of board
  • 42. SHALL WE PLAY A GAME? UART (Serial) - boot messages: U-Boot 2011.09-rc1 (May 11 2017 - 16:32:31) Allwinner Technology 
 [ 0.220]version: 1.1.
 [ 0.223]uboot commit : eb2b275e0877fc98b3ba6d3b7bab225ebecb993a
 ready no battery, limit to dc
 no key input
 dram_para_set start
 dram_para_set end
 
 Using default environment
 
 In: Out: Err: 
 Uncompressing Linux... done, booting the kernel.
 ion: failed to create debug files.
 <4sunxi_leds_fetch_sysconfig_para script_parser_fetch "leds_para" leds_used = -1067179912 [ audio ] err:try to get audio_pa_ctrl failed! [I2S1]sunxi-i2s1 cannot find any using configuration for controllers, return directly!
 [I2S]sndi2s1 cannot find any using configuration for controllers, return directly
 ths_fetch_sysconfig_para: type err device_used = 1.
 fetch C0_LV_count from sysconfig failed
 

  • 43. SHALL WE PLAY A GAME? UART (Serial) - boot messages (hakchi): hakchi init script version: 1.0.2
 
 loading hakchi
 
 waiting for usbhost ... 0
 usbMode: device
 overmounting /bin
 overmounting /etc
 overmounting /root
 overmounting /etc/init.d/S92rndis on /etc/init.d/S90usb-gadget
 menu code: 000
 
 Welcome to CLOVER dp-sneseur-nerd release-v2.0.7-0-geb2b275BuildId final.cis.cis-d9- clvrel0.20170511164229CEST
 
 madmonkey login:
  • 44. SHALL WE PLAY A GAME? FEL Mode
  • 45. SHALL WE PLAY A GAME? FEL mode ‣ hold "reset" for 5 seconds while powering on ‣ a low-level USB programming and recovery mode in Boot ROM of Allwinner System-on-Chip ‣ FEL commands are chip, not device, specific ‣ read & write memory and execute code ‣ dump or write kernel and firmware
  • 46. SHALL WE PLAY A GAME? FEL mode - clean boot [ 0.213]
 
 U-Boot 2011.09-rc1 (May 11 2017 - 16:32:31) Allwinner Technology 
 
 [ 0.221]version: 1.1.0
 [ 0.223]uboot commit : eb2b275e0877fc98b3ba6d3b7bab225ebecb993a
 
 ready
 no battery, limit to dc
  • 47. SHALL WE PLAY A GAME? FEL mode - upload fes1.bin sunxi-fel write 0x2000 fes1.bin FEL mode - execute fes1.bin sunxi-fel exec 0x2000
  • 48. SHALL WE PLAY A GAME? FEL mode - Initialising DRAM and switch to FES fes commit : fc3061df4dbd4153819b2d2f141d82b88fea51cf
 
 begin to init dram
 DRAM DRIVE INFO: V1.7
 DRAM Type =3 (2:DDR2,3:DDR3,6:LPDDR2,7:LPDDR3)
 DRAM zq value: 00003bbbDRAM CLK =600 MHZ
 ID CHECK VERSION: V0.1
 using ic R16
 USE PLL DDR1
 USE PLL NORMAL
 PLL FREQUENCE = 1200 MHZ
 DRAM PLL DDR1 frequency extend open !
 ...
 DRAM PHY INTERFACE PARA = 02040102
 DRAM VTC is disable
 DRAM dynamic DQS/DQ ODT is on
 DRAM DQS gate is PD mode.
 DRAM one rank training is on,the value is 91003587
 DRAM work mode register value = 004318d4
 DRAM SIZE =256 M
 set one rank ODTMAP
 DRAM simple test OK.
 init dram ok
  • 49. SHALL WE PLAY A GAME? FES mode - upload uboot.bin sunxi-fel write 0x47000000 uboot.bin FES mode - command to run instead of kernel sunxi_flash phy_read 47400000 30 20;efex_test FES mode - kernel dump boot command sunxi-fel write 0x470604ff kernel_dump_bootcmd
  • 50. SHALL WE PLAY A GAME? FES mode - uboot booting [ 194.359]
 
 U-Boot 2011.09-rc1-00000-g1352b18-dirty (Jan 02 2017 - 10:46:29) Allwinner Technology 
 
 [ 194.368]version: 1.1.0
 [ 194.371]uboot commit : fc3061df4dbd4153819b2d2f141d82b88fea51cf
 
 ready no battery, limit to dc
 no key input
 dram_para_set start
 dram_para_set end
 Using default environment
 
 In: Out: Err: 
 Ph
  • 51. SHALL WE PLAY A GAME? Dump kernel to file sunxi-fel read 0x47400030 0x600000 kernel.dump (can then use additional tools to extract the "keyfile" from it to decrypt the NAND flash storage)
  • 52. SHALL WE PLAY A GAME? Weaponizing
  • 53. SHALL WE PLAY A GAME? Weaponizing: ‣ Connectivity ‣ Tools ‣ Backdooring
  • 54. SHALL WE PLAY A GAME? Adding WiFi: ‣ "WPA Supplication" (wifi) hmod ‣ correct OTG cable/adapter ‣ compatible network dongle (RTL8188 seems to work) ‣ SSH in, run "wifi-wpa-setup", restart with 
 OTG & wifi plugged in, hope for the best ‣ no visual indicator it works :/
  • 55. SHALL WE PLAY A GAME? wifi-wpa-setup mod:
  • 56. SHALL WE PLAY A GAME? wifi-wpa-setup mod: login as: root hakchi v1.0.4-122 by madmonkey Special thanks to all of the contributors including: potyl, mistydemeo,
 skogaby, DanTheMan827, KMFDManic, Mugi, princess_daphie, xorloser, ghoost82,
 thomas-alrek, ClusterM, zigg, thomascrha and anyone else I may have forgotten root@madmonkey:~# 
 
 
 
 

  • 57. SHALL WE PLAY A GAME? wifi-wpa-setup mod: login as: root hakchi v1.0.4-122 by madmonkey Special thanks to all of the contributors including: potyl, mistydemeo,
 skogaby, DanTheMan827, KMFDManic, Mugi, princess_daphie, xorloser, ghoost82,
 thomas-alrek, ClusterM, zigg, thomascrha and anyone else I may have forgotten root@madmonkey:~# wifi-wpa-setup 
 
 
 
 

  • 58. SHALL WE PLAY A GAME? wifi-wpa-setup mod: login as: root hakchi v1.0.4-122 by madmonkey Special thanks to all of the contributors including: potyl, mistydemeo,
 skogaby, DanTheMan827, KMFDManic, Mugi, princess_daphie, xorloser, ghoost82,
 thomas-alrek, ClusterM, zigg, thomascrha and anyone else I may have forgotten root@madmonkey:~# wifi-wpa-setup Enter your SSID (Your SSID must not include spaces):
 D-Link Enter your Wi-Fi password:
 hunter2 Details entered. You can reset your console now. Make sure that only your wifi
 adapter is connected on first boot. When your console boots, you need to turn
 off and reconnect your OTG hub and USB drive (if applicable). Failure to do so
 will mean you will have to restart the process.
  • 59. SHALL WE PLAY A GAME? Adding tools: ‣ via mods (eg: wireless tools, gdb) ‣ see HakchiResources.com "Experimental" mods ‣ or... add our own
  • 60. SHALL WE PLAY A GAME? (url/dns brute forcer for webapps) ‣ git clone and compile with static flags: ‣ output of "file": Porting GoBuster: CGO_ENABLED=0 GOOS=linux GOARM=7 GOARCH=arm go build -a 
 -ldflags '-extldflags "-static"' . gobuster: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), 
 statically linked, not stripped
  • 61. SHALL WE PLAY A GAME?
  • 62. SHALL WE PLAY A GAME? ‣ Kali is available for "ARMHF" ‣ can be run on a Raspberry Pi ‣ comes bundled with tools :D ‣ output of "file": Porting Nmap: /usr/bin/nmap: ELF 32-bit LSB pie executable ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.3, for GNU/Linux 3.2.0
  • 63. SHALL WE PLAY A GAME? ‣ output of "ldd": Porting Nmap: libpcre.so.3 => /lib/arm-linux-gnueabi/libpcre.so.3 (0xb6c37000)
 libssh2.so.1 => /lib/arm-linux-gnueabi/libssh2.so.1 (0xb6c02000)
 libssl.so.1.1 => /lib/arm-linux-gnueabi/libssl.so.1.1 (0xb6ba1000)
 libcrypto.so.1.1 => /lib/arm-linux-gnueabi/libcrypto.so.1.1 (0xb69cc000)
 libz.so.1 => /lib/arm-linux-gnueabi/libz.so.1 (0xb69a2000)
 liblua5.3.so.0 => /lib/arm-linux-gnueabi/liblua5.3.so.0 (0xb6964000)
 liblinear.so.3 => /lib/arm-linux-gnueabi/liblinear.so.3 (0xb6944000)
 libstdc++.so.6 => /lib/arm-linux-gnueabi/libstdc++.so.6 (0xb67fe000)
 libm.so.6 => /lib/arm-linux-gnueabi/libm.so.6 (0xb673b000)
 libgcc_s.so.1 => /lib/arm-linux-gnueabi/libgcc_s.so.1 (0xb670c000)
 libc.so.6 => /lib/arm-linux-gnueabi/libc.so.6 (0xb65b9000)
 /lib/ld-linux.so.3 (0xb6fc8000)
 libpthread.so.0 => /lib/arm-linux-gnueabi/libpthread.so.0 (0xb658e000)
 libgcrypt.so.20 => /lib/arm-linux-gnueabi/libgcrypt.so.20 (0xb64c1000)
 libdl.so.2 => /lib/arm-linux-gnueabi/libdl.so.2 (0xb64ae000)
 libblas.so.3 => /lib/arm-linux-gnueabi/libblas.so.3 (0xb6416000)
 libgpg-error.so.0 => /lib/arm-linux-gnueabi/libgpg-error.so.0 (0xb63ec000)
 libgfortran.so.5 => /lib/arm-linux-gnueabi/libgfortran.so.5 (0xb630b000)
  • 64. SHALL WE PLAY A GAME? ‣ copy binary + files + dependencies to NES Classic ‣ use "LD_LIBRARY_PATH" to load dependencies when running Porting Nmap: LD_LIBRARY_PATH=. ./nmap <target> <options>
  • 65. SHALL WE PLAY A GAME?
  • 66. SHALL WE PLAY A GAME? ‣ In Ubuntu 16.04 Porting socat: sudo apt install gcc-4.8-arm-linux-gnueabihf # download and extract socat .tar.get:
 # http://www.dest-unreach.org/socat/download/socat-1.7.3.2.tar.gz ./configure LDFLAGS="-static"
 sed -i 's/gcc/arm-linux-gnueabihf-gcc/g' Makefile
 make file ./socat
 => ELF 32-bit LSB executable, ARM, EABI5 version 1 (GNU/Linux), statically linked, for GNU/Linux 3.2.0 ‣ Output of "file":
  • 67. SHALL WE PLAY A GAME? ‣ using a Raspberry Pi + Kali ARMHF Compiling sources: gcc slideshow.c -o slideshow --static
 => ELF 32-bit LSB executable, ARM, EABI5 version 1 (...), statically linked, for GNU/Linux 3.2.0 ‣ use GCC cross compilation arm-linux-gnueabihf-gcc slideshow.c -o slideshow --static
 => ELF 32-bit LSB executable, ARM, EABI5 version 1 (...), statically linked, for GNU/Linux 3.2.0 ✓ ✓ ‣ using DockCross (dockcross-linux-armv7) ./dockcross-linux-armv7 bash -c '$CC slideshow.c -o slideshow --static'
 => ELF 32-bit LSB executable, ARM, EABI5 version 1 (...), statically linked, for GNU/Linux 4.10.8 ✗ ("for Linux 4.10.8", gives a "FATAL: kernel too old" error)
  • 68. SHALL WE PLAY A GAME? These Slides!
  • 69. SHALL WE PLAY A GAME? Interacting with the hardware: ‣ FrameBuffer is used for video: /dev/fb0 ‣ have to pause UI/emulator to write to it kill -STOP `pgrep kachikachi`
 kill -STOP `pgrep ReedPlayer-Clover` ‣ controller events can be read from /dev/inputs/joystick ‣ events have a timestamp, value, type and number ‣ there's a "/dev/inputs/event4" for reset button event
  • 70. SHALL WE PLAY A GAME? Interacting with the hardware: ‣ "read_event" loop ‣ if left/right/A/B button ‣ next/previous slide ‣ check if video or image file exists ‣ output using "ffmpeg" or "decodepng" to frame buffer ‣ these slides are (hopefully) being played from our custom slideshow app :D/
  • 71. SHALL WE PLAY A GAME? Other stuff
  • 72. SHALL WE PLAY A GAME? Misc stuff: ‣ hakchi .hmod (mods) are just tar files:
 tar -czvf "../MyMod.hmod" * ‣ Can have multiple firmwares on a single device and swap between them (eg: NES on SNES) ‣ Active community on Reddit and Discord ‣ Wolf3D (and other games) ported across! ‣ Theres a "FBVNC" (FrameBuffer VNC) but
 frame rate is low with tearing
  • 73. SHALL WE PLAY A GAME? Misc stuff: ‣ "reset" button sends an event to "/dev/inputs/event4" ‣ input events have "time", "value", "type" and number" ‣ can capture + replay "reset" event:
 cat /dev/inputs/event4 > reset.bin
 cat reset.bin > /dev/inputs/event4 ‣ was not able to automate/replay joystick
 inputs (was hoping to make a Mario bot)
  • 74. SHALL WE PLAY A GAME? RetroArch: ‣ RetroArch emulator adds supports from many more platforms: * snes9x2010 (Super Famicom/Super Nintendo)
 * gambatte_libretro (Game Boy, Game Boy Color)
 * mgba (Game Boy Advance)
 * genesis_plus_gx (Sega Master System, Genesis/Mega Drive, Game Gear)
 * stella (Atari 2600)
 * mednafen_pce_fast (PC Engine/Turbografx 16)
 * fb_alpha and fb_alpha_cps2 (various arcade machines)
 * picodrive (Sega Master System, Genesis/Mega Drive, Game Gear, Sega)
 * dosbox and more: http://buildbot.libretro.com/nightly/linux/armhf/
  • 75. SHALL WE PLAY A GAME? Stuff that sucked: ‣ Trying to get an OTG adapter (had to order online) ‣ getting USB and wifi working is mostly blind ‣ "just" use BuildRoot - https://hakchi.net/hakchi/sdk/ ‣ "just" use GCC <= 4.9 (good luck if you need zlib) ‣ compiling stuff for SDL is a major pain ‣ relatively easy to crash to console
  • 76. SHALL WE PLAY A GAME? ‣ eBay OTG adapter ‣ Amazon OTG adapter ‣ Hakchi Community Edition ‣ HakchiResources (mods + Discord Channel) Links
  • 77. SHALL WE PLAY A GAME? ‣ https://www.xor.co.za/talks/shall_we_play/ (Dale) ‣ https://www.hypn.za.net/blog/?p=1272 (Ross) Our notes + more info: Thanks!