zoukankan      html  css  js  c++  java
  • linux连接远程桌面

    #!/usr/bin/env python3
    #-*-encoding:utf-8-*-
    
    import re
    import os
    import urllib.request, urllib.parse, urllib.error
    import urllib.request, urllib.error, urllib.parse
    import http.cookiejar
     
    filename = '/tmp/cookie.txt'
    
    cookie = http.cookiejar.MozillaCookieJar(filename)
    opener = urllib.request.build_opener(urllib.request.HTTPCookieProcessor(cookie))
    postdata = urllib.parse.urlencode({'username' : 'username',  'userpwd' : 'password'}).encode(encoding='UTF8')
    
    loginUrl = 'http://xxxx/login'
    
    result = opener.open(loginUrl,postdata)
    
    cookie.save(ignore_discard=True, ignore_expires=True)
    
    gradeUrl = 'http://xxxx'
    
    result = opener.open(gradeUrl)
    
    
    '''以上是抓取网页数据,下面是筛选地址'''
    
    
    file = result.read().decode('utf-8')
    r = file.partition('所有已启用且异常')
    file = r[2]
    
    p=re.compile('[a-f0-9]{2}:[a-f0-9]{2}:[a-f0-9]{2}:[a-f0-9]{2}:[a-f0-9]{2}:[a-f0-9]{2}')
    list_mac = p.findall(file)
    p=re.compile('[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}:[0-9]{4,5}')
    list_ip = p.findall(file)
    p=re.compile('秘密')
    list_user = p.findall(file)
    ip_user = list(zip(list_ip, list_user))
    name = dict(zip(list_mac, ip_user))
    for i in name.values():
        user = i[1]
        ip = i[0]
        os.environ['user'] = str(user)
        os.environ['ip'] = str(ip)
        os.system('rdesktop -u ${user} -p password -a 16 -r clipboard:PRIMARYCLIPBOARD ${ip} &')
  • 相关阅读:
    python_ 学习笔记(hello world)
    python_ 学习笔记(运算符)
    MySQL-联合查询
    MySQL-date和datetime
    python_ 学习笔记(基本数据类型)
    python_ 学习笔记(基础语法)
    Visaul Studio 常用快捷键的动画演示
    IIS日志-网站运维的好帮手
    浅谈反射机制
    SQL Server 数据库优化文章
  • 原文地址:https://www.cnblogs.com/hygs/p/5464588.html
Copyright © 2011-2022 走看看