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
+10-3
Original file line number
Diff line number
Diff line change
@@ -22,6 +22,8 @@ The snippet below shows sample code that creates two files in external storage u
22
22
23
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.
24
24
25
+
**Note**: When apps write files using the `ContentResolver.insert()` method, the files are managed by Android's MediaStore and are identified by `content://` URIs, not direct file system paths. This design abstracts the actual file locations, making them inaccessible through standard file system operations like the `open` function in libc. Consequently, when using Frida to hook into file operations, intercepting calls to `open` won't reveal these files.
26
+
25
27
{{ run.sh # script.js }}
26
28
27
29
### Observation
@@ -32,16 +34,21 @@ In the output you can observe the file paths, the relevant stack traces, and oth
32
34
33
35
Two files are written to external storage:
34
36
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)`.
- Found as URI: `content://media/external/downloads/1000000108`.
37
44
38
45
The `ContentResolver.insert` call used the following `ContentValues`:
39
46
40
47
-`_display_name: secretFile55.txt`
41
48
-`mime_type: text/plain`
42
49
-`relative_path: Download`
43
50
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.
51
+
Using this information we can infer the path of the file written to external storage: `/storage/emulated/0/Download/secretFile55.txt`.
0 commit comments