Skip to content

Commit f1a47c1

Browse files
authored
Fixed some issues which can cause crashes within module
1 parent 8a35041 commit f1a47c1

File tree

1 file changed

+28
-17
lines changed

1 file changed

+28
-17
lines changed

Main Files/modules/virus_total.py

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -326,19 +326,22 @@ def extract_comments(self):
326326
print("[-] Unable to extract user comments, The community may have submitted nothing.\n")
327327
return
328328

329-
comment_number = 1
330-
for elements in range(len(output.get("data", ""))):
331-
comments = ((output.get("data", [])[elements]).get("attributes", "").get("text", ""))
332-
if len(comments) > 700 : continue # Prevent Screen Clutter
333-
334-
# Data Extracted
335-
comments = comments.replace("[/b]", "").replace("[b]", "")
336-
337-
print("\t",colored(f'> Comment {comment_number} :', attrs=['bold']))
338-
print("\n".join([f"\t{line}" for line in comments.splitlines()]))
339-
print() # Add spacing
340-
341-
comment_number += 1
329+
try:
330+
comment_number = 1
331+
for elements in range(len(output.get("data", ""))):
332+
comments = ((output.get("data", [])[elements]).get("attributes", "").get("text", ""))
333+
if len(comments) > 700 : continue # Prevent Screen Clutter
334+
335+
# Data Extracted
336+
comments = comments.replace("[/b]", "").replace("[b]", "")
337+
338+
print("\t",colored(f'> Comment {comment_number} :', attrs=['bold']))
339+
print("\n".join([f"\t{line}" for line in comments.splitlines()]))
340+
print() # Add spacing
341+
342+
comment_number += 1
343+
except (KeyError, TypeError):
344+
return
342345

343346
# Extract behaviour analysis information
344347
def extract_behaviour_techniques_of_file(self):
@@ -349,7 +352,11 @@ def extract_behaviour_techniques_of_file(self):
349352
print("[-] Unable to extract file behaviour data.")
350353
return
351354

352-
techniques = output.get("data", "").get("attack_techniques", [])
355+
try:
356+
techniques = output.get("data", "").get("attack_techniques", [])
357+
except (KeyError, TypeError):
358+
print("[-] Unable to extract MITRE Techniques")
359+
return
353360

354361
for index, technique in enumerate(techniques):
355362
if index == 15: break
@@ -383,12 +390,16 @@ def find_alternative_names(self):
383390
return
384391

385392
# Extracting the subject alternative names from the last_https_certificate
386-
last_https_certificate = output.get("data", {}).get("attributes", {}).get("last_https_certificate", {})
387-
subject_alternative_names = last_https_certificate.get("extensions", {}).get("subject_alternative_name", [])
393+
try:
394+
last_https_certificate = output.get("data", {}).get("attributes", {}).get("last_https_certificate", {})
395+
subject_alternative_names = last_https_certificate.get("extensions", {}).get("subject_alternative_name", [])
396+
except (KeyError, TypeError):
397+
print("[-] No subject alternative names found.")
398+
return
388399

389400
if subject_alternative_names:
390401
for index , name in enumerate(subject_alternative_names):
391402
if index > 15 : break
392403
print(f"[+] {name}")
393404
else:
394-
print("[-] No subject alternative names found.")
405+
print("[-] No subject alternative names found.")

0 commit comments

Comments
 (0)