def configure(self, updated): if "client_replay" in updated and ctx.options.client_replay: try: flows = io.read_flows_from_paths(ctx.options.client_replay) except exceptions.FlowReadException as e: raise exceptions.OptionsError(str(e)) self.start_replay(flows)
def load_files(self, paths): try: if "," in paths[0]: paths = paths[0].split(",") for path in paths: ctx.log.info("Loading flows from %s" % path) if not os.path.exists(path): raise Exception("File does not exist!") try: flows = io.read_flows_from_paths([path]) except exceptions.FlowReadException as e: raise exceptions.CommandError(str(e)) self.load_flows(flows) proto = os.path.join(os.path.dirname(path), "metadata.json") if os.path.exists(proto): ctx.log.info("Loading proto info from %s" % proto) with open(proto) as f: recording_info = json.loads(f.read()) if recording_info.get("http_protocol", False): ctx.log.info( "Replaying file {} recorded on {}".format( path, recording_info["recording_date"] ) ) _PROTO.update(recording_info["http_protocol"]) else: ctx.log.warn( "Replaying file {} has no http_protocol info.".format(proto) ) except Exception as e: ctx.log.error("Could not load recording file! Stopping playback process!") ctx.log.error(str(e)) ctx.master.shutdown()
def load_files(self, paths): try: if "," in paths[0]: paths = paths[0].split(",") for path in paths: ctx.log.info("Loading flows from %s" % path) try: flows = io.read_flows_from_paths([path]) except exceptions.FlowReadException as e: raise exceptions.CommandError(str(e)) self.load_flows(flows) proto = os.path.splitext(path)[0] + ".json" if os.path.exists(proto): ctx.log.info("Loading proto info from %s" % proto) with open(proto) as f: recording_info = json.loads(f.read()) ctx.log.info("Replaying file {} recorded on {}".format( os.path.basename(path), recording_info["recording_date"])) _PROTO.update(recording_info["http_protocol"]) except Exception: ctx.log.error( "Could not load recording file! Stopping playback process! ") ctx.log.info(traceback.print_exc()) ctx.master.shutdown()
def load_file(self, path: mitmproxy.types.Path) -> None: ctx.log.info("Replaying from files: {}".format(path)) try: flows = io.read_flows_from_paths([path]) except exceptions.FlowReadException as e: raise exceptions.CommandError(str(e)) self.load_flows(flows)
def load_file(self, path: mitmproxy.types.Path) -> None: try: flows = io.read_flows_from_paths([path]) except exceptions.FlowReadException as e: raise exceptions.CommandError(str(e)) ctx.log.alert("Replaying %s flows." % len(self.flows)) self.flows = flows ctx.master.addons.trigger("update", [])
def configure(self, options, updated): self.options = options self.clear() try: flows = io.read_flows_from_paths(self.replayfiles) except exceptions.FlowReadException as e: raise exceptions.OptionsError(str(e)) self.load(flows)
def configure(self, updated): if not self.configured and ctx.options.server_replay: self.configured = True try: flows = io.read_flows_from_paths(ctx.options.server_replay) except exceptions.FlowReadException as e: raise exceptions.OptionsError(str(e)) self.load_flows(flows)
def configure(self, updated): if not self.configured and ctx.options.server_replay: self.configured = True try: ctx.log.info("Replaying from files: {}".format(ctx.options.server_replay)) flows = io.read_flows_from_paths(ctx.options.server_replay) except exceptions.FlowReadException as e: raise exceptions.OptionsError(str(e)) self.load_flows(flows)
def _readflow(self, paths): """ Utitility function that reads a list of flows or raises a DumpError if that fails. """ try: return io.read_flows_from_paths(paths) except exceptions.FlowReadException as e: raise DumpError(str(e))
def configure(self, updated): if not self.configured and ctx.options.client_replay: self.configured = True ctx.log.info("Client Replay: {}".format(ctx.options.client_replay)) try: flows = io.read_flows_from_paths(ctx.options.client_replay) except exceptions.FlowReadException as e: raise exceptions.OptionsError(str(e)) self.start_replay(flows)
def load_file(self, path: mitmproxy.types.Path) -> None: """ Append server responses from file. """ try: flows = io.read_flows_from_paths([path]) except exceptions.FlowReadException as e: raise exceptions.CommandError(str(e)) self.add_flows(flows)
def load_file(self, path: mitmproxy.types.Path) -> None: """ Load flows from file, and add them to the replay queue. """ try: flows = io.read_flows_from_paths([path]) except exceptions.FlowReadException as e: raise exceptions.CommandError(str(e)) self.start_replay(flows)
def configure(self, updated): if "server_replay" in updated: self.clear() if ctx.options.server_replay: try: flows = io.read_flows_from_paths(ctx.options.server_replay) except exceptions.FlowReadException as e: raise exceptions.OptionsError(str(e)) self.load_flows(flows)
def configure(self, options, updated): self.options = options if "server_replay" in updated: self.clear() if options.server_replay: try: flows = io.read_flows_from_paths(options.server_replay) except exceptions.FlowReadException as e: raise exceptions.OptionsError(str(e)) self.load(flows)
def configure(self, options, updated): if "client_replay" in updated: if options.client_replay: ctx.log.info("Client Replay: {}".format(options.client_replay)) try: flows = io.read_flows_from_paths(options.client_replay) except exceptions.FlowReadException as e: raise exceptions.OptionsError(str(e)) self.load(flows) else: self.flows = None
def configure(self, updated): if "client_replay" in updated and ctx.options.client_replay: try: flows = io.read_flows_from_paths(ctx.options.client_replay) except exceptions.FlowReadException as e: raise exceptions.OptionsError(str(e)) self.start_replay(flows) if "client_replay_concurrency" in updated: if ctx.options.client_replay_concurrency not in [-1, 1]: raise exceptions.OptionsError("Currently the only valid client_replay_concurrency values are -1 and 1.")
def configure(self, options, updated): if "client_replay" in updated: if options.client_replay: ctx.log.info("Client Replay: {}".format(options.client_replay)) try: flows = io.read_flows_from_paths(options.client_replay) except exceptions.FlowReadException as e: raise exceptions.OptionsError(str(e)) self.load(flows) else: self.flows = None self.keepserving = options.keepserving
def _readflows(self, path): """ Utitility function that reads a list of flows or prints an error to the UI if that fails. Returns - None, if there was an error. - a list of flows, otherwise. """ try: return io.read_flows_from_paths(path) except exceptions.FlowReadException as e: signals.status_message.send(message=str(e))
def load_files(self, paths): for path in paths: ctx.log.info("Loading flows from %s" % path) try: flows = io.read_flows_from_paths([path]) except exceptions.FlowReadException as e: raise exceptions.CommandError(str(e)) self.load_flows(flows) proto = os.path.splitext(path)[0] + ".json" if os.path.exists(proto): ctx.log.info("Loading proto info from %s" % proto) with open(proto) as f: recording_info = json.loads(f.read()) ctx.log.info("Replaying file {} recorded on {}".format( os.path.basename(path), recording_info["recording_date"])) _PROTO.update(recording_info["http_protocol"])
def load_file(self, path: str) -> None: try: flows = io.read_flows_from_paths([path]) except exceptions.FlowReadException as e: raise exceptions.CommandError(str(e)) self.flows = flows
import time import json qu = queue.Queue() path = 'fuzz_log' flows = [] new = [] rule_file = open('rule.json', 'r') rule = json.load(rule_file) cur_cycle = [None] * (rule['group'] + 1) cur_group = 2 cur_ptn = 1 cur_rule = 0 flows = io.read_flows_from_paths([path]) flows.sort(key=lambda f: f.request.timestamp_start) for f in flows: hf = typing.cast(http.HTTPFlow, f) qu.put(hf) ctx.log.error('Fuzzing group 1 in rule ' + str(rule['value'][0]) + ' with pattern 1') f = qu.get() pre_flow = f.copy() ctx.master.commands.call("replay.client", [f]) def response(flow): global qu, new, cur_group, cur_ptn, cur_rule, pre_flow new.append(flow) compare_resp(pre_flow, flow)
def load_file(self, path: mitmproxy.types.Path) -> None: try: flows = io.read_flows_from_paths([path]) except exceptions.FlowReadException as e: raise exceptions.CommandError(str(e)) self.load_flows(flows)
def configure(self, updated): if "web_static_viewer" in updated and ctx.options.web_static_viewer: flows = io.read_flows_from_paths([ctx.options.rfile]) p = pathlib.Path(ctx.options.web_static_viewer).expanduser() self.export(p, flows)
def load_file(self, path: mitmproxy.types.Path) -> None: try: flows = io.read_flows_from_paths([path]) except exceptions.FlowReadException as e: raise exceptions.CommandError(str(e)) self.flows = flows
def load_file(self, path: command.Path) -> None: try: flows = io.read_flows_from_paths([path]) except exceptions.FlowReadException as e: raise exceptions.CommandError(str(e)) self.load_flows(flows)