If you don't know Gynvael - check his channel where he shows some RE/hacking stuff. After each video he posts some small challenge for solving by viewers. In this post I'll show how to solve mission 11.
In this task we're given a file that is the "firmware". When we open the file it is immediately know that it's a python byte code. If you don't know it - it's quite simple and actually very descriptive.
If you apply the opcodes definition to the given firmware you will start reconstructing the original function that was written in python.
It's not hard at all as all the information is given and not obfuscated at all.
So for example the lines:
0 LOAD_CONST 1
3 LOAD_ATTR 0
6 LOAD_CONST 2
9 CALL_FUNCTION 1
can be written in python as
"4e5d4e92865a4e495a86494b5a5d49525261865f5758534d4a89".decode('hex'). If we follow that for the rest of the file we are able to reconstruct the original function as:
And if we want to find out the password we need to create a reverse function.
If we run this, we will get:
huh, that actually worked! which is the mission password.