You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: demos/android/MASVS-STORAGE/MASTG-DEMO-0002/MASTG-DEMO-0002.md
+14-12
Original file line number
Diff line number
Diff line change
@@ -8,39 +8,41 @@ test: MASTG-TEST-0201
8
8
9
9
### Sample
10
10
11
-
The snippet below shows sample code that creates two files in the external storage using the `getExternalFilesDir` method and the `MediaStore` API.
11
+
The snippet below shows sample code that creates two files in external storage using the `getExternalFilesDir` method and the `MediaStore` API.
12
12
13
13
{{ MastgTest.kt }}
14
14
15
15
### Steps
16
16
17
-
1. Ensure the app is running on the target device.
18
-
2. Execute `run.sh`.
19
-
3. Close the app once you finish testing.
17
+
1. Install the app on a device (@MASTG-TECH-0005)
18
+
2. Make sure you have @MASTG-TOOL-0001 installed on your machine and the frida-server running on the device
19
+
3. Run `run.sh` to spawn the app with Frida
20
+
4. Click the **Start** button
21
+
5. Stop the script by pressing `Ctrl+C`
20
22
21
-
The `run.sh` script will inject a @MASTG-TOOL-0001 script called`script.js`. The Frida script will hook and log calls to `open` and `android.content.ContentResolver.insert`. The script will log the paths of the files written to the external storage, the stack trace of the caller, and additional details such as `ContentValues`.
23
+
The `run.sh` script injects a @MASTG-TOOL-0001 script named`script.js`. This script hooks and logs calls to the native `open`function and to `android.content.ContentResolver.insert`. It logs the paths of files written to external storage, the caller's stack trace, and additional details such as the `ContentValues` provided.
22
24
23
25
{{ run.sh # script.js }}
24
26
25
27
### Observation
26
28
27
-
In the output you can see the paths, the relevant stack trace, and additional details which help to identify the actual APIs used to write to external storage and their respective callers.
29
+
In the output you can observe the file paths, the relevant stack traces, and other details that help identify which APIs were used to write to external storage and their respective callers.
28
30
29
31
{{ output.txt }}
30
32
31
-
There are two files written to the external storage:
33
+
Two files are written to external storage:
32
34
33
-
-`/storage/emulated/0/Android/data/org.owasp.mastestapp/files/secret.txt` written using`java.io.FileOutputStream` from `org.owasp.mastestapp.MastgTest.mastgTestApi(MastgTest.kt:26)`
34
-
-`content://media/external/downloads/1000000108` written using`android.content.ContentResolver.insert` from `org.owasp.mastestapp.MastgTest.mastgTestMediaStore(MastgTest.kt:44)`
35
+
-`/storage/emulated/0/Android/data/org.owasp.mastestapp/files/secret.txt`: written via`java.io.FileOutputStream` from `org.owasp.mastestapp.MastgTest.mastgTestApi(MastgTest.kt:26)`.
36
+
-`content://media/external/downloads/1000000108`: written via`android.content.ContentResolver.insert` from `org.owasp.mastestapp.MastgTest.mastgTestMediaStore(MastgTest.kt:44)`.
35
37
36
-
The `ContentResolver.insert` call included the following `ContentValues`:
38
+
The `ContentResolver.insert` call used the following `ContentValues`:
37
39
38
40
-`_display_name: secretFile55.txt`
39
41
-`mime_type: text/plain`
40
42
-`relative_path: Download`
41
43
42
-
Note that the calls via `ContentResolver.insert`do not write directly to the file system, but to the `MediaStore` content provider, and therefore we can't see the actual file path, instead we see the`content://` URI. However, the `ContentValues` reveal the file name and the directory where the file was written.
44
+
Note that calls via `ContentResolver.insert` write to the MediaStore content provider rather than directly to the file system. As a result, you see a`content://` URI instead of a typical file path. However, the provided `ContentValues`still reveal the intended file name and the target directory.
43
45
44
46
### Evaluation
45
47
46
-
This test fails because the files are not encrypted and contain sensitive data (a password and an API key). You can further confirm this by reverseengineering the app and inspecting the code as well as retrieving the files from the device.
48
+
This test fails because the files are not encrypted and contain sensitive data (such as a password and an API key). This can be further confirmed by reverse-engineering the app to inspect its code and retrieving the files from the device.
0 commit comments