ReassemblerBackend Error
pfsun opened this issue · 10 comments
Hi,
I just install and try patcherex. When I try the example "modifies the binary CADET_00003 so that it prints "HI!" ", if I use backend = DetourBackend
, everything compiles and runs well. However, if I use backend = ReassemblerBackend
, there will be the following error:
Traceback (most recent call last):
File "test_sun.py", line 38, in <module>
backend.save("/tmp/CADET_00003_mod1")
File "/var/home/psun/fla/angr-rw/patcherex/patcherex/backends/reassembler_backend.py", line 134, in save
raise CompilationError("File: %s Error: %s" % (tmp_file_path,res))
patcherex.errors.CompilationError: File: /tmp/CADET_000032Yp69w.s Error: ('', 'bash: /var/home/psun/.virtualenvs/angr-rw/local/lib/python2.7/site-packages/compilerex/../assemble.sh: No such file or directory\n')
You also need compilerex
to automatically compile things.
Also, at the moment, Patcherex does not work with the latest angr on master (after a gigantic merge occurred earlier this morning). I hope we will fix it soon.
Here is compilerex: https://github.com/mechaphish/compilerex
I do install compilerex. It looks the reason is path problem "/var/home/psun/.virtualenvs/angr-rw/local/lib/python2.7/site-packages/compilerex/../assemble.sh". When I install compilerrex, the assemble.sh will not copy to ../site-packages/
It looks like a problem of the setup.py
in compilerex. It will be fixed. Thanks for reporting.
For now, please manually copy the script there.
PS: I wish I could move issues across repos!
Now I copy the assemble.sh to this dir. And I also check the $DIR in assemble.sh (You may also fix it). If I don't change it, the error cannot find clang line 29: /var/home/psun/.virtualenvs/angr rw/local/lib/python2.7/site-packages/compilerex/../bin/clang: No such file or directory\n
.
After I modify $DIR. There is error for "error: instruction requires: Not 64-bit mode". Do you use Patcherex in 32bit machine or 64bit machine?
raise CompilationError("File: %s Error: %s" % (tmp_file_path,res))
patcherex.errors.CompilationError: File: /tmp/CADET_00003UFltFE.s Error: ('/usr\n/var/home/psun/.virtualenvs/angr-rw/local/lib/python2.7/site-packages/compilerex/..\n/var/home/psun/.virtualenvs/angr-rw/lib/python2.7/site-packages\n', '/tmp/CADET_00003UFltFE.s:11:1: error: instruction requires: Not 64-bit mode\npushal\n^\n/tmp/CADET_00003UFltFE.s:18:1: error: instruction requires: Not 64-bit mode\npopal\n^\n/tmp/CADET_00003UFltFE.s:19:1: error: instruction requires: Not 64-bit mode\nretl\n^\n/tmp/CADET_00003UFltFE.s:29:2: error: instruction requires: Not 64-bit mode\n pushl %ebp\n ^\n/tmp/CADET_00003UFltFE.s:53:2: error: instruction requires: Not 64-bit mode\n calll s
And then I add -m32 flag. The error is like:
raise CompilationError("File: %s Error: %s" % (tmp_file_path,res))
patcherex.errors.CompilationError: File: /tmp/CADET_00003FVjDDf.s Error: ('/usr\n/var/home/psun/.virtualenvs/angr-rw/local/lib/python2.7/site-packages/compilerex/..\n/var/home/psun/.virtualenvs/angr-rw/lib/python2.7/site-packages\n', '/usr/bin/ld.bfd.real: unrecognised emulation mode: cgc_i386\nSupported emulations: elf_x86_64 elf32_x86_64 elf_i386 i386linux elf_l1om elf_k1om i386pep i386pe\nclang: error: linker command failed with exit code 1 (use -v to see invocation)\n')
The test case you are running uses a CGC binary, which uses x86 instructions internally. You'll want to use the CGC-version clang. It supports the emulation mode cgc_i386
.
Have you tried it successfully?why I use cgc clang and it also doesn't support the cgc_i386 mode.
This issue has been marked as stale
because it has no recent activity. Please comment or add the pinned
tag to prevent this issue from being closed.
This issue has been closed due to inactivity.