WakeOnLan_Python 发表于 2021-04-17 | 更新于 2025-08-28
| 总字数: 544 | 阅读时长: 3分钟 | 浏览量:
preview
attention 1 2 3 4 chmod 777 wolcp wol /usr/bin/wolvi /usr/bin/wol wol / wol 1.1.1.1 / wol google.com
1 2 3 4 DestIp = "localhost" DestNatIp = "127.0.0.1" DestMacAddress = "B43E98F386A4" DestPort = 9
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 import socket, binascii, os, sys, requests, redef banaer (): os.system("clear" ) print ("\n\033[24;37;34m __ __ ____ \033[0m" ) print ("\033[24;37;32m \ \/ / | _ \ ___ ___ ___ \033[0m" ) print ("\033[24;37;36m \ \/ | |_) | / __| / _ \ / __| \033[0m" ) print ("\033[24;37;31m / \ | _ < \__ \ | __/ | (__ \033[0m" ) print ("\033[24;37;35m /_/\_\ |_| \_\ |___/ \___| \___| \n\033[0m" ) print ("\033[24;37;35m [ Help ] \n\033[0m" ) print ("\033[24;37;31m wol / wol 1.1.1.1 / wol google.com \033[0m" ) print ("\033[24;37;32m Edit wol「 DestIp DestPort DestMacAddress 」 \n\033[0m" ) def DpmainToIp (dest_ip ): web_status = requests.get("https://myssl.com/api/v1/tools/dns_query?qtype=1&host=%s&qmode=1" % dest_ip, timeout=5 ) try : dest_ip = (web_status.json()["data" ])["86" ][0 ]["answer" ]["records" ][0 ]["value" ] except : try : if (web_status.json()["data" ])["86" ][0 ]["answer" ]["records" ] == "null" : dest_ip = (web_status.json()["data" ])["86" ][0 ]["answer" ]["records" ][0 ]["value" ] except : print ("\033[24;37;31m Error : DpmainToIp > except > except \n\033[0m" ) exit() send_msg(dest_ip) def IpOrDomain (dest_ip ): check_ip = re.compile ( '^(1\d{2}|2[0-4]\d|25[0-5]|[1-9]\d|[1-9])\.(1\d{2}|2[0-4]\d|25[0-5]|[1-9]\d|\d)\.(1\d{2}|2[0-4]\d|25[0-5]|[' '1-9]\d|\d)\.(1\d{2}|2[0-4]\d|25[0-5]|[1-9]\d|\d)$' ) if check_ip.match (dest_ip): send_msg(dest_ip) else : DpmainToIp(dest_ip) def ip_init (dest_ip ): if len (sys.argv) == 2 : dest_ip = sys.argv[1 ] IpOrDomain(dest_ip) elif len (sys.argv) == 1 : IpOrDomain(dest_ip) else : print ("Domain error" ) def send_msg (DestIp ): udp_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) send_data = binascii.unhexlify('FF' * 6 + DestMacAddress * 16 ) udp_socket.sendto(send_data, (DestIp, DestPort)) udp_socket.sendto(send_data, (DestNatIp, DestPort)) print ("\033[24;37;35m Python Wol " + DestIp + " Successful! \033[0m" ) print ("\033[24;37;34m" ) if __name__ == "__main__" : DestIp = "localhost" DestNatIp = "127.0.0.1" DestMacAddress = "B43E98F386A4" DestPort = 9 banaer() ip_init(DestIp)
转载请声明来源:Blog Github
XRSec has the right to modify and interpret this article. If you want to reprint or disseminate this article, you must ensure the integrity of this article, including all contents such as copyright notice. Without the permission of the author, the content of this article shall not be modified or increased or decreased arbitrarily, and it shall not be used for commercial purposes in any way