-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Proxy fixes #2490
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
+147
−88
Closed
Proxy fixes #2490
Changes from 10 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
320f31d
Fix proxy in Jadx download, fix proxy in app func, fix frida server v…
59c4ffa
add SSO groups mapping
b4eca9d
typo corrected
45d4549
Merge pull request #1 from Antiksec/saml-group-mapping
Antiksec 81c752a
Merge pull request #2 from Antiksec/proxy_for_appstore_fix
Antiksec 1662bc7
Merge branch 'master' of github.com:Antiksec/Mobile-Security-Framewor…
398e145
delete ngin.conf
84cde5d
fix google fetching info from google play stucking
11432ac
rewrite play google check
c84a4e6
some fixes
fa14732
linter fix
a8c2ca0
linter fix
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,67 @@ | ||
| import os | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rename this file as |
||
| import re | ||
| import logging | ||
| from . import settings | ||
|
|
||
| logger = logging.getLogger(__name__) | ||
|
|
||
| def upstream_proxy(flaw_type, for_urllib=False): | ||
| """Set upstream Proxy if needed.""" | ||
| if settings.UPSTREAM_PROXY_ENABLED: | ||
| if not settings.UPSTREAM_PROXY_USERNAME: | ||
| proxy_port = str(settings.UPSTREAM_PROXY_PORT) | ||
| proxy_host = '{}://{}:{}'.format( | ||
| settings.UPSTREAM_PROXY_TYPE, | ||
| docker_translate_proxy_ip(settings.UPSTREAM_PROXY_IP), | ||
| proxy_port) | ||
| proxies = {flaw_type: proxy_host} | ||
| else: | ||
| proxy_port = str(settings.UPSTREAM_PROXY_PORT) | ||
| proxy_host = '{}://{}:{}@{}:{}'.format( | ||
| settings.UPSTREAM_PROXY_TYPE, | ||
| settings.UPSTREAM_PROXY_USERNAME, | ||
| settings.UPSTREAM_PROXY_PASSWORD, | ||
| docker_translate_proxy_ip(settings.UPSTREAM_PROXY_IP), | ||
| proxy_port) | ||
| proxies = {flaw_type: proxy_host} | ||
| else: | ||
| if for_urllib: | ||
| proxies = {} | ||
| else: | ||
| proxies = {flaw_type: None} | ||
| verify = settings.UPSTREAM_PROXY_SSL_VERIFY in ('1', '"1"') | ||
| return proxies, verify | ||
|
|
||
|
|
||
| def docker_translate_localhost(identifier): | ||
| """Convert localhost to host.docker.internal.""" | ||
| if not identifier: | ||
| return identifier | ||
| if not os.getenv('MOBSF_PLATFORM') == 'docker': | ||
| return identifier | ||
| try: | ||
| identifier = identifier.strip() | ||
| docker_internal = 'host.docker.internal:' | ||
| if re.match(r'^emulator-\d{4}$', identifier): | ||
| adb_port = int(identifier.split('emulator-')[1]) + 1 | ||
| # ADB port is console port + 1 | ||
| return f'{docker_internal}{adb_port}' | ||
| m = re.match(r'^(localhost|127\.0\.0\.1):\d{1,5}$', identifier) | ||
| if m: | ||
| adb_port = int(identifier.split(m.group(1))[1].replace(':', '')) | ||
| return f'{docker_internal}{adb_port}' | ||
| return identifier | ||
| except Exception: | ||
| logger.exception('Failed to convert device ' | ||
| 'identifier for docker connectivity') | ||
| return identifier | ||
|
|
||
|
|
||
| def docker_translate_proxy_ip(ip): | ||
| """Convert localhost proxy ip to host.docker.internal.""" | ||
| if not os.getenv('MOBSF_PLATFORM') == 'docker': | ||
| return ip | ||
| if ip and ip.strip() in ('127.0.0.1', 'localhost'): | ||
| return 'host.docker.internal' | ||
| return ip | ||
|
|
||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: line indent.