preview

20210425235956573396.png
20210417050652008075.png

attention

1
2
3
4
chmod 777 wol
cp wol /usr/bin/wol
vi /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
#!/usr/bin/python3
# _*_ coding: utf-8 _*_

import socket, binascii, os, sys, requests, re


def 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__":
# TODO
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