lifting-bits / mcsema

Framework for lifting x86, amd64, aarch64, sparc32, and sparc64 program binaries to LLVM bitcode
https://www.trailofbits.com/expertise/mcsema
GNU Affero General Public License v3.0
2.65k stars 343 forks source link

mcsema-disass failure #563

Open weiwang999 opened 5 years ago

weiwang999 commented 5 years ago

weiwang99@cs000061:~/mcsema-ve/remill$ mcsema-disass --disassembler ~/ida-7.2/idat64 --os linux --arch amd64 --output xz.cfg --binary xz --entrypoint main --log_file xz.log Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/mcsema_disass-2.0-py2.7.egg/mcsema_disass/ida7/disass.py", line 77, in execute cwd=os.path.dirname(file)) File "/usr/lib/python2.7/subprocess.py", line 541, in check_call raise CalledProcessError(retcode, cmd) CalledProcessError: Command '/home/weiwang99/ida-7.2/idat64 -B -S"/usr/local/lib/python2.7/dist-packages/mcsema_disass-2.0-py2.7.egg/mcsema_disass/ida7/get_cfg.py --output /home/weiwang99/mcsema-ve/remill/xz.cfg --log_file /home/weiwang99/mcsema-ve/remill/xz.log --arch amd64 --os linux --entrypoint main" /tmp/tmpVs3NWU/xz' returned non-zero exit status 1 Could not generate a CFG. Try using the --log_file option to see an error log. Traceback (most recent call last): File "/usr/local/bin/mcsema-disass", line 9, in load_entry_point('mcsema-disass==2.0', 'console_scripts', 'mcsema-disass')() File "/usr/local/lib/python2.7/dist-packages/mcsema_disass-2.0-py2.7.egg/mcsema_disass/main.py", line 162, in main if 0 == os.path.getsize(args.output): File "/usr/lib/python2.7/genericpath.py", line 57, in getsize return os.stat(filename).st_size OSError: [Errno 2] No such file or directory: '/home/weiwang99/mcsema-ve/remill/xz.cfg'

artemdinaburg commented 5 years ago

For some reason IDA is having a problem before it can open the log file. Can you try running the script manually, something like:

This is the same command line as the log but without -B.

/home/weiwang99/ida-7.2/idat64 -S"/usr/local/lib/python2.7/dist-packages/mcsema_disass-2.0-py2.7.egg/mcsema_disass/ida7/get_cfg.py --output /home/weiwang99/mcsema-ve/remill/xz.cfg --log_file /home/weiwang99/mcsema-ve/remill/xz.log --arch amd64 --os linux --entrypoint main" xz

The IDA screen should hopefully have some useful information for you in an error message or similar.

weiwang999 commented 5 years ago

Screenshot from 2019-05-09 17-52-23

artemdinaburg commented 5 years ago

Thanks for posting. Were there any IDAPython messages? I didn't see any in your console. Does the console just exit after a bit? If yes, then it should have done something.

I also notice that your directory is ~/mcsema-ve but you are using the system install of mcsema. If you installed to a virtualenv, don't forget to source ~/mcsema-ve/bin/activate.

As a sidenote, I just tried with latest mcsema and IDA 7.1, and it works for me on xz from 1604 and 1804.

Other things to try:

edit /usr/local/lib/python2.7/dist-packages/mcsema_disass-2.0-py2.7.egg/mcsema_disass/ida7/get_cfg.py and comment out the last two lines, which are responsible for quitting IDA.

Then re-run using the QT IDA and see if you get any more useful error messages, via:

/home/weiwang99/ida-7.2/ida64 -S"/usr/local/lib/python2.7/dist-packages/mcsema_disass-2.0-py2.7.egg/mcsema_disass/ida7/get_cfg.py --output /home/weiwang99/mcsema-ve/remill/xz.cfg --log_file /home/weiwang99/mcsema-ve/remill/xz.log --arch amd64 --os linux --entrypoint main" xz

(edited to fix above command line)

yueyuep commented 5 years ago

when i use the mcsema,i met the same problems as above,but i use the IDA PRO(v6.4),whether this problems is caused by the version of IDA pro.

artemdinaburg commented 5 years ago

The 6.x series should still work (we test with 6.9 occasionally), although 6.4 is a bit ancient.

weiwang999 commented 5 years ago

Screenshot from 2019-05-10 15-15-00

artemdinaburg commented 5 years ago

Thats a very odd error. Do you by chance have the IDA Student license? That one has a 1MB size limit for open files.

weiwang999 commented 5 years ago

No. I used the pro version

artemdinaburg commented 5 years ago

Can you try launching the gui version (ida64 instead of idat64) but with the same command line?

salomon1184 commented 4 years ago

I get a error with the same question too (in docker vm) Traceback (most recent call last): File "/opt/ida-6.8/python/init.py", line 14, in <module> import os zipimport.ZipImportError: can't decompress data; zlib not available Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/mcsema_disass-2.0-py2.7.egg/mcsema_disass/ida/disass.py", line 77, in execute cwd=os.path.dirname(__file__)) File "/usr/lib/python2.7/subprocess.py", line 190, in check_call raise CalledProcessError(retcode, cmd) CalledProcessError: Command '/opt/ida-6.8/idal64 -B -S"/usr/local/lib/python2.7/dist-packages/mcsema_disass-2.0-py2.7.egg/mcsema_disass/ida/get_cfg.py --output /home/user/local/test.cfg --log_file /home/user/local/log.txt --arch amd64 --os linux --entrypoint main --pie_mode" /tmp/tmp6VBGjG/xxxxx' returned non-zero exit status 1 Could not generate a CFG. Try using the --log_file option to see an error log. Traceback (most recent call last): File "/usr/local/bin/mcsema-disass", line 11, in <module> load_entry_point('mcsema-disass==2.0', 'console_scripts', 'mcsema-disass')() File "/usr/local/lib/python2.7/dist-packages/mcsema_disass-2.0-py2.7.egg/mcsema_disass/__main__.py", line 163, in main if 0 == os.path.getsize(args.output): File "/usr/lib/python2.7/genericpath.py", line 57, in getsize return os.stat(filename).st_size OSError: [Errno 2] No such file or directory: '/home/user/local/test.cfg'

I tried with ida 6.8 pro without -B like this : /opt/ida-6.8/idal64 -S"/usr/local/lib/python2.7/dist-packages/mcsema_disass-2.0-py2.7.egg/mcsema_disass/ida/get_cfg.py --output /home/ToB/test.cfg --log_file /home/ToB/log.txt --arch x86 --os linux --entrypoint main"

same internal error occured, without log file generated image

is there some suggestion or help?