def do_perform_test(self, caplog, url, expected, type_="local"): thug = ThugAPI() thug.set_useragent('win7ie90') thug.set_features_logging() thug.set_ssl_verify() thug.set_connect_timeout(1) thug.add_urlclassifier( os.path.join(self.signatures_path, "url_signature_13.yar")) thug.register_pyhook("DFT", "do_handle_params", self.do_handle_params_hook) thug.register_pyhook("ThugLogging", "log_classifier", self.log_classifier_hook) thug.log_init(url) m = getattr(thug, "run_{}".format(type_)) m(url) records = [r.message for r in caplog.records] matches = 0 for e in expected: for record in records: if e in record: matches += 1 assert matches >= len(expected)
def do_perform_test(self, caplog, sample, expected, useragent='osx10safari5'): thug = ThugAPI() thug.set_useragent(useragent) thug.set_events('click,storage') thug.set_connect_timeout(2) thug.disable_cert_logging() thug.set_features_logging() thug.set_ssl_verify() thug.log_init(sample) thug.run_local(sample) records = [r.message for r in caplog.records] matches = 0 for e in expected: for record in records: if e in record: matches += 1 assert matches >= len(expected)
def do_perform_test(self, caplog, sample, expected): thug = ThugAPI() thug.set_useragent('win7ie90') thug.set_events('click,storage') thug.set_features_logging() thug.set_connect_timeout(2) thug.log_init(sample) thug.run_local(sample) records = [r.message for r in caplog.records] matches = 0 for e in expected: for record in records: if e in record: matches += 1 assert matches >= len(expected)
def do_perform_test(self, caplog, sample, expected): thug = ThugAPI() thug.set_useragent('winxpie70') thug.set_events('click') thug.set_connect_timeout(2) thug.disable_cert_logging() thug.set_features_logging() thug.log_init(sample) thug.run_local(sample) records = [r.message for r in caplog.records] matches = 0 for e in expected: for record in records: if e in record: matches += 1 assert matches >= len(expected)
def do_perform_test(self, caplog, url, expected, type_ = "local"): thug = ThugAPI() thug.set_useragent('win7ie90') thug.set_features_logging() thug.set_connect_timeout(1) thug.log_init(url) thug.register_pyhook("DFT", "do_handle_params", self.do_handle_params_hook) m = getattr(thug, "run_{}".format(type_)) m(url) records = [r.message for r in caplog.records] matches = 0 for e in expected: for record in records: if e in record: matches += 1 assert matches >= len(expected)