def __init__(self, filter_id, package_name, description): self.report = {} self.filter_id = filter_id self.package_name = package_name self.description = description config = proxy.ProxyConfig(port=8080,mode="transparent") server = ProxyServer(config) controller.Master.__init__(self, server) flow_dump_file = open(self.get_package_name()+"_network_traffic", "wb") self.network_flow = FlowWriter(flow_dump_file) self.should_exit = None self.extra_analyzers = [InsecureTransmissionAnalyzer(self),ZIPPathTraversalAnalyzer(self)] logging.debug("Init analyzer")
def start(context, argv): if len(argv) != 2: raise ValueError('Usage: -s "flowriter.py filename"') if argv[1] == "-": f = sys.stdout else: f = open(argv[1], "wb") context.flow_writer = FlowWriter(f)
def __init__(self, filter_id, package_name, description): self.report = {} self.filter_id = filter_id self.package_name = package_name self.description = description config = proxy.ProxyConfig(port=8080,mode="transparent") server = ProxyServer(config) controller.Master.__init__(self, server) flow_dump_file = open(self.get_package_name()+"_network_traffic", "wb") self.network_flow = FlowWriter(flow_dump_file) self.should_exit = None self.extra_analyzers = [InsecureTransmissionAnalyzer(self),ZIPPathTraversalAnalyzer(self)]
class Analyzer(controller.Master): acting_component = None def __init__(self, filter_id, package_name, description): self.report = {} self.filter_id = filter_id self.package_name = package_name self.description = description config = proxy.ProxyConfig(port=8080, mode="transparent") server = ProxyServer(config) controller.Master.__init__(self, server) flow_dump_file = open(self.get_package_name() + "_network_traffic", "wb") self.network_flow = FlowWriter(flow_dump_file) self.should_exit = None self.extra_analyzers = [ InsecureTransmissionAnalyzer(self), ZIPPathTraversalAnalyzer(self) ] def get_extra_analyzers(self): return self.extra_analyzers def get_package_name(self): return self.package_name def get_filter_id(self): return self.filter_id def get_description(self): return self.description def start_analyzer(self, error_message_queue, signal_init, signal_close): try: signal_init.set() self.should_exit = signal_close controller.Master.run(self) StorageAnalyzer(self).analyze_storage() self.send_report() except Exception: print traceback.format_exc() error_message_queue.put(traceback.format_exc()) finally: self.shutdown() @staticmethod def get_analyzer(): if not Analyzer.acting_component: raise Exception("Analyzer not initialized") return Analyzer.acting_component @staticmethod def get_analyzer_for(filter_id, package_name, description): if not Analyzer.acting_component: analyzer_class = Dispatcher.get_component_for(filter_id, Analyzer) Analyzer.acting_component = analyzer_class(filter_id, package_name, description) return Analyzer.acting_component @staticmethod def is_for(FILTER_ID): return False def add_to_report(self, key, value): self.report[key] = value def get_report(self): return self.report def handle_request(self, flow): for analyzer in self.get_extra_analyzers(): analyzer.handle_request(flow) self.network_flow.add(flow) flow.reply() def handle_response(self, flow): for analyzer in self.get_extra_analyzers(): analyzer.handle_response(flow) self.network_flow.add(flow) flow.reply() def send_report(self): Utils.notify(Utils.get_reporter(), 'analyzer', Analyzer.get_analyzer().get_report())
class Analyzer(controller.Master): acting_component = None def __init__(self, filter_id, package_name, description): self.report = {} self.filter_id = filter_id self.package_name = package_name self.description = description config = proxy.ProxyConfig(port=8080,mode="transparent") server = ProxyServer(config) controller.Master.__init__(self, server) flow_dump_file = open(self.get_package_name()+"_network_traffic", "wb") self.network_flow = FlowWriter(flow_dump_file) self.should_exit = None self.extra_analyzers = [InsecureTransmissionAnalyzer(self),ZIPPathTraversalAnalyzer(self)] def get_extra_analyzers(self): return self.extra_analyzers def get_package_name(self): return self.package_name def get_filter_id(self): return self.filter_id def get_description(self): return self.description def start_analyzer(self, error_message_queue, signal_init, signal_close): try: signal_init.set() self.should_exit = signal_close controller.Master.run(self) StorageAnalyzer(self).analyze_storage() self.send_report() except Exception: print traceback.format_exc() error_message_queue.put(traceback.format_exc()) finally: self.shutdown() @staticmethod def get_analyzer(): if not Analyzer.acting_component: raise Exception("Analyzer not initialized") return Analyzer.acting_component @staticmethod def get_analyzer_for(filter_id, package_name, description): if not Analyzer.acting_component: analyzer_class = Dispatcher.get_component_for(filter_id, Analyzer) Analyzer.acting_component = analyzer_class(filter_id, package_name, description) return Analyzer.acting_component @staticmethod def is_for(FILTER_ID): return False def add_to_report(self, key, value): self.report[key] = value def get_report(self): return self.report def handle_request(self, flow): for analyzer in self.get_extra_analyzers(): analyzer.handle_request(flow) self.network_flow.add(flow) flow.reply() def handle_response(self, flow): for analyzer in self.get_extra_analyzers(): analyzer.handle_response(flow) self.network_flow.add(flow) flow.reply() def send_report(self): Utils.notify(Utils.get_reporter(), 'analyzer', Analyzer.get_analyzer().get_report())