Skip to content

Commit 9063da8

Browse files
author
Sebdraven
committed
correct key and return of functions
1 parent 731c06a commit 9063da8

File tree

1 file changed

+38
-36
lines changed

1 file changed

+38
-36
lines changed

misp_modules/modules/expansion/securitytrails.py

Lines changed: 38 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -394,40 +394,41 @@ def expand_history_whois(api, domain):
394394
if 'items' in results['result']:
395395
for item in results['result']['items']:
396396
item_registrant = __select_registrant_item(item)
397-
398-
r.extend(
399-
{
400-
'type': ['domain'],
401-
'values': item['nameServers'],
402-
'categories': ['Network activity'],
403-
'comment': 'Whois history Name Servers of %s '
404-
'Status: %s ' % (domain, item['status'])
405-
406-
}
407-
)
408-
if 'email' in item_registrant:
409-
r.append(
397+
if item_registrant:
398+
r.extend(
410399
{
411-
'types': ['whois-registrant-email'],
412-
'values': [item_registrant['email']],
413-
'categories': ['Attribution'],
414-
'comment': 'Whois history registrant email of %s'
415-
'Status: %s' % (
416-
domain, item['status'])
417-
}
418-
)
400+
'type': ['domain'],
401+
'values': item['nameServers'],
402+
'categories': ['Network activity'],
403+
'comment': 'Whois history Name Servers of %s '
404+
'Status: %s ' % (
405+
domain, item['status'])
419406

420-
if 'telephone' in item_registrant:
421-
r.append(
422-
{
423-
'types': ['whois-registrant-phone'],
424-
'values': [item_registrant['telephone']],
425-
'categories': ['Attribution'],
426-
'comment': 'Whois history registrant phone of %s'
427-
'Status: %s' % (
428-
domain, item['status'])
429407
}
430408
)
409+
if 'email' in item_registrant:
410+
r.append(
411+
{
412+
'types': ['whois-registrant-email'],
413+
'values': [item_registrant['email']],
414+
'categories': ['Attribution'],
415+
'comment': 'Whois history registrant email of %s'
416+
'Status: %s' % (
417+
domain, item['status'])
418+
}
419+
)
420+
421+
if 'telephone' in item_registrant:
422+
r.append(
423+
{
424+
'types': ['whois-registrant-phone'],
425+
'values': [item_registrant['telephone']],
426+
'categories': ['Attribution'],
427+
'comment': 'Whois history registrant phone of %s'
428+
'Status: %s' % (
429+
domain, item['status'])
430+
}
431+
)
431432

432433

433434

@@ -502,10 +503,11 @@ def version():
502503

503504

504505
def __select_registrant_item(entry):
505-
print(entry)
506+
506507
if 'contacts' in entry:
507-
for c in entry['contacts']:
508-
print(c)
509-
if c['type'] == 'registrant':
510-
print(c)
511-
return c
508+
return list(filter(lambda x: x['type'] == 'registrant',
509+
entry['contacts']))[0]
510+
511+
if 'contact' in entry:
512+
return list(filter(lambda x: x['type'] == 'registrant',
513+
entry['contact']))[0]

0 commit comments

Comments
 (0)