我试图生成一个恶意软件文件的hextump的bigram,这将帮助我与基于bigram的不同恶意软件文件相关联,我试图使用counter、zip和slice来获得结果,但是却得到了一个错误。如果有人能帮我,我会很高兴的。你知道吗
import binascii
import re
import collections
try:
from itertools import izip as zip
except ImportError: # will be 3.x series
pass
try:
from itertools import islice as slice
except ImportError: # will be 3.x series
pass
with open('path', 'rb') as f:
for chunk in iter(lambda: f.read(), b''):
s=binascii.hexlify(chunk)
print(collections.Counter(zip(s),slice(s,1,None)))
The result should be like:Counter({(4d5a):200,(5a76):120,(7635):1000...}) but instead i am getting this error:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-110-d99ed11a1260> in <module>
3 for chunk in iter(lambda: f.read(), b''):
4 s=binascii.hexlify(chunk)
----> 5 print(collections.Counter(zip(s),slice(s,1,None)))
6
~\Anaconda3\lib\collections\__init__.py in __init__(*args, **kwds)
562 self, *args = args
563 if len(args) > 1:
--> 564 raise TypeError('expected at most 1 arguments, got %d' % len(args))
565 super(Counter, self).__init__()
566 self.update(*args, **kwds)
TypeError: expected at most 1 arguments, got 2
输出(截断):
相关问题 更多 >
编程相关推荐