• Stars
    star
    132
  • Rank 274,205 (Top 6 %)
  • Language
    Assembly
  • License
    The Unlicense
  • Created over 6 years ago
  • Updated almost 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Reverse-engineering efforts to generate license keys for Raspberry Pi hardware video decoding

raspi-keygen

This is an effort to reverse-engineer the Raspberry Pi license key check for MPEG-2 and VC-1 hardware video encoding.

Patch

A patch for start.elf, a firmwware blob for the VideoCore IV processor used by all Raspberry Pi models, was posted to reddit by /u/fuck_the_mpeg_la on 03-03-2017:

cd /boot
cp start.elf start.elf_backup && \
 perl -pne 's/\x47\xE9362H\x3C\x18/\x47\xE9362H\x3C\x1F/g' < start.elf_backup > start.elf

Applying it to a 4.14.44 start.elf (latest as of time of writing) results in the following diff:

$ diff <(xxd -e start.elf_backup) <(xxd -e start.elf)
38340c38340
< 00095c30: 400703a4 40161799 3633e947 183c4832  ...@[email protected]<.
---
> 00095c30: 400703a4 40161799 3633e947 1f3c4832  ...@[email protected]<.
$ md5sum start.elf_backup start.elf
8327a0720f806814b677efaeb94a7671  start.elf_backup
fe55537c71b22e8f8c1a92257da2c45b  start.elf

Some initial analysis was done by q3k on Hacker News:

Yes, it seems to patch a licensing function at 0xEC95FD4 [1] to always return 1, by patching the jump at 0xEC95FE2 (that should be only taken for the always-allowed H263 codec) to always be taken, thus always allowing all codecs.

Mirrored from https://q3k.org/u/8e3173aef341df726e4f38f30e58417239423250f3e44f5b8b79acdc451d1553.png

Reverse-engineering

The initial entry point is disassembled using the VideoCore IV plugin for IDA Pro 6 by hermanhermitage.

After loading and analyzing start.elf, we can find the is_licensed routine at address 0xEC96290 by jumping to the file offset given to us by xxd beforehand. The relevant code sections are available in sub_EC96290.asm and is_licensed.asm.

not_WMV9:				; CODE XREF: is_licensed+56�j
		cmp	r7, 'MPG2'
		cmpeq	r6, 0
		bne	not_MPG2
		ld	r1, 0x1DC0(gp) ; XREF 0xEE86680	dword_EE86680
		addcmpbne r1, 0, 0, return_1

not_MPG2:				; CODE XREF: is_licensed+68�j
		cmp	r7, 'WVC1'
		cmpeq	r6, 0
		bne	deny
		ld	r2, 0x2120(gp) ; XREF 0xEE869E0	dword_EE869E0
		addcmpbeq r2, 0, 0, deny

Here, two memory locations (0xEE86680 for MPEG-2 and 0xEE869E0 for VC-1) that point to the .bss segment are checked to determine the return value of is_licensed. There are no other obvious references to these locations in start.elf, so memory-breakpoint debugging (TBD) is probably needed.

More Repositories

1

sfxrlua

A port of the sfxr sound effect synthesizer to Lua
Lua
97
star
2

mmpi-2

An implementation of the MMPI-2 (Minnesota Multiphasic Personality Inventory rev. 2)
JavaScript
52
star
3

tcclua

LuaJIT FFI bindings for the Tiny C Compiler
Lua
26
star
4

icedrop

HTML5 audio visualization and station selector for Icecast servers
JavaScript
9
star
5

jsbp

A web-based BytePusher VM written in JavaScript, intended as a Chrome experiment
JavaScript
9
star
6

art

OpenCL raytracing pipeline as a LuaJIT library
Lua
7
star
7

hedgecam-mirror

Git mirror of HedgeCam 2 by Caddish Hedgehog aka alexxxx82
Java
6
star
8

sdvx-emulator

A basic Sound Voltex emulator with support for K-Shoot MANIA maps, written in Lua using LÖVE
Lua
5
star
9

dbp

A little implementation of the BytePusher virtual machine, written in the D language and using the Derelict SDL 2 bindings.
D
5
star
10

powder-djs

An ironic attempt at a powder/particle-based game
Dogescript
3
star
11

equatio

An interactive canvas-based experiment inspired by IBNIZ and derivatives
JavaScript
3
star
12

oxy

XY-Oscilloscope visualization for JACK
D
2
star
13

fullmoviefinder

Web utility that searches the FullMoviesOnX subreddits for a movie title and embeds the matching player
JavaScript
2
star
14

stuff

Things I made that don't deserve their own repo
JavaScript
2
star
15

wkill

Xkill for Windows
C#
2
star
16

gofigure

An IRC statistics generator that actually works! (hopefully, once it's actually written)
Python
2
star
17

jsparty

Multiplayer JavaScript console mayhem
JavaScript
1
star
18

kirei

A basic open-source osu! skin, built from the ground up in SVG
Python
1
star
19

aiotpt

Server for The Powder Toy written in Python
Python
1
star
20

bloodagar

A reimplementation of the Agar.io client
JavaScript
1
star
21

Js141

[DEFUNCT] Emulator of the Busicom 141PF, including the Intel 4004 CPU
JavaScript
1
star
22

tipstatbot

Node.js IRC bot that provides interesting statistics about public Doger tips
JavaScript
1
star
23

reactor

[DEFUNCT] Multi-language graphical element generator for The Powder Toy and an alternative GUI library
Lua
1
star
24

Moeterial

An online skin editor for osu!
JavaScript
1
star
25

0x20hues

A port of 0x40 Hues to the Lua LÖVE engine
Lua
1
star