-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial commit: source code for EavesDroid (IoT-J'24).
- Loading branch information
0 parents
commit 8d8502a
Showing
66 changed files
with
4,308 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
**/.vscode/ | ||
**/target/ | ||
**/build/ | ||
**/bin/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2024 iamywang | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
# EavesDroid: Eavesdropping User Behaviors via OS Side Channels on Smartphones | ||
|
||
This repo contains the source code and dataset of our paper "EavesDroid: Eavesdropping User Behaviors via OS Side Channels on Smartphones" published in IEEE Internet of Things Journal (IoT-J). | ||
|
||
![EavesDroid](./overview.png) | ||
|
||
## 0x01 Getting Started | ||
|
||
Prerequisites: | ||
|
||
- Android Studio | ||
- Android NDK | ||
- Python 3.11 | ||
- numpy | ||
- matplotlib | ||
- keras | ||
- django | ||
- cydtw | ||
|
||
## 0x02 Repo Structure | ||
|
||
**1. Android App** | ||
|
||
- `app/` contains the source code of our Android app. | ||
|
||
- Please rename it to `Sampler` and import it into Android Studio to build the app. | ||
|
||
- Note: `val api = "http://192.168.1.2:8000"` in `MainActivity.kt` should be changed to the proper server address. | ||
|
||
**2. Server** | ||
|
||
- `backend/` contains the source code of our Django server. | ||
|
||
- Please run `python manage.py runserver` to start the server. | ||
|
||
**3. Data Collection** | ||
|
||
- `collection/` contains the source code of emulated data collection tool. | ||
|
||
- Please run `python sample.py/sample2.py` to collect data from your own devices. | ||
|
||
- Note: parameters should be changed to the proper values. | ||
|
||
**4. Data Classification** | ||
|
||
- `classification/` contains the source code of user behavior classification tool. | ||
|
||
- `all_model.py` contains the baseline models used in our paper: 1D-CNN, LSTM, GRU. | ||
|
||
- `dtw_model.py` contains the DTW-KNN algorithm used in our paper. | ||
|
||
- `classify.py` is the main script to infer user behaviors with our CNN-GRU model. | ||
|
||
**4. Dataset** | ||
|
||
- `dataset/` contains the dataset used in our paper. | ||
|
||
- Data in this directory can be used to train classification models and reproduce our results. | ||
|
||
**5. Figures** | ||
|
||
- `figures/` contains the figure generation scripts used in our paper. | ||
|
||
- Files in this directory can be used to reproduce the figures in our paper. | ||
|
||
## 0x03 Copyright and License | ||
|
||
This project is licensed under the terms of the MIT License. | ||
|
||
## 0x04 Contact and Citation | ||
|
||
If you have any questions, please contact me through `GitHub Issues` or email: [email protected]. | ||
|
||
If our work is useful for your research, please consider citing our paper: | ||
|
||
```bibtex | ||
@ARTICLE{wang2024eavesdroid, | ||
author={Wang, Quancheng and Tang, Ming and Fu, Jianming}, | ||
journal={IEEE Internet of Things Journal (IoT-J)}, | ||
title={EavesDroid: Eavesdropping User Behaviors via OS Side Channels on Smartphones}, | ||
year={2024}, | ||
volume={11}, | ||
number={3}, | ||
pages={3979-3993}, | ||
doi={10.1109/JIOT.2023.3298992} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
*.iml | ||
.gradle | ||
/local.properties | ||
/.idea/caches | ||
/.idea/libraries | ||
/.idea/modules.xml | ||
/.idea/workspace.xml | ||
/.idea/navEditor.xml | ||
/.idea/assetWizardSettings.xml | ||
.DS_Store | ||
/build | ||
/captures | ||
.externalNativeBuild | ||
.cxx | ||
local.properties | ||
build/ | ||
.idea | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
plugins { | ||
id 'com.android.application' | ||
id 'org.jetbrains.kotlin.android' | ||
} | ||
|
||
android { | ||
compileSdk 33 | ||
|
||
defaultConfig { | ||
applicationId "com.iamywang.sampler" | ||
minSdk 29 | ||
targetSdk 33 | ||
versionCode 22070709 | ||
versionName "1.1.20220707" | ||
|
||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | ||
externalNativeBuild { | ||
cmake { | ||
cppFlags '-std=c++11' | ||
} | ||
} | ||
|
||
ndk { | ||
moduleName "app" | ||
abiFilters "arm64-v8a" | ||
} | ||
} | ||
|
||
buildTypes { | ||
release { | ||
minifyEnabled true | ||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_1_8 | ||
targetCompatibility JavaVersion.VERSION_1_8 | ||
} | ||
kotlinOptions { | ||
jvmTarget = '1.8' | ||
} | ||
externalNativeBuild { | ||
cmake { | ||
path file('src/main/cpp/CMakeLists.txt') | ||
version '3.18.1' | ||
} | ||
} | ||
buildFeatures { | ||
viewBinding true | ||
} | ||
} | ||
|
||
dependencies { | ||
|
||
implementation 'androidx.core:core-ktx:1.8.0' | ||
implementation 'androidx.appcompat:appcompat:1.4.2' | ||
implementation 'com.google.android.material:material:1.6.1' | ||
implementation 'androidx.constraintlayout:constraintlayout:2.1.4' | ||
testImplementation 'junit:junit:4.13.2' | ||
androidTestImplementation 'androidx.test.ext:junit:1.1.3' | ||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' | ||
implementation 'com.squareup.okhttp3:okhttp:4.9.3' | ||
implementation 'com.alibaba:fastjson:1.2.83' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Add project specific ProGuard rules here. | ||
# You can control the set of applied configuration files using the | ||
# proguardFiles setting in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
24 changes: 24 additions & 0 deletions
24
app/app/src/androidTest/java/com/iamywang/sampler/ExampleInstrumentedTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.iamywang.sampler | ||
|
||
import androidx.test.platform.app.InstrumentationRegistry | ||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
|
||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
import org.junit.Assert.* | ||
|
||
/** | ||
* Instrumented test, which will execute on an Android device. | ||
* | ||
* See [testing documentation](http://d.android.com/tools/testing). | ||
*/ | ||
@RunWith(AndroidJUnit4::class) | ||
class ExampleInstrumentedTest { | ||
@Test | ||
fun useAppContext() { | ||
// Context of the app under test. | ||
val appContext = InstrumentationRegistry.getInstrumentation().targetContext | ||
assertEquals("com.iamywang.sampler", appContext.packageName) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
package="com.iamywang.sampler"> | ||
|
||
<uses-permission android:name="android.permission.INTERNET" /> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:dataExtractionRules="@xml/data_extraction_rules" | ||
android:extractNativeLibs="true" | ||
android:fullBackupContent="@xml/backup_rules" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:networkSecurityConfig="@xml/network_security_config" | ||
android:roundIcon="@mipmap/ic_launcher_round" | ||
android:supportsRtl="true" | ||
android:theme="@style/Theme.AppCompat.Light.NoActionBar" | ||
tools:targetApi="33"> | ||
<activity | ||
android:name=".MainActivity" | ||
android:exported="true"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
|
||
<service android:name=".BackService" /> | ||
|
||
</application> | ||
|
||
</manifest> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# For more information about using CMake with Android Studio, read the | ||
# documentation: https://d.android.com/studio/projects/add-native-code.html | ||
|
||
# Sets the minimum version of CMake required to build the native library. | ||
|
||
cmake_minimum_required(VERSION 3.18.1) | ||
|
||
# Declares and names the project. | ||
|
||
project("sampler") | ||
|
||
# Creates and names a library, sets it as either STATIC | ||
# or SHARED, and provides the relative paths to its source code. | ||
# You can define multiple libraries, and CMake builds them for you. | ||
# Gradle automatically packages shared libraries with your APK. | ||
|
||
add_library( # Sets the name of the library. | ||
sampler | ||
|
||
# Sets the library as a shared library. | ||
SHARED | ||
|
||
# Provides a relative path to your source file(s). | ||
native-lib.cpp) | ||
|
||
# Searches for a specified prebuilt library and stores the path as a | ||
# variable. Because CMake includes system libraries in the search path by | ||
# default, you only need to specify the name of the public NDK library | ||
# you want to add. CMake verifies that the library exists before | ||
# completing its build. | ||
|
||
find_library( # Sets the name of the path variable. | ||
log-lib | ||
|
||
# Specifies the name of the NDK library that | ||
# you want CMake to locate. | ||
log) | ||
|
||
# Specifies libraries CMake should link to your target library. You | ||
# can link multiple libraries, such as libraries you define in this | ||
# build script, prebuilt third-party libraries, or system libraries. | ||
|
||
target_link_libraries( # Specifies the target library. | ||
sampler | ||
|
||
# Links the target library to the log library | ||
# included in the NDK. | ||
${log-lib}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// ============================================================================ | ||
// This file is part of EavesDroid. | ||
// | ||
// Author: iamywang | ||
// Date Created: Jan 27, 2024 | ||
// ============================================================================ | ||
#include <jni.h> | ||
#include <string> | ||
#include <sys/sysinfo.h> | ||
#include <sys/statvfs.h> | ||
#include <unistd.h> | ||
|
||
extern "C" JNIEXPORT jint JNICALL | ||
Java_com_iamywang_sampler_BackService_sysinfo_1procs(JNIEnv *env, jobject thiz) { | ||
struct sysinfo info{}; | ||
sysinfo(&info); | ||
return info.procs; | ||
} | ||
|
||
extern "C" JNIEXPORT jlong JNICALL | ||
Java_com_iamywang_sampler_BackService_statvfs_1f_1bavail(JNIEnv *env, jobject thiz) { | ||
struct statvfs st{}; | ||
statvfs("/sdcard", &st); | ||
return st.f_bavail; | ||
} | ||
|
||
extern "C" | ||
JNIEXPORT jlong JNICALL | ||
Java_com_iamywang_sampler_BackService_sysconf_1avphys_1pages(JNIEnv *env, jobject thiz) { | ||
return sysconf(_SC_AVPHYS_PAGES); | ||
} | ||
|
||
extern "C" | ||
JNIEXPORT jlong JNICALL | ||
Java_com_iamywang_sampler_BackService_statvfs_1f_1ffree(JNIEnv *env, jobject thiz) { | ||
struct statvfs st{}; | ||
statvfs("/sdcard", &st); | ||
return st.f_ffree; | ||
} | ||
|
||
extern "C" JNIEXPORT jlong JNICALL | ||
Java_com_iamywang_sampler_BackService_sysinfo_1freeram(JNIEnv *env, jobject thiz) { | ||
struct sysinfo info{}; | ||
sysinfo(&info); | ||
return info.freeram; | ||
} | ||
|
||
extern "C" JNIEXPORT jlong JNICALL | ||
Java_com_iamywang_sampler_BackService_sysinfo_1sharedram(JNIEnv *env, jobject thiz) { | ||
struct sysinfo info{}; | ||
sysinfo(&info); | ||
return info.sharedram; | ||
} | ||
|
||
extern "C" JNIEXPORT jlong JNICALL | ||
Java_com_iamywang_sampler_BackService_get_1avphys_1pages(JNIEnv *env, jobject thiz) { | ||
return get_avphys_pages(); | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.