MOUSELOGGER IN PYTHON ..πŸ€‘πŸ€‘

 Creating a mouse logger in Python ..

create a mouse.py file and mouse_log.txt file in the same directory ..


The code :

from pynput.mouse import Listener   # pip install pynput
import logging                      # pre-installed

logging.basicConfig(filename="mouse_log.txt", level=logging.DEBUG, format='%(asctime)s: %(message)s')

def on_move(x, y):
logging.info("Mouse moved to ({0}, {1})".format(x, y))

def on_click(x, y, button, pressed):
if pressed:
logging.info('Mouse clicked at ({0}, {1}) with {2}'.format(x, y, button))

def on_scroll(x, y, dx, dy):
logging.info('Mouse scrolled at ({0}, {1})({2}, {3})'.format(x, y, dx, dy))

with Listener(on_move=on_move, on_click=on_click, on_scroll=on_scroll) as listener:
listener.join()

And if you run the code ..

you could see where the mouse had moved in the mouse_log.txt


*see the source code for the first flag ..

* click the links in the lines 14,15 or 16 ..

* You can find the flags in those pages ..

Comments

Popular posts from this blog

Testing insecure web server configurations ...