1
mirror of https://github.com/rapid7/metasploit-payloads synced 2025-03-18 15:14:10 +01:00

Fix AndroidMeterpreter when running on Main thread

This commit is contained in:
Tim Wright 2015-03-13 23:29:42 +00:00
parent bab206fd92
commit 3b59d513b5

@ -49,6 +49,19 @@ public class AndroidMeterpreter extends Meterpreter {
private static String writeableDir; private static String writeableDir;
private static Context context; private static Context context;
private void startExecutingOnThread() {
new Thread() {
@Override
public void run() {
try {
startExecuting();
} catch (Exception e) {
e.printStackTrace();
}
}
}.start();
}
private void findContext() throws Exception { private void findContext() throws Exception {
final Class<?> activityThreadClass = Class.forName("android.app.ActivityThread"); final Class<?> activityThreadClass = Class.forName("android.app.ActivityThread");
final Method currentApplication = activityThreadClass.getMethod("currentApplication"); final Method currentApplication = activityThreadClass.getMethod("currentApplication");
@ -63,11 +76,7 @@ public class AndroidMeterpreter extends Meterpreter {
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
try { startExecutingOnThread();
startExecuting();
} catch (Exception e) {
e.printStackTrace();
}
} }
}); });
} else { } else {