mirror of
https://github.com/rapid7/metasploit-payloads
synced 2025-01-20 20:37:27 +01:00
Land #162, add android_wakelock to Android meterpreter
This commit is contained in:
commit
74b665ea82
@ -28,6 +28,7 @@
|
||||
<uses-permission android:name="android.permission.SET_WALLPAPER" />
|
||||
<uses-permission android:name="android.permission.READ_CALL_LOG"/>
|
||||
<uses-permission android:name="android.permission.WRITE_CALL_LOG"/>
|
||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||
|
||||
<uses-feature android:name="android.hardware.camera" />
|
||||
<uses-feature android:name="android.hardware.camera.autofocus" />
|
||||
|
@ -145,6 +145,7 @@ public class AndroidMeterpreter extends Meterpreter {
|
||||
mgr.registerCommand("android_hide_app_icon", android_hide_app_icon.class);
|
||||
mgr.registerCommand("android_set_audio_mode", android_set_audio_mode.class);
|
||||
mgr.registerCommand("android_sqlite_query", android_sqlite_query.class);
|
||||
mgr.registerCommand("android_wakelock", android_wakelock.class);
|
||||
mgr.registerCommand("android_set_wallpaper", android_set_wallpaper.class);
|
||||
mgr.registerCommand("extapi_clipboard_get_data", clipboard_get_data.class);
|
||||
mgr.registerCommand("extapi_clipboard_set_data", clipboard_set_data.class);
|
||||
|
@ -0,0 +1,36 @@
|
||||
package com.metasploit.meterpreter.android;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.PowerManager;
|
||||
import com.metasploit.meterpreter.AndroidMeterpreter;
|
||||
import com.metasploit.meterpreter.Meterpreter;
|
||||
import com.metasploit.meterpreter.TLVPacket;
|
||||
import com.metasploit.meterpreter.TLVType;
|
||||
import com.metasploit.meterpreter.command.Command;
|
||||
|
||||
public class android_wakelock implements Command {
|
||||
|
||||
private PowerManager.WakeLock wakeLock = null;
|
||||
|
||||
@Override
|
||||
public int execute(Meterpreter meterpreter, TLVPacket request, TLVPacket response) throws Exception {
|
||||
final Context context = AndroidMeterpreter.getContext();
|
||||
if (context == null) {
|
||||
return ERROR_FAILURE;
|
||||
}
|
||||
int flags = request.getIntValue(TLVType.TLV_TYPE_FLAGS);
|
||||
if (wakeLock == null) {
|
||||
if (flags != 0) {
|
||||
PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
|
||||
wakeLock = powerManager.newWakeLock(flags, android_wakelock.class.getSimpleName());
|
||||
wakeLock.acquire();
|
||||
}
|
||||
} else {
|
||||
if (flags == 0) {
|
||||
wakeLock.release();
|
||||
wakeLock = null;
|
||||
}
|
||||
}
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user