mirror of
https://github.com/j93es/oauth-backend.git
synced 2026-06-04 07:01:51 +09:00
리팩토링
This commit is contained in:
parent
fcc0b6d2f3
commit
0d09f191c5
7 changed files with 559 additions and 141 deletions
46
main.py
46
main.py
|
|
@ -1,31 +1,21 @@
|
|||
import sys
|
||||
from mitmproxy.tools.main import mitmdump
|
||||
from flask import Flask, request
|
||||
from runner.proxy import run_proxy
|
||||
import subprocess
|
||||
import threading
|
||||
import lib.target as target
|
||||
|
||||
def main():
|
||||
sys.argv = ["mitmdump", "-s", "./addon/init.py", "--listen-port", "11080"]
|
||||
mitmdump()
|
||||
|
||||
# get target from browser use web api
|
||||
app = Flask(__name__)
|
||||
|
||||
@app.route('/start', methods=['GET', 'POST'])
|
||||
def start():
|
||||
target_url = request.args.get('url')
|
||||
if target_url:
|
||||
target.save(target_url)
|
||||
print(f"Target URL set to: {target_url}")
|
||||
return f"Target URL set to: {target_url}"
|
||||
return "No URL provided"
|
||||
|
||||
def run_web_server():
|
||||
app.run(host='localhost', port=11081, debug=False)
|
||||
|
||||
# Start web server in a separate thread
|
||||
web_thread = threading.Thread(target=run_web_server, daemon=True)
|
||||
web_thread.start()
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
# Start web server in a separate thread
|
||||
server_process = subprocess.Popen([
|
||||
"granian",
|
||||
"--interface", "asgi",
|
||||
"--host", "0.0.0.0",
|
||||
"--port", "11081",
|
||||
"--loop", "asyncio",
|
||||
"--reload",
|
||||
"runner.backend:app",
|
||||
])
|
||||
|
||||
try:
|
||||
# Run mitmdump proxy
|
||||
run_proxy()
|
||||
finally:
|
||||
server_process.terminate()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue