我在下面使用此代码,但它不起作用.. peid.yarafilepath
此处提供的内容。完整的代码在这里integrated_feature_extraction.py
def __init__(self,source,output,label):
self.source = source
self.output = output
self.type = label
#Need PEiD rules compile with yara
self.rules= yara.compile(filepath='/home/osboxes/honeymalware/scripts/peid.yara')
def check_packer(self,filepath):
result=[]
matches = self.rules.match(filepath)
if matches == []:
result.append([0,"NoPacker"])
else:
result.append([1,matches['main'][0]['rule']])
return result
def main():
source_path= raw_input("Enter the path of samples (ending with /) >> ")
output_file= raw_input("Give file name of output file. (.csv) >>")
label = raw_input("Enter type of sample( malware(1)|benign(0))>>")
当我运行程序时出现错误
Traceback (most recent call last):
File "integrated_features_extraction.py", line 375, in <module>
main()
File "integrated_features_extraction.py", line 372, in main
features.create_dataset()
File "integrated_features_extraction.py", line 356, in create_dataset
data = self.extract_all(filepath)
File "integrated_features_extraction.py", line 330, in extract_all
packer = self.check_packer(filepath)
File "integrated_features_extraction.py", line 239, in check_packer
result.append([1,matches['main'][0]['rule']])
TypeError: list indices must be integers, not str
我认为执行时出现问题result.append([1,matches['main'][0]['rule']])
。上面的代码有什么问题???。我该怎么办 ??输出应该是文件路径中的“no packer”或规则名。