bug fixes, tweaks, and python3 learning curve :)

pull/111/head
kx499 2017-03-04 03:10:45 +01:00
parent 01fdf3e52b
commit 3ecd095d1e
2 changed files with 9 additions and 6 deletions

View File

@ -2,4 +2,4 @@ from . import _vmray
__all__ = ['vmray_submit', 'asn_history', 'circl_passivedns', 'circl_passivessl', __all__ = ['vmray_submit', 'asn_history', 'circl_passivedns', 'circl_passivessl',
'countrycode', 'cve', 'dns', 'domaintools', 'eupi', 'ipasn', 'passivetotal', 'sourcecache', 'countrycode', 'cve', 'dns', 'domaintools', 'eupi', 'ipasn', 'passivetotal', 'sourcecache',
'virustotal', 'whois', 'shodan', 'reversedns', 'geoip_country', 'wiki'] 'virustotal', 'whois', 'shodan', 'reversedns', 'geoip_country', 'wiki', 'iprep']

View File

@ -5,7 +5,7 @@ import requests
misperrors = {'error': 'Error'} misperrors = {'error': 'Error'}
mispattributes = {'input': ['ip-src', 'ip-dst'], 'output': ['freetext']} mispattributes = {'input': ['ip-src', 'ip-dst'], 'output': ['text']}
moduleinfo = {'version': '1.0', 'author': 'Keith Faber', moduleinfo = {'version': '1.0', 'author': 'Keith Faber',
'description': 'Query IPRep Data for IP Address', 'description': 'Query IPRep Data for IP Address',
'module-type': ['expansion']} 'module-type': ['expansion']}
@ -33,7 +33,7 @@ def handler(q=False):
if len(err) > 0: if len(err) > 0:
misperrors['error'] = ','.join(err) misperrors['error'] = ','.join(err)
return misperrors return misperrors
return rep return {'results': rep}
def parse_iprep(ip, api): def parse_iprep(ip, api):
@ -41,13 +41,14 @@ def parse_iprep(ip, api):
'MaxMind_Free_GeoIP', 'Unique_Lookups', 'query_result'] 'MaxMind_Free_GeoIP', 'Unique_Lookups', 'query_result']
rep = [] rep = []
err = [] err = []
full_text = ''
url = 'https://www.packetmail.net/iprep.php/%s' % ip url = 'https://www.packetmail.net/iprep.php/%s' % ip
try: try:
data = requests.get(url, params={'apikey': api}).json() data = requests.get(url, params={'apikey': api}).json()
except: except:
return ['Error pulling data'], rep return ['Error pulling data'], rep
# print '%s' % data # print '%s' % data
for name, val in data.iteritems(): for name, val in data.items():
if name not in meta_fields: if name not in meta_fields:
try: try:
context = val['context'] context = val['context']
@ -62,17 +63,19 @@ def parse_iprep(ip, api):
elif context[0].get('phishing_kit') and context[0].get('url'): elif context[0].get('phishing_kit') and context[0].get('url'):
context = ','.join(['%s (%s)' % (hit['phishing_kit'], hit['url']) for hit in context]) context = ','.join(['%s (%s)' % (hit['phishing_kit'], hit['url']) for hit in context])
else: else:
context = ';'.join(['%s: %s' % (k, v) for k, v in context[0].iteritems()]) context = ';'.join(['%s: %s' % (k, v) for k, v in context[0].items()])
if val.get('special_note'): if val.get('special_note'):
context += '; ' + val['special_note'] context += '; ' + val['special_note']
misp_val = context misp_val = context
full_text += '\n%s' % context
misp_comment = 'IPRep Source %s: %s' % (name, val['last_seen']) misp_comment = 'IPRep Source %s: %s' % (name, val['last_seen'])
rep.append({'types': mispattributes['output'], 'values': misp_val, 'comment': misp_comment}) rep.append({'types': mispattributes['output'], 'categories':['External analysis'], 'values': misp_val, 'comment': misp_comment})
except: except:
err.append('Error parsing source: %s' % name) err.append('Error parsing source: %s' % name)
rep.append({'types': ['freetext'], 'values': full_text , 'comment': 'Free text import of IPRep'})
return err, rep return err, rep