mirror of
https://github.com/rapid7/metasploit-payloads
synced 2025-06-09 12:03:41 +02:00
fix error returning
This commit is contained in:
parent
a7da40dc34
commit
09e02fc4d6
@ -1,13 +1,11 @@
|
||||
package com.metasploit.meterpreter.android;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.telephony.SmsManager;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ResolveInfo;
|
||||
|
||||
import com.metasploit.meterpreter.AndroidMeterpreter;
|
||||
import com.metasploit.meterpreter.Meterpreter;
|
||||
@ -15,6 +13,7 @@ import com.metasploit.meterpreter.TLVPacket;
|
||||
import com.metasploit.meterpreter.command.Command;
|
||||
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class activity_start_android implements Command {
|
||||
@ -22,17 +21,26 @@ public class activity_start_android implements Command {
|
||||
private static final int TLV_EXTENSIONS = 20000;
|
||||
private static final int TLV_TYPE_URI_STRING = TLVPacket.TLV_META_TYPE_STRING | (TLV_EXTENSIONS + 9101);
|
||||
private static final int TLV_TYPE_ACTIVITY_START_RESULT = TLVPacket.TLV_META_TYPE_BOOL | (TLV_EXTENSIONS + 9102);
|
||||
private static final int TLV_TYPE_ACTIVITY_START_ERROR = TLVPacket.TLV_META_TYPE_STRING | (TLV_EXTENSIONS + 9103);
|
||||
|
||||
private boolean startIntent(Context context, String uri) {
|
||||
private String startIntent(Context context, String uri) {
|
||||
try {
|
||||
Intent intent = Intent.getIntent(uri);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
if (intent.getComponent() == null) {
|
||||
PackageManager pm = context.getPackageManager();
|
||||
List<ResolveInfo> resolveInfoList = pm.queryIntentActivities(intent, 0);
|
||||
if (resolveInfoList.size() >= 1) {
|
||||
ResolveInfo resolveInfo = resolveInfoList.get(0);
|
||||
intent.setComponent(new ComponentName(resolveInfo.activityInfo.packageName, resolveInfo.activityInfo.name));
|
||||
}
|
||||
}
|
||||
context.startActivity(intent);
|
||||
return true;
|
||||
return null;
|
||||
} catch (ActivityNotFoundException e) {
|
||||
return false;
|
||||
return e.getMessage();
|
||||
} catch (URISyntaxException e) {
|
||||
return false;
|
||||
return e.getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
@ -44,7 +52,13 @@ public class activity_start_android implements Command {
|
||||
if (context == null) {
|
||||
return ERROR_FAILURE;
|
||||
}
|
||||
response.addOverflow(TLV_TYPE_ACTIVITY_START_RESULT, startIntent(context, uri));
|
||||
String error = startIntent(context, uri);
|
||||
if (error == null) {
|
||||
response.addOverflow(TLV_TYPE_ACTIVITY_START_RESULT, true);
|
||||
} else {
|
||||
response.addOverflow(TLV_TYPE_ACTIVITY_START_RESULT, false);
|
||||
response.addOverflow(TLV_TYPE_ACTIVITY_START_ERROR, error);
|
||||
}
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user