Python中的键盘记录器 [英] keylogger in Python

查看:298
本文介绍了Python中的键盘记录器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,我想2秒钟我可能在python中创建了一个键盘记录器

但是我还有一个主要的想法阻止我...... PYTHON。当我运行

程序时,我让python创建一个名为keylog2.log的文件,然后将所有在python IDE中按下/键入的键记录到该文件中。我想知道现在我知道如何隐藏或背景python,这样它就会记录所有在Python之外按下的键。

>
随便玩我的程序...但请在我的帖子上发布您的调查结果

...

####### ##############################################

class keylogger:

pass


keylogging = keylogger()

keylog = open(" keylog2.log" ;," w")

text = raw_input()


keylog.write(text)

keylog.close

keylog = open(" keylog2.log"," r")

keylog.read

解决方案

" Jay" < JA ***** @ gawab.com>写道:

好吧,我想2秒钟我可能在python中创建了一个键盘记录器
但是我还有一个主要的想法阻止我...... PYTHON。当我运行
程序时,我让python创建一个名为keylog2.log的文件,然后将所有在python IDE中按下/键入的键记录到该文件中。我现在想知道的是我如何隐藏或背景python,以便记录所有在Python之外按下的键。




你完全糊涂了,键盘记录器不能做那样的工作。

你为什么要记录按键?


30 2005年7月01:11:32 -0700,周杰伦 < JA ***** @ gawab.com>在comp.lang.python中声明

跟随:

好吧,我想2秒钟我可能在python中创建了一个键盘记录器


不,你所做的就是创建一个/用户模式/应用程序

读取ITS系统输入流(甚至不是字符 -

raw_input在输入< cr>之前不会返回,此时

你得到所有字符到那一点。)

但是我还有一个主要想法阻止我...... PYTHON。当我运行
程序时,我让python创建一个名为keylog2.log的文件,然后将所有在python IDE中按下/键入的键记录到该文件中。我现在想知道的是我如何隐藏或背景python,以便记录所有在Python之外按下的键。


一个键盘记录器,在最低级别,在

键盘驱动程序和OS调度程序之间注入(对于窗口系统,特别是

)。它必须是透明的 - 你的程序正在消耗

字符,这意味着它们在其他任何地方都不可用;关键记录器

必须复制来自

的键(可能是原始键码而不是字符)输入流,而不会阻止它们到达需要它们的普通

应用程序。这就是为什么,例如,Windows(NT)使用

< ctrl>< alt>< del>获取登录提示。键盘驱动程序的最低级别处理的键组合是

,并且绝不会将
传递到用户程序可以拦截它的位置 - 这意味着可以

不写登录捕获用于伪造Windows登录屏幕的程序。


执行密钥记录与操作系统有很大关系。在AmigaOS下,一个

会将高优先级的密钥处理程序注入到操作系统输入流中

chain(想要查看的优先级顺序程序的链接列表

输入)。记录器将在其输入端口上接收一个OS数据包,其中包含

的时间戳和密钥代码,可以记录它,然后将其返回给操作系统

以通过到链中的下一个程序(某些程序使用

流并且不传递它)。注入虚假事件也很容易 -

a程序可以注入,例如,其他

程序会响应的磁盘更改事件。


在Windows上......我不确定......第25页

Microsoft Windows第4版编程应用程序。可能是有用的

(也可能是一个更新的版本)。它显示了一些

系统调用AttachThreadInput()用于将程序的输入

流(本书的术语中的队列)链接到另一个程序,以便

收到相同的数据(我认为)。你是记录器必须在进程启动系统中加入

,以便它可以链接到

可能正在读取密钥的每个进程。


- ======================================== ========== ============<
wl *****@ix.netcom.com | Wulfraed Dennis Lee Bieber KD6MOG<
wu******@dm.net | Bestiaria支持人员<
========================================= ========= ============<
主页:< http://www.dm.net/~wulfraed/> <
溢出页面:< http://wlfraed.home.netcom.com/> <



哟,谢谢你的精彩输入。我想要创建一个基于python的键盘记录器的唯一原因是因为没有。只是一个有趣的项目...

