How to use the mitmproxy.ctx.log.info function in mitmproxy

To help you get started, we’ve selected a few mitmproxy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mitmproxy / mitmproxy / test / mitmproxy / data / addonscripts / addon.py View on Github external
def load(self, opts):
        ctx.log.info("addon running")
        event_log.append("addonload")
github demisto / content / Tests / timestamp_replacer.py View on Github external
skip_key = False
            for k in keys[:-1]:
                if k in body:
                    body = body[k]
                    # ctx.log.info('updated body: {}'.format(body))
                elif isinstance(body, list) and k.isdigit():
                    if int(k) > len(body) - 1:
                        skip_key = True
                        break
                    body = body[int(k)]
                else:
                    skip_key = True
                    break
            if not skip_key:
                if lastkey in body:
                    ctx.log.info('modifying request to "{}"'.format(flow.request.pretty_url))
                    body[lastkey] = self.count
                    modified = True
                elif isinstance(body, list) and lastkey.isdigit() and int(lastkey) <= len(body) - 1:
                    ctx.log.info('modifying request to "{}"'.format(flow.request.pretty_url))
                    body[int(lastkey)] = self.count
                    modified = True
        if modified:
            ctx.log.info('original request body:\n{}'.format(json.dumps(original_content, indent=4)))
            ctx.log.info('modified request body:\n{}'.format(json.dumps(json_body, indent=4)))
            flow.request.raw_content = json.dumps(json_body).encode()
github aniketpanjwani / chomper / chomper / filter.py View on Github external
def load(l):
    ctx.log.info("Registering arguments.")
    l.add_option("addresses_str", str, '', 'Concatenated addresses.')
    l.add_option("block_type", str, '', 'Whitelist or blacklist.')
    l.add_option("rule_name", str, '', 'Name of block rule.')
    l.add_option("block_end_time", str, '', 'Time at which block will end.')
github SimonAlling / userscript-proxy / src / injector.py View on Github external
def logInfo(s: str) -> None:
    try:
        ctx.log.info(s)
    except Exception:
        print(s)
github Areizen / Android-Malware-Sandbox / lib / proxy / HttpProxy.py View on Github external
def request(self, flow):
        '''
        Addon used by mitmproxy that store each url in a file
        :param flow:
        :return:
        '''
        url_b = flow.request.url

        with open(f"{dirname}tmp/urls.txt","a") as f:
            ctx.log.info(f"Writing url : {url_b}")
            f.write(url_b +'\n')
github byt3bl33d3r / SprayingToolkit / vaporizer.py View on Github external
def shutdown(self):
        with open("emails.txt", "a+") as email_file:
            for email in self.emails:
                email_file.write(email + '\n')

        with open("names.txt", "a+") as name_file:
            for name in self.names:
                name_file.write(name + '\n')

        ctx.log.info(print_good(f"Dumped {len(self.emails)} email(s) to emails.txt"))

        if self.atomizer:
            self.atomizer.shutdown()

        self.loop.stop()
        pending = asyncio.Task.all_tasks()
        self.loop.run_until_complete(asyncio.gather(*pending))
github demisto / content / Tests / timestamp_replacer.py View on Github external
def handle_url_query(self, flow: flow.Flow) -> None:
        query_data = flow.request._get_query()
        ctx.log.info('query_data: {}'.format(query_data))
        for key, val in query_data:
            # don't bother trying to interpret an argument less than 4 characters as some type of timestamp
            if len(val) > 4:
                try:
                    parse(val)
                    self.query_keys.add(key)
                except ValueError:
                    pass
github mitmproxy / mitmproxy / examples / complex / tcp_message.py View on Github external
def tcp_message(tcp_msg):
    modified_msg = tcp_msg.message.replace("foo", "bar")

    is_modified = False if modified_msg == tcp_msg.message else True
    tcp_msg.message = modified_msg

    ctx.log.info(
        "[tcp_message{}] from {} {} to {} {}:\r\n{}".format(
            " (modified)" if is_modified else "",
            "client" if tcp_msg.sender == tcp_msg.client_conn else "server",
            tcp_msg.sender.address,
            "server" if tcp_msg.receiver == tcp_msg.server_conn else "client",
            tcp_msg.receiver.address, strutils.bytes_to_escaped_str(tcp_msg.message))
    )
github zlorb / locust.replay / locust_extractor.py View on Github external
def configure(self, _) -> None:
        """Keep configuration options in context."""
        self.context.dump_file = ctx.options.filename_prefix
        ctx.log.info('Dump file prefix "{}"'.format(repr(self.context.dump_file)))