-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
PoC frida.re Base Script #3359
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
Merged
Merged
PoC frida.re Base Script #3359
Changes from 11 commits
Commits
Show all changes
49 commits
Select commit
Hold shift + click to select a range
4d1d2b0
added frida.re base script and DEMO-0058 which uses this script
bernhste 246fdf9
clean up after frida.re run, clearer description in DEMO code
bernhste 2acc017
added previously removed output.txt
bernhste 4120adc
Added DEMO-0059
bernhste 1946708
changed demo to be compatible with the MAS Android base app from the …
bernhste 09c89d4
refactor: improve formatting and add missing semicolons in registerHook
cpholguera ca6251a
feat: add maxFrames parameter to registerHook for stack trace control
cpholguera d9b74ae
fix: change output file extension from .txt to .json in run.sh
cpholguera cbd5040
update demo-0058 output to be json
cpholguera 8a78b1c
update demo-0059 output to be json
cpholguera 4703049
fix demo-0059 kotlin file to be the original
cpholguera 4974b99
Merge branch 'OWASP:master' into DEMO-KeyGenParamSpec
bernhste c0785a2
removed reversed code from demos which only use frida.re
bernhste 8818782
removed reference to reversed files
bernhste b0675ea
Merge branch 'OWASP:master' into DEMO-KeyGenParamSpec
bernhste 6308bd2
moved frida.re decoder to /utils
bernhste 4218303
Merge branch 'OWASP:master' into DEMO-KeyGenParamSpec
bernhste a495baf
refactored the frida files for more clarity, and less folders
bernhste 210cbfa
Merge branch 'OWASP:master' into DEMO-KeyGenParamSpec
bernhste 5022d75
JSON evaluation for frida.re script done in evaluat.sh, fixed wrong f…
bernhste de052a0
Update demos/android/MASVS-CRYPTO/MASTG-DEMO-0058/MASTG-DEMO-0058.md
bernhste 762b3ad
Update demos/android/MASVS-CRYPTO/MASTG-DEMO-0058/MASTG-DEMO-0058.md
bernhste 4c29d82
changed the order of the files shown in the steps (hooks.js bevore ru…
bernhste 34fe78b
Update demos/android/MASVS-CRYPTO/MASTG-DEMO-0058/MASTG-DEMO-0058.md
bernhste 8bb145c
Update demos/android/MASVS-CRYPTO/MASTG-DEMO-0058/MASTG-DEMO-0058.md
bernhste 7784bdc
Update demos/android/MASVS-STORAGE/MASTG-DEMO-0059/MASTG-DEMO-0059.md
bernhste b696d05
updated evaluation text in demo 0058/0059 for better clarity.
bernhste 5491380
Update demos/android/MASVS-STORAGE/MASTG-DEMO-0059/MastgTest.kt
bernhste 3dc936d
updated how to use SharedPreferences in secure and insecure ways.
bernhste 436b463
Update demos/android/MASVS-CRYPTO/MASTG-DEMO-0058/hooks.js
bernhste f4c7aae
updated DEMO-0058 with additional use cases of ECB keys on current An…
bernhste b033f52
updated output.json
bernhste 872caa4
updated output.json
bernhste d653de6
Merge branch 'master' into DEMO-KeyGenParamSpec
bernhste 1100fc4
fixed a MD file linting issue
bernhste 044ceda
updated Check Website Build" to also work with PR form forks
bernhste 31f7ea8
revert changes to Check Website Build due to pipeline error
bernhste 03dac59
Merge branch 'master' into DEMO-KeyGenParamSpec
cpholguera f6505ca
Merge branch 'master' into DEMO-KeyGenParamSpec
cpholguera f4a1f54
Merge branch 'master' into DEMO-KeyGenParamSpec
bernhste 8e1c052
Merge branch 'OWASP:master' into DEMO-KeyGenParamSpec
bernhste 8638823
Update demos/android/MASVS-STORAGE/MASTG-DEMO-0059/hooks.js
bernhste c12806b
added the suggested tests for the sandbox analysis to the shared pref…
bernhste 980ee97
fix md lint
bernhste 664f608
Merge branch 'master' into DEMO-KeyGenParamSpec
bernhste 1eb6617
Update utils/frida/android/android_decoder.js
bernhste 0fac32a
Update utils/frida/android/base_script.js
bernhste f14a3ab
Update demos/android/MASVS-CRYPTO/MASTG-DEMO-0058/hooks.js
bernhste 5a0c8e5
Update demos/android/MASVS-STORAGE/MASTG-DEMO-0059/hooks.js
bernhste 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
60 changes: 60 additions & 0 deletions
60
demos/android/MASVS-CRYPTO/MASTG-DEMO-0058/MASTG-DEMO-0058.md
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,60 @@ | ||
| --- | ||
| platform: android | ||
| title: Use of Insecure ECB Block Mode in KeyGenParameterSpec | ||
| id: MASTG-DEMO-0058 | ||
| code: [kotlin] | ||
| test: MASTG-TEST-0232 | ||
| --- | ||
|
|
||
| ### Sample | ||
|
|
||
| The code snippet below shows sample code which uses insecure ECB block modes with `KeyGenParameterSpec`. | ||
|
|
||
bernhste marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| The method used to configure the block mode is: | ||
|
|
||
| ```kotlin | ||
| public KeyGenParameterSpec.Builder setBlockModes (String... blockModes) | ||
| ``` | ||
bernhste marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| As the parameter can be variable, the demo sets the ECB block mode in the following ways: | ||
|
|
||
| 1. ECB as a single parameter | ||
| 2. ECB as the second of two parameters | ||
| 3. ECB as the first of two parameters | ||
|
|
||
bernhste marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| {{ MastgTest.kt # MastgTest_reversed.java }} | ||
bernhste marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ### Steps | ||
|
|
||
| 1. Make sure a mobile phone is attached to your computer with a @MASTG-TOOL-0031 server running on it. | ||
| 1. Run the script `run.sh`. | ||
| 1. Run the DEMO on Android while the script is running. | ||
| 1. Terminate @MASTG-TOOL-0031 by typing `exit` into its shell. | ||
bernhste marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| {{ run.sh # hooks.js }} | ||
bernhste marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ### Observation | ||
|
|
||
| The script will use @MASTG-TOOL-0031 to intercept the methods defined in `hooks.js`. | ||
|
|
||
| It will intercept calls to the methods and capture the stacktrace, the decoded parameters the methods is calls with and its decoded return value. | ||
|
|
||
| All information will be written as JSON to `output.txt`. | ||
|
|
||
| {{ output.txt }} | ||
bernhste marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ### Evaluation | ||
|
|
||
| The method `setBlockModes` has now been called three times with ECB as one of the block modes. | ||
|
|
||
| You can also evaluate the output automatically using tools like `jq`: | ||
|
|
||
| ```bash | ||
| ➜ MASTG-DEMO-0058 git:(DEMO-KeyGenParamSpec) ✗ jq -s '.[0]|(.class == "android.security.keystore.KeyGenParameterSpec$Builder" and .method == "setBlockModes" and (.inputParameters[0].value | contains(["ECB"])))' output.txt | ||
|
|
||
| true | ||
| ``` | ||
bernhste marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| The test fails, as key used with these `KeyGenParameterSpec` can now be used used to insecurely encrypt data. | ||
bernhste marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| See @MASTG-TEST-0232 for more information. | ||
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,34 @@ | ||
| package org.owasp.mastestapp | ||
bernhste marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| import android.content.Context | ||
| import android.security.keystore.KeyGenParameterSpec | ||
| import android.security.keystore.KeyProperties | ||
|
|
||
| class MastgTest (private val context: Context){ | ||
|
|
||
| fun mastgTest(): String { | ||
| // val r = DemoResults("0058") | ||
|
|
||
| try { | ||
| val b = KeyGenParameterSpec.Builder( | ||
bernhste marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| "testKeyGenParameter", | ||
| KeyProperties.PURPOSE_ENCRYPT | ||
| ) | ||
| b.setBlockModes(KeyProperties.BLOCK_MODE_ECB) | ||
| // r.add(Status.FAIL, "The associated key can only use the insecure symmetric encryption block mode ECB.") | ||
|
|
||
| b.setBlockModes(KeyProperties.BLOCK_MODE_ECB, KeyProperties.BLOCK_MODE_CBC) | ||
| // r.add(Status.FAIL, "The associated key may use the insecure symmetric encryption block mode ECB.") | ||
|
|
||
| b.setBlockModes(KeyProperties.BLOCK_MODE_CBC, KeyProperties.BLOCK_MODE_ECB) | ||
| // r.add(Status.FAIL, "The associated key may use the insecure symmetric encryption block mode ECB.") | ||
|
|
||
| } | ||
| catch (e: Exception){ | ||
| // r.add(Status.ERROR, e.toString()) | ||
| } | ||
| // return r.toJson()\ | ||
| return "The associated key can use the insecure symmetric encryption block mode ECB." | ||
| } | ||
|
|
||
| } | ||
31 changes: 31 additions & 0 deletions
31
demos/android/MASVS-CRYPTO/MASTG-DEMO-0058/MastgTest_reversed.java
bernhste marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
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,31 @@ | ||
| package org.owasp.mastestapp; | ||
|
|
||
| import android.content.Context; | ||
| import android.security.keystore.KeyGenParameterSpec; | ||
| import kotlin.Metadata; | ||
| import kotlin.jvm.internal.Intrinsics; | ||
|
|
||
| /* compiled from: MastgTest.kt */ | ||
| @Metadata(d1 = {"\u0000\u0018\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\u000e\n\u0000\b\u0007\u0018\u00002\u00020\u0001B\u000f\u0012\u0006\u0010\u0002\u001a\u00020\u0003¢\u0006\u0004\b\u0004\u0010\u0005J\u0006\u0010\u0006\u001a\u00020\u0007R\u000e\u0010\u0002\u001a\u00020\u0003X\u0082\u0004¢\u0006\u0002\n\u0000¨\u0006\b"}, d2 = {"Lorg/owasp/mastestapp/MastgTest;", "", "context", "Landroid/content/Context;", "<init>", "(Landroid/content/Context;)V", "mastgTest", "", "app_debug"}, k = 1, mv = {2, 0, 0}, xi = 48) | ||
| /* loaded from: classes3.dex */ | ||
| public final class MastgTest { | ||
| public static final int $stable = 8; | ||
| private final Context context; | ||
|
|
||
| public MastgTest(Context context) { | ||
| Intrinsics.checkNotNullParameter(context, "context"); | ||
| this.context = context; | ||
| } | ||
|
|
||
| public final String mastgTest() { | ||
| try { | ||
| KeyGenParameterSpec.Builder b = new KeyGenParameterSpec.Builder("testKeyGenParameter", 1); | ||
| b.setBlockModes("ECB"); | ||
| b.setBlockModes("ECB", "CBC"); | ||
| b.setBlockModes("CBC", "ECB"); | ||
| return "The associated key can use the insecure symmetric encryption block mode ECB."; | ||
| } catch (Exception e) { | ||
| return "The associated key can use the insecure symmetric encryption block mode ECB."; | ||
| } | ||
| } | ||
| } |
cpholguera marked this conversation as resolved.
Show resolved
Hide resolved
|
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,12 @@ | ||
| var target = { | ||
| category: "CRYPTO", | ||
| demo: "0058", | ||
| hooks: [ | ||
| { | ||
cpholguera marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| class: "android.security.keystore.KeyGenParameterSpec$Builder", | ||
| methods: [ | ||
| "setBlockModes" | ||
| ] | ||
| } | ||
bernhste marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ] | ||
| } | ||
bernhste marked this conversation as resolved.
Show resolved
Hide resolved
|
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,89 @@ | ||
| { | ||
| "id": "95627692-17be-430b-960d-83d0b90fbf37", | ||
| "category": "CRYPTO", | ||
| "time": "2025-07-01T06:12:55.558Z", | ||
| "class": "android.security.keystore.KeyGenParameterSpec$Builder", | ||
| "method": "setBlockModes", | ||
| "stackTrace": [ | ||
| "android.security.keystore.KeyGenParameterSpec$Builder.setBlockModes(Native Method)", | ||
| "org.owasp.mastestapp.MastgTest.mastgTest(MastgTest.kt:17)", | ||
| "org.owasp.mastestapp.MainActivityKt.MainScreen$lambda$9$lambda$8(MainActivity.kt:53)", | ||
| "org.owasp.mastestapp.MainActivityKt.$r8$lambda$PhzGLzmkS_ibruOfiTT32AhzWl4(Unknown Source:0)", | ||
| "org.owasp.mastestapp.MainActivityKt$$ExternalSyntheticLambda0.run(D8$$SyntheticClass:0)", | ||
| "java.lang.Thread.run(Thread.java:1012)" | ||
| ], | ||
| "inputParameters": [ | ||
| { | ||
| "type": "[Ljava.lang.String;", | ||
| "value": [ | ||
| "ECB" | ||
| ] | ||
| } | ||
| ], | ||
| "returnValue": [ | ||
| { | ||
| "type": "android.security.keystore.KeyGenParameterSpec$Builder", | ||
| "value": "<instance: android.security.keystore.KeyGenParameterSpec$Builder>" | ||
| } | ||
| ] | ||
| } | ||
| { | ||
| "id": "ba434f74-ac8f-4e0c-a83f-bba8309bf0ba", | ||
| "category": "CRYPTO", | ||
| "time": "2025-07-01T06:12:55.560Z", | ||
| "class": "android.security.keystore.KeyGenParameterSpec$Builder", | ||
| "method": "setBlockModes", | ||
| "stackTrace": [ | ||
| "android.security.keystore.KeyGenParameterSpec$Builder.setBlockModes(Native Method)", | ||
| "org.owasp.mastestapp.MastgTest.mastgTest(MastgTest.kt:20)", | ||
| "org.owasp.mastestapp.MainActivityKt.MainScreen$lambda$9$lambda$8(MainActivity.kt:53)", | ||
| "org.owasp.mastestapp.MainActivityKt.$r8$lambda$PhzGLzmkS_ibruOfiTT32AhzWl4(Unknown Source:0)", | ||
| "org.owasp.mastestapp.MainActivityKt$$ExternalSyntheticLambda0.run(D8$$SyntheticClass:0)", | ||
| "java.lang.Thread.run(Thread.java:1012)" | ||
| ], | ||
| "inputParameters": [ | ||
| { | ||
| "type": "[Ljava.lang.String;", | ||
| "value": [ | ||
| "ECB", | ||
| "CBC" | ||
| ] | ||
| } | ||
| ], | ||
| "returnValue": [ | ||
| { | ||
| "type": "android.security.keystore.KeyGenParameterSpec$Builder", | ||
| "value": "<instance: android.security.keystore.KeyGenParameterSpec$Builder>" | ||
| } | ||
| ] | ||
| } | ||
| { | ||
| "id": "0e47dbdb-968e-4ced-8826-db7cee8bc26a", | ||
| "category": "CRYPTO", | ||
| "time": "2025-07-01T06:12:55.563Z", | ||
| "class": "android.security.keystore.KeyGenParameterSpec$Builder", | ||
| "method": "setBlockModes", | ||
| "stackTrace": [ | ||
| "android.security.keystore.KeyGenParameterSpec$Builder.setBlockModes(Native Method)", | ||
| "org.owasp.mastestapp.MastgTest.mastgTest(MastgTest.kt:23)", | ||
| "org.owasp.mastestapp.MainActivityKt.MainScreen$lambda$9$lambda$8(MainActivity.kt:53)", | ||
| "org.owasp.mastestapp.MainActivityKt.$r8$lambda$PhzGLzmkS_ibruOfiTT32AhzWl4(Unknown Source:0)", | ||
| "org.owasp.mastestapp.MainActivityKt$$ExternalSyntheticLambda0.run(D8$$SyntheticClass:0)", | ||
| "java.lang.Thread.run(Thread.java:1012)" | ||
| ], | ||
| "inputParameters": [ | ||
| { | ||
| "type": "[Ljava.lang.String;", | ||
| "value": [ | ||
| "CBC", | ||
| "ECB" | ||
| ] | ||
| } | ||
| ], | ||
| "returnValue": [ | ||
| { | ||
| "type": "android.security.keystore.KeyGenParameterSpec$Builder", | ||
| "value": "<instance: android.security.keystore.KeyGenParameterSpec$Builder>" | ||
| } | ||
| ] | ||
| } |
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,2 @@ | ||
| #!/bin/bash | ||
| ../../../../frida/android/run.sh ./hooks.js |
40 changes: 40 additions & 0 deletions
40
demos/android/MASVS-STORAGE/MASTG-DEMO-0059/MASTG-DEMO-0059.md
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,40 @@ | ||
| --- | ||
| platform: android | ||
| title: App Writing Sensitive Data to Sandbox using SharedPreferences | ||
| id: MASTG-DEMO-0059 | ||
| code: [kotlin] | ||
| test: MASTG-TEST-0207 | ||
bernhste marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| --- | ||
|
|
||
| ### Sample | ||
|
|
||
| The code snippet below shows sample code which stores sensitive data using `SharedPreferences`. It stores sensitive data using `String` and `StringSet`. | ||
|
|
||
| {{ MastgTest.kt # MastgTest_reversed.java }} | ||
|
|
||
| ### Steps | ||
|
|
||
| 1. Make sure a mobile phone is attached to your computer with a @MASTG-TOOL-0031 server running on it. | ||
| 1. Run the script `run.sh`. | ||
| 1. Run the DEMO on Android while the script is running. | ||
| 1. Terminate @MASTG-TOOL-0031 by typing `exit` into its shell. | ||
bernhste marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| {{ run.sh # hooks.js }} | ||
bernhste marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ### Observation | ||
|
|
||
| The script will use @MASTG-TOOL-0031 to intercept the methods defined in `hooks.js`. | ||
|
|
||
| It will intercept calls to the methods and capture the stacktrace, the decoded parameters the methods is calls with and its decoded return value. | ||
|
|
||
| All information will be written as JSON to `output.txt`. | ||
|
|
||
| {{ output.txt }} | ||
bernhste marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ### Evaluation | ||
|
|
||
| The `SharedPreference` `Editor` was used to write a String and a StringSet unencrypted into the local sandbox. | ||
|
|
||
| The test fails, as the data can be potentially extracted from the sandbox using backups or root access on a compromised phone for example. | ||
|
|
||
| See @MASTG-TEST-0207 for more information. | ||
bernhste marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
bernhste marked this conversation as resolved.
Show resolved
Hide resolved
|
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,70 @@ | ||
| package org.owasp.mastestapp | ||
|
|
||
| import android.content.Context | ||
| import android.content.SharedPreferences | ||
| import java.util.HashSet | ||
|
|
||
| class MastgTest(private val context: Context) { | ||
| private val sensitiveData: String = """These are some strings which are considered sensitive data. They should not be stored insecurely: | ||
| Artifactory: AKCp73pL4kpx91TSG1v2J5sLz6rHbHCVF5S3A | ||
| AWSKey: AKIAIOSFODNN7EXAMPLE | ||
| AzureStorageKey: Eby8vdM02xNO+G6CZDtl/JlEt2k='ExAmPlEkEy | ||
| BasicAuth: dXNlcm5hbWU6cGFzc3dvcmQ= | ||
| Cloudant: 4c9d0a20f5-2f52-4be1-9a27-19e40bd2ac83-bluemix | ||
| DiscordBotToken: ODkxMjI2OTg0ODIxNzcyMDY4.YfP-cw.k5FVSFOjVC0GZ6qHwWr2hsU-34U | ||
| GitHubToken: ghp_1234567890abcdefghijklmnOPQRSTUV | ||
| GitLabToken: glpat-12abc34XYZ5efGHIJKL67mnOpQrSt | ||
| Base64HighEntropyString: QWxhZGRpbjpvcGVuIHNlc2FtZQ== | ||
| HexHighEntropyString: 4a1d2c1f9f835c82d15694e445f7cd9f1db7f6a7 | ||
| IbmCloudIam: eyJraWQiOiI2Nzg5eCIsImFsZyI6IkhTMjU2In0 | ||
| IbmCosHmac: OUnS6XcBYLArEtyHPtH8/Sdgr7EjIUhe7gZtnrZj | ||
| IPPrivate: 192.168.1.1 | ||
| IPPrivate: 172.16.4.5.0 | ||
| IPPrivate: 10.0.2.5 | ||
| IPLocalHost: 127.0.0.1 | ||
| JwtToken: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ1c2VyMSIsImlhdCI6MTYxNzA1NjgwMCwiZXhwIjoxNjE3MDU3MDAwfQ.sJgFhsr5d2JG1hKOnwzzd8qzNx56Z76pRVKkJVGmPAI | ||
| Mailchimp: 9d7c1b4fd8bbddad8ecf841d-us20 | ||
| Npm: npm_AZ4D3XFUGYD2HC3YBWLNLFIE | ||
| OpenAI: sk-2t1HcLdKzRrn0pOI5GwIaRn8Z2Xgf9 | ||
| PrivateKey: MIIEvAIBADANBgkqhkiG9w0BAQEFAASCAmIwggJeAgEAAoGBALfX7kbfFv3pc3JjOHQ= | ||
| PypiToken: pypi-AgENdGVzdC10b2tlbi0xMjM0 | ||
| SendGrid: SG.dummykey12345Uwv5ecA7QG-3W4dUMG | ||
| Slack: xoxb-123456789012-1234567890123-ABCDEFG12345678 | ||
| Softlayer: abcdefghijklmnopqrstuvwxyz1234567890abcdef1234567890abcdef1234567890abcdef | ||
| SquareOAuth: sq0atp-1rLNX1q4TaLRcS1Xr1kWlA | ||
| Stripe: sk_test_4eC39HqLyjWDarjtT1zdp7dc | ||
| TelegramBotToken: 123456789:AAHojBo45KxlmdmpI3XlVu3iTDnjFPlwd | ||
| TwilioKey: SKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX | ||
| PrivateKey: MIIEvAIBADANBgkqhkiG9w0BAQEFAASCAmIwggJeAgEAAoGBALfX7kbfFv3pc3JjOHQ= | ||
| PrivateKey: -----BEGIN RSA PRIVATE KEY----- | ||
| PrivateKey: -----BEGIN RSA PRIVATE KEY----- | ||
| PrivateKey: -----BEGIN DSA PRIVATE KEY----- | ||
| PrivateKey: -----BEGIN DSA PUBLIC KEY----- | ||
| PrivateKey: -----BEGIN EC PRIVATE KEY----- | ||
| PrivateKey: -----BEGIN EC PUBLIC KEY----- | ||
| PrivateKey: -----BEGIN DH PARAMETERS----- | ||
| PrivateKey: -----BEGIN PRIVATE KEY----- | ||
| PrivateKey: -----BEGIN EC PRIVATE KEY----- | ||
| PrivateKey: -----BEGIN ENCRYPTED PRIVATE KEY----- | ||
| PrivateKey: -----END RSA PRIVATE KEY----- | ||
| PrivateKey: -----END EC PRIVATE KEY----- | ||
| PrivateKey: Proc-Type: 4,ENCRYPTED""" | ||
|
|
||
| fun mastgTest(): String { | ||
| try { | ||
| val sharedPref = context.getSharedPreferences("MasSharedPref_Sensitive_Data", Context.MODE_PRIVATE) | ||
| val editor = sharedPref.edit() | ||
| editor.putString("SensitiveData", sensitiveData) | ||
| editor.apply() | ||
|
|
||
| val stringSet = HashSet<String>() | ||
| stringSet.add(sensitiveData) | ||
| editor.putStringSet("SensitiveDataStringSet", stringSet) | ||
| editor.apply() | ||
|
|
||
| return "Sensitive data has been written to the sandbox." | ||
| } catch (e: Exception) { | ||
| return "Sensitive data has been written to the sandbox." | ||
| } | ||
| } | ||
| } | ||
bernhste marked this conversation as resolved.
Show resolved
Hide resolved
|
||
39 changes: 39 additions & 0 deletions
39
demos/android/MASVS-STORAGE/MASTG-DEMO-0059/MastgTest_reversed.java
bernhste marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
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,39 @@ | ||
| package org.owasp.mastestapp; | ||
|
|
||
| import android.content.Context; | ||
| import android.content.SharedPreferences; | ||
| import java.util.HashSet; | ||
| import java.util.Set; | ||
| import kotlin.Metadata; | ||
| import kotlin.jvm.internal.Intrinsics; | ||
|
|
||
| /* compiled from: MastgTest.kt */ | ||
| @Metadata(d1 = {"\u0000\u001a\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\u000e\n\u0002\b\u0002\b\u0007\u0018\u00002\u00020\u0001B\u000f\u0012\u0006\u0010\u0002\u001a\u00020\u0003¢\u0006\u0004\b\u0004\u0010\u0005J\u0006\u0010\b\u001a\u00020\u0007R\u000e\u0010\u0002\u001a\u00020\u0003X\u0082\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\u0006\u001a\u00020\u0007X\u0082\u0004¢\u0006\u0002\n\u0000¨\u0006\t"}, d2 = {"Lorg/owasp/mastestapp/MastgTest;", "", "context", "Landroid/content/Context;", "<init>", "(Landroid/content/Context;)V", "sensitiveData", "", "mastgTest", "app_debug"}, k = 1, mv = {2, 0, 0}, xi = 48) | ||
| /* loaded from: classes3.dex */ | ||
| public final class MastgTest { | ||
| public static final int $stable = 8; | ||
| private final Context context; | ||
| private final String sensitiveData; | ||
|
|
||
| public MastgTest(Context context) { | ||
| Intrinsics.checkNotNullParameter(context, "context"); | ||
| this.context = context; | ||
| this.sensitiveData = "These are some strings which are considered sensitive data. They should not be stored insecurely: \nArtifactory: AKCp73pL4kpx91TSG1v2J5sLz6rHbHCVF5S3A\nAWSKey: AKIAIOSFODNN7EXAMPLE\nAzureStorageKey: Eby8vdM02xNO+G6CZDtl/JlEt2k='ExAmPlEkEy\nBasicAuth: dXNlcm5hbWU6cGFzc3dvcmQ=\nCloudant: 4c9d0a20f5-2f52-4be1-9a27-19e40bd2ac83-bluemix\nDiscordBotToken: ODkxMjI2OTg0ODIxNzcyMDY4.YfP-cw.k5FVSFOjVC0GZ6qHwWr2hsU-34U\nGitHubToken: ghp_1234567890abcdefghijklmnOPQRSTUV\nGitLabToken: glpat-12abc34XYZ5efGHIJKL67mnOpQrSt\nBase64HighEntropyString: QWxhZGRpbjpvcGVuIHNlc2FtZQ==\nHexHighEntropyString: 4a1d2c1f9f835c82d15694e445f7cd9f1db7f6a7\nIbmCloudIam: eyJraWQiOiI2Nzg5eCIsImFsZyI6IkhTMjU2In0\nIbmCosHmac: OUnS6XcBYLArEtyHPtH8/Sdgr7EjIUhe7gZtnrZj\nIPPrivate: 192.168.1.1\nIPPrivate: 172.16.4.5.0\nIPPrivate: 10.0.2.5\nIPLocalHost: 127.0.0.1\nJwtToken: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ1c2VyMSIsImlhdCI6MTYxNzA1NjgwMCwiZXhwIjoxNjE3MDU3MDAwfQ.sJgFhsr5d2JG1hKOnwzzd8qzNx56Z76pRVKkJVGmPAI\nMailchimp: 9d7c1b4fd8bbddad8ecf841d-us20\nNpm: npm_AZ4D3XFUGYD2HC3YBWLNLFIE\nOpenAI: sk-2t1HcLdKzRrn0pOI5GwIaRn8Z2Xgf9\nPrivateKey: MIIEvAIBADANBgkqhkiG9w0BAQEFAASCAmIwggJeAgEAAoGBALfX7kbfFv3pc3JjOHQ=\nPypiToken: pypi-AgENdGVzdC10b2tlbi0xMjM0\nSendGrid: SG.dummykey12345Uwv5ecA7QG-3W4dUMG\nSlack: xoxb-123456789012-1234567890123-ABCDEFG12345678\nSoftlayer: abcdefghijklmnopqrstuvwxyz1234567890abcdef1234567890abcdef1234567890abcdef\nSquareOAuth: sq0atp-1rLNX1q4TaLRcS1Xr1kWlA\nStripe: sk_test_4eC39HqLyjWDarjtT1zdp7dc\nTelegramBotToken: 123456789:AAHojBo45KxlmdmpI3XlVu3iTDnjFPlwd\nTwilioKey: SKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\nPrivateKey: MIIEvAIBADANBgkqhkiG9w0BAQEFAASCAmIwggJeAgEAAoGBALfX7kbfFv3pc3JjOHQ=\nPrivateKey: -----BEGIN RSA PRIVATE KEY-----\nPrivateKey: -----BEGIN RSA PRIVATE KEY-----\nPrivateKey: -----BEGIN DSA PRIVATE KEY-----\nPrivateKey: -----BEGIN DSA PUBLIC KEY-----\nPrivateKey: -----BEGIN EC PRIVATE KEY-----\nPrivateKey: -----BEGIN EC PUBLIC KEY-----\nPrivateKey: -----BEGIN DH PARAMETERS-----\nPrivateKey: -----BEGIN PRIVATE KEY-----\nPrivateKey: -----BEGIN EC PRIVATE KEY-----\nPrivateKey: -----BEGIN ENCRYPTED PRIVATE KEY-----\nPrivateKey: -----END RSA PRIVATE KEY-----\nPrivateKey: -----END EC PRIVATE KEY-----\nPrivateKey: Proc-Type: 4,ENCRYPTED\n"; | ||
| } | ||
|
|
||
| public final String mastgTest() { | ||
| try { | ||
| SharedPreferences sharedPref = this.context.getSharedPreferences("MasSharedPref_Sensitive_Data", 0); | ||
| SharedPreferences.Editor editor = sharedPref.edit(); | ||
| editor.putString("SensitiveData", this.sensitiveData); | ||
| editor.apply(); | ||
| Set stringSet = new HashSet(); | ||
| stringSet.add(this.sensitiveData); | ||
| editor.putStringSet("SensitiveDataStringSet", stringSet); | ||
| editor.apply(); | ||
| return "Sensitive data has been written to the sandbox."; | ||
| } catch (Exception e) { | ||
| return "Sensitive data has been written to the sandbox."; | ||
| } | ||
| } | ||
| } |
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.
Uh oh!
There was an error while loading. Please reload this page.