但是我要对键盘驱动程序和东西做更多的研究

那样,并学习如何将我的python porgrams附加到

子流程,以便它在IDE中记录每个字符而不仅仅是

char。

thx

ok, i thought for 2 seconds i might have created a Keylogger in python
but i still have one major think stopping me... PYTHON. when i run the
program i have python create a file named keylog2.log and it then logs
all keys pressed/typed in the python IDE into that file. All i want to
know now is how do i hide or background python so that it will log all
the keys pressed outside of Python.

feel free to play around with my program... but please post ur findings
on my post...
################################################## ###
class keylogger:
pass

keylogging = keylogger()
keylog = open("keylog2.log", "w")
text = raw_input()

keylog.write(text)
keylog.close
keylog = open("keylog2.log", "r")
keylog.read

解决方案

"Jay" <ja*****@gawab.com> writes:

ok, i thought for 2 seconds i might have created a Keylogger in python
but i still have one major think stopping me... PYTHON. when i run the
program i have python create a file named keylog2.log and it then logs
all keys pressed/typed in the python IDE into that file. All i want to
know now is how do i hide or background python so that it will log all
the keys pressed outside of Python.



You are completely confused and keyloggers don''t work anything like that.
Why do you want to log keystrokes anyway?


On 30 Jul 2005 01:11:32 -0700, "Jay" <ja*****@gawab.com> declaimed the
following in comp.lang.python:

ok, i thought for 2 seconds i might have created a Keylogger in python
No, all you''ve done is create a /user mode/ application that
reads ITS system input stream (and not even character by character --
raw_input doesn''t return until a <cr> has been entered, at which point
you get all characters up to that point).
but i still have one major think stopping me... PYTHON. when i run the
program i have python create a file named keylog2.log and it then logs
all keys pressed/typed in the python IDE into that file. All i want to
know now is how do i hide or background python so that it will log all
the keys pressed outside of Python.

A keylogger, at the lowest level, injects itself between the
keyboard driver and the OS dispatcher (for windowing systems, in
particular). It has to be transparent -- your program is consuming the
characters meaning they are not available anywhere else; a key logger
has to "copy" the keys (probably raw key-codes and not characters) from
the input stream without blocking them from reaching the normal
application that want them. That''s why, for example, Windows (NT) uses
the <ctrl><alt><del> to get a log-in prompt. That key combination is
handled at the very lowest level of the keyboard driver, and NEVER
passes out to where a user program can intercept it -- meaning one can
not write a "login capture" program to fake a Windows login screen.

Doing key logging is highly OS dependent. Under AmigaOS, one
would inject a key handler at high-priority into the OS input stream
chain (a linked list of priority ordered programs that want to see
input). The logger would receive, on its input port, an OS packet with
the timestamp and key codes, could log it, and then return it to the OS
to be passed to the next program in the chain (some programs consume the
stream and don''t pass it on). It was also easy to inject fake events --
a program could inject, for example, disk-change events that other
programs would respond to.

On Windows... I don''t know for sure... Chapter 27 of
"Programming Applications for Microsoft Windows 4th Ed." might be of use
(may also be a more up-to-date version available too). It shows some
system call of AttachThreadInput() being used to link a program''s input
stream (queue in the book''s terminology) to another program so both
receive the same data (I think). You''re logger would have to hook into
the process start-up system so that it could link to every process that
might be reading keys.

-- ================================================== ============ <
wl*****@ix.netcom.com | Wulfraed Dennis Lee Bieber KD6MOG <
wu******@dm.net | Bestiaria Support Staff <
================================================== ============ <
Home Page: <http://www.dm.net/~wulfraed/> <
Overflow Page: <http://wlfraed.home.netcom.com/> <



yo, thanks for the great input. And the only reason i want to create a
python based keylogger is because there is none. Just a fun project...
But im gonna do some more research on the keyboard drivers and stuff
like that and to learn how to attach my python porgrams into the
sub-processes so that it would instead log every char instead of just
char in the IDE.
thx


这篇关于Python中的键盘记录器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