-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from MobSF/bump
Migrate to mitmproxy 11.0.0
- Loading branch information
Showing
5 changed files
with
62 additions
and
9 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
"""Upstream proxy module.""" | ||
|
||
import http_tools.settings as settings | ||
|
||
from mitmproxy import ctx | ||
from mitmproxy import http | ||
from mitmproxy.connection import Server | ||
from mitmproxy.net.server_spec import ServerSpec | ||
|
||
|
||
def load(loader): | ||
loader.add_option( | ||
name='proxy_ip', | ||
typespec=str, | ||
default='127.0.0.1', | ||
help='Upstream Proxy IP', | ||
) | ||
loader.add_option( | ||
name='proxy_port', | ||
typespec=int, | ||
default=8000, | ||
help='Upstream Proxy Port', | ||
) | ||
|
||
|
||
def request(flow: http.HTTPFlow) -> None: | ||
if (flow.request.url.endswith('/kill') | ||
and flow.request.method == 'GET' | ||
and flow.request.port == settings.PROXY_PORT): | ||
# Prevent killing the proxy server | ||
flow.kill() | ||
|
||
address = (ctx.options.proxy_ip, ctx.options.proxy_port) | ||
# Check if the server connection already exists | ||
if flow.server_conn.timestamp_start: | ||
# Replace the existing server connection with a new one | ||
flow.server_conn = Server(address=flow.server_conn.address) | ||
|
||
# Set the upstream proxy (via) server | ||
flow.server_conn.via = ServerSpec(('http', address)) |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,7 @@ def read(rel_path): | |
'[mitmproxy](https://mitmproxy.org/)') | ||
setup( | ||
name='http-tools', | ||
version='4.0.0', | ||
version='5.0.0', | ||
description=description, | ||
author='Ajin Abraham', | ||
author_email='[email protected]', | ||
|
@@ -42,7 +42,7 @@ def read(rel_path): | |
long_description=read('README.md'), | ||
long_description_content_type='text/markdown', | ||
install_requires=[ | ||
'mitmproxy==10.1.5', | ||
'markupsafe>=2.1.3', | ||
'mitmproxy==11.0.0', | ||
'markupsafe>=3.0.2', | ||
], | ||
) |
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