Ledger-Donjon / rainbow

Makes Unicorn traces. Generic Side-Channel and Fault Injection simulator
GNU Lesser General Public License v3.0
172 stars 34 forks source link

elfloader is broken with LIEF 0.10.0-826965b #3

Closed snx90 closed 5 years ago

snx90 commented 5 years ago

CortexM_AES example in an Ubuntu 19.04 64-bit is broken (similar issue with other examples):

santitox@ubuntu:~/Tools/sca/rainbow/examples/CortexM_AES$ python3 cortexm_aes.py Exported functions... Traceback (most recent call last): File "cortexm_aes.py", line 54, in traces = np.array([aes_encrypt(KEY, bytes(values[i])) for i in range(N)]) File "cortexm_aes.py", line 54, in traces = np.array([aes_encrypt(KEY, bytes(values[i])) for i in range(N)]) File "cortexm_aes.py", line 23, in aes_encrypt e.start(e.functions["AES_128_keyschedule"] | 1, 0) KeyError: 'AES_128_keyschedule'

There is a problem with elfloader using LIEF 0.10.0-826965b:

import lief lief.version '0.10.0-826965b' elffile = lief.parse("aes.bin") elffile.segments for r in elffile.relocations: ... if r.symbol.is_function: ... print("[+] Function found") ...

No output, hence no function found. Also, in the following code there is another issue:

for i in elffile.exported_functions: ... elffile.get_function_address(i) ... Traceback (most recent call last): File "", line 2, in TypeError: get_function_address(): incompatible function arguments. The following argument >types are supported:

  1. (self: lief.Binary, function_name: str) -> int

This latter issue seems to be fixed with the following:

for i in elffile.exported_functions: ... elffile.get_function_address(i.name) ... 1025 1769 5793 8785

Besides fixing this problem, it would be nice to have a docker image to check which versions you are considering.

yhql commented 5 years ago

Hi, thanks for the heads-up ! I'll push a fix in a minute.

As for which version should be used, the requirements in setup.py should cover for that, but I had not tested with recent versions of LIEF...

snx90 commented 5 years ago

Thanks for the quick fix!