Ex2 partially working, unable to access storage
This commit is contained in:
@@ -9,14 +9,13 @@
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/Theme.Mobiotsec2filehasher">
|
||||
<activity android:name=".HashfileActivity">
|
||||
|
||||
</activity>
|
||||
<activity android:name=".MainActivity">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity android:name=".HashfileActivity">
|
||||
<intent-filter>
|
||||
<action android:name="com.mobiotsec.intent.action.HASHFILE"/>
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
|
||||
@@ -20,6 +20,8 @@ public class HashfileActivity extends AppCompatActivity {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_hashfile);
|
||||
|
||||
Log.d("MOBIOTSEC", "Activity called oh yes");
|
||||
|
||||
Intent intent = getIntent();
|
||||
String filePath = intent.getData().getPath();
|
||||
|
||||
|
||||
@@ -2,9 +2,17 @@ package com.example.maliciousapp;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
@@ -12,6 +20,36 @@ public class MainActivity extends AppCompatActivity {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
|
||||
Log.d("MOBIOTSEC", "123 HELLOOOOO");
|
||||
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);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,6 @@
|
||||
--------- 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
|
||||
|
||||
Reference in New Issue
Block a user