コード例 #1
0
ファイル: clientplayback.py プロジェクト: mitmproxy/mitmproxy
 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)
コード例 #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()
コード例 #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)
コード例 #4
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)
             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()
コード例 #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)
コード例 #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)
コード例 #8
0
ファイル: clientplayback.py プロジェクト: jbremer/mitmproxy
 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", [])
コード例 #9
0
ファイル: serverplayback.py プロジェクト: cortesi/mitmproxy
 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)
コード例 #10
0
ファイル: serverplayback.py プロジェクト: jimhigson/mitmproxy
 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)
コード例 #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)
コード例 #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))
コード例 #13
0
ファイル: dump.py プロジェクト: MatthewShao/mitmproxy
 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))
コード例 #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)
コード例 #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)
コード例 #16
0
ファイル: clientplayback.py プロジェクト: jbremer/mitmproxy
 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)
コード例 #17
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)
コード例 #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)
コード例 #19
0
ファイル: clientplayback.py プロジェクト: mitmproxy/mitmproxy
 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)
コード例 #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)
コード例 #21
0
ファイル: clientplayback.py プロジェクト: yeaxxx/mitmproxy
 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
コード例 #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.")
コード例 #23
0
ファイル: clientplayback.py プロジェクト: YangjunZ/mitmproxy
 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
コード例 #24
0
ファイル: master.py プロジェクト: nickraptis/mitmproxy
 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))
コード例 #25
0
ファイル: master.py プロジェクト: hongpingwei/mitmproxy
 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))
コード例 #26
0
 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"])
コード例 #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
コード例 #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)
コード例 #29
0
ファイル: serverplayback.py プロジェクト: cortesi/mitmproxy
 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)
コード例 #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)
コード例 #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
コード例 #32
0
ファイル: serverplayback.py プロジェクト: jimhigson/mitmproxy
 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)
コード例 #33
0
ファイル: static_viewer.py プロジェクト: u2ubf989u2/mitmproxy
 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)