Created
August 3, 2019 04:18
-
-
Save bwangelme/29866331cadd1a90a89e85332bd6fede to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from mitmproxy import command, flow, ctx | |
from http import client | |
import pyperclip | |
import tempfile | |
from urllib import request, parse | |
import typing | |
import json | |
import re | |
import os | |
def create_pastebin(code): | |
pass | |
class DoubanDomain: | |
def _save_on_clip(self, content): | |
try: | |
pyperclip.copy(content) | |
ctx.log.info("Copyed %s" % content) | |
except pyperclip.PyperclipException as e: | |
ctx.log.error(str(e)) | |
@command.command("douban.save_resp_content") | |
def save_resp_content(self, flow: flow.Flow) -> None: | |
content = flow.response.content | |
fd, name = tempfile.mkstemp(prefix="douban-mitmproxy") | |
os.write(fd, content) | |
os.close(fd) | |
self._save_on_clip(name) | |
@command.command("douban.share_resp_content") | |
def share_resp_content(self, flow: flow.Flow) -> None: | |
content = flow.response.content | |
url = create_pastebin(content) | |
self._save_on_clip(url) | |
addons = [ | |
DoubanDomain() | |
] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment