cuckoo相关

本文档解决了多个Python库的安装与使用过程中遇到的问题,包括pefile版本过旧、weasyprint安装与中文显示、re2安装失败、m2crypto安装错误及yara模块导入等问题,并提供了详细的解决方案。

Q1:pefile is out of date

现象:ERROR: Your version of pefile is out of date.  Please update to the latest version on https://github.com/erocarrera/pefile

解决方法:https://github.com/erocarrera/pefile下载,然后解压后执行python setup.py install

Q2:安装weasyprint时报fatal error: ffi.h: No such file or directory错误

原因:主要是在pip install所用到的Python库时编译出错导致的compilation terminated

解决方法:apt-get install libffi-dev libxml2-dev libxslt1-dev

安装上述库后再执行命令pip install weasyprint

Q3:使用weasyprint生成pdf出现中文乱码问题

原因:linux不存在对应的中文字体

解决方法:复制C:\Windows\Fonts下的宋体到/usr/share/fonts/chinese下,然后执行命令fc-cache -fv重新加载字体缓存

Q4:优化生成pdf生成时间

前提:apt-get install wkhtmltopdf xvfb

python代码:from subprocess import callcall(["/usr/bin/xvfb-run", "--auto-servernum", "--server-num", "1", "/usr/bin/wkhtmltopdf", "-q", os.path.join(self.reports_path, "summary-report.html"), os.path.join(self.reports_path, "report.pdf")])
针对同一份summary-report.html,使用weasyprint生成pdf大致在750页,花费时间10分钟左右,但是生成的pdf无书签,使用wkhtmltopdf生成pdf大致在590,花费时间17秒,有书签导航

Q5:pip安装re2出现fatal error: re2/stringpiece.h: No such file or directory
原因:缺少re2框架
解决方法:
https://github.com/google/re2下载zip包,解压完后执行make ,make install,然后再pip install re2
如果还报错的话需要把更新c++的库,strings /polyhawk/lib/libstdc++.so.6 | grep GLIBCXX, 更新到最新版
reference:
http://stackoverflow.com/questions/30956128/installation-of-re2-module-in-python-failed

Q6:pip install m2crypto error
error1:unable to execute 'swig': No such file or directory
solution: sudo apt-get install swig
error2:Unable to find 'openssl/opensslconf.h'
solution:apt-get install libssl-dev
                ln -s /usr/include/x86_64-linux-gnu/openssl/opensslconf.h /usr/include/openssl/opensslconf.h

Q:python导入yara报import pe错误
github下载yara,重新编译生成so

cd /tmp/
wget
https://github.com/plusvic/yara/archive/v3.4.0.tar.gz
tar zxvf v3.4.0.tar.gz
cd yara-3.4.0/
./bootstrap.sh
./configure
make    # 只需要make,不要make install
cd yara-python/
python setup.py build    # 只需build,不需要install,install只是把so复制到默认路径/usr/local/lib/python2.7/dist-packages,我们可以复制到PYTHONPATH所在路径

root@polyhawk-55:~# echo $PYTHONPATH
/polyhawk/pythonlib
cp build/lib.linux-x86_64-2.7/yara.so /polyhawk/pythonlib/

如此就可以在yara中使用python了

In [6]: import yara

In [7]: yara.compile("/polydata/content/yara/rules/all.yar")
/polydata/content/yara/rules/all.yar

ImportError: No module named past.builtins
pip install future

 

转载于:https://www.cnblogs.com/lunachy/p/4756740.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值