-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9b2e9cd
commit 0a04b97
Showing
3 changed files
with
30 additions
and
21 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
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 |
---|---|---|
|
@@ -12,7 +12,18 @@ Once with mitmproxy installed and your device configured to use it, you can crea | |
|
||
from mitmproxy import http | ||
|
||
SENSITIVE_STRINGS = ["dummyPassword", "sampleUser"] | ||
# This data would come from another file and should be defined after identifying the data that is considered sensitive for this application. | ||
# For example by using the Google Play Store Data Safety section. | ||
SENSITIVE_DATA = { | ||
"precise_location_latitude": "37.7749", | ||
"precise_location_longitude": "-122.4194", | ||
"name": "John Doe", | ||
"email_address": "[email protected]", | ||
"phone_number": "+11234567890", | ||
"credit_card_number": "1234 5678 9012 3456" | ||
} | ||
|
||
SENSITIVE_STRINGS = SENSITIVE_DATA.values() | ||
|
||
def contains_sensitive_data(string): | ||
return any(sensitive in string for sensitive in SENSITIVE_STRINGS) | ||
|
@@ -26,18 +37,16 @@ def process_flow(flow): | |
|
||
if (contains_sensitive_data(url) or | ||
contains_sensitive_data(request_body) or | ||
any(contains_sensitive_data(header) for header in request_headers.values()) or | ||
any(contains_sensitive_data(header) for header in response_headers.values()) or | ||
contains_sensitive_data(response_body)): | ||
with open("sensitive_data.log", "a") as file: | ||
if flow.response: | ||
file.write(f"RESPONSE URL: {flow.request.pretty_url}\n") | ||
file.write(f"Response Headers: {flow.response.headers}\n") | ||
file.write(f"Response Body: {flow.response.text}\n\n") | ||
file.write(f"RESPONSE URL: {url}\n") | ||
file.write(f"Response Headers: {response_headers}\n") | ||
file.write(f"Response Body: {response_body}\n\n") | ||
else: | ||
file.write(f"REQUEST URL: {flow.request.pretty_url}\n") | ||
file.write(f"Request Headers: {flow.request.headers}\n") | ||
file.write(f"Request Body: {flow.request.text}\n\n") | ||
file.write(f"REQUEST URL: {url}\n") | ||
file.write(f"Request Headers: {request_headers}\n") | ||
file.write(f"Request Body: {request_body}\n\n") | ||
def request(flow: http.HTTPFlow): | ||
process_flow(flow) | ||
|
||
|