a0rtega / metame

metame is a metamorphic code engine for arbitrary executables

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Key error in fcn_ctx

Sycor4x opened this issue · comments

I've run into an error using metame. It appears that fcn_ctx is missing the key 'type'.

I'm using python 3.5.

$ metame -i file.exe -o foo.exe
[INFO] Opening file with r2
[INFO] Analyzing functions with r2
[anal.jmptbl] Missing cjmp bb in predecessor at 0x0040485b
[anal.jmptbl] Missing cjmp bb in predecessor at 0x0040485b
[anal.jmptbl] Missing cjmp bb in predecessor at 0x0040485b
[anal.jmptbl] Missing cjmp bb in predecessor at 0x0040485b
[anal.jmptbl] Missing cjmp bb in predecessor at 0x0040485b
[anal.jmptbl] Missing cjmp bb in predecessor at 0x0040485b
[anal.jmptbl] Missing cjmp bb in predecessor at 0x0040485b
[anal.jmptbl] Missing cjmp bb in predecessor at 0x0040485b
[anal.jmptbl] Missing cjmp bb in predecessor at 0x004049f7
[INFO] Loading functions information
[INFO] Replacing instructions
Traceback (most recent call last):
  File "venv/bin/metame", line 5, in <module>
    metame.main()
  File "venv/lib/python3.5/site-packages/metame/__init__.py", line 20, in main
    patches = r.iterate_fcn()
  File "venv/lib/python3.5/site-packages/metame/r2parser.py", line 43, in iterate_fcn
    replacements += arch.replace_fcn_opcodes(fcn_ctx)
  File "venv/lib/python3.5/site-packages/metame/x86handler.py", line 174, in replace_fcn_opcodes
    if fcn_ctx["ops"][count]["type"] not in self.mutables:
KeyError: 'type'

It seems that this could be easy enough to fix -- use the dict.get method & provide a sensible default.

Sorry for the late response!

I've fixed it in the git version and soon in pip. Thanks!