diff --git a/mobiotsec2filehasher/app/src/main/AndroidManifest.xml b/mobiotsec2filehasher/app/src/main/AndroidManifest.xml index 5067315..95f28dc 100644 --- a/mobiotsec2filehasher/app/src/main/AndroidManifest.xml +++ b/mobiotsec2filehasher/app/src/main/AndroidManifest.xml @@ -1,7 +1,8 @@ - + + = 23) { + + if (checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) + == PackageManager.PERMISSION_GRANTED) { + Log.d("MOBIOTSEC", "Permission is granted"); + return true; + } else { + + Log.d("MOBIOTSEC", "Permission is revoked"); + ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, 1); + return false; + } + } else { //permission is automatically granted on sdk<23 upon installation + Log.d("MOBIOTSEC", "Permission is granted"); + return true; + } + } + } \ No newline at end of file diff --git a/mobiotsec2filehasher/app/src/main/java/com/example/maliciousapp/MainActivity.java b/mobiotsec2filehasher/app/src/main/java/com/example/maliciousapp/MainActivity.java index b570f35..40c06e5 100644 --- a/mobiotsec2filehasher/app/src/main/java/com/example/maliciousapp/MainActivity.java +++ b/mobiotsec2filehasher/app/src/main/java/com/example/maliciousapp/MainActivity.java @@ -1,9 +1,13 @@ package com.example.maliciousapp; import androidx.appcompat.app.AppCompatActivity; +import androidx.core.app.ActivityCompat; +import android.Manifest; import android.app.Activity; import android.content.Intent; +import android.content.pm.PackageManager; +import android.os.Build; import android.os.Bundle; import android.util.Log; @@ -19,37 +23,6 @@ public class MainActivity extends AppCompatActivity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); - - Intent intent = getIntent(); - Log.d("MOBIOTSEC", intent.toString()); - Log.d("MOBIOTSEC", "ACTION = " + intent.getAction()); - - if(intent.getAction() != null) { - String filePath = intent.getData().getPath(); - - // calculate hash - String hash = calcHash(filePath); - - // return the hash in a "result" intent - Intent resultIntent = new Intent(); - resultIntent.putExtra("hash", hash); - setResult(Activity.RESULT_OK, resultIntent); - finish(); - } - - Log.d("MOBIOTSEC", "123 END HELLOOOOO"); } - static public String calcHash(String filePath) { - File file = new File(filePath); - byte[] bytes = new byte[0]; - Log.d("MOBIOTSEC", "HELLOOOOO"); - try { - bytes = FileUtils.readFileToByteArray(file); - } catch (IOException e) { - e.printStackTrace(); - } - return DigestUtils.sha256Hex(bytes); - - } } \ No newline at end of file diff --git a/mobiotsec2filehasher/filehasher/filehasher_logs.txt b/mobiotsec2filehasher/filehasher/filehasher_logs.txt index 09796d4..084ea2f 100644 --- a/mobiotsec2filehasher/filehasher/filehasher_logs.txt +++ b/mobiotsec2filehasher/filehasher/filehasher_logs.txt @@ -1,6 +1,7 @@ --------- beginning of main --------- beginning of system ---------- beginning of kernel -03-08 16:23:39.191 8344 8344 I MOBIOTSEC: /storage/emulated/0/YM3oPnYG.dat -03-08 16:23:40.933 8372 8372 D MOBIOTSEC: Activity called oh yes -03-08 16:23:40.933 8372 8372 D MOBIOTSEC: HELLOOOOO +03-08 17:06:52.125 6728 6728 I MOBIOTSEC: /storage/emulated/0/YM3oPnYG.dat +03-08 17:06:53.912 6771 6771 D MOBIOTSEC: Activity called.. +03-08 17:06:53.914 6771 6771 D MOBIOTSEC: Permission is granted +03-08 17:06:53.946 6771 6771 D MOBIOTSEC: Activity finished.. +03-08 17:06:54.120 6728 6728 I MOBIOTSEC: Good job! The expected hash and the received hash match! The flag is FLAG{piger_ipse_sibi_obstat}