Python远程控制开机 Python黑魔法远程控制开机的实例
日常分享Python 人气:0想了解Python黑魔法远程控制开机的实例的相关内容吗,日常分享Python在本文为您仔细讲解Python远程控制开机的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点:Python远程控制开机,Python黑魔法,下面大家一起来学习吧。
python黑魔法~只要知道你电脑的ip,远程控制便可开机,嘻嘻《只能用来学习哦~不可恶作剧哈》
def wake_up(request, mac='DC-4A-3E-78-3E-0A'): MAC = mac BROADCAST = "192.168.0.255" if len(MAC) != 17: raise ValueError("MAC address should be set as form 'XX-XX-XX-XX-XX-XX'") mac_address = MAC.replace("-", '') data = ''.join(['FFFFFFFFFFFF', mac_address * 20]) # 构造原始数据格式 send_data = b'' # 把原始数据转换为16进制字节数组, for i in range(0, len(data), 2): send_data = b''.join([send_data, struct.pack('B', int(data[i: i + 2], 16))]) print(send_data) # 通过socket广播出去,为避免失败,间隔广播三次 try: sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) sock.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1) sock.sendto(send_data, (BROADCAST, 7)) time.sleep(1) sock.sendto(send_data, (BROADCAST, 7)) time.sleep(1) sock.sendto(send_data, (BROADCAST, 7)) return HttpResponse() print("Done") except Exception as e: return HttpResponse() print(e)
执行关机的命令即可
import os os.system('shutdown -s -t 00')
加载全部内容