Skip to content

Instantly share code, notes, and snippets.

@bwangelme
Created August 3, 2019 04:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bwangelme/29866331cadd1a90a89e85332bd6fede to your computer and use it in GitHub Desktop.
Save bwangelme/29866331cadd1a90a89e85332bd6fede to your computer and use it in GitHub Desktop.
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