def test_get_bintest_found(self): myteam = ShadowServerApi() try: print 'Get Binary Whitelist Test Results for {}'.format('5e28284f9b5f9097640d58a73d38ad4c') print json.dumps(myteam.get_bintest('5e28284f9b5f9097640d58a73d38ad4c'), sort_keys=False, indent=4) except Exception as e: self.fail(e)
def test_get_bintest_bad_input(self): myteam = ShadowServerApi() try: print 'Get Binary Whitelist Test Results for {}'.format('Not a hash') print json.dumps(myteam.get_bintest('Not a hash'), sort_keys=False, indent=4) except Exception as e: self.fail(e)
def test_get_av_hash_clean(self): myteam = ShadowServerApi() try: print 'Get AV Results for {}'.format('5e28284f9b5f9097640d58a73d38ad4c') print json.dumps(myteam.get_av('5e28284f9b5f9097640d58a73d38ad4c'), sort_keys=False, indent=4) except Exception as e: self.fail(e)
def test_get_bintest_not_found(self): myteam = ShadowServerApi() try: print 'Get Binary Whitelist Test Results for NOT FOUND {}'.format('039ea049f6d0f36f55ec064b3b371c4A') print json.dumps(myteam.get_bintest('039ea049f6d0f36f55ec064b3b371c4A'), sort_keys=False, indent=4) except Exception as e: self.fail(e)
def test_get_av_hash_found(self): myteam = ShadowServerApi() try: print 'Get AV Results for FOUND {}'.format('039ea049f6d0f36f55ec064b3b371c46') print json.dumps(myteam.get_av('039ea049f6d0f36f55ec064b3b371c46'), sort_keys=False, indent=4) except Exception as e: self.fail(e)
def test_get_av_bad_input(self): myteam = ShadowServerApi() try: print 'Get AV Results for {}'.format('Not a hash') print json.dumps(myteam.get_av('Not a hash'), sort_keys=False, indent=4) except Exception as e: self.fail(e)
def __init__(self, filename): if is_file(filename): self.config = objdict({}) self.config.filename = filename self.config.md5 = file_hashes(self.config.filename, 'md5') self.config.ssdeep = file_hashes(self.config.filename, 'ssdeep') self.api = ShadowServerApi() self.report = objdict({}) else: return None
def test_get_av_hash_clean(self): myteam = ShadowServerApi() try: print 'Get AV Results for {}'.format( '5e28284f9b5f9097640d58a73d38ad4c') print json.dumps(myteam.get_av('5e28284f9b5f9097640d58a73d38ad4c'), sort_keys=False, indent=4) except Exception as e: self.fail(e)
def test_get_av_hash_found(self): myteam = ShadowServerApi() try: print 'Get AV Results for FOUND {}'.format( '039ea049f6d0f36f55ec064b3b371c46') print json.dumps(myteam.get_av('039ea049f6d0f36f55ec064b3b371c46'), sort_keys=False, indent=4) except Exception as e: self.fail(e)
def test_get_bintest_found(self): myteam = ShadowServerApi() try: print 'Get Binary Whitelist Test Results for {}'.format( '5e28284f9b5f9097640d58a73d38ad4c') print json.dumps( myteam.get_bintest('5e28284f9b5f9097640d58a73d38ad4c'), sort_keys=False, indent=4) except Exception as e: self.fail(e)
def test_get_bintest_not_found(self): myteam = ShadowServerApi() try: print 'Get Binary Whitelist Test Results for NOT FOUND {}'.format( '039ea049f6d0f36f55ec064b3b371c4A') print json.dumps( myteam.get_bintest('039ea049f6d0f36f55ec064b3b371c4A'), sort_keys=False, indent=4) except Exception as e: self.fail(e)
class ShadowServerAPI: def __init__(self, filename): if is_file(filename): self.config = objdict({}) self.config.filename = filename self.config.md5 = file_hashes(self.config.filename, 'md5') self.config.ssdeep = file_hashes(self.config.filename, 'ssdeep') self.api = ShadowServerApi() self.report = objdict({}) else: return None def apiconfig(self): self.report.avengines = self.api.list_av_engines["av"] self.report.avurl = self.api.shadowserver_av self.report.bintesturl = self.api.shadowserver_bintest def bintest(self): try: self.report.bintest = self.api.get_bintest(self.config.md5) except Exception as ex: self.report.bintest = None def lookup_getav(self): try: self.report.getav = self.api.get_av(self.config.md5) if "error" in self.report.getav: self.report.getav = None except Exception as ex: self.report.getav = None def lookup_fuzzy(self): try: self.report.fuzzy = self.api.get_ssdeep_matches(self.config.ssdeep) except Exception as ex: self.report.fuzzy = None # wrapper over internal functions # prefer calling this instead of other class funcs # as it will ensure all details are captured in returned report dict def lookup(self): #self.apiconfig() self.bintest() self.lookup_getav() return self.report
def test_list_av_engines(self): myteam = ShadowServerApi() try: print 'Get list of Anti-Virus Vendors' print json.dumps(myteam.list_av_engines, sort_keys=False, indent=4) except Exception as e: self.fail(e)