Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide helpful debug when Unicorn is not installed #22

Closed
ebursztein opened this issue Sep 4, 2020 · 2 comments
Closed

Provide helpful debug when Unicorn is not installed #22

ebursztein opened this issue Sep 4, 2020 · 2 comments
Assignees
Labels
component:scald scald related issue type:bug Something isn't working

Comments

@ebursztein
Copy link
Collaborator

Currently the leak mapping code don't work when unicorn is not installed but don't crash and as a result silently fail

[Emulating target]
Starting emulation
Traceback (most recent call last):
  File "_ctypes/callbacks.c", line 234, in 'calling callback function'
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/unicorn-1.0.2rc4-py3.6.egg/unicorn/unicorn.py", line 479, in _hookcode_cb
  File "/Users/elieb/git/scaaml/scaaml/scald/tracer/devices/rainbow/generics/cortexm.py", line 109, in block_handler
    self.base_block_handler(address)
  File "/Users/elieb/git/scaaml/scaaml/scald/tracer/devices/rainbow/rainbow.py", line 414, in base_block_handler
    r = self.stubbed_functions[f](self)
  File "/Users/elieb/git/scaaml/scaaml/scald/tracer/chipwhisperer_leakage_automaton.py", line 194, in trigger_high
    self.trigger_hook = e.emu.hook_add(uc.UC_HOOK_MEM_WRITE,
NameError: name 'uc' is not defined
Traceback (most recent call last):
  File "_ctypes/callbacks.c", line 234, in 'calling callback function'
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/unicorn-1.0.2rc4-py3.6.egg/unicorn/unicorn.py", line 479, in _hookcode_cb
  File "/Users/elieb/git/scaaml/scaaml/scald/tracer/devices/rainbow/generics/cortexm.py", line 109, in block_handler
    self.base_block_handler(address)
  File "/Users/elieb/git/scaaml/scaaml/scald/tracer/devices/rainbow/rainbow.py", line 414, in base_block_handler
    r = self.stubbed_functions[f](self)
  File "/Users/elieb/git/scaaml/scaaml/scald/tracer/chipwhisperer_leakage_automaton.py", line 205, in trigger_low
    e.emu.hook_del(self.trigger_hook)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/unicorn-1.0.2rc4-py3.6.egg/unicorn/unicorn.py", line 592, in hook_del
TypeError: an integer is required (got type NoneType)
Encryption: FAIL
KEY=2b7e151628aed2a6abf7158809cf4f3c
 PT=6bc1bee22e409f96e93d7e117393172a
EXP=3ad77bb40d7a3660a89ecaf32466ef97
@ebursztein ebursztein added type:bug Something isn't working component:scald scald related issue labels Sep 4, 2020
@jmichelp
Copy link
Collaborator

jmichelp commented Sep 9, 2020

When I manually uninstalled unicorn and launched the tool, I got a completely different message than yours:

python3 emulate_target.py -c config/stm32f415_tinyaes_sync.json
scaaml/scald/tracer/devices/rainbow/rainbow.py:356: SyntaxWarning: "is" with a literal. Did you mean "=="?
if s is '':
Traceback (most recent call last):
File "emulate_target.py", line 18, in <module>
from scaaml.scald.tracer import ChipwhispererLeakageAutomaton
File "scaaml/scald/tracer/__init__.py", line 1, in <module>
from .chipwhisperer_leakage_automaton import ChipwhispererLeakageAutomaton  # noqa
File "scaaml/scald/tracer/chipwhisperer_leakage_automaton.py", line 4, in <module>
from .devices import Stm32f415
File "scaaml/scald/tracer/devices/__init__.py", line 17, in <module>
from .stm32 import Stm32fxxx  # noqa
File "scaaml/scald/tracer/devices/stm32.py", line 20, in <module>
from .cortex_m4 import CortexM4
File "scaaml/scald/tracer/devices/cortex_m4.py", line 2, in <module>
from .rainbow.generics import rainbow_cortexm
File "scaaml/scald/tracer/devices/rainbow/__init__.py", line 19, in <module>
from .rainbow import rainbowBase  # noqa
File "scaaml/scald/tracer/devices/rainbow/rainbow.py", line 22, in <module>
import unicorn as uc
ModuleNotFoundError: No module named 'unicorn'

And the execution stopped there.

According to your output, unicorn is installed but something's wrong with it.
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/unicorn-1.0.2rc4-py3.6.egg/unicorn/unicorn.py", line 479, in _hookcod tells me that it is installed.

@jmichelp
Copy link
Collaborator

jmichelp commented Sep 9, 2020

The problem came from commit ae12d7d which remove the following line:

import unicorn as uc

@jmichelp jmichelp reopened this Sep 9, 2020
@jmichelp jmichelp closed this as completed Sep 9, 2020
invernizzi pushed a commit that referenced this issue Mar 19, 2021
Commit ae12d7d removed a necessary
import.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:scald scald related issue type:bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants