-
Notifications
You must be signed in to change notification settings - Fork 7
/
alive_logger.py
executable file
·55 lines (51 loc) · 1.83 KB
/
alive_logger.py
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
#!/usr/bin/python3
import socket
import select
import time
import os
import pathlib
import time
path = pathlib.Path(__file__).parent.resolve()
os.chdir(path)
print ("started in", os.getcwd())
#sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) # UDP
html = """
<html>
[DA]
</html>
"""
#sock.bind(("0.0.0.0", 59999))
while True:
print(int(time.time()%60))
if int(time.time()) % 300 == 0:
print("unpacking")
os.system("curl -s -X GET \"https://filebin.net/archive/ehf5e4bfzof8m18m/zip\" --output ./RAM/filebin.zip")
os.system("unzip -o RAM/filebin.zip -d public/local_links/ 2> RAM/unzip.out")
os.system("rm RAM/filebin.zip")
os.system("rm RAM/unzip.out")
time.sleep(1)
"""if sock in select.select( [sock], [], [], 1)[0]:
incoming_msg, addr=sock.recvfrom(37000)
# print "***", incomming_msg, "***"
# print incomming_msg.find("ether")
if incoming_msg.find(b"ether") > 0:
ip = incoming_msg[61:75]
mac = incoming_msg[14:31]
else:
mac = incoming_msg[38:55]
ip = incoming_msg[58:72]
print (time.ctime(), "MAC:", mac, "From:",addr)
# print "active IP:",ip
for_file = html.replace("[IP]",str(ip))
for_file += html.replace("[DA]", str(incoming_msg))
# for_file += "\n"+incomming_msg
filename = "./public/local_links/"+mac+".html"
for_file += "\n"+"Source:"+str(addr)
# print "filename:",filename
# print for_file
for_file.replace("\n", "<br>##")
try:
if len(mac) != 0:
open(filename, "w+").write(for_file)
except IOError:
print ("file missing", filename)"""