• 欢迎访问开心洋葱网站,在线教程,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站,欢迎加入开心洋葱 QQ群
  • 为方便开心洋葱网用户,开心洋葱官网已经开启复制功能!
  • 欢迎访问开心洋葱网站,手机也能访问哦~欢迎加入开心洋葱多维思维学习平台 QQ群
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏开心洋葱吧~~~~~~~~~~~~~!
  • 由于近期流量激增,小站的ECS没能经的起亲们的访问,本站依然没有盈利,如果各位看如果觉着文字不错,还请看官给小站打个赏~~~~~~~~~~~~~!

微信-python远程控制电脑

python 水墨上仙 2978次浏览

微信-python远程控制电脑

#!/etc/bin/env python
#-*-encoding=utf-8-*-
#auth@:dengyongkai
#blog@:blog.sina.com.cn/kaiyongdeng

import poplib,email
from email.header import decode_header
import smtplib
import time
import os,sys
import random

def accp_mail():
        try:
                p=poplib.POP3('pop.qq.com')
                p.user('用户名')
                p.pass_('密码')
                ret = p.stat()
        except poplib.error_proto,e:
                return 1
                print "Login failed:",e
                sys.exit(1)
#       for i in range(1,ret[0]+1):
#               str=s.top(i,0)
#               strlist=[]
#               for x in str[1]:
#                       try:
#                               strlist.append(x.decode())
#                       except:
#                               try:
#                                       strlist.append(x.decode('gbk'))
#                               except:
#                                       strlist.append(x.decode('big5'))
#                                       
#               mm = email.message_from_string('\n'.join(strlist))
#               sub=decode_header(mm['subject'])
#               if sub[0][1]:
#                       submsg = sub[0][0].decode(sub[0][1])
#               else:
#                       submsg = sub[0][0]
#
#               if submsg.strip()=='startpc':
#                       s.dele(i)
#                       return 0
#               
#       s.quit()
#       return 1
#
        for item in p.list()[1]:
                number,octets = item.split(' ')
#               print "Message %s: %sbytes"%(number,octets)
                lines = p.retr(number)[1]
                msg = email.message_from_string("\n".join(lines))
#       print msg.as_string()
                print msg.get_payload()
                if msg.get_payload()=="start\n\n":
                        return 0

def send_mail():
        try:
                handle = smtplib.SMTP('smtp.163.com', 25)
                handle.login('123x456f@163.com','密码')
                msg = "To: 598999792@qq.com\r\nFrom: 123x456f@163.com\r\nSubject: startpc \r\n\r\nstart\r\n"
                handle.sendmail('123x456f@163.com','598999792@qq.com', msg)
                handle.close()
                return 1
        except:
                return 0


if __name__=='__main__':
        while send_mail()==0:
                time.sleep(2)

        while 1:
                time.sleep(5)
                if accp_mail()==0:
                        os.system('shutdown -f -s -t 10 -c closing...')
                        #print "哈哈哈哈哈哈哈,成功啦!!!!!!"
                        break

        


开心洋葱 , 版权所有丨如未注明 , 均为原创丨未经授权请勿修改 , 转载请注明微信-python远程控制电脑
喜欢 (0)
加载中……