Cannot print pcode
Closed this issue · 2 comments
Hi:
I am trying to use pypcode to generate pcode from binary. And I always receive baddataerror as followed:
(pypcode) muqi@muqi-desktop:~/pcode_test/code_A_calls_B/angr_script$ python -m pypcode x86:LE:64:default -r /bin/true
--------------------------------------------------------------------------------
00000000/2: JG 0x47
--------------------------------------------------------------------------------
0: unique[0x19e0:1] = BOOL_NEGATE register[0x206:1]
1: unique[0x19f0:1] = INT_EQUAL register[0x20b:1], register[0x207:1]
2: unique[0x1a10:1] = BOOL_AND unique[0x19e0:1], unique[0x19f0:1]
3: CBRANCH ram[0x47:8], unique[0x1a10:1]
** An error occured during translation: BadDataError('r0x00000002: Unable to resolve constructor',)
Tried pypcode from 1.0.0 to the current version on my virtual environment, all report the same.
Btw, The pypcode with version 0.0.2 works well for me.
Is that because I missed some settings relating to cffi?
Thanks!
my python version is 3.6.9, os version ubuntu 18.04 and here is my pip list:
(pypcode) muqi@muqi-desktop:~/pcode_test/code_A_calls_B/angr_script$ pip list
(pypcode) muqi@muqi-desktop:~/pcode_test/code_A_calls_B/angr_script$ pip list
Package Version
------------- -------
cffi 1.14.6
pip 21.2
pkg_resources 0.0.0
pycparser 2.20
pypcode 1.0.1
setuptools 57.4.0
wheel 0.36.2
pypcode doesn't understand executable formats and is choking on input it can't decode. You'll need to have a file with some raw executable code in it, or you can write a script to load an ELF and decode it with pypcode library.
Aha, I see. Thanks a lot! Could I have one more question about printing?
Everytime I run the "block().vex.pp()" using pcode as IR in anger, I will have error as followed:
import angr
p = angr.Project('./Hash_Function_Shift_Folding_Linked_List_clang', engine=angr.engines.UberEnginePcode)
#p.factory.entry_state().block().vex.pp()
Traceback (most recent call last):
File "angr_test.py", line 4, in <module>
p.factory.entry_state().block().vex.pp()
File "/home/muqi/decompile_tool/angr-dev/angr/angr/sim_state.py", line 598, in block
return self.project.factory.block(*args, backup_state=self, **kwargs)
File "/home/muqi/decompile_tool/angr-dev/angr/angr/factory.py", line 311, in block
cross_insn_opt=cross_insn_opt,
File "/home/muqi/decompile_tool/angr-dev/angr/angr/block.py", line 187, in __init__
buffer, _, offset = self._vex_engine._load_bytes(addr - thumb, size, state=backup_state)
ValueError: not enough values to unpack (expected 3, got 2)
I used the latest version of angr and pypcode:
(angr_latest_offiical) muqi@muqi-desktop:~/decompile_tool/some_open_source_projects/test_C_programming/test_muqi/originalclang$ pip list
Package Version
----------------- ------------
ailment 9.0.9166
angr 9.0.9166
archinfo 9.0.9166
bitstring 3.1.7
cachetools 4.2.2
capstone 4.0.2
cffi 1.14.6
claripy 9.0.9166
cle 9.0.9166
CppHeaderParser 2.7.4
decorator 4.4.2
dpkt 1.9.6
future 0.18.2
gitdb 4.0.7
GitPython 3.1.18
itanium-demangler 1.0
mulpyplexer 0.9
nampa 0.1.1
networkx 2.5.1
pefile 2021.5.24
pip 21.2.1
pkg_resources 0.0.0
plumbum 1.7.0
ply 3.11
progressbar2 3.53.1
protobuf 3.17.3
psutil 5.8.0
pycparser 2.20
pyelftools 0.27
pypcode 1.0.2
PySMT 0.9.1.dev137
python-utils 2.5.6
pyvex 9.0.9166
rpyc 5.0.1
setuptools 57.4.0
six 1.16.0
smmap 4.0.0
sortedcontainers 2.4.0
typing-extensions 3.10.0.0
unicorn 1.0.2rc4
wheel 0.36.2
z3-solver 4.8.12.0
and with same command, the old version(angr 9.0.4885 + pypcode 0.0.2) prints good for me.