Documentviewer Write-up
Intro Download the application from introduction section of the lab. Open apk file in jadx-gui Observe Manifest file and start from MainActivity as it is exported and has schemes and mimetype in manifest. In MainActivity file we can spot the following code: private final void handleIntent() { Intent intent = getIntent(); String action = intent.getAction(); Uri data = intent.getData(); if (Intrinsics.areEqual("android.intent.action.VIEW", action) && data != null) { CopyUtil.INSTANCE.copyFileFromUri(data).observe(this, new MainActivity3(new Function1<Uri, Unit>() { We can see that the app can open URI. The code itself is a mechanism to present data to the user. So it will open the file with mimetype pdf from file,http and https link. Also we can see that there is copyFileFromUri function, which downloads a file that we submit and put it into the Downloads folder! At the same time the exact file variable is used in outFile + lastPathSegment which basically adds one thing to another without proper validation. What I mean by that is the fact that we can manipulate the outfile because file = /storage/emulated/0/Downloads/ and lastPathSegment can be ../../../../../../filewewanttooverwrite. Testing ...