我该如何编写 Linux TTY 嗅探器?
出于教育目的(并不是说任何人都应该关心这种练习背后的动机),我想编写一个可以从备用 ttys/ptys 读取/写入的程序。我读过论文(来自 20 世纪 90 年代)但不能采用他们在现代 Linux/glibc 上使用的实现
我希望有人在过去研究过这个(过去不太远),或者至少阅读他们可以提供的与之相关的文档,这将进一步启发我。
我还想知道(考虑到 Linux 没有流)这个练习是否必须通过可加载内核模块 [lkm] 来完成。
我有很多问题,并且可能对一些允许实现这些目标的基本意识形态存在误解,有人可以帮忙吗? :)
For educational purposes (not that anyone should care about the motivations behind such an exercise) I'd like to write a program that can read/write to/from alternate ttys/ptys. I've read papers (from the 1990s) but can't employ the implementation they use on modern Linux/glibc
I was hoping that someone had researched into this in the past (not too far in the past), or at least, read documentation pertaining to it, that they could provide, that would enlighten me further.
I also wonder if (considering the fact that Linux doesn't have streams) if this exercise must be done via a loadable kernel module [lkm].
I have many questions and probably a misunderstanding of some of the fundamental ideologies that allow such objectives to be put in place, could someone help? :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您不介意对一堆换行符进行排序,似乎效果很好。至于 TTY ..
tail -f /dev/vcsa1-6
Jessica
Seems to work pretty well if you don't mind sorting through a bunch of line breaks. As for the TTYs..
tail -f /dev/vcsa1-6
Jessica
Phrack 文章中的 linspy.c 代码是一个 Linux 内核模块。它不会针对现代内核进行编译,因为内部内核接口经常更改。
然而,它使用的基本方法是合理的(尽管它完全缺少 SMP 环境中正确性所需的锁定),并且通过应用足够的苦力,您应该能够将其移植到针对最新内核进行编译。
The
linspy.c
code in that Phrack article is a Linux kernel module. It won't compile against a modern kernel, because the internal kernel interfaces change frequently.However, the basic approach it uses is sound (although it is completely missing locking required for correctness in an SMP environment), and with the application of sufficient elbow grease you should be able to port it to compile against the latest kernel.
我两次通过 ssh 进入远程 Linux 机器,生成 /dev/pts/0 和 /dev/pts/1。从 0 开始,我可以打开 1 进行读取,从而窃取用户输入到 1 的所有内容。如果我希望他们看到他们的输入,我必须将其写回 /dev/pts/1。当然,他们的输入永远不会到达他们的 shell,所以我必须在我的末端(在 0 上)创建一个 shell 进程,并将其输入通过管道传输,然后将 shell 输出回 1。
这对我来说非常有用。当这一切发生时,我可以在任何我喜欢的地方保存在此过程中读取和写入的所有数据。
当然,除非您是 root 或正在窥探您拥有的会话,否则您无法执行此操作,但您只想将此用于教育目的,对吧?
I'm ssh'd into a remote linux box twice, producing /dev/pts/0 and /dev/pts/1. From 0, I can open 1 for read, thereby stealing all the stuff the user types to 1. If I want them to see their typing, I have to write it back to /dev/pts/1. Of course, their input never makes it to their shell, so I have to create a shell process at my end (on 0) and pipe their input it, then pipe the shell's out back to 1.
This all works great for me. While all this is going on, I can save off all the data read and written during the process wherever I like.
Of course, you can't do this unless you are root or are snooping on a session you own, but you only wanted this for educational purposes, right?