├── 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 |
10 |
--------------------------------------------------------------------------------
/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 | 64dp
9 |
10 |
11 |
--------------------------------------------------------------------------------
/res/menu/app_detail.xml:
--------------------------------------------------------------------------------
1 |
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 |
67 |
68 |
69 |
--------------------------------------------------------------------------------
/src/at/fhooe/mcm14/damn/xposed/XListener.java:
--------------------------------------------------------------------------------
1 | package at.fhooe.mcm14.damn.xposed;
2 |
3 | import android.util.Log;
4 | import at.fhooe.mcm14.damn.jni.DAMNServer;
5 | import at.fhooe.mcm14.damn.objects.MessageObject;
6 |
7 | public class XListener extends Thread {
8 | public boolean STEPPING = true;
9 | private boolean first = false;
10 | private boolean running = true;
11 | private final static String TAG = XListener.class.getName();
12 | private volatile String app = null;
13 | private volatile String data = null;
14 | private Thread thread = null;
15 | private long tid = 0;
16 | private XDAMNHook hook = null;
17 |
18 |
19 | public XListener(String _app, Thread _thread, XDAMNHook _hook) {
20 | app = _app;
21 | thread = _thread;
22 | hook = _hook;
23 |
24 | tid = thread!=null ? thread.getId() : 1L;
25 |
26 | if(thread!=null)
27 | new Thread(new Runnable() {
28 |
29 | @Override
30 | public void run() {
31 | // check if thread running
32 | Log.d(TAG, "join thread [" + tid + "]");
33 |
34 | try{
35 | thread.join();
36 |
37 | }catch(Exception e) {
38 | Log.e(TAG, "error thread join [" + tid + "]");
39 | Log.e(TAG, e.getMessage());
40 | }
41 |
42 | Log.i(TAG, "thread ended [" + tid + "]");
43 | hook.threads.remove(tid);
44 | running = false;
45 |
46 | //close browser tab remotely
47 | DAMNServer.endAppThread(app, tid);
48 | }
49 | }).start();
50 | }
51 |
52 |
53 | @Override
54 | public void run() {
55 | while(running) {
56 | Log.d(TAG, "wait for " + app + ":" + tid);
57 | MessageObject msg = DAMNServer.getReceivedMessageBlocking(app, tid);
58 | Log.d(TAG, "got: " + msg.code.name() + ":" + tid);
59 |
60 | switch (msg.code) {
61 | case play:
62 | synchronized (app) {
63 | STEPPING = false;
64 | app.notifyAll();
65 | Log.d(TAG, "play");
66 | }
67 | break;
68 |
69 | case pause:
70 | synchronized (app) {
71 | STEPPING = true;
72 | app.notify();
73 | Log.d(TAG, "pause");
74 | }
75 | break;
76 |
77 | case step:
78 | synchronized (app) {
79 | STEPPING = true;
80 | data = msg.payload.length()==0 ? null : msg.payload;
81 | app.notify();
82 | Log.d(TAG, "step");
83 | }
84 | break;
85 |
86 | default:
87 | Log.d(TAG, "default: " + msg.code.name());
88 | break;
89 | }
90 | }
91 |
92 | Log.i(TAG, "end listening to " + app + ":" + tid);
93 | }
94 |
95 | public String waitForNextStep() {
96 | synchronized (app) {
97 | try {
98 | if(!first) {
99 | first = true;
100 | Log.d(TAG, "first was flase");
101 |
102 | }else{
103 | app.wait();
104 | return data;
105 | }
106 |
107 | } catch (InterruptedException e) {
108 | e.printStackTrace();
109 | Log.e(TAG, "error: " + e.getLocalizedMessage());
110 | }
111 |
112 | return null;
113 | }
114 | }
115 | }
116 |
--------------------------------------------------------------------------------
/src/at/fhooe/mcm14/damn/jni/USBTethering.java:
--------------------------------------------------------------------------------
1 | package at.fhooe.mcm14.damn.jni;
2 |
3 |
4 | public class USBTethering {
5 |
6 | /**
7 | * Load usb-tethering library.
8 | */
9 | static {
10 | System.loadLibrary("usb-tethering");
11 |
12 | //check state
13 | state = checkUSBTethering() ? USBState.usb_ready : USBState.usb_off;
14 | }
15 |
16 | public static enum USBState {
17 | usb_off(0),
18 | usb_init(1),
19 | usb_ready(2),
20 | usb_connected(3),
21 | usb_unknown(4);
22 |
23 | private int val;
24 |
25 | private USBState(int val) {
26 | this.val = val;
27 | }
28 |
29 | public int getNumVal() {
30 | return val;
31 | }
32 | }
33 |
34 | private static native String startUSBTetheringJNI();
35 | private static native boolean stopUSBTetheringJNI();
36 | private static native boolean checkUSBTetheringJNI();
37 | private static native int getStateBlockingJNI();
38 | private static native int getStateJNI();
39 |
40 | private static USBState state = USBState.usb_unknown;
41 |
42 | /**
43 | * Prepare device for usb-tethering and wait till a client connect or the timeout occurs.
44 | *
45 | * @return client IP address or null if no client connects
46 | */
47 | public static String startUSBTethering() {
48 | //change state to init
49 | state = USBState.usb_init;
50 | //update notification
51 | // context.startService(new Intent(context, NotificationService.class));
52 |
53 | //start usb-tethering
54 | String result = startUSBTetheringJNI();
55 | if(result!=null)
56 | state = USBState.usb_connected;
57 | else
58 | state = USBState.usb_off;
59 |
60 | //update notification
61 | // context.startService(new Intent(context, NotificationService.class));
62 |
63 | return result;
64 | }
65 |
66 | /**
67 | * Stop usb-tethering.
68 | *
69 | * @return true if everything works fine, false otherwise
70 | */
71 | public static boolean stopUSBTethering() {
72 | boolean result = stopUSBTetheringJNI();
73 | if(result){
74 | state = USBState.usb_off;
75 |
76 | }else{
77 | state = USBState.usb_ready; //TODO check if usb state is really on?
78 | }
79 |
80 | //update notification
81 | // context.startService(new Intent(context, NotificationService.class));
82 |
83 | return result;
84 | }
85 |
86 | /**
87 | * Explicit check if usb-tethering is active.
88 | *
89 | * @return true if active, false otherwise
90 | */
91 | public static boolean checkUSBTethering() {
92 | //TODO get all states...
93 | return checkUSBTetheringJNI();
94 | }
95 |
96 | /**
97 | * Block till state changed.
98 | *
99 | * @return state of usb-tethering
100 | */
101 | public static USBState getStateBlocking() {
102 | return USBState.values()[getStateBlockingJNI()];
103 | }
104 |
105 | /**
106 | * Return the actual state.
107 | *
108 | * @return state of usb-tethering
109 | */
110 | public static USBState getState() {
111 | return USBState.values()[getStateJNI()];
112 | }
113 | }
114 |
--------------------------------------------------------------------------------
/assets/root/ssl_cert.pem:
--------------------------------------------------------------------------------
1 | -----BEGIN RSA PRIVATE KEY-----
2 | MIIEogIBAAKCAQEAwONaLOP7EdegqjRuQKSDXzvHmFMZfBufjhELhNjo5KsL4ieH
3 | hMSGCcSV6y32hzhqR5lvTViaQez+xhc58NZRu+OUgEhodRBW/vAOjpz/xdMz5HaC
4 | EhP3E9W1pkitVseS8B5rrgJo1BfCGai1fPav1nutPq2Kj7vMy24+g460Lonf6ln1
5 | di4aTIRtAqXtUU6RFpPJP35PkCXbTK65O8HJSxxt/XtfoezHCU5+UIwmZGYx46UB
6 | Wzg3IfK6bGPSiHU3pdiTol0uMPt/GUK+x4NyZJ4/ImsNAicRwMBdja4ywHKXJehH
7 | gXBthsVIHbL21x+4ibsg9eVM/XioTV6tW3IrdwIDAQABAoIBACFfdLutmkQFBcRN
8 | HAJNNHmmsyr0vcUOVnXTFyYeDXV67qxrYHQlOHe6LqIpKq1Mon7O2kYMnWvooFAP
9 | trOnsS6L+qaTYJdYg2TKjgo4ubw1hZXytyB/mdExuaMSkgMgtpia+tB5lD+V+LxN
10 | x1DesZ+veFMO3Zluyckswt4qM5yVa04YFrt31H0E1rJfIen61lidXIKYmHHWuRxK
11 | SadjFfbcqJ6P9ZF22BOkleg5Fm5NaxJmyQynOWaAkSZa5w1XySFfRjRfsbDr64G6
12 | +LSG8YtRuvfxnvUNhynVPHcpE40eiPo6v8Ho6yZKXpV5klCKciodXAORsswSoGJa
13 | N3nnu/ECgYEA6Yb2rM3QUEPIALdL8f/OzZ1GBSdiQB2WSAxzl9pR/dLF2H+0pitS
14 | to0830mk92ppVmRVD3JGxYDRZQ56tlFXyGaCzJBMRIcsotAhBoNbjV0i9n5bLJYf
15 | BmjU9yvWcgsTt0tr3B0FrtYyp2tCvwHqlxvFpFdUCj2oRw2uGpkhmNkCgYEA03M6
16 | WxFhsix3y6eVCVvShfbLBSOqp8l0qiTEty+dgVQcWN4CO/5eyaZXKxlCG9KMmKxy
17 | Yx+YgxZrDhfaZ0cxhHGPRKEAxM3IKwT2C8/wCaSiLWXZZpTifnSD99vtOt4wEfrG
18 | +AghNd5kamFiM9tU0AyvhJc2vdJFuXrfeC7ntM8CgYBGDA+t4cZcbRhu7ow/OKYF
19 | kulP3nJgHP/Y+LMrl3cEldZ2jEfZmCElVNQvfd2XwTl7injhOzvzPiKRF3jDez7D
20 | g8w0JAxceddvttJRK9GoY4l7OoeKpjUELSnEQkf+yUfOsTbXPXVY7jMfeNL6jE6b
21 | qN7t3qv8rmXtejMBE3G6cQKBgGR5W2BMiRSlxqKx1cKlrApV87BUe1HRCyuR3xuA
22 | d6Item7Lx1oEi7vb242yKdSYnpApWQ06xTh83Y/Ly87JaIEbiM0+h+P8OEIg0F1a
23 | iB+86AcUX1I8KseVy+Np0HbpfwP8GrFfA5DaRPK7pXMopEtby8cAJ1XZZaI1/ZvZ
24 | BebHAoGAcQU9WvCkT+nIp9FpXfBybYUsvgkaizMIqp66/l3GYgYAq8p1VLGvN4v5
25 | ec0dW58SJrCpqsM3NP78DtEzQf9OOsk+FsjBFzDU2RkeUreyt2/nQBj/2mN/+hEy
26 | hYN0Zii2yTb63jGxKY6gH1R/r9dL8kXaJmcZrfSa3AgywnteJWg=
27 | -----END RSA PRIVATE KEY-----
28 | -----BEGIN CERTIFICATE-----
29 | MIIDBjCCAe4CCQCX05m0b053QzANBgkqhkiG9w0BAQQFADBFMQswCQYDVQQGEwJB
30 | VTETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0
31 | cyBQdHkgTHRkMB4XDTA4MTIwNzEwMjUyMloXDTE4MTIwNTEwMjUyMlowRTELMAkG
32 | A1UEBhMCQVUxEzARBgNVBAgTClNvbWUtU3RhdGUxITAfBgNVBAoTGEludGVybmV0
33 | IFdpZGdpdHMgUHR5IEx0ZDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB
34 | AMDjWizj+xHXoKo0bkCkg187x5hTGXwbn44RC4TY6OSrC+Inh4TEhgnElest9oc4
35 | akeZb01YmkHs/sYXOfDWUbvjlIBIaHUQVv7wDo6c/8XTM+R2ghIT9xPVtaZIrVbH
36 | kvAea64CaNQXwhmotXz2r9Z7rT6tio+7zMtuPoOOtC6J3+pZ9XYuGkyEbQKl7VFO
37 | kRaTyT9+T5Al20yuuTvByUscbf17X6HsxwlOflCMJmRmMeOlAVs4NyHyumxj0oh1
38 | N6XYk6JdLjD7fxlCvseDcmSePyJrDQInEcDAXY2uMsBylyXoR4FwbYbFSB2y9tcf
39 | uIm7IPXlTP14qE1erVtyK3cCAwEAATANBgkqhkiG9w0BAQQFAAOCAQEAW4yZdqpB
40 | oIdiuXRosr86Sg9FiMg/cn+2OwQ0QIaA8ZBwKsc+wIIHEgXCS8J6316BGQeUvMD+
41 | plNe0r4GWzzmlDMdobeQ5arPRB89qd9skE6pAMdLg3FyyfEjz3A0VpskolW5VBMr
42 | P5R7uJ1FLgH12RyAjZCWYcCRqEMOffqvyMCH6oAjyDmQOA5IssRKX/HsHntSH/HW
43 | W7slTcP45ty1b44Nq22/ubYk0CJRQgqKOIQ3cLgPomN1jNFQbAbfVTaK1DpEysrQ
44 | 5V8a8gNW+3sVZmV6d1Mj3pN2Le62wUKuV2g6BNU7iiwcoY8HI68aRxz2hVMS+t5f
45 | SEGI4JSxV56lYg==
46 | -----END CERTIFICATE-----
47 | -----BEGIN DH PARAMETERS-----
48 | MEYCQQD+ef8hZ4XbdoyIpJyCTF2UrUEfX6mYDvxuS5O1UNYcslUqlj6JkA11e/yS
49 | 6DK8Z86W6mSj5CEk4IjbyEOECXH7AgEC
50 | -----END DH PARAMETERS-----
51 |
--------------------------------------------------------------------------------
/src/at/fhooe/mcm14/damn/xposed/XModule.java:
--------------------------------------------------------------------------------
1 | package at.fhooe.mcm14.damn.xposed;
2 |
3 | import java.io.BufferedInputStream;
4 | import java.io.File;
5 | import java.io.FileInputStream;
6 | import java.io.InputStream;
7 | import java.io.ObjectInput;
8 | import java.io.ObjectInputStream;
9 | import java.util.List;
10 |
11 | import android.util.Log;
12 | import de.robv.android.xposed.IXposedHookLoadPackage;
13 | import de.robv.android.xposed.IXposedHookZygoteInit;
14 | import de.robv.android.xposed.callbacks.XC_LoadPackage.LoadPackageParam;
15 |
16 | public class XModule implements IXposedHookLoadPackage, IXposedHookZygoteInit {
17 |
18 | private static final String TAG = XModule.class.toString();
19 |
20 | public static final String PACKAGE_FILE = "damn_packages.pkg";
21 |
22 | @Override
23 | public void handleLoadPackage(LoadPackageParam lpparam) throws Throwable {
24 | //pushMessage("application " + lpparam.packageName + " loading");
25 | Log.d(TAG, "application " + lpparam.packageName + " loading");
26 |
27 | //update trackable apps
28 | List packages = null;
29 | try {
30 | packages = XModule.getTrackablePackages(lpparam.appInfo.dataDir);
31 |
32 | }catch(Exception e) {
33 | Log.e(TAG, "cant open getTrackablePackages()..");
34 | return;
35 | }
36 |
37 | // search if actual loaded application match with trackable applications
38 | if(packages!=null){
39 | Log.d(TAG, "package: " + lpparam.packageName);
40 | if (lpparam.packageName.contains(packages.get(0))) {
41 | packages.remove(0);
42 | new XHookAll(lpparam.packageName, lpparam.appInfo.sourceDir, lpparam.classLoader, packages);
43 | Log.d(TAG, "application " + lpparam.packageName + " done");
44 | }
45 | }
46 | }
47 |
48 | @Override
49 | protected void finalize() throws Throwable {
50 | super.finalize();
51 | Log.i(TAG, "finalize");
52 | }
53 |
54 | @Override
55 | public void initZygote(StartupParam startupParam) throws Throwable {
56 | Log.i(TAG, "zygote startup");
57 | }
58 |
59 |
60 |
61 |
62 | @SuppressWarnings("unchecked")
63 | public static List getTrackablePackages(String app) {
64 | InputStream is = null;
65 | InputStream buffer = null;
66 | ObjectInput input = null;
67 | List packages = null;
68 |
69 | File file = new File(app, XModule.PACKAGE_FILE);
70 | if(!file.exists()){
71 | Log.e(TAG, file.getAbsolutePath() + " dont exist");
72 | return null;
73 | }
74 |
75 | try {
76 | is = new FileInputStream(file);
77 | buffer = new BufferedInputStream(is);
78 | input = new ObjectInputStream (buffer);
79 |
80 | //deserialize the List
81 | packages = (List)input.readObject();
82 |
83 |
84 | //log its data
85 | // for(String app: trackableApps){
86 | // Log.i(TAG, "trackable app: " + app);
87 | // }
88 |
89 | }catch(Exception ex){
90 | Log.e(TAG, "error: " + ex.getMessage());
91 | ex.printStackTrace();
92 | }finally{
93 | try {if(input!=null)input.close();if(buffer!=null)buffer.close();if(is!=null)is.close();} catch (Exception e) {}
94 | }
95 |
96 | return packages;
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/assets/root/docroot/rules.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | DAMN welcome
6 |
43 |
44 |
66 |
67 |
113 |
114 |
115 |
116 |
117 |
Rules
118 |
121 |
124 |
125 |
126 |
--------------------------------------------------------------------------------
/assets/root/docroot/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | DAMN welcome
6 |
40 |
41 |
63 |
64 |
126 |
127 |
128 |
129 |
130 |

131 |
Connect ...
132 |
133 |
134 |
--------------------------------------------------------------------------------
/src/at/fhooe/mcm14/damn/jni/DAMNServer.java:
--------------------------------------------------------------------------------
1 | package at.fhooe.mcm14.damn.jni;
2 |
3 | import android.util.Log;
4 | import at.fhooe.mcm14.damn.objects.MessageObject;
5 |
6 |
7 | public class DAMNServer {
8 |
9 | //load library
10 | static {
11 | System.loadLibrary("damn-server");
12 |
13 | //check state
14 | state = getState();
15 | }
16 |
17 | public static enum ServerState {
18 | server_off(0),
19 | server_init(1),
20 | server_on(2),
21 | server_unknown(3);
22 |
23 | private int val;
24 |
25 | private ServerState(int val) {
26 | this.val = val;
27 | }
28 |
29 | public int getNumVal() {
30 | return val;
31 | }
32 | }
33 |
34 | public static enum Code {
35 | connected(0),
36 | pause(1),
37 | play(2),
38 | step(3),
39 | methodCode(4),
40 | varGlobal(5),
41 | varParam(6),
42 | varReturn(7),
43 | varManipulatedParam(8),
44 | varManipulatedReturn(9),
45 | unhook(10),
46 | undefined(11),
47 | close(12);
48 |
49 | private int val;
50 |
51 | private Code(int val) {
52 | this.val = val;
53 | }
54 |
55 | public int getNumVal() {
56 | return val;
57 | }
58 | }
59 |
60 | private static native void startServerJNI(String docroot, String pemfile, String cachedir);
61 | private static native boolean stopServerJNI();
62 | private static native int getConnectionsJNI();
63 | private static native int getStateBlockingJNI();
64 | private static native int getStateJNI();
65 | private static native void pushJNI(int code, String payload, String application, long threadId);
66 | private static native String receiveBlockingJNI(String application, long threadId);
67 | private static native void newAppJNI(String application, long threadId);
68 | private static native void deleteAppJNI(String application, long threadId);
69 |
70 | private static ServerState state = ServerState.server_unknown;
71 |
72 | /**
73 | * Starts the DAMN server and block until it gets terminated.
74 | *
75 | * @param docroot holds the absolute path to the document folder
76 | * @param pemfile holds the absolute path to the pem file
77 | */
78 | public static void startServer(String docroot, String pemfile, String cachedir) {
79 |
80 | startServerJNI(docroot, pemfile, cachedir);
81 | }
82 |
83 | /**
84 | * Stops the DAMN server and will cause the {@link DAMNServer#startServer(String, String)} to return.
85 | *
86 | * @return true if server
87 | */
88 | public static boolean stopServer() {
89 | return stopServerJNI();
90 | }
91 |
92 | /**
93 | * Return the count of connected clients.
94 | *
95 | * @return count of connected clients
96 | */
97 | public static int getConnections() {
98 | return getConnectionsJNI();
99 | }
100 |
101 | /**
102 | * Blocking till a state change of the server occur and return it.
103 | *
104 | * @return actual state of the server
105 | */
106 | public static ServerState getStateBlocking() {
107 | return ServerState.values()[getStateBlockingJNI()];
108 | }
109 |
110 | /**
111 | * Return the actual state of the server.
112 | *
113 | * @return actual state of the server
114 | */
115 | public static ServerState getState() {
116 | return ServerState.values()[getStateJNI()];
117 | }
118 |
119 | public synchronized static void push(MessageObject msg) {
120 | pushJNI(msg.code.val, msg.payload, msg.app, msg.threadId);
121 | try {Thread.sleep(0, 100);} catch (InterruptedException e) { }
122 | }
123 |
124 | public static MessageObject getReceivedMessageBlocking(String app, long threadId) {
125 | String msg = receiveBlockingJNI(app, threadId);
126 |
127 | String payload = "";
128 | Code code = Code.undefined;
129 | try{
130 | code = Code.values()[Integer.valueOf(msg.substring(0, 3))];
131 | payload = msg.substring(3, msg.length());
132 |
133 | } catch(Exception e) {}
134 |
135 | return new MessageObject(code, payload, app, threadId);
136 | }
137 |
138 | public static void newAppStarted(String app) {
139 | newAppJNI(app, 1);
140 | }
141 |
142 | public static void startAppThread(String app, long threadId) {
143 | Log.d("faaaaat", "threadId: " + threadId);
144 | newAppJNI(app, threadId);
145 | }
146 |
147 | public static void endAppThread(String app, long threadId) {
148 | Log.d("faaaaat", "threadId: " + threadId);
149 | deleteAppJNI(app, threadId);
150 | }
151 | }
152 |
--------------------------------------------------------------------------------
/src/at/fhooe/mcm14/damn/xposed/XHookAll.java:
--------------------------------------------------------------------------------
1 | package at.fhooe.mcm14.damn.xposed;
2 |
3 | import java.io.IOException;
4 | import java.lang.reflect.Method;
5 | import java.util.ArrayList;
6 | import java.util.Collection;
7 | import java.util.Enumeration;
8 | import java.util.List;
9 | import java.util.concurrent.Callable;
10 | import java.util.concurrent.ExecutorService;
11 | import java.util.concurrent.Executors;
12 | import java.util.concurrent.Future;
13 | import java.util.concurrent.TimeUnit;
14 |
15 | import android.util.Log;
16 | import at.fhooe.mcm14.damn.jni.DAMNServer;
17 | import dalvik.system.DexFile;
18 | import de.robv.android.xposed.XposedHelpers;
19 | import de.robv.android.xposed.XposedHelpers.ClassNotFoundError;
20 |
21 | public class XHookAll {
22 | private static final String TAG = XHookAll.class.getCanonicalName();
23 |
24 | private String app;
25 | private String source;
26 | private List pkgs = null;
27 | private ClassLoader clazzloader;
28 | private List> tasks = new ArrayList>();
29 | private ExecutorService pool = null;
30 |
31 |
32 | public XHookAll(String _app, String _source, ClassLoader _clazzloader, List _pkgs) {
33 | app = _app;
34 | source = _source;
35 | clazzloader = _clazzloader;
36 | pkgs = _pkgs;
37 |
38 | hook();
39 | }
40 |
41 |
42 | private void hook() {
43 | // get all classes and hook every constructor and method
44 | DexFile df;
45 | try {
46 | df = new DexFile(source);
47 |
48 | } catch (IOException e) {
49 | e.printStackTrace();
50 | return;
51 | }
52 | Log.i(TAG, "register " + df.getName());
53 | XDAMNHook hook = new XDAMNHook(app);
54 |
55 | DAMNServer.newAppStarted(app);
56 | XListener xl = new XListener(app, null, hook);
57 | xl.start();
58 |
59 | hook.threads.put(1L, xl);
60 | Log.e(TAG, "opened new site");
61 |
62 | //if there are no packages specified - return
63 | if(pkgs==null)
64 | return;
65 |
66 |
67 | // literate through every class of application
68 | for (Enumeration iter = df.entries(); iter.hasMoreElements();) {
69 | String clazzName = iter.nextElement();
70 |
71 | //check if package is in
72 | boolean pack = false;
73 | for(String pkg : pkgs)
74 | if(clazzName.startsWith(pkg)){
75 | pack = true;
76 | break;
77 | }
78 |
79 | if(!pack)
80 | continue;
81 |
82 | // get class
83 | Class> clazz = null;
84 | try {
85 | clazz = XposedHelpers.findClass(clazzName, clazzloader);
86 | // Log.i(TAG, "in class: " + clazzName);
87 |
88 | //hook all constructors
89 | tasks.add(new XCallableHookConstructors(hook, clazz));
90 | // Log.i(TAG, "constructors hooked");
91 |
92 | //get all methods
93 | Method[] methods = clazz.getMethods();
94 |
95 | //hook methods
96 | if(methods != null)
97 | for(Method method : methods){
98 | tasks.add(new XCallableHookMethods(hook, clazz, method.getName()));
99 |
100 | // Log.i(TAG, "method " + method.getName() + " hooked");
101 | }
102 |
103 | // Log.d(TAG, "before done: " + clazzName);
104 |
105 |
106 | } catch (NoClassDefFoundError ncd) {
107 | // Log.e(TAG, "def not found " + clazzName);
108 |
109 | } catch (ClassNotFoundError cn) {
110 | // Log.e(TAG, "can't find " + clazzName);
111 |
112 | } catch (Exception e) {
113 | // Log.e(TAG, "error: " + e.getMessage());
114 | }
115 |
116 | // Log.d(TAG, "done: " + clazzName);
117 | }
118 |
119 | Log.d(TAG, "size of tasks:" + tasks.size());
120 |
121 | // pool = Executors.newSingleThreadExecutor();
122 | int size = tasks.size()/10;
123 | int max = 300;
124 |
125 | if(size>max)
126 | size=max;
127 | else if(size<1)
128 | size=1;
129 |
130 | pool = Executors.newFixedThreadPool(size);
131 |
132 | try {
133 | List> ret = pool.invokeAll(tasks, 5, TimeUnit.SECONDS);
134 |
135 | Log.i(TAG, "served methods: " + ret.size());
136 |
137 |
138 | } catch (InterruptedException e1) {
139 | e1.printStackTrace();
140 | Log.e(TAG, e1.getMessage());
141 | }
142 |
143 | //go on
144 | Log.d(TAG, "notifyAll...");
145 | synchronized (hook.threads) {
146 | hook.init_done = true;
147 | Log.d(TAG, "notifyAll");
148 | Collection values = hook.threads.values();
149 | for(XListener l : values)
150 | try{l.notify();}catch(IllegalMonitorStateException e){ }
151 | }
152 |
153 | pool.shutdown();
154 | Log.d(TAG, "wait till all down");
155 | // try {
156 | // pool.awaitTermination(60, TimeUnit.SECONDS);
157 | //
158 | // } catch (InterruptedException e) {
159 | // Log.e(TAG, e.getMessage());
160 | // }
161 |
162 | Log.e(TAG, "DONE WITH HOOKING");
163 | }
164 | }
165 |
--------------------------------------------------------------------------------
/src/at/fhooe/mcm14/damn/activities/AppListActivity.java:
--------------------------------------------------------------------------------
1 | package at.fhooe.mcm14.damn.activities;
2 |
3 | import java.io.File;
4 | import java.util.ArrayList;
5 | import java.util.List;
6 |
7 | import android.app.ListActivity;
8 | import android.app.PendingIntent;
9 | import android.app.PendingIntent.CanceledException;
10 | import android.content.Context;
11 | import android.content.Intent;
12 | import android.os.Bundle;
13 | import android.support.v4.app.Fragment;
14 | import android.support.v4.app.FragmentActivity;
15 | import android.support.v4.app.FragmentManager;
16 | import android.support.v4.app.FragmentStatePagerAdapter;
17 | import android.support.v4.view.ViewPager;
18 | import android.util.Log;
19 | import android.view.Menu;
20 | import android.view.MenuItem;
21 | import at.fhooe.mcm14.damn.R;
22 | import at.fhooe.mcm14.damn.fragments.AppListFragment;
23 | import at.fhooe.mcm14.damn.jni.DAMNServer;
24 | import at.fhooe.mcm14.damn.misc.Extract;
25 | import at.fhooe.mcm14.damn.services.BootCompleteNotifier;
26 | import at.fhooe.mcm14.damn.services.XModuleService;
27 |
28 | /**
29 | * List all activities which are installed on the phone.
30 | */
31 | public class AppListActivity extends FragmentActivity {
32 | private static final String TAG = ListActivity.class.getName();
33 |
34 |
35 | private ViewPageAdapter pageAdapter;
36 | private ViewPager pager;
37 |
38 | public Context getContext() {
39 | return getApplicationContext();
40 | }
41 |
42 | @Override
43 | protected void onCreate(Bundle _bundle) {
44 | super.onCreate(_bundle);
45 |
46 | //create necessary files
47 | File dir = new File("/data/data/at.fhooe.mcm.faaaat/files/root");
48 | if(!dir.exists()){
49 | dir.mkdirs();
50 | dir.setReadable(true, false);
51 | dir.setWritable(true, false);
52 | dir.setExecutable(true, false);
53 | }
54 |
55 | Extract.copyAssetFolder(getApplicationContext(), "root", "/data/data/at.fhooe.mcm.faaaat/files/root");
56 |
57 | Log.d(TAG, DAMNServer.getState().name());
58 | this.sendBroadcast(new Intent("DAMN").putExtra("key", "value"));
59 |
60 | Log.i(TAG, "onCreate AppListActivity");
61 | setContentView(R.layout.fragment_app_list);
62 |
63 | //check if we have to start the service -> same as after boot complete
64 | try {
65 | PendingIntent.getBroadcast(getApplicationContext(), 0, new Intent(getApplicationContext(), BootCompleteNotifier.class), 0).send();
66 | } catch (CanceledException e) {
67 | e.printStackTrace();
68 | }
69 |
70 | pageAdapter = new ViewPageAdapter(getSupportFragmentManager());
71 | pager = (ViewPager) findViewById(R.id.pager);
72 | pager.setAdapter(pageAdapter);
73 |
74 | //check if it comes from ControlService
75 | Bundle e = getIntent().getExtras();
76 | if(e!=null && e.getBoolean(XModuleService.FROM_SERVICE))
77 | pager.setCurrentItem(pageAdapter.getCount());
78 | }
79 |
80 | @Override
81 | public boolean onCreateOptionsMenu(Menu menu) {
82 | getMenuInflater().inflate(R.menu.app_list, menu);
83 | return true;
84 | }
85 |
86 | @Override
87 | public boolean onOptionsItemSelected(MenuItem item) {
88 | int id = item.getItemId();
89 | if (id == R.id.action_settings)
90 | return true;
91 |
92 | return super.onOptionsItemSelected(item);
93 | }
94 |
95 |
96 | private class ViewPageAdapter extends FragmentStatePagerAdapter {
97 |
98 | private static final int PAGES = 5;
99 | private List fragments = null;
100 |
101 | public ViewPageAdapter(FragmentManager fm) {
102 | super(fm);
103 | fragments = new ArrayList();
104 | }
105 |
106 | @Override
107 | public CharSequence getPageTitle(int position) {
108 | switch(position) {
109 | case 0:
110 | return getString(R.string.fragment_title_download);
111 | case 1:
112 | return getString(R.string.fragment_title_system);
113 | case 2:
114 | return getString(R.string.fragment_title_running);
115 | case 3:
116 | return getString(R.string.fragment_title_all);
117 | case 4:
118 | return getString(R.string.fragment_title_active);
119 |
120 | default:
121 | return null;
122 | }
123 | }
124 |
125 | @Override
126 | public Fragment getItem(int pos) {
127 | AppListFragment frag = null;
128 |
129 | try{
130 | frag = fragments.get(pos);
131 |
132 | }catch(IndexOutOfBoundsException e){
133 |
134 | frag = new AppListFragment();
135 | Bundle bundle = new Bundle();
136 |
137 | switch (pos) {
138 | case 0:
139 | bundle.putSerializable(AppListFragment.LIST_TYPE, AppListFragment.AppListType.DOWNLOADED); break;
140 | case 1:
141 | bundle.putSerializable(AppListFragment.LIST_TYPE, AppListFragment.AppListType.SYSTEM); break;
142 | case 2:
143 | bundle.putSerializable(AppListFragment.LIST_TYPE, AppListFragment.AppListType.RUNNING); break;
144 | case 3:
145 | bundle.putSerializable(AppListFragment.LIST_TYPE, AppListFragment.AppListType.ALL); break;
146 | case 4:
147 | bundle.putSerializable(AppListFragment.LIST_TYPE, AppListFragment.AppListType.ACTIVE); break;
148 | }
149 |
150 | //set arguments
151 | frag.setArguments(bundle);
152 | fragments.add(frag);
153 | Log.i(TAG, "add "+ bundle.get(AppListFragment.LIST_TYPE).toString());
154 | }
155 |
156 | return frag;
157 | }
158 |
159 | @Override
160 | public int getCount() {
161 | return PAGES;
162 | }
163 | }
164 | }
165 |
--------------------------------------------------------------------------------
/src/at/fhooe/mcm14/damn/misc/Extract.java:
--------------------------------------------------------------------------------
1 | package at.fhooe.mcm14.damn.misc;
2 |
3 | import java.io.BufferedInputStream;
4 | import java.io.File;
5 | import java.io.FileInputStream;
6 | import java.io.FileNotFoundException;
7 | import java.io.FileOutputStream;
8 | import java.io.IOException;
9 | import java.io.InputStream;
10 | import java.io.OutputStream;
11 | import java.util.zip.ZipEntry;
12 | import java.util.zip.ZipInputStream;
13 |
14 | import android.content.Context;
15 | import android.content.res.AssetManager;
16 | import android.util.Log;
17 |
18 | public class Extract {
19 |
20 | public static void unpackZipAsset(Context context, String resource, String path) {
21 | ZipInputStream zis = null;
22 |
23 | try {
24 | zis = new ZipInputStream(new BufferedInputStream(context.getAssets().open(resource)));
25 | ZipEntry ze;
26 | int count;
27 | byte[] buffer = new byte[8192];
28 |
29 | while ((ze = zis.getNextEntry()) != null) {
30 | File file = new File(path, ze.getName());
31 | File dir = ze.isDirectory() ? file : file.getParentFile();
32 | Log.d("damn", "file: " + ze.getName());
33 |
34 | if (!dir.isDirectory() && !dir.mkdirs())
35 | throw new FileNotFoundException("Failed to ensure directory: " + dir.getAbsolutePath());
36 |
37 | if (ze.isDirectory())
38 | continue;
39 |
40 | FileOutputStream fout = new FileOutputStream(file);
41 |
42 | while ((count = zis.read(buffer)) != -1)
43 | fout.write(buffer, 0, count);
44 |
45 | fout.close();
46 | Log.d("damn", "write done");
47 | }
48 |
49 | } catch(Exception e) {
50 | Log.e("damn", e.getMessage());
51 |
52 | } finally {
53 | try {zis.close();} catch (Exception e) { }
54 | }
55 |
56 | Log.d("damn", "done");
57 | }
58 |
59 |
60 | public static boolean unpackZip(Context context, String resource, String path) {
61 | ZipInputStream zis;
62 |
63 | try
64 | {
65 | String filename;
66 | zis = new ZipInputStream(new BufferedInputStream(new FileInputStream(resource)));
67 | ZipEntry ze;
68 | byte[] buffer = new byte[1024];
69 | int count;
70 |
71 | while ((ze = zis.getNextEntry()) != null)
72 | {
73 | // zapis do souboru
74 | filename = ze.getName();
75 |
76 | // Need to create directories if not exists, or
77 | // it will generate an Exception...
78 | if (ze.isDirectory()) {
79 | File fmd = new File(path + filename);
80 | fmd.mkdirs();
81 | continue;
82 | }
83 |
84 | FileOutputStream fout = new FileOutputStream(path + filename);
85 |
86 | // cteni zipu a zapis
87 | while ((count = zis.read(buffer)) != -1)
88 | {
89 | fout.write(buffer, 0, count);
90 | }
91 |
92 | fout.close();
93 | zis.closeEntry();
94 | }
95 |
96 | zis.close();
97 | }
98 | catch(IOException e)
99 | {
100 | e.printStackTrace();
101 | return false;
102 | }
103 |
104 | return true;
105 | }
106 |
107 |
108 | public static void copyAssetFolder(Context context, String assetFolder, String outputPath) {
109 | // "Name" is the name of your folder!
110 | AssetManager assetManager = context.getAssets();
111 |
112 | try {
113 | extractFiles(assetManager, assetFolder, assetManager.list(assetFolder), outputPath);
114 |
115 | } catch (IOException e) {
116 | Log.e("ERROR", "Failed to get asset file list.", e);
117 | }
118 |
119 | }
120 |
121 | private static void extractFiles(AssetManager assetManager, String assetFolder, String[] files, String outputPath) {
122 | // Analyzing all file on assets subfolder
123 | Log.d("damn", "files: " + files.length);
124 | for(String filename : files) {
125 | Log.d("damn", "create file: " + outputPath + "/" + filename);
126 | InputStream in = null;
127 | OutputStream out = null;
128 |
129 | File f = new File(outputPath, filename);
130 | try {
131 | Log.d("damn", "asset file: " + assetFolder + "/" + filename);
132 | if(assetManager.list(assetFolder + "/" + filename).length!=0) {
133 | if(!f.exists()){
134 | f.mkdirs();
135 | f.setReadable(true, false);
136 | f.setWritable(true, false);
137 | f.setExecutable(true, false);
138 | }
139 | Log.d("damn", "in: " + assetFolder + "/" + filename + "->" + f.getAbsolutePath());
140 | extractFiles(assetManager, assetFolder + "/" + filename, assetManager.list(assetFolder + "/" + filename), f.getAbsolutePath());
141 | }
142 |
143 | if(!f.exists()){
144 | f.createNewFile();
145 | f.setReadable(true, false);
146 | f.setWritable(true, false);
147 |
148 | }else
149 | continue;
150 |
151 | Log.d("damn", "copy: " + assetFolder + "/" + filename + "->" + f.getAbsolutePath());
152 |
153 | in = assetManager.open(assetFolder + "/" + filename);
154 | out = new FileOutputStream(f.getAbsolutePath());
155 |
156 | copyFile(in, out);
157 | in.close();
158 | in = null;
159 | out.flush();
160 | out.close();
161 | out = null;
162 |
163 | } catch(IOException e) {
164 | Log.e("ERROR", "Failed to copy asset file: " + filename, e);
165 | }
166 | }
167 | }
168 |
169 | //Method used by copyAssets() on purpose to copy a file.
170 | private static void copyFile(InputStream in, OutputStream out) throws IOException {
171 | byte[] buffer = new byte[1024];
172 | int read;
173 | while((read = in.read(buffer)) != -1) {
174 | out.write(buffer, 0, read);
175 | }
176 | }
177 | }
178 |
--------------------------------------------------------------------------------
/src/at/fhooe/mcm14/damn/fragments/AppListFragment.java:
--------------------------------------------------------------------------------
1 | package at.fhooe.mcm14.damn.fragments;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 | import java.util.Set;
6 |
7 | import android.annotation.SuppressLint;
8 | import android.app.ActivityManager;
9 | import android.app.ActivityManager.RunningAppProcessInfo;
10 | import android.content.Context;
11 | import android.content.Intent;
12 | import android.content.SharedPreferences;
13 | import android.content.pm.ApplicationInfo;
14 | import android.content.pm.PackageManager;
15 | import android.os.Bundle;
16 | import android.preference.PreferenceManager;
17 | import android.support.v4.app.ListFragment;
18 | import android.util.Log;
19 | import android.view.LayoutInflater;
20 | import android.view.View;
21 | import android.view.ViewGroup;
22 | import android.widget.ArrayAdapter;
23 | import android.widget.ImageView;
24 | import android.widget.ListView;
25 | import android.widget.TextView;
26 | import at.fhooe.mcm14.damn.R;
27 | import at.fhooe.mcm14.damn.activities.AppDetailActivity;
28 |
29 | public class AppListFragment extends ListFragment {
30 |
31 | public static enum AppListType {DOWNLOADED, SYSTEM, RUNNING, ALL, ACTIVE}
32 | public static final String LIST_TYPE = "listtype";
33 | public static final String ACTIVE_APPS = "active apps";
34 |
35 | private static final String TAG = AppListFragment.class.getName();
36 | private AppListType listType = null;
37 | private PackageArrayAdapter listAdapter = null;
38 | private List packages = null;
39 |
40 |
41 | @SuppressWarnings("incomplete-switch")
42 | @Override
43 | public void onCreate(Bundle savedInstanceState) {
44 | super.onCreate(savedInstanceState);
45 |
46 | //get list type
47 | listType = (AppListType) getArguments().get(LIST_TYPE);
48 |
49 | //get list of all installed applications
50 | packages = getAllApps();
51 |
52 | List list = new ArrayList();
53 |
54 | switch(listType){
55 | case DOWNLOADED:
56 | //filter all applications which are not system apps
57 | for(int n=0;n running = am.getRunningAppProcesses();
75 |
76 | for(int n=0;n getAllApps() {
101 | final PackageManager pm = getActivity().getApplicationContext().getPackageManager();
102 | return pm.getInstalledApplications(PackageManager.GET_META_DATA);
103 | }
104 |
105 | private List getActiveApps() {
106 | List list = new ArrayList();
107 | List all = getAllApps();
108 |
109 | //filter all applications which are actively tracked
110 | SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity().getApplicationContext());
111 | Set actives = prefs.getStringSet(ACTIVE_APPS, null);
112 |
113 | if(actives!=null){
114 | for(String activity : actives){
115 | for(int m=0;m {
151 | private Context context = null;
152 |
153 | /**
154 | * Constructor which also set the context for later use.
155 | *
156 | * @param _context Context of application
157 | * @param _values Array of all installed applications
158 | */
159 | public PackageArrayAdapter(Context _context, List _values) {
160 | super(_context, R.layout.listitem_package, _values);
161 |
162 | context = _context;
163 | }
164 |
165 | @SuppressLint("ViewHolder")
166 | @Override
167 | public View getView(int _position, View _convertView, ViewGroup _parent) {
168 | LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
169 | View rowView = inflater.inflate(R.layout.listitem_package, _parent, false);
170 |
171 | //get views
172 | ImageView icon = (ImageView) rowView.findViewById(R.id.iv_package_icon);
173 | TextView name = (TextView) rowView.findViewById(R.id.tv_package_name);
174 | TextView location = (TextView) rowView.findViewById(R.id.tv_package_location);
175 |
176 | PackageManager pm = getActivity().getPackageManager();
177 | ApplicationInfo app = this.getItem(_position);
178 |
179 | //set values from application
180 | icon.setImageDrawable(pm.getApplicationIcon(app));
181 | name.setText(app.loadLabel(pm));
182 | location.setText(app.sourceDir);
183 |
184 | return rowView;
185 | }
186 | }
187 | }
188 |
--------------------------------------------------------------------------------
/obj/local/armeabi/objs/usb-tethering/usb-tethering/usb_tethering.o.d:
--------------------------------------------------------------------------------
1 | obj/local/armeabi/objs/usb-tethering/usb-tethering/usb_tethering.o: \
2 | jni/usb-tethering/usb_tethering.c jni/usb-tethering/usb_tethering.h \
3 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/stdlib.h \
4 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/cdefs.h \
5 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/cdefs_elf.h \
6 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/android/api-level.h \
7 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/string.h \
8 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/malloc.h \
9 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/alloca.h \
10 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/strings.h \
11 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/types.h \
12 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/stdint.h \
13 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/_types.h \
14 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/machine/_types.h \
15 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/_wchar_limits.h \
16 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/linux/posix_types.h \
17 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/linux/stddef.h \
18 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/linux/compiler.h \
19 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm/posix_types.h \
20 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm/types.h \
21 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/linux/types.h \
22 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/machine/kernel.h \
23 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/sysmacros.h \
24 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/memory.h \
25 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/unistd.h \
26 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/select.h \
27 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/time.h \
28 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/linux/time.h \
29 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/signal.h \
30 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/limits.h \
31 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/limits.h \
32 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/linux/limits.h \
33 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/machine/internal_types.h \
34 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/machine/limits.h \
35 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/syslimits.h \
36 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm/page.h \
37 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm/signal.h \
38 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm-generic/signal.h \
39 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm/sigcontext.h \
40 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm/siginfo.h \
41 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm-generic/siginfo.h \
42 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/ucontext.h \
43 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/user.h \
44 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/sysconf.h \
45 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/linux/capability.h \
46 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/pathconf.h \
47 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/stdio.h \
48 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/assert.h \
49 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/pthread.h \
50 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/time.h \
51 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sched.h \
52 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/jni.h \
53 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/android/log.h
54 |
55 | jni/usb-tethering/usb_tethering.h:
56 |
57 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/stdlib.h:
58 |
59 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/cdefs.h:
60 |
61 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/cdefs_elf.h:
62 |
63 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/android/api-level.h:
64 |
65 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/string.h:
66 |
67 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/malloc.h:
68 |
69 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/alloca.h:
70 |
71 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/strings.h:
72 |
73 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/types.h:
74 |
75 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/stdint.h:
76 |
77 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/_types.h:
78 |
79 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/machine/_types.h:
80 |
81 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/_wchar_limits.h:
82 |
83 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/linux/posix_types.h:
84 |
85 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/linux/stddef.h:
86 |
87 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/linux/compiler.h:
88 |
89 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm/posix_types.h:
90 |
91 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm/types.h:
92 |
93 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/linux/types.h:
94 |
95 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/machine/kernel.h:
96 |
97 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/sysmacros.h:
98 |
99 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/memory.h:
100 |
101 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/unistd.h:
102 |
103 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/select.h:
104 |
105 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/time.h:
106 |
107 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/linux/time.h:
108 |
109 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/signal.h:
110 |
111 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/limits.h:
112 |
113 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/limits.h:
114 |
115 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/linux/limits.h:
116 |
117 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/machine/internal_types.h:
118 |
119 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/machine/limits.h:
120 |
121 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/syslimits.h:
122 |
123 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm/page.h:
124 |
125 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm/signal.h:
126 |
127 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm-generic/signal.h:
128 |
129 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm/sigcontext.h:
130 |
131 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm/siginfo.h:
132 |
133 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm-generic/siginfo.h:
134 |
135 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/ucontext.h:
136 |
137 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/user.h:
138 |
139 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/sysconf.h:
140 |
141 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/linux/capability.h:
142 |
143 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/pathconf.h:
144 |
145 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/stdio.h:
146 |
147 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/assert.h:
148 |
149 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/pthread.h:
150 |
151 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/time.h:
152 |
153 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sched.h:
154 |
155 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/jni.h:
156 |
157 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/android/log.h:
158 |
--------------------------------------------------------------------------------
/obj/local/armeabi/objs/daemonize/misc/daemonize.o.d:
--------------------------------------------------------------------------------
1 | obj/local/armeabi/objs/daemonize/misc/daemonize.o: jni/misc/daemonize.c \
2 | jni/misc/daemonize.h \
3 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/stdio.h \
4 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/cdefs.h \
5 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/cdefs_elf.h \
6 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/android/api-level.h \
7 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/types.h \
8 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/stdint.h \
9 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/_types.h \
10 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/machine/_types.h \
11 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/_wchar_limits.h \
12 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/linux/posix_types.h \
13 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/linux/stddef.h \
14 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/linux/compiler.h \
15 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm/posix_types.h \
16 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm/types.h \
17 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/linux/types.h \
18 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/machine/kernel.h \
19 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/sysmacros.h \
20 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/stdlib.h \
21 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/string.h \
22 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/malloc.h \
23 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/alloca.h \
24 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/strings.h \
25 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/memory.h \
26 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/unistd.h \
27 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/select.h \
28 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/time.h \
29 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/linux/time.h \
30 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/signal.h \
31 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/limits.h \
32 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/limits.h \
33 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/linux/limits.h \
34 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/machine/internal_types.h \
35 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/machine/limits.h \
36 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/syslimits.h \
37 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm/page.h \
38 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm/signal.h \
39 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm-generic/signal.h \
40 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm/sigcontext.h \
41 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm/siginfo.h \
42 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm-generic/siginfo.h \
43 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/ucontext.h \
44 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/user.h \
45 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/sysconf.h \
46 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/linux/capability.h \
47 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/pathconf.h \
48 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/stat.h \
49 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/linux/stat.h \
50 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/endian.h \
51 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/endian.h \
52 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/machine/endian.h \
53 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/syslog.h \
54 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/android/log.h
55 |
56 | jni/misc/daemonize.h:
57 |
58 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/stdio.h:
59 |
60 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/cdefs.h:
61 |
62 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/cdefs_elf.h:
63 |
64 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/android/api-level.h:
65 |
66 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/types.h:
67 |
68 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/stdint.h:
69 |
70 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/_types.h:
71 |
72 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/machine/_types.h:
73 |
74 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/_wchar_limits.h:
75 |
76 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/linux/posix_types.h:
77 |
78 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/linux/stddef.h:
79 |
80 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/linux/compiler.h:
81 |
82 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm/posix_types.h:
83 |
84 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm/types.h:
85 |
86 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/linux/types.h:
87 |
88 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/machine/kernel.h:
89 |
90 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/sysmacros.h:
91 |
92 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/stdlib.h:
93 |
94 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/string.h:
95 |
96 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/malloc.h:
97 |
98 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/alloca.h:
99 |
100 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/strings.h:
101 |
102 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/memory.h:
103 |
104 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/unistd.h:
105 |
106 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/select.h:
107 |
108 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/time.h:
109 |
110 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/linux/time.h:
111 |
112 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/signal.h:
113 |
114 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/limits.h:
115 |
116 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/limits.h:
117 |
118 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/linux/limits.h:
119 |
120 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/machine/internal_types.h:
121 |
122 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/machine/limits.h:
123 |
124 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/syslimits.h:
125 |
126 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm/page.h:
127 |
128 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm/signal.h:
129 |
130 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm-generic/signal.h:
131 |
132 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm/sigcontext.h:
133 |
134 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm/siginfo.h:
135 |
136 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm-generic/siginfo.h:
137 |
138 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/ucontext.h:
139 |
140 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/user.h:
141 |
142 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/sysconf.h:
143 |
144 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/linux/capability.h:
145 |
146 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/pathconf.h:
147 |
148 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/stat.h:
149 |
150 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/linux/stat.h:
151 |
152 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/endian.h:
153 |
154 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/endian.h:
155 |
156 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/machine/endian.h:
157 |
158 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/syslog.h:
159 |
160 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/android/log.h:
161 |
--------------------------------------------------------------------------------
/jni/usb-tethering/usb_tethering.c:
--------------------------------------------------------------------------------
1 | #include "usb_tethering.h"
2 |
3 | #define TAG "usb_tethering"
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 | #define TIMEOUT 60 //seconds
10 |
11 | typedef enum
12 | {
13 | OFF=0,
14 | INIT=1,
15 | READY=2,
16 | CONNECT=3,
17 | UNKNOWN=4
18 | } state_t;
19 |
20 | state_t state = UNKNOWN;
21 |
22 | /**
23 | * Used to store all three pthreads to kill them later if needed.
24 | */
25 | pthread_t tid[3];
26 | /**
27 | * Hold the ip of the desktop pc if connected.
28 | */
29 | char* client_ip = NULL;
30 |
31 | pthread_cond_t state_cond = PTHREAD_COND_INITIALIZER;
32 | pthread_mutex_t state_mutex = PTHREAD_MUTEX_INITIALIZER;
33 |
34 |
35 | /**
36 | * Execute a system command and return it's exit value.
37 | */
38 | int execute(char* command)
39 | {
40 | return system(command);
41 | }
42 |
43 | /**
44 | * Splits a string with the given delimiter and return array of char*.
45 | */
46 | char** str_split(char* a_str, const char a_delim)
47 | {
48 | char** result = 0;
49 | size_t count = 0;
50 | char* tmp = a_str;
51 | char* last_comma = 0;
52 | char delim[2];
53 | delim[0] = a_delim;
54 | delim[1] = 0;
55 |
56 | // count how many elements will be extracted.
57 | while (*tmp)
58 | {
59 | if (a_delim == *tmp)
60 | {
61 | count++;
62 | last_comma = tmp;
63 | }
64 | tmp++;
65 | }
66 |
67 | // add space for trailing token.
68 | count += last_comma < (a_str + strlen(a_str) - 1);
69 | count++;
70 |
71 | result = malloc(sizeof(char*) * count);
72 |
73 | if (result)
74 | {
75 | size_t idx = 0;
76 | char* token = strtok(a_str, delim);
77 |
78 | while (token)
79 | {
80 | assert(idx < count);
81 | *(result + idx++) = strdup(token);
82 | token = strtok(0, delim);
83 | }
84 | assert(idx == count - 1);
85 | *(result + idx) = 0;
86 | }
87 |
88 | return result;
89 | }
90 |
91 | void change_state(state_t _state) {
92 |
93 | pthread_mutex_lock(&state_mutex);
94 | state = _state;
95 | pthread_cond_signal(&state_cond);
96 | pthread_mutex_unlock(&state_mutex);
97 | }
98 |
99 | /**
100 | * Kill an open pipe which was opened with popen.
101 | */
102 | void* kill_pipe(void *fp)
103 | {
104 | if(fp!=NULL) {
105 | LOGI("return value of pipe: %i", pclose(fp));
106 | }else{
107 | LOGI("pipe is null");
108 | }
109 |
110 | //pthread_mutex_unlock(&logcat_lock);
111 | //pthread_exit(NULL);
112 | }
113 |
114 | /**
115 | * Wait till the timeout (which is defined in header) is reached and if no connection is established, call stop_tethering().
116 | */
117 | void timeout()
118 | {
119 | int n = 0;
120 |
121 | LOGD("timeout");
122 | //timeout till client_ip was found or timeout reached
123 | while(client_ip==NULL && n++ <= TIMEOUT) {
124 | sleep(1);
125 | }
126 |
127 | LOGD("timeout done, client_ip=%s, count=%d", client_ip, n);
128 | }
129 |
130 | /**
131 | * Clear and set the ip address of a client which dnsmasq has written to the logcat.
132 | */
133 | void* logcat()
134 | {
135 | FILE *fp;
136 | char line[1024];
137 |
138 | //pthread_mutex_lock(&logcat_lock);
139 | //reset logcat
140 | LOGD("clear logcat");
141 | if(execute("su -c 'logcat -c'")) {
142 | LOGE("clear logcat failed");
143 | }else{
144 | LOGD("check output of dnsmasq");
145 | fp = popen("su -c 'logcat -s dnsmasq'", "r");
146 | if (fp == NULL){
147 | LOGE("logcat failed");
148 |
149 | }else{
150 | /* Read the output a line at a time - output it. */
151 | while (fgets(line, sizeof(line)-1, fp) != NULL) {
152 | LOGI("line: %s", line);
153 | if (strstr(line, "DHCPACK(rndis0)") != NULL) {
154 | // contains
155 | LOGD("contains DHCPACK(rndis0)");
156 | //I/dnsmasq ( 1838): DHCPOFFER(rndis0) 192.168.42.13 16:6e:a4:54:ae:31
157 | //TODO not necessary and not really stable in my opinion
158 | char** tokens;
159 | tokens = str_split(line, ' ');
160 | int n = sizeof(tokens)/sizeof(tokens[0]);
161 | client_ip = tokens[4];
162 |
163 | break;
164 | }
165 |
166 | LOGI("wait for next line");
167 | }
168 |
169 | //close pipe in pthread, cause it could take a lot of time...
170 | if(fp!=NULL) {
171 | LOGD("close pipe in new thread");
172 | if (pthread_create(&(tid[1]), NULL, &kill_pipe, (void *)&fp))
173 | {
174 | LOGE("pthread_create failed");
175 | }
176 | }
177 | }
178 | }
179 |
180 | LOGD("exit logcat");
181 | //pthread_exit(NULL);
182 | }
183 |
184 | /**
185 | * Use 'netcfg' to check if usb-tethering is active.
186 | */
187 | bool netcfg()
188 | {
189 | FILE *fp;
190 | char line[1024];
191 | bool active = false;
192 |
193 | //pthread_mutex_lock(&logcat_lock);
194 | LOGD("check output of netcfg");
195 | //use 'grep' to be faster ;)
196 | fp = popen("su -c 'netcfg | grep rndis0'", "r");
197 | if (fp == NULL){
198 | LOGE("netcfg failed");
199 | }else{
200 |
201 | /* Read the output a line at a time - output it. */
202 | while (fgets(line, sizeof(line)-1, fp) != NULL) {
203 | LOGI("line: %s", line);
204 | if (strstr(line, "rndis0") != NULL && strstr(line, "UP") != NULL) {
205 | // active!
206 | LOGD("rndis0 is UP");
207 | change_state(READY);
208 |
209 | active = true;
210 | //TODO - check if connected!
211 | break;
212 | }
213 | }
214 | }
215 |
216 | //close pipe in pthread, cause it could take a lot of time...
217 | LOGD("close pipe in new thread");
218 | pthread_t id;
219 | if (pthread_create(&id, NULL, &kill_pipe, (void *)&fp))
220 | {
221 | LOGE("pthread_create failed");
222 | }
223 |
224 | return active;
225 | }
226 |
227 | /**
228 | * Run the dnsmasq command which acts like a DNS server and give the client a ip address out of the pool.
229 | */
230 | void* dnsmasq()
231 | {
232 | LOGD("dnsmasq");
233 | //--address=/#//192.168.42.1 - will redirect every http to server
234 | if(execute("su -c 'dnsmasq --no-daemon --no-poll --no-resolv --interface=rndis0 --address=/one.damn/192.168.42.1 --address=/www.one.damn/192.168.42.1 --dhcp-range=192.168.42.10,192.168.42.100,2h'")) {
235 | LOGE("dnsmasq failed");
236 | }
237 |
238 | LOGI("dnsmasq ended");
239 | //pthread_exit(NULL);
240 | }
241 |
242 |
243 | char* start_tethering()
244 | {
245 | //check if usb-tethering is active TODO ???
246 | if(is_tethering_active()) {
247 | LOGD("usb-tethering is active");
248 |
249 | return "unknown host";
250 | }
251 |
252 | LOGD("start_tethering");
253 | change_state(INIT);
254 |
255 | //'setprop' - does not have to be checked explicit because we check with ifconfig
256 | int ret = 0;
257 | ret = execute("su -c 'touch /data/local/tmp/test1'");
258 | if(ret)
259 | {
260 | LOGE("touch failed, val=%d", ret);
261 | stop_tethering();
262 | return NULL;
263 | }
264 |
265 | execute("su -c 'setprop sys.usb.config rndis,adb'");
266 | ret=execute("su -c 'ifconfig rndis0 192.168.42.1 netmask 255.255.255.0 up'");
267 | if(ret)
268 | {
269 | LOGE("ifconfig failed, val=%d",ret);
270 | stop_tethering();
271 | return NULL;
272 | }
273 |
274 | if(execute("su -c 'route add default gw 192.168.42.2 dev rndis0'"))
275 | {
276 | LOGE("route failed");
277 | stop_tethering();
278 | return NULL;
279 | }
280 |
281 | change_state(READY);
282 |
283 | LOGI("start logcat");
284 | //first thread for checking logcat
285 | if (pthread_create(&(tid[0]), NULL, &logcat, NULL))
286 | {
287 | LOGE("pthread_create failed");
288 | stop_tethering();
289 | return NULL;
290 | }
291 |
292 | LOGI("start dnsmasq");
293 | //second thread for dnsmasq
294 | if (pthread_create(&(tid[1]), NULL, &dnsmasq, NULL))
295 | {
296 | LOGE("pthread_create failed");
297 | stop_tethering();
298 | return NULL;
299 | }
300 |
301 | //wait for timeout or client is connected TODO should we have a timeout for this? may longer...
302 | timeout();
303 |
304 | //something went wrong
305 | if(client_ip==NULL)
306 | stop_tethering();
307 |
308 | change_state(CONNECT);
309 | return client_ip;
310 | }
311 |
312 | int stop_tethering()
313 | {
314 | LOGD("stop_tethering");
315 | execute("su -c 'ifconfig rndis0 192.168.42.1 netmask 255.255.255.0 down'");
316 | client_ip = NULL;
317 | change_state(OFF);
318 |
319 | return execute("su -c 'setprop sys.usb.config adb'");
320 | }
321 |
322 | bool is_tethering_active()
323 | {
324 | return netcfg();
325 | }
326 |
327 | jstring Java_at_fhooe_mcm14_damn_jni_USBTethering_startUSBTetheringJNI(JNIEnv* env)
328 | {
329 | return (*env)->NewStringUTF(env, start_tethering());
330 | }
331 |
332 | bool Java_at_fhooe_mcm14_damn_jni_USBTethering_stopUSBTetheringJNI()
333 | {
334 | return stop_tethering()==0;
335 | }
336 |
337 | bool Java_at_fhooe_mcm14_damn_jni_USBTethering_checkUSBTetheringJNI()
338 | {
339 | return is_tethering_active();
340 | }
341 |
342 | int Java_at_fhooe_mcm14_damn_jni_USBTethering_getStateBlockingJNI()
343 | {
344 | //block until something changed
345 | pthread_mutex_lock(&state_mutex);
346 | pthread_cond_wait(&state_cond, &state_mutex);
347 | pthread_mutex_unlock(&state_mutex);
348 |
349 | return state;
350 | }
351 |
352 | int Java_at_fhooe_mcm14_damn_jni_USBTethering_getStateJNI()
353 | {
354 | return state;
355 | }
356 |
357 | //not needed if we do not initialize anything
358 | jint JNI_OnLoad(JavaVM* vm, void* reserved)
359 | {
360 | JNIEnv* env;
361 | if ((*vm)->GetEnv(vm, (void**) &env, JNI_VERSION_1_6) != JNI_OK)
362 | return -1;
363 |
364 | LOGI("jni version: %d", JNI_VERSION_1_6);
365 |
366 | return JNI_VERSION_1_6;
367 | }
368 |
--------------------------------------------------------------------------------
/obj/local/armeabi/objs/install-sys-lib/misc/install_sys_lib.o.d:
--------------------------------------------------------------------------------
1 | obj/local/armeabi/objs/install-sys-lib/misc/install_sys_lib.o: \
2 | jni/misc/install_sys_lib.c jni/misc/install_sys_lib.h \
3 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/stdlib.h \
4 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/cdefs.h \
5 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/cdefs_elf.h \
6 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/android/api-level.h \
7 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/string.h \
8 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/malloc.h \
9 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/alloca.h \
10 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/strings.h \
11 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/types.h \
12 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/stdint.h \
13 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/_types.h \
14 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/machine/_types.h \
15 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/_wchar_limits.h \
16 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/linux/posix_types.h \
17 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/linux/stddef.h \
18 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/linux/compiler.h \
19 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm/posix_types.h \
20 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm/types.h \
21 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/linux/types.h \
22 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/machine/kernel.h \
23 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/sysmacros.h \
24 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/memory.h \
25 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/mount.h \
26 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/ioctl.h \
27 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/linux/ioctl.h \
28 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm/ioctl.h \
29 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm-generic/ioctl.h \
30 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm/ioctls.h \
31 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm/termbits.h \
32 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/ioctl_compat.h \
33 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/unistd.h \
34 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/select.h \
35 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/time.h \
36 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/linux/time.h \
37 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/signal.h \
38 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/limits.h \
39 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/limits.h \
40 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/linux/limits.h \
41 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/machine/internal_types.h \
42 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/machine/limits.h \
43 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/syslimits.h \
44 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm/page.h \
45 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm/signal.h \
46 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm-generic/signal.h \
47 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm/sigcontext.h \
48 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm/siginfo.h \
49 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm-generic/siginfo.h \
50 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/ucontext.h \
51 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/user.h \
52 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/sysconf.h \
53 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/linux/capability.h \
54 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/pathconf.h \
55 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/stdio.h \
56 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/jni.h \
57 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/android/log.h
58 |
59 | jni/misc/install_sys_lib.h:
60 |
61 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/stdlib.h:
62 |
63 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/cdefs.h:
64 |
65 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/cdefs_elf.h:
66 |
67 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/android/api-level.h:
68 |
69 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/string.h:
70 |
71 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/malloc.h:
72 |
73 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/alloca.h:
74 |
75 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/strings.h:
76 |
77 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/types.h:
78 |
79 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/stdint.h:
80 |
81 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/_types.h:
82 |
83 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/machine/_types.h:
84 |
85 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/_wchar_limits.h:
86 |
87 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/linux/posix_types.h:
88 |
89 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/linux/stddef.h:
90 |
91 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/linux/compiler.h:
92 |
93 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm/posix_types.h:
94 |
95 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm/types.h:
96 |
97 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/linux/types.h:
98 |
99 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/machine/kernel.h:
100 |
101 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/sysmacros.h:
102 |
103 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/memory.h:
104 |
105 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/mount.h:
106 |
107 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/ioctl.h:
108 |
109 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/linux/ioctl.h:
110 |
111 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm/ioctl.h:
112 |
113 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm-generic/ioctl.h:
114 |
115 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm/ioctls.h:
116 |
117 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm/termbits.h:
118 |
119 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/ioctl_compat.h:
120 |
121 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/unistd.h:
122 |
123 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/select.h:
124 |
125 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/time.h:
126 |
127 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/linux/time.h:
128 |
129 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/signal.h:
130 |
131 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/limits.h:
132 |
133 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/limits.h:
134 |
135 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/linux/limits.h:
136 |
137 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/machine/internal_types.h:
138 |
139 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/machine/limits.h:
140 |
141 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/syslimits.h:
142 |
143 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm/page.h:
144 |
145 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm/signal.h:
146 |
147 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm-generic/signal.h:
148 |
149 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm/sigcontext.h:
150 |
151 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm/siginfo.h:
152 |
153 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm-generic/siginfo.h:
154 |
155 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/ucontext.h:
156 |
157 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/user.h:
158 |
159 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/sysconf.h:
160 |
161 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/linux/capability.h:
162 |
163 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/pathconf.h:
164 |
165 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/stdio.h:
166 |
167 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/jni.h:
168 |
169 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/android/log.h:
170 |
--------------------------------------------------------------------------------
/assets/root/docroot/track.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | DAMN
6 |
7 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
82 |
119 |
138 |
279 |
280 |
281 |
282 |
294 |
295 |
296 |
299 |
302 |
305 |
308 |
309 |
310 |
311 |
312 |
--------------------------------------------------------------------------------
/obj/local/armeabi/objs/damn-server/damn-server/damn_server.o.d:
--------------------------------------------------------------------------------
1 | obj/local/armeabi/objs/damn-server/damn-server/damn_server.o: \
2 | jni/damn-server/damn_server.c jni/damn-server/damn_server.h \
3 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/stdio.h \
4 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/cdefs.h \
5 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/cdefs_elf.h \
6 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/android/api-level.h \
7 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/types.h \
8 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/stdint.h \
9 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/_types.h \
10 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/machine/_types.h \
11 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/_wchar_limits.h \
12 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/linux/posix_types.h \
13 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/linux/stddef.h \
14 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/linux/compiler.h \
15 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm/posix_types.h \
16 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm/types.h \
17 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/linux/types.h \
18 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/machine/kernel.h \
19 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/sysmacros.h \
20 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/stdlib.h \
21 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/string.h \
22 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/malloc.h \
23 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/alloca.h \
24 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/strings.h \
25 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/memory.h \
26 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/fcntl.h \
27 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/linux/fcntl.h \
28 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm/fcntl.h \
29 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm-generic/fcntl.h \
30 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/unistd.h \
31 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/select.h \
32 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/time.h \
33 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/linux/time.h \
34 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/signal.h \
35 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/limits.h \
36 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/limits.h \
37 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/linux/limits.h \
38 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/machine/internal_types.h \
39 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/machine/limits.h \
40 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/syslimits.h \
41 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm/page.h \
42 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm/signal.h \
43 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm-generic/signal.h \
44 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm/sigcontext.h \
45 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm/siginfo.h \
46 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm-generic/siginfo.h \
47 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/ucontext.h \
48 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/user.h \
49 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/sysconf.h \
50 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/linux/capability.h \
51 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/pathconf.h \
52 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/stat.h \
53 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/linux/stat.h \
54 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/endian.h \
55 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/endian.h \
56 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/machine/endian.h \
57 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/time.h \
58 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/pthread.h \
59 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sched.h \
60 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/jni.h \
61 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/android/log.h \
62 | jni/civetweb/civetweb.h
63 |
64 | jni/damn-server/damn_server.h:
65 |
66 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/stdio.h:
67 |
68 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/cdefs.h:
69 |
70 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/cdefs_elf.h:
71 |
72 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/android/api-level.h:
73 |
74 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/types.h:
75 |
76 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/stdint.h:
77 |
78 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/_types.h:
79 |
80 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/machine/_types.h:
81 |
82 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/_wchar_limits.h:
83 |
84 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/linux/posix_types.h:
85 |
86 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/linux/stddef.h:
87 |
88 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/linux/compiler.h:
89 |
90 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm/posix_types.h:
91 |
92 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm/types.h:
93 |
94 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/linux/types.h:
95 |
96 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/machine/kernel.h:
97 |
98 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/sysmacros.h:
99 |
100 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/stdlib.h:
101 |
102 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/string.h:
103 |
104 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/malloc.h:
105 |
106 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/alloca.h:
107 |
108 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/strings.h:
109 |
110 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/memory.h:
111 |
112 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/fcntl.h:
113 |
114 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/linux/fcntl.h:
115 |
116 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm/fcntl.h:
117 |
118 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm-generic/fcntl.h:
119 |
120 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/unistd.h:
121 |
122 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/select.h:
123 |
124 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/time.h:
125 |
126 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/linux/time.h:
127 |
128 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/signal.h:
129 |
130 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/limits.h:
131 |
132 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/limits.h:
133 |
134 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/linux/limits.h:
135 |
136 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/machine/internal_types.h:
137 |
138 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/machine/limits.h:
139 |
140 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/syslimits.h:
141 |
142 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm/page.h:
143 |
144 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm/signal.h:
145 |
146 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm-generic/signal.h:
147 |
148 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm/sigcontext.h:
149 |
150 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm/siginfo.h:
151 |
152 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm-generic/siginfo.h:
153 |
154 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/ucontext.h:
155 |
156 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/user.h:
157 |
158 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/sysconf.h:
159 |
160 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/linux/capability.h:
161 |
162 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/pathconf.h:
163 |
164 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/stat.h:
165 |
166 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/linux/stat.h:
167 |
168 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/endian.h:
169 |
170 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/endian.h:
171 |
172 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/machine/endian.h:
173 |
174 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/time.h:
175 |
176 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/pthread.h:
177 |
178 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sched.h:
179 |
180 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/jni.h:
181 |
182 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/android/log.h:
183 |
184 | jni/civetweb/civetweb.h:
185 |
--------------------------------------------------------------------------------
/obj/local/armeabi/objs/damn-server-exec/damn-server/damn_server_exec.o.d:
--------------------------------------------------------------------------------
1 | obj/local/armeabi/objs/damn-server-exec/damn-server/damn_server_exec.o: \
2 | jni/damn-server/damn_server_exec.c \
3 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/stdio.h \
4 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/cdefs.h \
5 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/cdefs_elf.h \
6 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/android/api-level.h \
7 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/types.h \
8 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/stdint.h \
9 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/_types.h \
10 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/machine/_types.h \
11 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/_wchar_limits.h \
12 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/linux/posix_types.h \
13 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/linux/stddef.h \
14 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/linux/compiler.h \
15 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm/posix_types.h \
16 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm/types.h \
17 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/linux/types.h \
18 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/machine/kernel.h \
19 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/sysmacros.h \
20 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/unistd.h \
21 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/select.h \
22 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/time.h \
23 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/linux/time.h \
24 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/signal.h \
25 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/limits.h \
26 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/limits.h \
27 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/linux/limits.h \
28 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/machine/internal_types.h \
29 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/machine/limits.h \
30 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/syslimits.h \
31 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm/page.h \
32 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/string.h \
33 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/malloc.h \
34 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm/signal.h \
35 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm-generic/signal.h \
36 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm/sigcontext.h \
37 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm/siginfo.h \
38 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm-generic/siginfo.h \
39 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/ucontext.h \
40 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/user.h \
41 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/sysconf.h \
42 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/linux/capability.h \
43 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/pathconf.h \
44 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/pthread.h \
45 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/time.h \
46 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sched.h \
47 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/android/log.h \
48 | jni/damn-server/damn_server.h \
49 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/stdlib.h \
50 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/alloca.h \
51 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/strings.h \
52 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/memory.h \
53 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/fcntl.h \
54 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/linux/fcntl.h \
55 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm/fcntl.h \
56 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm-generic/fcntl.h \
57 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/stat.h \
58 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/linux/stat.h \
59 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/endian.h \
60 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/endian.h \
61 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/machine/endian.h \
62 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/jni.h \
63 | jni/civetweb/civetweb.h jni/misc/daemonize.h \
64 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/syslog.h
65 |
66 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/stdio.h:
67 |
68 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/cdefs.h:
69 |
70 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/cdefs_elf.h:
71 |
72 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/android/api-level.h:
73 |
74 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/types.h:
75 |
76 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/stdint.h:
77 |
78 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/_types.h:
79 |
80 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/machine/_types.h:
81 |
82 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/_wchar_limits.h:
83 |
84 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/linux/posix_types.h:
85 |
86 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/linux/stddef.h:
87 |
88 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/linux/compiler.h:
89 |
90 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm/posix_types.h:
91 |
92 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm/types.h:
93 |
94 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/linux/types.h:
95 |
96 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/machine/kernel.h:
97 |
98 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/sysmacros.h:
99 |
100 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/unistd.h:
101 |
102 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/select.h:
103 |
104 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/time.h:
105 |
106 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/linux/time.h:
107 |
108 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/signal.h:
109 |
110 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/limits.h:
111 |
112 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/limits.h:
113 |
114 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/linux/limits.h:
115 |
116 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/machine/internal_types.h:
117 |
118 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/machine/limits.h:
119 |
120 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/syslimits.h:
121 |
122 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm/page.h:
123 |
124 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/string.h:
125 |
126 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/malloc.h:
127 |
128 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm/signal.h:
129 |
130 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm-generic/signal.h:
131 |
132 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm/sigcontext.h:
133 |
134 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm/siginfo.h:
135 |
136 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm-generic/siginfo.h:
137 |
138 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/ucontext.h:
139 |
140 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/user.h:
141 |
142 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/sysconf.h:
143 |
144 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/linux/capability.h:
145 |
146 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/pathconf.h:
147 |
148 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/pthread.h:
149 |
150 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/time.h:
151 |
152 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sched.h:
153 |
154 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/android/log.h:
155 |
156 | jni/damn-server/damn_server.h:
157 |
158 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/stdlib.h:
159 |
160 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/alloca.h:
161 |
162 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/strings.h:
163 |
164 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/memory.h:
165 |
166 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/fcntl.h:
167 |
168 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/linux/fcntl.h:
169 |
170 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm/fcntl.h:
171 |
172 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/asm-generic/fcntl.h:
173 |
174 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/stat.h:
175 |
176 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/linux/stat.h:
177 |
178 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/endian.h:
179 |
180 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/sys/endian.h:
181 |
182 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/machine/endian.h:
183 |
184 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/jni.h:
185 |
186 | jni/civetweb/civetweb.h:
187 |
188 | jni/misc/daemonize.h:
189 |
190 | /home/baer/android-ndk-r10e/platforms/android-19/arch-arm/usr/include/syslog.h:
191 |
--------------------------------------------------------------------------------
/src/at/fhooe/mcm14/damn/activities/AppDetailActivity.java:
--------------------------------------------------------------------------------
1 | package at.fhooe.mcm14.damn.activities;
2 |
3 | import java.io.BufferedOutputStream;
4 | import java.io.File;
5 | import java.io.FileOutputStream;
6 | import java.io.IOException;
7 | import java.io.ObjectOutput;
8 | import java.io.ObjectOutputStream;
9 | import java.io.OutputStream;
10 | import java.util.ArrayList;
11 | import java.util.Collection;
12 | import java.util.Enumeration;
13 | import java.util.HashSet;
14 | import java.util.List;
15 | import java.util.Set;
16 |
17 | import android.app.Activity;
18 | import android.app.AlertDialog;
19 | import android.content.Context;
20 | import android.content.DialogInterface;
21 | import android.content.Intent;
22 | import android.content.SharedPreferences;
23 | import android.content.SharedPreferences.Editor;
24 | import android.content.pm.ApplicationInfo;
25 | import android.os.Bundle;
26 | import android.preference.PreferenceManager;
27 | import android.util.Log;
28 | import android.view.Menu;
29 | import android.view.MenuItem;
30 | import android.view.View;
31 | import android.view.View.OnClickListener;
32 | import android.view.ViewGroup;
33 | import android.widget.ArrayAdapter;
34 | import android.widget.Button;
35 | import android.widget.CheckBox;
36 | import android.widget.CompoundButton;
37 | import android.widget.CompoundButton.OnCheckedChangeListener;
38 | import android.widget.ImageView;
39 | import android.widget.ListView;
40 | import android.widget.TextView;
41 | import at.fhooe.mcm14.damn.R;
42 | import at.fhooe.mcm14.damn.fragments.AppListFragment;
43 | import at.fhooe.mcm14.damn.services.XModuleService;
44 | import at.fhooe.mcm14.damn.xposed.XModule;
45 | import dalvik.system.DexFile;
46 |
47 | public class AppDetailActivity extends Activity {
48 |
49 | /**
50 | * Used for the extra in the bundle.
51 | */
52 | public static final String APPINFO = "appinfo";
53 |
54 | private static final String TAG = AppDetailActivity.class.getName();
55 | private ApplicationInfo applicationInfo = null;
56 | private Button activate = null;
57 | private HashSet actives = null;
58 | private HashSet packages = null;
59 | private HashSet allPackages = null;
60 | private PackageArrayAdapter adapter = null;
61 |
62 |
63 | @Override
64 | protected void onCreate(Bundle savedInstanceState) {
65 | super.onCreate(savedInstanceState);
66 |
67 | //get applicationInfo from bundle
68 | applicationInfo = (ApplicationInfo)getIntent().getExtras().get(APPINFO);
69 |
70 | //close this activity if appinfo is empty
71 | if(applicationInfo==null){
72 | AlertDialog.Builder dialogbuilder = new AlertDialog.Builder(this);
73 | dialogbuilder
74 | .setMessage("Sorry, no detailed information available")
75 | .setCancelable(false)
76 | .setTitle("No Information")
77 | .setPositiveButton("OK", new DialogInterface.OnClickListener() {
78 | @Override
79 | public void onClick(DialogInterface dialogInterface, int i) {
80 | AppDetailActivity.this.finish();
81 | }
82 | });
83 |
84 | AlertDialog alert = dialogbuilder.create();
85 | alert.show();
86 | }
87 |
88 | //get shared preferences
89 | SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
90 | actives = (HashSet) prefs.getStringSet(AppListFragment.ACTIVE_APPS, new HashSet());
91 | packages = (HashSet) prefs.getStringSet(applicationInfo.packageName, new HashSet());
92 | Log.d(TAG, "loaded packages:" + packages.size());
93 |
94 | //set view
95 | setContentView(R.layout.activity_app_detail);
96 |
97 | //get packages
98 | DexFile df;
99 | try {
100 | df = new DexFile(applicationInfo.sourceDir);
101 |
102 | } catch (IOException e) {
103 | e.printStackTrace();
104 | return;
105 | }
106 |
107 |
108 | if(df!=null){
109 | ArrayList pkgs = new ArrayList();
110 | for (Enumeration iter = df.entries(); iter.hasMoreElements();) {
111 | String pkg = iter.nextElement();
112 | pkg.replaceAll("\\.*\\.java", "");
113 |
114 | String[] parts = pkg.split("\\.");
115 |
116 | if(parts.length>3){
117 | int i = pkg.indexOf(parts[3]);
118 | pkg = pkg.substring(0, i);
119 | if(pkg.endsWith("."))
120 | pkg = pkg.substring(0, pkg.length()-1);
121 | }
122 |
123 | if(!pkgs.contains(pkg))
124 | pkgs.add(pkg);
125 | }
126 |
127 | allPackages = new HashSet(pkgs);
128 | adapter = new PackageArrayAdapter(getApplicationContext(), R.layout.listitem_packages, pkgs);
129 | ((ListView)findViewById(R.id.lv_details_permissons)).setAdapter(adapter);
130 | }
131 |
132 |
133 | //set detail information
134 | ((TextView)findViewById(R.id.tv_detail_name)).setText(applicationInfo.loadLabel(getPackageManager()));
135 | ((TextView)findViewById(R.id.tv_detail_package)).setText(applicationInfo.packageName);
136 | ((ImageView)findViewById(R.id.iv_detail_icon)).setImageDrawable(getPackageManager().getApplicationIcon(applicationInfo));
137 |
138 | //set button
139 | activate = (Button)findViewById(R.id.b_detail_activate);
140 |
141 | if(actives.contains(applicationInfo.packageName))
142 | activate.setText(getString(R.string.fragment_title_deactivate));
143 | else
144 | activate.setText(getString(R.string.fragment_title_active));
145 |
146 | activate.setOnClickListener(new OnClickListener() {
147 |
148 |
149 | @SuppressWarnings("unchecked")
150 | @Override
151 | public void onClick(View _view) {
152 | //activate tracing, change button text
153 | SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
154 | Editor editor = prefs.edit();
155 |
156 | if(actives==null)
157 | actives = new HashSet();
158 |
159 | if(actives.contains(applicationInfo.packageName) && !activate.getText().toString().equalsIgnoreCase("save changes")){
160 | Log.i(TAG, "remove package");
161 | activate.setText(getString(R.string.fragment_title_active));
162 | actives.remove(applicationInfo.packageName);
163 | Set tmp_actives = (Set) actives.clone();
164 |
165 | editor.remove(AppListFragment.ACTIVE_APPS);
166 | editor.commit();
167 | editor.putStringSet(AppListFragment.ACTIVE_APPS, tmp_actives);
168 | if(actives.isEmpty()){
169 | //deactivate service if nothing left to track
170 | Log.i(TAG, "stop service because of empty list of tracked apps");
171 | stopService(new Intent(getApplicationContext(), XModuleService.class));
172 | }
173 |
174 | for(int n=0;n tmp_actives = (Set) actives.clone();
182 | editor.remove(AppListFragment.ACTIVE_APPS);
183 | editor.commit();
184 | editor.putStringSet(AppListFragment.ACTIVE_APPS, tmp_actives);
185 | if(actives.size()==1){
186 | //activate service
187 | Log.i(TAG, "start service because of new entry of app");
188 | startService(new Intent(getApplicationContext(), XModuleService.class));
189 | }
190 |
191 | if(activate.getText().toString().equalsIgnoreCase("save changes")){
192 | //save packages
193 | Set tmp_packages = (Set) packages.clone();
194 | editor.remove(applicationInfo.packageName);
195 | editor.commit();
196 | editor.putStringSet(applicationInfo.packageName, tmp_packages);
197 | Log.i(TAG, "save packages:" + packages.size());
198 |
199 | }else{
200 | //otherwise the user want all packages!
201 | packages = allPackages;
202 | for(int n=0;n tmpList = new ArrayList((Set)packages.clone());
217 | tmpList.add(0, applicationInfo.packageName);
218 |
219 | try {
220 | if(!tmp.exists()) {
221 | tmp.createNewFile();
222 | tmp.setReadable(true, false);
223 | tmp.setWritable(true, false);
224 | }
225 |
226 | //create tmp file
227 | OutputStream os = new FileOutputStream(tmp);
228 | OutputStream buffer = new BufferedOutputStream(os);
229 | ObjectOutput output = new ObjectOutputStream(buffer);
230 | output.writeObject(tmpList);
231 | output.flush();
232 | output.close();
233 |
234 |
235 |
236 | //copy tmp file to target file and change permissions
237 | Log.d(TAG, "cp: " + Runtime.getRuntime().exec(new String[]{"su", String.valueOf(applicationInfo.uid), "cp", tmp.getAbsolutePath(), target.getAbsolutePath()}).waitFor());
238 | Log.d(TAG, "chmod: " + Runtime.getRuntime().exec(new String[]{"su", String.valueOf(applicationInfo.uid), "chmod", "0666", target.getAbsolutePath()}).waitFor());
239 |
240 | tmp.delete();
241 |
242 | }catch(Exception ex){
243 | ex.printStackTrace();
244 | }
245 |
246 |
247 | Log.i(TAG, "saved changes to shared preferences");
248 | }
249 | });
250 | }
251 |
252 |
253 | @Override
254 | public boolean onCreateOptionsMenu(Menu menu) {
255 | getMenuInflater().inflate(R.menu.app_detail, menu);
256 | return true;
257 | }
258 |
259 | @Override
260 | public boolean onOptionsItemSelected(MenuItem item) {
261 | int id = item.getItemId();
262 | if (id == R.id.action_settings)
263 | return true;
264 |
265 | return super.onOptionsItemSelected(item);
266 | }
267 |
268 |
269 | private class PackageArrayAdapter extends ArrayAdapter {
270 |
271 | public boolean[] packageItems = null;
272 |
273 | public PackageArrayAdapter(Context context, int resource, List objects) {
274 | super(context, resource, objects);
275 | packageItems = new boolean[objects.size()];
276 |
277 | //get active packages
278 | String[] pkgs = objects.toArray(new String[objects.size()]);
279 | Log.i(TAG, "length: " + pkgs.length);
280 |
281 | if(pkgs!=null && packages!=null)
282 | for(int n=0;n collection) {
298 | super.addAll(collection);
299 | Log.i(TAG, "add collection");
300 | }
301 |
302 | @Override
303 | public View getView(int position, View convertView, ViewGroup parent) {
304 | CheckBox view = (CheckBox) super.getView(position, convertView, parent);
305 | view.setChecked(isChecked(position));
306 |
307 | view.setOnCheckedChangeListener(new OnCheckedChangeListener() {
308 |
309 | @Override
310 | public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
311 | ListView list = (ListView) buttonView.getParent();
312 | if(list!=null)
313 | packageItems[list.getPositionForView(buttonView)] = isChecked;
314 |
315 | String pkg = buttonView.getText().toString();
316 |
317 | if(!isChecked && packages.contains(pkg))
318 | packages.remove(pkg);
319 | else if(isChecked && !packages.contains(pkg))
320 | packages.add(pkg);
321 |
322 | activate.setText("save changes");
323 | }
324 | });
325 |
326 | return view;
327 | }
328 |
329 | private boolean isChecked(int pos) {
330 | return packageItems[pos];
331 | }
332 |
333 | }
334 | }
335 |
--------------------------------------------------------------------------------
/src/at/fhooe/mcm14/damn/xposed/XDAMNHook.java:
--------------------------------------------------------------------------------
1 | package at.fhooe.mcm14.damn.xposed;
2 |
3 | import java.io.BufferedReader;
4 | import java.io.FileInputStream;
5 | import java.io.InputStreamReader;
6 | import java.lang.reflect.Field;
7 | import java.util.ArrayList;
8 | import java.util.HashMap;
9 | import java.util.Iterator;
10 |
11 | import org.json.JSONArray;
12 | import org.json.JSONException;
13 | import org.json.JSONObject;
14 |
15 | import android.util.Log;
16 | import at.fhooe.mcm14.damn.jni.DAMNServer;
17 | import at.fhooe.mcm14.damn.jni.DAMNServer.Code;
18 | import at.fhooe.mcm14.damn.objects.MessageObject;
19 | import de.robv.android.xposed.XC_MethodHook;
20 |
21 | public class XDAMNHook extends XC_MethodHook {
22 |
23 | private static final String TAG = XDAMNHook.class.getCanonicalName();
24 |
25 | public volatile boolean init_done = false;
26 | public volatile HashMap threads = new HashMap<>();
27 | private String app = null;
28 |
29 | public XDAMNHook(String app) {
30 | this.app = app;
31 | }
32 |
33 | @Override
34 | protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
35 | //TODO get div object from http class
36 | JSONObject jMethod = new JSONObject();
37 | jMethod.put("class", param.method.getDeclaringClass().getCanonicalName());
38 | jMethod.put("method", param.method.getName());
39 | jMethod.put("parameters", new JSONArray().put(getPrimitiveObjects(param.args, 0)));
40 |
41 | JSONObject jClass = new JSONObject();
42 | jClass.put("fields", new JSONArray().put(getFieldObjects(param.method.getDeclaringClass().getFields(), param.thisObject, 0)));
43 |
44 | long tid = Thread.currentThread().getId();
45 |
46 | //check if entry is available
47 | if(!threads.containsKey(tid)){
48 | //open new page
49 | // DAMNServer.newAppStarted(app, tid);
50 |
51 | XListener xl = new XListener(app, Thread.currentThread(), this);
52 | xl.STEPPING = false;
53 | xl.start();
54 |
55 | threads.put(tid, xl);
56 | }
57 |
58 |
59 | XListener lock = threads.get(tid);
60 |
61 | //if init not done- wait for it! (special case)
62 | synchronized (lock) {
63 | if(!init_done && lock.STEPPING){
64 | Log.d(TAG, "wait @" + param.method.getName());
65 | lock.wait();
66 | Log.d(TAG, "done waiting @" + param.method.getName());
67 | }
68 | }
69 |
70 | //send info to browser
71 | synchronized (lock) {
72 | DAMNServer.push(new MessageObject(Code.varParam, jMethod.toString(), app, tid));
73 | if(lock.STEPPING) {
74 | DAMNServer.push(new MessageObject(Code.varGlobal, jClass.toString(), app, tid));
75 |
76 | String source = null;
77 | try {
78 | source = readSource("data/data/" + app + "/source/" + param.method.getDeclaringClass().getCanonicalName().replace(".", "/") + ".java");
79 |
80 | } catch(Exception e) {
81 | Log.e(TAG, "something terrible going wrong");
82 | }
83 | if(source!=null)
84 | DAMNServer.push(new MessageObject(
85 | Code.methodCode,
86 | source,
87 | app,
88 | tid));
89 | }
90 | }
91 |
92 | //wait for response if stepping is on
93 | synchronized (lock) {
94 | if(lock.STEPPING) {
95 | String data = lock.waitForNextStep();
96 | if(data!=null){
97 | Log.d(TAG, "json: " + data);
98 | JSONObject payload = new JSONObject(data);
99 | Log.d(TAG, "set new params " + param.method.getName());
100 |
101 | //change parameters
102 | try{
103 | JSONArray parameters = (JSONArray) payload.get("parameters");
104 |
105 | for (int n = 0; n < parameters.length(); n++) {
106 | JSONObject obj = parameters.getJSONObject(n);
107 | Iterator> keys = obj.keys();
108 |
109 | while( keys.hasNext() ) {
110 | String key = (String)keys.next();
111 | Log.d(TAG, "key: " + key);
112 | String[] io = key.replaceAll("\\s","").split(":");
113 |
114 | int pos = Integer.valueOf(io[0]);
115 | if(io[1].equals("class"))
116 | continue;
117 |
118 |
119 | if(param.args[pos-1].getClass().getCanonicalName().equalsIgnoreCase(obj.get(key).getClass().getCanonicalName()))
120 | param.args[pos-1] = obj.get(key);
121 |
122 | else{
123 | Log.e(TAG, "old arg: " + param.args[pos-1].getClass().getCanonicalName());
124 | Log.e(TAG, "new arg: " + key + "@" + (pos-1) + " : " + obj.get(key).getClass().getCanonicalName());
125 | }
126 |
127 |
128 | }
129 | }
130 | }catch(Exception e) {
131 | Log.e(TAG, "get params error: " + e.getMessage());
132 | return;
133 | }
134 |
135 | }else{
136 | Log.d(TAG, "proceed without new data" + param.method.getName());
137 | }
138 |
139 | }else{
140 | // Log.d(TAG, "no stepping");
141 | }
142 | }
143 |
144 | }
145 |
146 | @Override
147 | protected void afterHookedMethod(MethodHookParam param) throws Throwable {
148 | JSONObject jMethod = new JSONObject();
149 | jMethod.put("class", param.method.getDeclaringClass().getCanonicalName());
150 | jMethod.put("method", param.method.getName());
151 | jMethod.put("result", getPrimitiveObjects(new Object[]{param.getResult()}, 0));
152 | JSONObject jClass = new JSONObject();
153 | jClass.put("fields", new JSONArray().put(getFieldObjects(param.method.getDeclaringClass().getFields(), param.thisObject, 0)));
154 |
155 |
156 | long tid = Thread.currentThread().getId();
157 | XListener lock = threads.get(tid);
158 |
159 | //check if entry is available
160 | if(!threads.containsKey(tid)){
161 | //open new page
162 | // DAMNServer.newAppStarted(app, tid);
163 |
164 | XListener xl = new XListener(app, Thread.currentThread(), this);
165 | xl.STEPPING = false;
166 | xl.start();
167 |
168 | threads.put(tid, xl);
169 | }
170 |
171 | synchronized (lock) {
172 | DAMNServer.push(new MessageObject(Code.varReturn, jMethod.toString(), app, tid));
173 | if(lock.STEPPING) {
174 | DAMNServer.push(new MessageObject(Code.varGlobal, jClass.toString(), app, tid));
175 |
176 | String source = null;
177 | try {
178 | source = readSource("data/data/" + app + "/source/" + param.method.getDeclaringClass().getCanonicalName().replace(".", "/") + ".java");
179 |
180 | } catch(Exception e) {
181 | Log.e(TAG, "something terrible going wrong");
182 | }
183 | if(source!=null)
184 | DAMNServer.push(new MessageObject(
185 | Code.methodCode,
186 | source,
187 | app,
188 | tid));
189 | }
190 | }
191 |
192 | //wait for response if stepping is on
193 | synchronized (lock) {
194 | if(lock.STEPPING) {
195 | String data = lock.waitForNextStep();
196 | if(data!=null){
197 | Log.d(TAG, "json: " + data);
198 | JSONObject payload = new JSONObject(data);
199 | Log.d(TAG, "set new return val " + param.method.getName());
200 |
201 | JSONObject ret = null;
202 | //change parameters
203 | try{
204 | ret = (JSONObject) payload.get("result");
205 |
206 | }catch(Exception e) {
207 | Log.e(TAG, "returnvalue: " + e.getMessage());
208 | return;
209 | }
210 |
211 | Iterator> keys = ret.keys();
212 |
213 | while( keys.hasNext() ) {
214 | String key = (String)keys.next();
215 | Log.d(TAG, "key: " + key);
216 | String[] io = key.replaceAll("\\s","").split(":");
217 |
218 | int pos = Integer.valueOf(io[0]);
219 | if(io[1].equals("class"))
220 | continue;
221 |
222 |
223 | if(param.getResult().getClass().getCanonicalName().equalsIgnoreCase(ret.get(key).getClass().getCanonicalName()))
224 | param.setResult(ret.get(key));
225 |
226 | else{
227 | Log.e(TAG, "old result: " + param.getResult().getClass().getCanonicalName());
228 | Log.e(TAG, "new result: " + key + "@" + (pos-1) + " : " + ret.get(key).getClass().getCanonicalName());
229 | }
230 | }
231 |
232 | }else{
233 | Log.d(TAG, "proceed without new data" + param.method.getName());
234 | }
235 |
236 | }else{
237 | // Log.d(TAG, "no stepping");
238 | }
239 | }
240 | }
241 |
242 |
243 | private String readSource(String clazz) {
244 | StringBuilder sb = new StringBuilder();
245 |
246 | FileInputStream fis = null;
247 | InputStreamReader isr = null;
248 | BufferedReader bufferedReader = null;
249 |
250 | try {
251 | fis = new FileInputStream(clazz);
252 | isr = new InputStreamReader(fis);
253 | bufferedReader = new BufferedReader(isr);
254 |
255 | String line;
256 | while ((line = bufferedReader.readLine()) != null)
257 | sb.append(line + "
");
258 |
259 | return sb.toString();
260 |
261 | }catch(Exception e) {
262 | Log.e(TAG, e.getMessage());
263 |
264 | }finally {
265 | try {
266 | if(bufferedReader!=null)
267 | bufferedReader.close();
268 | if(isr!=null)
269 | isr.close();
270 | if(fis!=null)
271 | fis.close();
272 |
273 | } catch (Exception e) { }
274 | }
275 |
276 | return "no code available";
277 | }
278 |
279 |
280 | private JSONObject getFieldObjects(Field[] fields, Object object, int limit) {
281 | JSONObject jParameters = new JSONObject();
282 | try {
283 |
284 | for(int n=0; n clazz = fields[n].getType();
287 | String key = (n+1) + ": " + fields[n].getName();
288 | Object value = fields[n].get(object);
289 |
290 | if(clazz.getCanonicalName().equals(String.class.getCanonicalName()))
291 | jParameters.put(key, (String)value);
292 | else if(clazz.getCanonicalName().equals(Integer.class.getCanonicalName()))
293 | jParameters.put(key, (Integer)value);
294 | else if(clazz.getCanonicalName().equals(Long.class.getCanonicalName()))
295 | jParameters.put(key, (Long)value);
296 | else if(clazz.getCanonicalName().equals(Boolean.class.getCanonicalName()))
297 | jParameters.put(key, (Boolean)value);
298 | else if(clazz.getCanonicalName().equals(Float.class.getCanonicalName()))
299 | jParameters.put(key, (Float)value);
300 | else if(clazz.getCanonicalName().equals(Double.class.getCanonicalName()))
301 | jParameters.put(key, (Double)value);
302 | else if(clazz.getCanonicalName().equals(Character.class.getCanonicalName()))
303 | jParameters.put(key, (Character)value);
304 | else if(clazz.getCanonicalName().equals(Byte.class.getCanonicalName()))
305 | jParameters.put(key, (Byte)value);
306 | else if(clazz.getCanonicalName().equals(int.class.getCanonicalName()))
307 | jParameters.put(key, (int)value);
308 | else if(clazz.getCanonicalName().equals(long.class.getCanonicalName()))
309 | jParameters.put(key, (long)value);
310 | else if(clazz.getCanonicalName().equals(boolean.class.getCanonicalName()))
311 | jParameters.put(key, (boolean)value);
312 | else if(clazz.getCanonicalName().equals(float.class.getCanonicalName()))
313 | jParameters.put(key, (float)value);
314 | else if(clazz.getCanonicalName().equals(double.class.getCanonicalName()))
315 | jParameters.put(key, (double)value);
316 | else if(clazz.getCanonicalName().equals(char.class.getCanonicalName()))
317 | jParameters.put(key, (char)value);
318 | else if(clazz.getCanonicalName().equals(byte.class.getCanonicalName()))
319 | jParameters.put(key, (byte)value);
320 | else if(clazz.getCanonicalName().equals(byte[].class.getCanonicalName()))
321 | jParameters.put(key, new String((byte[])object));
322 | else {
323 | jParameters.put(key, clazz.getCanonicalName());
324 | }
325 | }
326 | } catch (Exception e) {
327 | // Log.e(TAG, "error: " + e.getLocalizedMessage());
328 | }
329 |
330 | return jParameters;
331 | }
332 |
333 | private JSONObject getPrimitiveObjects(Object[] objects, int limit) throws JSONException {
334 | JSONObject jParameters = new JSONObject();
335 |
336 | if(objects!=null)
337 | for(int n=0; n clazz, Object object, JSONObject jObject, int position, int limit) {
345 |
346 | try {
347 | if(clazz.getCanonicalName().equals(String.class.getCanonicalName()))
348 | jObject.put((position) + ": String", (String)object);
349 | else if(clazz.getCanonicalName().equals(Integer.class.getCanonicalName()))
350 | jObject.put((position+1) + ": Integer", (Integer)object);
351 | else if(clazz.getCanonicalName().equals(Long.class.getCanonicalName()))
352 | jObject.put((position+1) + ": Long", (Long)object);
353 | else if(clazz.getCanonicalName().equals(Boolean.class.getCanonicalName()))
354 | jObject.put((position+1) + ": Boolean", (Boolean)object);
355 | else if(clazz.getCanonicalName().equals(Float.class.getCanonicalName()))
356 | jObject.put((position+1) + ": Float", (Float)object);
357 | else if(clazz.getCanonicalName().equals(Double.class.getCanonicalName()))
358 | jObject.put((position+1) + ": Double", (Double)object);
359 | else if(clazz.getCanonicalName().equals(Character.class.getCanonicalName()))
360 | jObject.put((position+1) + ": Character", (Character)object);
361 | else if(clazz.getCanonicalName().equals(Byte.class.getCanonicalName()))
362 | jObject.put((position+1) + ": Byte", (Byte)object);
363 | else if(clazz.getCanonicalName().equals(int.class.getCanonicalName()))
364 | jObject.put((position+1) + ": int", (int)object);
365 | else if(clazz.getCanonicalName().equals(long.class.getCanonicalName()))
366 | jObject.put((position+1) + ": long", (long)object);
367 | else if(clazz.getCanonicalName().equals(boolean.class.getCanonicalName()))
368 | jObject.put((position+1) + ": boolean", (boolean)object);
369 | else if(clazz.getCanonicalName().equals(float.class.getCanonicalName()))
370 | jObject.put((position+1) + ": float", (float)object);
371 | else if(clazz.getCanonicalName().equals(double.class.getCanonicalName()))
372 | jObject.put((position+1) + ": double", (double)object);
373 | else if(clazz.getCanonicalName().equals(char.class.getCanonicalName()))
374 | jObject.put((position+1) + ": char", (char)object);
375 | else if(clazz.getCanonicalName().equals(byte.class.getCanonicalName()))
376 | jObject.put((position+1) + ": byte", (byte)object);
377 | else if(clazz.getCanonicalName().equals(byte[].class.getCanonicalName()))
378 | jObject.put((position+1) + ": byte[]", new String((byte[])object));
379 | else if(clazz.getCanonicalName().equals(ArrayList.class.getCanonicalName()))
380 | jObject.put((position+1) + ": ArrayList", ((ArrayList>)object).toString());
381 | else {
382 | jObject.put((position+1) + ": class", clazz.getCanonicalName());
383 | }
384 |
385 | } catch (Exception e) {
386 | // Log.e(TAG, "error: " + e.getLocalizedMessage());
387 | }
388 |
389 | return jObject;
390 | }
391 | }
392 |
--------------------------------------------------------------------------------
/jni/civetweb/md5.inl:
--------------------------------------------------------------------------------
1 | /*
2 | * This an amalgamation of md5.c and md5.h into a single file
3 | * with all static declaration to reduce linker conflicts
4 | * in Civetweb.
5 | *
6 | * The MD5_STATIC declaration was added to facilitate static
7 | * inclusion.
8 | * No Face Press, LLC
9 | */
10 |
11 | /* $Id: md5.h,v 1.4 2002/04/13 19:20:28 lpd Exp $ */
12 | /*
13 | Independent implementation of MD5 (RFC 1321).
14 |
15 | This code implements the MD5 Algorithm defined in RFC 1321, whose
16 | text is available at
17 | http://www.ietf.org/rfc/rfc1321.txt
18 | The code is derived from the text of the RFC, including the test suite
19 | (section A.5) but excluding the rest of Appendix A. It does not include
20 | any code or documentation that is identified in the RFC as being
21 | copyrighted.
22 |
23 | The original and principal author of md5.h is L. Peter Deutsch
24 | . Other authors are noted in the change history
25 | that follows (in reverse chronological order):
26 |
27 | 2002-04-13 lpd Removed support for non-ANSI compilers; removed
28 | references to Ghostscript; clarified derivation from RFC 1321;
29 | now handles byte order either statically or dynamically.
30 | 1999-11-04 lpd Edited comments slightly for automatic TOC extraction.
31 | 1999-10-18 lpd Fixed typo in header comment (ansi2knr rather than md5);
32 | added conditionalization for C++ compilation from Martin
33 | Purschke .
34 | 1999-05-03 lpd Original version.
35 | */
36 |
37 | #ifndef md5_INCLUDED
38 | # define md5_INCLUDED
39 |
40 | /*
41 | * This package supports both compile-time and run-time determination of CPU
42 | * byte order. If ARCH_IS_BIG_ENDIAN is defined as 0, the code will be
43 | * compiled to run only on little-endian CPUs; if ARCH_IS_BIG_ENDIAN is
44 | * defined as non-zero, the code will be compiled to run only on big-endian
45 | * CPUs; if ARCH_IS_BIG_ENDIAN is not defined, the code will be compiled to
46 | * run on either big- or little-endian CPUs, but will run slightly less
47 | * efficiently on either one than if ARCH_IS_BIG_ENDIAN is defined.
48 | */
49 |
50 | typedef unsigned char md5_byte_t; /* 8-bit byte */
51 | typedef unsigned int md5_word_t; /* 32-bit word */
52 |
53 | /* Define the state of the MD5 Algorithm. */
54 | typedef struct md5_state_s {
55 | md5_word_t count[2]; /* message length in bits, lsw first */
56 | md5_word_t abcd[4]; /* digest buffer */
57 | md5_byte_t buf[64]; /* accumulate block */
58 | } md5_state_t;
59 |
60 | #ifdef __cplusplus
61 | extern "C"
62 | {
63 | #endif
64 |
65 | /* Initialize the algorithm. */
66 | MD5_STATIC void md5_init(md5_state_t *pms);
67 |
68 | /* Append a string to the message. */
69 | MD5_STATIC void md5_append(md5_state_t *pms, const md5_byte_t *data, int nbytes);
70 |
71 | /* Finish the message and return the digest. */
72 | MD5_STATIC void md5_finish(md5_state_t *pms, md5_byte_t digest[16]);
73 |
74 | #ifdef __cplusplus
75 | } /* end extern "C" */
76 | #endif
77 |
78 | #endif /* md5_INCLUDED */
79 |
80 | /*
81 | Copyright (C) 1999, 2000, 2002 Aladdin Enterprises. All rights reserved.
82 |
83 | This software is provided 'as-is', without any express or implied
84 | warranty. In no event will the authors be held liable for any damages
85 | arising from the use of this software.
86 |
87 | Permission is granted to anyone to use this software for any purpose,
88 | including commercial applications, and to alter it and redistribute it
89 | freely, subject to the following restrictions:
90 |
91 | 1. The origin of this software must not be misrepresented; you must not
92 | claim that you wrote the original software. If you use this software
93 | in a product, an acknowledgment in the product documentation would be
94 | appreciated but is not required.
95 | 2. Altered source versions must be plainly marked as such, and must not be
96 | misrepresented as being the original software.
97 | 3. This notice may not be removed or altered from any source distribution.
98 |
99 | L. Peter Deutsch
100 | ghost@aladdin.com
101 |
102 | */
103 | /* $Id: md5.c,v 1.6 2002/04/13 19:20:28 lpd Exp $ */
104 | /*
105 | Independent implementation of MD5 (RFC 1321).
106 |
107 | This code implements the MD5 Algorithm defined in RFC 1321, whose
108 | text is available at
109 | http://www.ietf.org/rfc/rfc1321.txt
110 | The code is derived from the text of the RFC, including the test suite
111 | (section A.5) but excluding the rest of Appendix A. It does not include
112 | any code or documentation that is identified in the RFC as being
113 | copyrighted.
114 |
115 | The original and principal author of md5.c is L. Peter Deutsch
116 | . Other authors are noted in the change history
117 | that follows (in reverse chronological order):
118 |
119 | 2002-04-13 lpd Clarified derivation from RFC 1321; now handles byte order
120 | either statically or dynamically; added missing #include
121 | in library.
122 | 2002-03-11 lpd Corrected argument list for main(), and added int return
123 | type, in test program and T value program.
124 | 2002-02-21 lpd Added missing #include in test program.
125 | 2000-07-03 lpd Patched to eliminate warnings about "constant is
126 | unsigned in ANSI C, signed in traditional"; made test program
127 | self-checking.
128 | 1999-11-04 lpd Edited comments slightly for automatic TOC extraction.
129 | 1999-10-18 lpd Fixed typo in header comment (ansi2knr rather than md5).
130 | 1999-05-03 lpd Original version.
131 | */
132 |
133 | #ifndef MD5_STATIC
134 | #include
135 | #endif
136 |
137 | #undef BYTE_ORDER /* 1 = big-endian, -1 = little-endian, 0 = unknown */
138 | #ifdef ARCH_IS_BIG_ENDIAN
139 | # define BYTE_ORDER (ARCH_IS_BIG_ENDIAN ? 1 : -1)
140 | #else
141 | # define BYTE_ORDER 0
142 | #endif
143 |
144 | #define T_MASK ((md5_word_t)~0)
145 | #define T1 /* 0xd76aa478 */ (T_MASK ^ 0x28955b87)
146 | #define T2 /* 0xe8c7b756 */ (T_MASK ^ 0x173848a9)
147 | #define T3 0x242070db
148 | #define T4 /* 0xc1bdceee */ (T_MASK ^ 0x3e423111)
149 | #define T5 /* 0xf57c0faf */ (T_MASK ^ 0x0a83f050)
150 | #define T6 0x4787c62a
151 | #define T7 /* 0xa8304613 */ (T_MASK ^ 0x57cfb9ec)
152 | #define T8 /* 0xfd469501 */ (T_MASK ^ 0x02b96afe)
153 | #define T9 0x698098d8
154 | #define T10 /* 0x8b44f7af */ (T_MASK ^ 0x74bb0850)
155 | #define T11 /* 0xffff5bb1 */ (T_MASK ^ 0x0000a44e)
156 | #define T12 /* 0x895cd7be */ (T_MASK ^ 0x76a32841)
157 | #define T13 0x6b901122
158 | #define T14 /* 0xfd987193 */ (T_MASK ^ 0x02678e6c)
159 | #define T15 /* 0xa679438e */ (T_MASK ^ 0x5986bc71)
160 | #define T16 0x49b40821
161 | #define T17 /* 0xf61e2562 */ (T_MASK ^ 0x09e1da9d)
162 | #define T18 /* 0xc040b340 */ (T_MASK ^ 0x3fbf4cbf)
163 | #define T19 0x265e5a51
164 | #define T20 /* 0xe9b6c7aa */ (T_MASK ^ 0x16493855)
165 | #define T21 /* 0xd62f105d */ (T_MASK ^ 0x29d0efa2)
166 | #define T22 0x02441453
167 | #define T23 /* 0xd8a1e681 */ (T_MASK ^ 0x275e197e)
168 | #define T24 /* 0xe7d3fbc8 */ (T_MASK ^ 0x182c0437)
169 | #define T25 0x21e1cde6
170 | #define T26 /* 0xc33707d6 */ (T_MASK ^ 0x3cc8f829)
171 | #define T27 /* 0xf4d50d87 */ (T_MASK ^ 0x0b2af278)
172 | #define T28 0x455a14ed
173 | #define T29 /* 0xa9e3e905 */ (T_MASK ^ 0x561c16fa)
174 | #define T30 /* 0xfcefa3f8 */ (T_MASK ^ 0x03105c07)
175 | #define T31 0x676f02d9
176 | #define T32 /* 0x8d2a4c8a */ (T_MASK ^ 0x72d5b375)
177 | #define T33 /* 0xfffa3942 */ (T_MASK ^ 0x0005c6bd)
178 | #define T34 /* 0x8771f681 */ (T_MASK ^ 0x788e097e)
179 | #define T35 0x6d9d6122
180 | #define T36 /* 0xfde5380c */ (T_MASK ^ 0x021ac7f3)
181 | #define T37 /* 0xa4beea44 */ (T_MASK ^ 0x5b4115bb)
182 | #define T38 0x4bdecfa9
183 | #define T39 /* 0xf6bb4b60 */ (T_MASK ^ 0x0944b49f)
184 | #define T40 /* 0xbebfbc70 */ (T_MASK ^ 0x4140438f)
185 | #define T41 0x289b7ec6
186 | #define T42 /* 0xeaa127fa */ (T_MASK ^ 0x155ed805)
187 | #define T43 /* 0xd4ef3085 */ (T_MASK ^ 0x2b10cf7a)
188 | #define T44 0x04881d05
189 | #define T45 /* 0xd9d4d039 */ (T_MASK ^ 0x262b2fc6)
190 | #define T46 /* 0xe6db99e5 */ (T_MASK ^ 0x1924661a)
191 | #define T47 0x1fa27cf8
192 | #define T48 /* 0xc4ac5665 */ (T_MASK ^ 0x3b53a99a)
193 | #define T49 /* 0xf4292244 */ (T_MASK ^ 0x0bd6ddbb)
194 | #define T50 0x432aff97
195 | #define T51 /* 0xab9423a7 */ (T_MASK ^ 0x546bdc58)
196 | #define T52 /* 0xfc93a039 */ (T_MASK ^ 0x036c5fc6)
197 | #define T53 0x655b59c3
198 | #define T54 /* 0x8f0ccc92 */ (T_MASK ^ 0x70f3336d)
199 | #define T55 /* 0xffeff47d */ (T_MASK ^ 0x00100b82)
200 | #define T56 /* 0x85845dd1 */ (T_MASK ^ 0x7a7ba22e)
201 | #define T57 0x6fa87e4f
202 | #define T58 /* 0xfe2ce6e0 */ (T_MASK ^ 0x01d3191f)
203 | #define T59 /* 0xa3014314 */ (T_MASK ^ 0x5cfebceb)
204 | #define T60 0x4e0811a1
205 | #define T61 /* 0xf7537e82 */ (T_MASK ^ 0x08ac817d)
206 | #define T62 /* 0xbd3af235 */ (T_MASK ^ 0x42c50dca)
207 | #define T63 0x2ad7d2bb
208 | #define T64 /* 0xeb86d391 */ (T_MASK ^ 0x14792c6e)
209 |
210 |
211 | static void
212 | md5_process(md5_state_t *pms, const md5_byte_t *data /*[64]*/)
213 | {
214 | md5_word_t
215 | a = pms->abcd[0], b = pms->abcd[1],
216 | c = pms->abcd[2], d = pms->abcd[3];
217 | md5_word_t t;
218 | #if BYTE_ORDER > 0
219 | /* Define storage only for big-endian CPUs. */
220 | md5_word_t X[16];
221 | #else
222 | /* Define storage for little-endian or both types of CPUs. */
223 | md5_word_t xbuf[16];
224 | const md5_word_t *X;
225 | #endif
226 |
227 | {
228 | #if BYTE_ORDER == 0
229 | /*
230 | * Determine dynamically whether this is a big-endian or
231 | * little-endian machine, since we can use a more efficient
232 | * algorithm on the latter.
233 | */
234 | static const int w = 1;
235 |
236 | if (*((const md5_byte_t *)&w)) /* dynamic little-endian */
237 | #endif
238 | #if BYTE_ORDER <= 0 /* little-endian */
239 | {
240 | /*
241 | * On little-endian machines, we can process properly aligned
242 | * data without copying it.
243 | */
244 | if (!((data - (const md5_byte_t *)0) & 3)) {
245 | /* data are properly aligned */
246 | X = (const md5_word_t *)data;
247 | } else {
248 | /* not aligned */
249 | memcpy(xbuf, data, 64);
250 | X = xbuf;
251 | }
252 | }
253 | #endif
254 | #if BYTE_ORDER == 0
255 | else /* dynamic big-endian */
256 | #endif
257 | #if BYTE_ORDER >= 0 /* big-endian */
258 | {
259 | /*
260 | * On big-endian machines, we must arrange the bytes in the
261 | * right order.
262 | */
263 | const md5_byte_t *xp = data;
264 | int i;
265 |
266 | # if BYTE_ORDER == 0
267 | X = xbuf; /* (dynamic only) */
268 | # else
269 | # define xbuf X /* (static only) */
270 | # endif
271 | for (i = 0; i < 16; ++i, xp += 4)
272 | xbuf[i] = xp[0] + (xp[1] << 8) + (xp[2] << 16) + (xp[3] << 24);
273 | }
274 | #endif
275 | }
276 |
277 | #define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32 - (n))))
278 |
279 | /* Round 1. */
280 | /* Let [abcd k s i] denote the operation
281 | a = b + ((a + F(b,c,d) + X[k] + T[i]) <<< s). */
282 | #define F(x, y, z) (((x) & (y)) | (~(x) & (z)))
283 | #define SET(a, b, c, d, k, s, Ti)\
284 | t = a + F(b,c,d) + X[k] + Ti;\
285 | a = ROTATE_LEFT(t, s) + b
286 | /* Do the following 16 operations. */
287 | SET(a, b, c, d, 0, 7, T1);
288 | SET(d, a, b, c, 1, 12, T2);
289 | SET(c, d, a, b, 2, 17, T3);
290 | SET(b, c, d, a, 3, 22, T4);
291 | SET(a, b, c, d, 4, 7, T5);
292 | SET(d, a, b, c, 5, 12, T6);
293 | SET(c, d, a, b, 6, 17, T7);
294 | SET(b, c, d, a, 7, 22, T8);
295 | SET(a, b, c, d, 8, 7, T9);
296 | SET(d, a, b, c, 9, 12, T10);
297 | SET(c, d, a, b, 10, 17, T11);
298 | SET(b, c, d, a, 11, 22, T12);
299 | SET(a, b, c, d, 12, 7, T13);
300 | SET(d, a, b, c, 13, 12, T14);
301 | SET(c, d, a, b, 14, 17, T15);
302 | SET(b, c, d, a, 15, 22, T16);
303 | #undef SET
304 |
305 | /* Round 2. */
306 | /* Let [abcd k s i] denote the operation
307 | a = b + ((a + G(b,c,d) + X[k] + T[i]) <<< s). */
308 | #define G(x, y, z) (((x) & (z)) | ((y) & ~(z)))
309 | #define SET(a, b, c, d, k, s, Ti)\
310 | t = a + G(b,c,d) + X[k] + Ti;\
311 | a = ROTATE_LEFT(t, s) + b
312 | /* Do the following 16 operations. */
313 | SET(a, b, c, d, 1, 5, T17);
314 | SET(d, a, b, c, 6, 9, T18);
315 | SET(c, d, a, b, 11, 14, T19);
316 | SET(b, c, d, a, 0, 20, T20);
317 | SET(a, b, c, d, 5, 5, T21);
318 | SET(d, a, b, c, 10, 9, T22);
319 | SET(c, d, a, b, 15, 14, T23);
320 | SET(b, c, d, a, 4, 20, T24);
321 | SET(a, b, c, d, 9, 5, T25);
322 | SET(d, a, b, c, 14, 9, T26);
323 | SET(c, d, a, b, 3, 14, T27);
324 | SET(b, c, d, a, 8, 20, T28);
325 | SET(a, b, c, d, 13, 5, T29);
326 | SET(d, a, b, c, 2, 9, T30);
327 | SET(c, d, a, b, 7, 14, T31);
328 | SET(b, c, d, a, 12, 20, T32);
329 | #undef SET
330 |
331 | /* Round 3. */
332 | /* Let [abcd k s t] denote the operation
333 | a = b + ((a + H(b,c,d) + X[k] + T[i]) <<< s). */
334 | #define H(x, y, z) ((x) ^ (y) ^ (z))
335 | #define SET(a, b, c, d, k, s, Ti)\
336 | t = a + H(b,c,d) + X[k] + Ti;\
337 | a = ROTATE_LEFT(t, s) + b
338 | /* Do the following 16 operations. */
339 | SET(a, b, c, d, 5, 4, T33);
340 | SET(d, a, b, c, 8, 11, T34);
341 | SET(c, d, a, b, 11, 16, T35);
342 | SET(b, c, d, a, 14, 23, T36);
343 | SET(a, b, c, d, 1, 4, T37);
344 | SET(d, a, b, c, 4, 11, T38);
345 | SET(c, d, a, b, 7, 16, T39);
346 | SET(b, c, d, a, 10, 23, T40);
347 | SET(a, b, c, d, 13, 4, T41);
348 | SET(d, a, b, c, 0, 11, T42);
349 | SET(c, d, a, b, 3, 16, T43);
350 | SET(b, c, d, a, 6, 23, T44);
351 | SET(a, b, c, d, 9, 4, T45);
352 | SET(d, a, b, c, 12, 11, T46);
353 | SET(c, d, a, b, 15, 16, T47);
354 | SET(b, c, d, a, 2, 23, T48);
355 | #undef SET
356 |
357 | /* Round 4. */
358 | /* Let [abcd k s t] denote the operation
359 | a = b + ((a + I(b,c,d) + X[k] + T[i]) <<< s). */
360 | #define I(x, y, z) ((y) ^ ((x) | ~(z)))
361 | #define SET(a, b, c, d, k, s, Ti)\
362 | t = a + I(b,c,d) + X[k] + Ti;\
363 | a = ROTATE_LEFT(t, s) + b
364 | /* Do the following 16 operations. */
365 | SET(a, b, c, d, 0, 6, T49);
366 | SET(d, a, b, c, 7, 10, T50);
367 | SET(c, d, a, b, 14, 15, T51);
368 | SET(b, c, d, a, 5, 21, T52);
369 | SET(a, b, c, d, 12, 6, T53);
370 | SET(d, a, b, c, 3, 10, T54);
371 | SET(c, d, a, b, 10, 15, T55);
372 | SET(b, c, d, a, 1, 21, T56);
373 | SET(a, b, c, d, 8, 6, T57);
374 | SET(d, a, b, c, 15, 10, T58);
375 | SET(c, d, a, b, 6, 15, T59);
376 | SET(b, c, d, a, 13, 21, T60);
377 | SET(a, b, c, d, 4, 6, T61);
378 | SET(d, a, b, c, 11, 10, T62);
379 | SET(c, d, a, b, 2, 15, T63);
380 | SET(b, c, d, a, 9, 21, T64);
381 | #undef SET
382 |
383 | /* Then perform the following additions. (That is increment each
384 | of the four registers by the value it had before this block
385 | was started.) */
386 | pms->abcd[0] += a;
387 | pms->abcd[1] += b;
388 | pms->abcd[2] += c;
389 | pms->abcd[3] += d;
390 | }
391 |
392 | MD5_STATIC void
393 | md5_init(md5_state_t *pms)
394 | {
395 | pms->count[0] = pms->count[1] = 0;
396 | pms->abcd[0] = 0x67452301;
397 | pms->abcd[1] = /*0xefcdab89*/ T_MASK ^ 0x10325476;
398 | pms->abcd[2] = /*0x98badcfe*/ T_MASK ^ 0x67452301;
399 | pms->abcd[3] = 0x10325476;
400 | }
401 |
402 | MD5_STATIC void
403 | md5_append(md5_state_t *pms, const md5_byte_t *data, int nbytes)
404 | {
405 | const md5_byte_t *p = data;
406 | int left = nbytes;
407 | int offset = (pms->count[0] >> 3) & 63;
408 | md5_word_t nbits = (md5_word_t)(nbytes << 3);
409 |
410 | if (nbytes <= 0)
411 | return;
412 |
413 | /* Update the message length. */
414 | pms->count[1] += nbytes >> 29;
415 | pms->count[0] += nbits;
416 | if (pms->count[0] < nbits)
417 | pms->count[1]++;
418 |
419 | /* Process an initial partial block. */
420 | if (offset) {
421 | int copy = (offset + nbytes > 64 ? 64 - offset : nbytes);
422 |
423 | memcpy(pms->buf + offset, p, copy);
424 | if (offset + copy < 64)
425 | return;
426 | p += copy;
427 | left -= copy;
428 | md5_process(pms, pms->buf);
429 | }
430 |
431 | /* Process full blocks. */
432 | for (; left >= 64; p += 64, left -= 64)
433 | md5_process(pms, p);
434 |
435 | /* Process a final partial block. */
436 | if (left)
437 | memcpy(pms->buf, p, left);
438 | }
439 |
440 | MD5_STATIC void
441 | md5_finish(md5_state_t *pms, md5_byte_t digest[16])
442 | {
443 | static const md5_byte_t pad[64] = {
444 | 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
445 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
446 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
447 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
448 | };
449 | md5_byte_t data[8];
450 | int i;
451 |
452 | /* Save the length before padding. */
453 | for (i = 0; i < 8; ++i)
454 | data[i] = (md5_byte_t)(pms->count[i >> 2] >> ((i & 3) << 3));
455 | /* Pad to 56 bytes mod 64. */
456 | md5_append(pms, pad, ((55 - (pms->count[0] >> 3)) & 63) + 1);
457 | /* Append the length. */
458 | md5_append(pms, data, 8);
459 | for (i = 0; i < 16; ++i)
460 | digest[i] = (md5_byte_t)(pms->abcd[i >> 2] >> ((i & 3) << 3));
461 | }
462 |
--------------------------------------------------------------------------------