InQuest / omnibus

The OSINT Omnibus (beta release)
MIT License
328 stars 72 forks source link

Update modules for better Exception and API key handling #25

Open deadbits opened 6 years ago

deadbits commented 6 years ago

YES:

    logger.error('Caught exception in module {mod}: {err}'.format(mod=module_name, err=err)

Example:

class Plugin(object):
    def __init__(self, artifact):
        self.artifact = artifact
        self.artifact['data']['censys'] = None
        self.api_key = get_apikey('censys')
        self.headers = {'User-Agent': 'OSINT Omnibus (https://github.com/InQuest/Omnibus)'}

    def run(self):
        if self.api_key == '':
            error('API keys cannot be left blank | set all keys in etc/apikeys.json')
            return

        url = 'https://censys.io/api/v1/view/ipv4{0}'.format(self.artifact['name'])

        try:
            status, response = get(url, auth=(self.api_key['token'], self.api_key['secret']), headers=self.headers)
            if status:
                self.artifact['data']['censys'] = response.json()
        except Exception as err:
            warning('Caught exception in module {0}'.format(err)

def main(artifact):
    plugin = Plugin(artifact)
    plugin.run()
    return plugin.artifact
deadbits commented 5 years ago

Completed in development branch