Ejemplo n.º 1
0
 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)
Ejemplo n.º 2
0
 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()
Ejemplo n.º 3
0
 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)
             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()
Ejemplo n.º 5
0
 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)
Ejemplo n.º 6
0
 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)
Ejemplo n.º 8
0
 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", [])
Ejemplo n.º 9
0
 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)
Ejemplo n.º 10
0
 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)
Ejemplo n.º 11
0
 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)
Ejemplo n.º 12
0
 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))
Ejemplo n.º 13
0
 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))
Ejemplo n.º 14
0
 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)
Ejemplo n.º 15
0
 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)
Ejemplo n.º 16
0
 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:
     """
         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)
Ejemplo n.º 18
0
 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)
Ejemplo n.º 19
0
 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)
Ejemplo n.º 20
0
 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)
Ejemplo n.º 21
0
 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
Ejemplo n.º 22
0
    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.")
Ejemplo n.º 23
0
 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
Ejemplo n.º 24
0
 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))
Ejemplo n.º 25
0
 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"])
Ejemplo n.º 27
0
 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
Ejemplo n.º 28
0
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)
Ejemplo n.º 29
0
 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)
Ejemplo n.º 30
0
 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)
Ejemplo n.º 31
0
 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
Ejemplo n.º 32
0
 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)
Ejemplo n.º 33
0
 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)