def process_classify(options):
if os.path.exists(options.files[0]):
filelist = options.files
if os.path.isdir(options.files[0]):
filelist = get_filelist(filelist[0])
result = BINOBJ.classify_files(
filelist, upload_missing=options.u, status_callback=my_callback)
else:
result = BINOBJ.classify_hashes(options.files)
if 'error' in result or result['status'] != 'done':
print(Style.BRIGHT + Fore.RED + "Request failed")
else:
print("Classification Results:")
reqid = result.get('results', None)
if reqid is None:
# the request failed before any files could be analyzed
print(Style.BRIGHT + Fore.RED +
"Fail reason: {0} (error code={1})".format(
result['error']['message'], result['error']['code']))
return
classify_data = []
for key, value in result['results'].iteritems():
status = Style.RESET_ALL + Fore.GREEN + "OK" + Style.RESET_ALL
if 'error' in value:
status = Fore.RED + value['error']['message'] + Style.RESET_ALL
row = {'SHA1': key, 'label': value.get('label', '.'), 'family': value.get('family', '.'), 'Status': status}
classify_data.append(row)
if options.pretty_print:
show_results(classify_data, pretty_print=options.pretty_print)
else:
print("-" * 100)
for row in classify_data:
show_row(row)
return
评论列表
文章目录