├── assets ├── xposed_init └── root │ ├── docroot │ ├── hack0.png │ ├── pause.png │ ├── play.png │ ├── save.png │ ├── step.png │ ├── scripts.png │ ├── rules.html │ ├── index.html │ └── track.html │ ├── decompile.sh │ └── ssl_cert.pem ├── lint.xml ├── ic_launcher-web.png ├── libs ├── android-support-v4.jar └── armeabi │ ├── damn-server-exec │ ├── libcivetweb.so │ ├── libdaemonize.so │ ├── libdamn-server.so │ ├── libinstall-sys-lib.so │ └── libusb-tethering.so ├── obj └── local │ └── armeabi │ ├── damn-server-exec │ ├── libcivetweb.so │ ├── libdaemonize.so │ ├── libdamn-server.so │ ├── libinstall-sys-lib.so │ ├── libusb-tethering.so │ └── objs │ ├── daemonize │ └── misc │ │ ├── daemonize.o │ │ └── daemonize.o.d │ ├── civetweb │ └── civetweb │ │ └── civetweb.o │ ├── damn-server │ └── damn-server │ │ ├── damn_server.o │ │ └── damn_server.o.d │ ├── install-sys-lib │ └── misc │ │ ├── install_sys_lib.o │ │ └── install_sys_lib.o.d │ ├── usb-tethering │ └── usb-tethering │ │ ├── usb_tethering.o │ │ └── usb_tethering.o.d │ └── damn-server-exec │ └── damn-server │ ├── damn_server_exec.o │ └── damn_server_exec.o.d ├── res ├── drawable-hdpi │ └── ic_launcher.png ├── drawable-mdpi │ └── ic_launcher.png ├── drawable-xhdpi │ └── ic_launcher.png ├── drawable-xxhdpi │ └── ic_launcher.png ├── values │ ├── dimens.xml │ ├── styles.xml │ └── strings.xml ├── layout │ ├── listitem_packages.xml │ ├── listitem_permission.xml │ ├── fragment_app_list.xml │ ├── listitem_package.xml │ └── activity_app_detail.xml ├── values-v11 │ └── styles.xml ├── menu │ ├── app_list.xml │ └── app_detail.xml ├── values-w820dp │ └── dimens.xml └── values-v14 │ └── styles.xml ├── clean-android.sh ├── .gitignore ├── src └── at │ └── fhooe │ └── mcm14 │ └── damn │ ├── objects │ └── MessageObject.java │ ├── jni │ ├── InstallSysLib.java │ ├── USBTethering.java │ └── DAMNServer.java │ ├── xposed │ ├── XCallableHookConstructors.java │ ├── XCallableHookMethods.java │ ├── XListener.java │ ├── XModule.java │ ├── XHookAll.java │ └── XDAMNHook.java │ ├── services │ ├── BootCompleteNotifier.java │ └── XModuleService.java │ ├── activities │ ├── AppListActivity.java │ └── AppDetailActivity.java │ ├── misc │ └── Extract.java │ └── fragments │ └── AppListFragment.java ├── jni ├── misc │ ├── daemonize.h │ ├── install_sys_lib.h │ ├── daemonize.c │ └── install_sys_lib.c ├── usb-tethering │ ├── usb_tethering.h │ └── usb_tethering.c ├── Android.mk ├── damn-server │ ├── damn_server.h │ └── damn_server_exec.c └── civetweb │ └── md5.inl ├── .classpath ├── project.properties ├── .settings └── org.eclipse.jdt.core.prefs ├── proguard-project.txt ├── .project └── AndroidManifest.xml /assets/xposed_init: -------------------------------------------------------------------------------- 1 | at.fhooe.mcm14.damn.xposed.XModule -------------------------------------------------------------------------------- /lint.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /ic_launcher-web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/baer-devl/DAMN/HEAD/ic_launcher-web.png -------------------------------------------------------------------------------- /assets/root/docroot/hack0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/baer-devl/DAMN/HEAD/assets/root/docroot/hack0.png -------------------------------------------------------------------------------- /assets/root/docroot/pause.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/baer-devl/DAMN/HEAD/assets/root/docroot/pause.png -------------------------------------------------------------------------------- /assets/root/docroot/play.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/baer-devl/DAMN/HEAD/assets/root/docroot/play.png -------------------------------------------------------------------------------- /assets/root/docroot/save.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/baer-devl/DAMN/HEAD/assets/root/docroot/save.png -------------------------------------------------------------------------------- /assets/root/docroot/step.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/baer-devl/DAMN/HEAD/assets/root/docroot/step.png -------------------------------------------------------------------------------- /libs/android-support-v4.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/baer-devl/DAMN/HEAD/libs/android-support-v4.jar -------------------------------------------------------------------------------- /libs/armeabi/damn-server-exec: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/baer-devl/DAMN/HEAD/libs/armeabi/damn-server-exec -------------------------------------------------------------------------------- /libs/armeabi/libcivetweb.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/baer-devl/DAMN/HEAD/libs/armeabi/libcivetweb.so -------------------------------------------------------------------------------- /libs/armeabi/libdaemonize.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/baer-devl/DAMN/HEAD/libs/armeabi/libdaemonize.so -------------------------------------------------------------------------------- /assets/root/docroot/scripts.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/baer-devl/DAMN/HEAD/assets/root/docroot/scripts.png -------------------------------------------------------------------------------- /libs/armeabi/libdamn-server.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/baer-devl/DAMN/HEAD/libs/armeabi/libdamn-server.so -------------------------------------------------------------------------------- /libs/armeabi/libinstall-sys-lib.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/baer-devl/DAMN/HEAD/libs/armeabi/libinstall-sys-lib.so -------------------------------------------------------------------------------- /libs/armeabi/libusb-tethering.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/baer-devl/DAMN/HEAD/libs/armeabi/libusb-tethering.so -------------------------------------------------------------------------------- /obj/local/armeabi/damn-server-exec: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/baer-devl/DAMN/HEAD/obj/local/armeabi/damn-server-exec -------------------------------------------------------------------------------- /obj/local/armeabi/libcivetweb.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/baer-devl/DAMN/HEAD/obj/local/armeabi/libcivetweb.so -------------------------------------------------------------------------------- /obj/local/armeabi/libdaemonize.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/baer-devl/DAMN/HEAD/obj/local/armeabi/libdaemonize.so -------------------------------------------------------------------------------- /res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/baer-devl/DAMN/HEAD/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/baer-devl/DAMN/HEAD/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/baer-devl/DAMN/HEAD/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /obj/local/armeabi/libdamn-server.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/baer-devl/DAMN/HEAD/obj/local/armeabi/libdamn-server.so -------------------------------------------------------------------------------- /res/drawable-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/baer-devl/DAMN/HEAD/res/drawable-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /obj/local/armeabi/libinstall-sys-lib.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/baer-devl/DAMN/HEAD/obj/local/armeabi/libinstall-sys-lib.so -------------------------------------------------------------------------------- /obj/local/armeabi/libusb-tethering.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/baer-devl/DAMN/HEAD/obj/local/armeabi/libusb-tethering.so -------------------------------------------------------------------------------- /obj/local/armeabi/objs/daemonize/misc/daemonize.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/baer-devl/DAMN/HEAD/obj/local/armeabi/objs/daemonize/misc/daemonize.o -------------------------------------------------------------------------------- /obj/local/armeabi/objs/civetweb/civetweb/civetweb.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/baer-devl/DAMN/HEAD/obj/local/armeabi/objs/civetweb/civetweb/civetweb.o -------------------------------------------------------------------------------- /obj/local/armeabi/objs/damn-server/damn-server/damn_server.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/baer-devl/DAMN/HEAD/obj/local/armeabi/objs/damn-server/damn-server/damn_server.o -------------------------------------------------------------------------------- /obj/local/armeabi/objs/install-sys-lib/misc/install_sys_lib.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/baer-devl/DAMN/HEAD/obj/local/armeabi/objs/install-sys-lib/misc/install_sys_lib.o -------------------------------------------------------------------------------- /obj/local/armeabi/objs/usb-tethering/usb-tethering/usb_tethering.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/baer-devl/DAMN/HEAD/obj/local/armeabi/objs/usb-tethering/usb-tethering/usb_tethering.o -------------------------------------------------------------------------------- /obj/local/armeabi/objs/damn-server-exec/damn-server/damn_server_exec.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/baer-devl/DAMN/HEAD/obj/local/armeabi/objs/damn-server-exec/damn-server/damn_server_exec.o -------------------------------------------------------------------------------- /res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 16dp 5 | 16dp 6 | 7 | 8 | -------------------------------------------------------------------------------- /res/layout/listitem_packages.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /res/layout/listitem_permission.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /clean-android.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | adb wait-for-device 3 | adb root 4 | adb wait-for-device 5 | adb remount 6 | adb wait-for-device 7 | 8 | adb shell 'rm /system/lib/libusb-tethering.so' 9 | adb shell 'rm /system/lib/libcivetweb.so' 10 | adb shell 'rm /system/lib/libdamn-server.so' 11 | adb shell 'rm /system/lib/libdaemonize.so' 12 | 13 | adb shell 'rm /data/local/tmp/damn-server-exec' 14 | -------------------------------------------------------------------------------- /res/values-v11/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /assets/root/decompile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ $# -le 1 ] 4 | then 5 | echo -e "usage:\tapk2damn " 6 | exit 1 7 | fi 8 | 9 | adb wait-for-device 10 | adb root 11 | adb wait-for-device 12 | 13 | adb pull $1 app.apk 14 | 15 | mkdir out 16 | jadx --deobf -d out app.apk 17 | 18 | adb push out $2 19 | 20 | rm -rf out out.jar app.apk -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # Files for the Dalvik VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # Generated files 12 | bin/ 13 | gen/ 14 | 15 | # Gradle files 16 | .gradle/ 17 | build/ 18 | 19 | # Local configuration file (sdk path, etc) 20 | local.properties 21 | 22 | # Proguard folder generated by Eclipse 23 | proguard/ 24 | 25 | # Log Files 26 | *.log 27 | -------------------------------------------------------------------------------- /res/menu/app_list.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 9 | 10 | -------------------------------------------------------------------------------- /res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 64dp 9 | 10 | 11 | -------------------------------------------------------------------------------- /res/menu/app_detail.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 9 | 10 | -------------------------------------------------------------------------------- /res/values-v14/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/at/fhooe/mcm14/damn/objects/MessageObject.java: -------------------------------------------------------------------------------- 1 | package at.fhooe.mcm14.damn.objects; 2 | 3 | import at.fhooe.mcm14.damn.jni.DAMNServer.Code; 4 | 5 | public class MessageObject { 6 | public Code code; 7 | public String payload; 8 | public String app; 9 | public long threadId; 10 | 11 | public MessageObject(Code _code, String _payload, String _app, long _threadId) { 12 | code = _code; 13 | payload = _payload; 14 | app = _app; 15 | threadId = _threadId; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /jni/misc/daemonize.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _DAEMONIZE_H 3 | #define _DAEMONIZE_H 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif /* __cplusplus */ 17 | 18 | void skeleton_daemon(); 19 | 20 | #ifdef __cplusplus 21 | } 22 | #endif /* __cplusplus */ 23 | #endif /* _DAEMONIZE_H */ 24 | -------------------------------------------------------------------------------- /src/at/fhooe/mcm14/damn/jni/InstallSysLib.java: -------------------------------------------------------------------------------- 1 | package at.fhooe.mcm14.damn.jni; 2 | 3 | public class InstallSysLib { 4 | 5 | /** 6 | * Load install-sys-lib library. 7 | */ 8 | static { 9 | System.loadLibrary("install-sys-lib"); 10 | } 11 | 12 | private static native boolean installSysLibJNI(String path_to_lib, String[] libname, int size); 13 | 14 | 15 | public static boolean installSystemLibrary(String path_to_library, String[] libname) { 16 | return installSysLibJNI(path_to_library, libname, libname.length); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /project.properties: -------------------------------------------------------------------------------- 1 | # This file is automatically generated by Android Tools. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must be checked in Version Control Systems. 5 | # 6 | # To customize properties used by the Ant build system edit 7 | # "ant.properties", and override values to adapt the script to your 8 | # project structure. 9 | # 10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): 11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt 12 | 13 | # Project target. 14 | target=android-19 15 | android.library=false 16 | -------------------------------------------------------------------------------- /src/at/fhooe/mcm14/damn/xposed/XCallableHookConstructors.java: -------------------------------------------------------------------------------- 1 | package at.fhooe.mcm14.damn.xposed; 2 | 3 | import java.util.concurrent.Callable; 4 | 5 | import de.robv.android.xposed.XposedBridge; 6 | 7 | public class XCallableHookConstructors implements Callable { 8 | 9 | private XDAMNHook hook; 10 | private Class clazz; 11 | 12 | 13 | public XCallableHookConstructors(XDAMNHook hook, Class clazz) { 14 | this.hook = hook; 15 | this.clazz = clazz; 16 | } 17 | 18 | @Override 19 | public Boolean call() { 20 | try{ 21 | XposedBridge.hookAllConstructors(clazz, hook); 22 | return true; 23 | 24 | }catch (Exception e) {} 25 | 26 | return false; 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /res/layout/fragment_app_list.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 12 | 13 | 18 | 19 | -------------------------------------------------------------------------------- /.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate 4 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 5 | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve 6 | org.eclipse.jdt.core.compiler.compliance=1.7 7 | org.eclipse.jdt.core.compiler.debug.lineNumber=generate 8 | org.eclipse.jdt.core.compiler.debug.localVariable=generate 9 | org.eclipse.jdt.core.compiler.debug.sourceFile=generate 10 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 11 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 12 | org.eclipse.jdt.core.compiler.source=1.7 13 | -------------------------------------------------------------------------------- /src/at/fhooe/mcm14/damn/xposed/XCallableHookMethods.java: -------------------------------------------------------------------------------- 1 | package at.fhooe.mcm14.damn.xposed; 2 | 3 | import java.util.concurrent.Callable; 4 | 5 | import de.robv.android.xposed.XposedBridge; 6 | 7 | public class XCallableHookMethods implements Callable { 8 | 9 | private XDAMNHook hook; 10 | private Class clazz; 11 | private String method; 12 | 13 | 14 | public XCallableHookMethods(XDAMNHook hook, Class clazz, String method) { 15 | this.hook = hook; 16 | this.clazz = clazz; 17 | this.method = method; 18 | } 19 | 20 | @Override 21 | public Boolean call() { 22 | try{ 23 | XposedBridge.hookAllMethods(clazz, method, hook); 24 | return true; 25 | 26 | }catch (Exception e) {} 27 | 28 | return false; 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 14 | 15 | 16 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /jni/misc/install_sys_lib.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _INSTALL_SYS_LIB_H 3 | #define _INSTALL_SYS_LIB_H 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif /* __cplusplus */ 16 | 17 | /** 18 | * Install passed libraries into system library path. 19 | */ 20 | bool install_sys_lib(const char *path_to_lib, const char **libs, int size); 21 | 22 | /** 23 | * Same as install_sys_libs but for jni interface. 24 | */ 25 | bool Java_at_fhooe_mcm14_damn_jni_InstallSysLib_installSysLibJNI(JNIEnv *env, jclass cls, jstring path_to_lib, jobjectArray libs, int size); 26 | 27 | #ifdef __cplusplus 28 | } 29 | #endif /* __cplusplus */ 30 | #endif /* _INSTALL_SYS_LIB_H */ 31 | -------------------------------------------------------------------------------- /proguard-project.txt: -------------------------------------------------------------------------------- 1 | # To enable ProGuard in your project, edit project.properties 2 | # to define the proguard.config property as described in that file. 3 | # 4 | # Add project specific ProGuard rules here. 5 | # By default, the flags in this file are appended to flags specified 6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt 7 | # You can edit the include path and order by changing the ProGuard 8 | # include property in project.properties. 9 | # 10 | # For more details, see 11 | # http://developer.android.com/guide/developing/tools/proguard.html 12 | 13 | # Add any project specific keep options here: 14 | 15 | # If your project uses WebView with JS, uncomment the following 16 | # and specify the fully qualified class name to the JavaScript interface 17 | # class: 18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 19 | # public *; 20 | #} 21 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | DAMN 4 | 5 | 6 | 7 | 8 | 9 | com.android.ide.eclipse.adt.ResourceManagerBuilder 10 | 11 | 12 | 13 | 14 | com.android.ide.eclipse.adt.PreCompilerBuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.jdt.core.javabuilder 20 | 21 | 22 | 23 | 24 | com.android.ide.eclipse.adt.ApkBuilder 25 | 26 | 27 | 28 | 29 | 30 | com.android.ide.eclipse.adt.AndroidNature 31 | org.eclipse.jdt.core.javanature 32 | 33 | 34 | -------------------------------------------------------------------------------- /res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | DAMN 5 | Hello world! 6 | Settings 7 | AppDetailActivity 8 | Tmp_Source 9 | Downloaded 10 | System 11 | Running 12 | ALL 13 | App Icon 14 | Active Tracking 15 | Packages 16 | Activate 17 | Deactivate 18 | Track 19 | Untrack 20 | 21 | -------------------------------------------------------------------------------- /src/at/fhooe/mcm14/damn/services/BootCompleteNotifier.java: -------------------------------------------------------------------------------- 1 | package at.fhooe.mcm14.damn.services; 2 | 3 | import java.util.HashSet; 4 | import java.util.Set; 5 | 6 | import android.content.BroadcastReceiver; 7 | import android.content.ComponentName; 8 | import android.content.Context; 9 | import android.content.Intent; 10 | import android.content.SharedPreferences; 11 | import android.preference.PreferenceManager; 12 | import android.util.Log; 13 | import at.fhooe.mcm14.damn.fragments.AppListFragment; 14 | 15 | public class BootCompleteNotifier extends BroadcastReceiver { 16 | 17 | private static final String TAG = BootCompleteNotifier.class.toString(); 18 | 19 | @Override 20 | public void onReceive(Context context, Intent intent) { 21 | Log.i(TAG, "boot complete"); 22 | 23 | //check if we have something where we should start the service 24 | //get shared preferences 25 | SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context.getApplicationContext()); 26 | Set values = prefs.getStringSet(AppListFragment.ACTIVE_APPS, new HashSet()); 27 | 28 | if(values.size()>0) { 29 | //start service 30 | ComponentName name = context.startService(new Intent(context, XModuleService.class)); 31 | Log.i(TAG, name + " started"); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /jni/usb-tethering/usb_tethering.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _USB_TETHERING_H 3 | #define _USB_TETHERING_H 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif /* __cplusplus */ 17 | 18 | /** 19 | * Execute a bunch of system commands and if a client is connected, return it's ip address, null otherwise. 20 | */ 21 | char* start_tethering(); 22 | /** 23 | * Stop tethering and set everything back. 24 | */ 25 | int stop_tethering(); 26 | /** 27 | * Check if tethering is activated. 28 | */ 29 | bool is_tethering_active(); 30 | 31 | /** 32 | * Same as start_tethering but for jni interface. 33 | */ 34 | jstring Java_at_fhooe_mcm14_damn_jni_USBTethering_startUSBTetheringJNI(JNIEnv* env); 35 | /** 36 | * Same as stop_tethering but for jni interface. 37 | */ 38 | bool Java_at_fhooe_mcm14_damn_jni_USBTethering_stopUSBTetheringJNI(); 39 | /** 40 | * Same as tethering_active but for jni interface. 41 | */ 42 | bool Java_at_fhooe_mcm14_damn_jni_USBTethering_checkUSBTetheringJNI(); 43 | /** 44 | * Block until status changed and return state value as integer. 45 | */ 46 | int Java_at_fhooe_mcm14_damn_jni_USBTethering_getStateBlockingJNI(); 47 | /** 48 | * Return state as integer. 49 | */ 50 | int Java_at_fhooe_mcm14_damn_jni_USBTethering_getStateJNI(); 51 | 52 | #ifdef __cplusplus 53 | } 54 | #endif /* __cplusplus */ 55 | #endif /* _USB_TETHERING_H */ 56 | -------------------------------------------------------------------------------- /jni/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | 3 | include $(CLEAR_VARS) 4 | LOCAL_MODULE := usb-tethering 5 | LOCAL_CFLAGS := -pthread -lz 6 | LOCAL_SRC_FILES := usb-tethering/usb_tethering.c 7 | LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/usb-tethering 8 | LOCAL_LDLIBS := -llog 9 | include $(BUILD_SHARED_LIBRARY) 10 | 11 | include $(CLEAR_VARS) 12 | LOCAL_MODULE := daemonize 13 | LOCAL_SRC_FILES := misc/daemonize.c 14 | LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/misc 15 | LOCAL_LDLIBS := -llog 16 | include $(BUILD_SHARED_LIBRARY) 17 | 18 | include $(CLEAR_VARS) 19 | LOCAL_MODULE := install-sys-lib 20 | LOCAL_SRC_FILES := misc/install_sys_lib.c 21 | LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/misc 22 | LOCAL_LDLIBS := -llog 23 | include $(BUILD_SHARED_LIBRARY) 24 | 25 | include $(CLEAR_VARS) 26 | LOCAL_MODULE := civetweb 27 | LOCAL_C_INCLUDES := civetweb 28 | LOCAL_CFLAGS := -std=c99 -O2 -W -Wall -pthread -DUSE_WEBSOCKET 29 | LOCAL_SRC_FILES := civetweb/civetweb.c 30 | include $(BUILD_SHARED_LIBRARY) 31 | 32 | include $(CLEAR_VARS) 33 | LOCAL_CFLAGS := -std=c99 -O2 -W -Wall -pthread -ldl 34 | LOCAL_MODULE := damn-server 35 | LOCAL_C_INCLUDES := $(LOCAL_PATH)/damn-server \ 36 | $(LOCAL_PATH)/civetweb 37 | LOCAL_SHARED_LIBRARIES := civetweb 38 | LOCAL_SRC_FILES := damn-server/damn_server.c 39 | LOCAL_LDLIBS := -llog 40 | include $(BUILD_SHARED_LIBRARY) 41 | 42 | include $(CLEAR_VARS) 43 | LOCAL_MODULE := damn-server-exec 44 | LOCAL_C_INCLUDES := $(LOCAL_PATH)/damn-server \ 45 | $(LOCAL_PATH)/civetweb \ 46 | $(LOCAL_PATH)/misc 47 | LOCAL_SHARED_LIBRARIES := damn-server \ 48 | daemonize 49 | LOCAL_SRC_FILES := damn-server/damn_server_exec.c 50 | LOCAL_LDLIBS := -llog 51 | include $(BUILD_EXECUTABLE) -------------------------------------------------------------------------------- /res/layout/listitem_package.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 16 | 17 | 28 | 29 | 41 | -------------------------------------------------------------------------------- /jni/misc/daemonize.c: -------------------------------------------------------------------------------- 1 | /* 2 | * from http://stackoverflow.com/a/17955149 3 | */ 4 | #include "daemonize.h" 5 | 6 | #define TAG "daemonize" 7 | #define printf(...) __android_log_print(ANDROID_LOG_DEBUG, TAG,__VA_ARGS__) 8 | #define LOGV(...) __android_log_print(ANDROID_LOG_VERBOSE, TAG,__VA_ARGS__) 9 | #define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG , TAG,__VA_ARGS__) 10 | #define LOGI(...) __android_log_print(ANDROID_LOG_INFO , TAG,__VA_ARGS__) 11 | #define LOGW(...) __android_log_print(ANDROID_LOG_WARN , TAG,__VA_ARGS__) 12 | #define LOGE(...) __android_log_print(ANDROID_LOG_ERROR , TAG,__VA_ARGS__) 13 | 14 | void skeleton_daemon() 15 | { 16 | pid_t pid; 17 | 18 | /* Fork off the parent process */ 19 | pid = fork(); 20 | 21 | /* An error occurred */ 22 | if (pid < 0) 23 | exit(EXIT_FAILURE); 24 | 25 | /* Success: Let the parent terminate */ 26 | if (pid > 0) 27 | exit(EXIT_SUCCESS); 28 | 29 | /* On success: The child process becomes session leader */ 30 | if (setsid() < 0) 31 | exit(EXIT_FAILURE); 32 | 33 | /* Catch, ignore and handle signals */ 34 | //TODO: Implement a working signal handler */ 35 | signal(SIGCHLD, SIG_IGN); 36 | signal(SIGHUP, SIG_IGN); 37 | 38 | /* Fork off for the second time*/ 39 | pid = fork(); 40 | 41 | /* An error occurred */ 42 | if (pid < 0) 43 | exit(EXIT_FAILURE); 44 | 45 | /* Success: Let the parent terminate */ 46 | if (pid > 0) 47 | exit(EXIT_SUCCESS); 48 | 49 | /* Set new file permissions */ 50 | umask(0); 51 | 52 | /* Change the working directory to the root directory */ 53 | /* or another appropriated directory */ 54 | chdir("/"); 55 | 56 | /* Close all open file descriptors */ 57 | int x; 58 | for (x = sysconf(_SC_OPEN_MAX); x>0; x--) 59 | { 60 | close (x); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /jni/damn-server/damn_server.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _DAMN_SERVER_H 3 | #define _DAMN_SERVER_H 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include "civetweb.h" 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif /* __cplusplus */ 22 | 23 | /** 24 | * Start server and block till server terminates. 25 | */ 26 | void start_server(const char *docroot, const char *pemfile, const char *cachedir); 27 | /** 28 | * Stop the server and cause 'start_server' to return. 29 | * Return true if stopping the server was successful, false otherwise. 30 | */ 31 | bool stop_server(const char *cachedir); 32 | /** 33 | * Return the connection count od the server. 34 | */ 35 | int get_connection_count(); 36 | 37 | void Java_at_fhooe_mcm14_damn_jni_DAMNServer_startServerJNI(JNIEnv *env, jclass clazz, jstring docroot, jstring pemfile, jstring cachedir); 38 | void Java_at_fhooe_mcm14_damn_jni_DAMNServer2_startServerJNI(JNIEnv *env, jclass clazz, jstring docroot, jstring pemfile, jstring cachedir); 39 | bool Java_at_fhooe_mcm14_damn_jni_DAMNServer_stopServerJNI();//JNIEnv *env, jclass clazz); 40 | int Java_at_fhooe_mcm14_damn_jni_DAMNServer_getConnectionsJNI(); 41 | int Java_at_fhooe_mcm14_damn_jni_DAMNServer_getStateBlockingJNI(); 42 | int Java_at_fhooe_mcm14_damn_jni_DAMNServer_getStateJNI(); 43 | void Java_at_fhooe_mcm14_damn_jni_DAMNServer_pushJNI(JNIEnv *env, jclass clazz, int code, jstring message, jstring application, long long threadId); 44 | jstring Java_at_fhooe_mcm14_damn_jni_DAMNServer_receiveBlockingJNI(JNIEnv *env, jclass clazz, jstring application, long long threadId); 45 | void Java_at_fhooe_mcm14_damn_jni_DAMNServer_newAppJNI(JNIEnv *env, jclass clazz, jstring application, long long threadId); 46 | void Java_at_fhooe_mcm14_damn_jni_DAMNServer_deleteAppJNI(JNIEnv *env, jclass clazz, jstring application, long long threadId); 47 | 48 | #ifdef __cplusplus 49 | } 50 | #endif /* __cplusplus */ 51 | #endif /* _DAMN_SERVER_H */ 52 | -------------------------------------------------------------------------------- /jni/misc/install_sys_lib.c: -------------------------------------------------------------------------------- 1 | #include "install_sys_lib.h" 2 | 3 | #define TAG "install_sys_lib" 4 | #define LOGV(...) __android_log_print(ANDROID_LOG_VERBOSE, TAG,__VA_ARGS__) 5 | #define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG , TAG,__VA_ARGS__) 6 | #define LOGI(...) __android_log_print(ANDROID_LOG_INFO , TAG,__VA_ARGS__) 7 | #define LOGW(...) __android_log_print(ANDROID_LOG_WARN , TAG,__VA_ARGS__) 8 | #define LOGE(...) __android_log_print(ANDROID_LOG_ERROR , TAG,__VA_ARGS__) 9 | 10 | int remount_system() 11 | { 12 | //execute remount 13 | return system("su -c 'mount -o rw,remount /system'"); 14 | } 15 | 16 | 17 | bool install_sys_lib(const char *path_to_lib, const char **libs, int size) 18 | { 19 | //remount '/system' 20 | if(remount_system()) { 21 | LOGE("remounting '/system' failed"); 22 | return false; 23 | } 24 | 25 | //copy library into system library path 26 | char *buf; 27 | size_t sz; 28 | int n=0; 29 | 30 | for(n=0;nGetObjectArrayElement(env, libs, n); 61 | libraries[n] = (*env)->GetStringUTFChars(env, string, 0); 62 | LOGD("lib: %s", libraries[n]); 63 | } 64 | 65 | return install_sys_lib((*env)->GetStringUTFChars(env, path_to_lib, 0), libraries, size); 66 | } 67 | -------------------------------------------------------------------------------- /src/at/fhooe/mcm14/damn/services/XModuleService.java: -------------------------------------------------------------------------------- 1 | package at.fhooe.mcm14.damn.services; 2 | 3 | import android.app.Notification; 4 | import android.app.NotificationManager; 5 | import android.app.PendingIntent; 6 | import android.app.Service; 7 | import android.content.Context; 8 | import android.content.Intent; 9 | import android.os.IBinder; 10 | import android.util.Log; 11 | import at.fhooe.mcm14.damn.R; 12 | import at.fhooe.mcm14.damn.activities.AppListActivity; 13 | 14 | public class XModuleService extends Service { 15 | 16 | public static final String FROM_SERVICE = "controlservice"; 17 | private static final String TAG = XModuleService.class.toString(); 18 | 19 | 20 | @Override 21 | public int onStartCommand(Intent _intent, int _flags, int _startId) { 22 | Log.i(TAG, "onStartCommand"); 23 | 24 | // show a notification in the status bar 25 | Intent intent = new Intent(getApplicationContext(), AppListActivity.class); 26 | intent.putExtra(FROM_SERVICE, true); 27 | PendingIntent pIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); 28 | 29 | // build notification 30 | Notification notifitaction = new Notification.Builder(getApplicationContext()) 31 | .setContentTitle("DAMN") 32 | .setContentText("Service running") 33 | .setSmallIcon(R.drawable.ic_launcher) 34 | .setContentIntent(pIntent) 35 | .setAutoCancel(true).build(); 36 | 37 | NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); 38 | 39 | //show notification 40 | notificationManager.notify(0, notifitaction); 41 | 42 | //cause we want to start or end the service 43 | return Service.START_STICKY; 44 | } 45 | 46 | @Override 47 | public void onCreate() { 48 | super.onCreate(); 49 | Log.i(TAG, "onCreate"); 50 | } 51 | 52 | @Override 53 | public IBinder onBind(Intent intent) { 54 | Log.i(TAG, "onBind"); 55 | return null; 56 | } 57 | 58 | public Context getXModuleServiceContext() { 59 | return getApplicationContext(); 60 | } 61 | 62 | @Override 63 | public void onDestroy() { 64 | super.onDestroy(); 65 | Log.i(TAG, "onDestroy"); 66 | 67 | //clear notifitaction 68 | NotificationManager notificationManager = (NotificationManager)getSystemService(NOTIFICATION_SERVICE); 69 | notificationManager.cancel(0); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /jni/damn-server/damn_server_exec.c: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _WS_SERVER_EXEC_H 3 | #define _WS_SERVER_EXEC_H 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include "damn_server.h" 11 | #include "daemonize.h" 12 | 13 | #define TAG "damn_server_exec" 14 | #define LOGV(...) __android_log_print(ANDROID_LOG_VERBOSE, TAG,__VA_ARGS__) 15 | #define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG , TAG,__VA_ARGS__) 16 | #define LOGI(...) __android_log_print(ANDROID_LOG_INFO , TAG,__VA_ARGS__) 17 | #define LOGW(...) __android_log_print(ANDROID_LOG_WARN , TAG,__VA_ARGS__) 18 | #define LOGE(...) __android_log_print(ANDROID_LOG_ERROR , TAG,__VA_ARGS__) 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif /* __cplusplus */ 23 | 24 | 25 | void* start(void *cmd) 26 | { 27 | printf("command: %s\n", (char*)cmd); 28 | system(cmd); 29 | printf("end command\n"); 30 | } 31 | 32 | int main(int argc, const char* argv[]) 33 | { 34 | LOGI("My process ID : %d\n", getpid()); 35 | LOGI("My parent's ID: %d\n", getppid()); 36 | LOGI("path %s\n", argv[0]); 37 | 38 | 39 | //check if we got 'docroot' as parameter passed 40 | if(argc!=4) { 41 | printf("usage ws-server-exec path/to/docroot path/to/pemfile /path/to/tmp\n"); 42 | LOGE("wrong amounts of parameters passed [%d]", argc-1); 43 | return -1; 44 | } 45 | 46 | //daemonize 47 | // skeleton_daemon(); 48 | 49 | uid_t uid=getuid(), euid=geteuid(); 50 | LOGI("uid=%d, euid=%d\n", uid, euid); 51 | 52 | // if (uid!=0 || uid!=euid) { 53 | // //restart with root privileges 54 | // char cmd[256]; 55 | // LOGI("params: %s %s %s", argv[0], argv[1], argv[2]); 56 | // sprintf(cmd, "su -c '%s %s %s' &", argv[0], argv[1], argv[2]); 57 | // 58 | // pthread_t id; 59 | // if (pthread_create(&id, NULL, &start, (void *)&cmd)) 60 | // { 61 | // LOGE("pthread_create failed :("); 62 | // return -2; 63 | // } 64 | // 65 | // pthread_join(id, NULL); 66 | // LOGD("join of server finished"); 67 | // return 0; 68 | // } 69 | 70 | LOGI("docroot: %s, pemfile: %s, tmp: %s", argv[1], argv[2], argv[3]); 71 | 72 | //start ws_server 73 | LOGD("start server"); 74 | start_server(argv[1], argv[2], argv[3]); 75 | 76 | LOGD("exiting damn server"); 77 | pthread_exit(NULL); 78 | } 79 | 80 | #ifdef __cplusplus 81 | } 82 | #endif /* __cplusplus */ 83 | #endif /* _WS_SERVER_EXEC_H */ 84 | -------------------------------------------------------------------------------- /AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 10 | 11 | 16 | 17 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 29 | 30 | 31 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 45 | 48 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /res/layout/activity_app_detail.xml: -------------------------------------------------------------------------------- 1 | 10 | 11 | 16 | 17 | 28 | 29 | 40 | 41 | 50 | 51 | 58 | 59 |