openbased/c.py
2025-02-22 22:36:08 -05:00

63 lines
2.0 KiB
Python

import requests, os, time
# go get hokierux@@@!!!!
if not os.path.exists("hkt.png"):
r = requests.get("https://vtluug.org/hokietux.png")
with open("hkt.png", "wb") as f:
f.write(r.content)
#uisbt he so cute...
def run(thread, node, threads, nodes):
im = Image.open("./hkt.png")
im.thumbnail((500, int((500 * im.width)/im.height)))
tgt = "2602:f75c:c0::XXXX:YYYY:RRGG:BBAA"
xo = 0
yo = 0
xchunk = im.width // nodes
xrange = (xchunk * node, xchunk * node + xchunk)
ychunk = im.height // threads
yrange = (ychunk * thread, ychunk * thread + ychunk)
d = im.load()
for x in range(xrange[0], xrange[1]):
for y in range(yrange[0], yrange[1]):
c = d[x, y]
if c[-1] == 0: continue
c = [hex(i).replace("0x", "") for i in c]
cmap = ["RR", "GG", "BB", "AA", "XXXX", "YYYY"]
sx = hex(x + xo).replace("0x", "")
sy = hex(y + yo).replace("0x", "")
while len(sx) < 4: sx = "0"+sx
while len(sy) < 4: sy = "0"+sy
for i in range(len(c)):
cc = c[i]
while len(cc) < 2: cc = "0"+cc
c[i] = cc
c.extend([sx, sy])
sighted = tgt
for i in range(len(cmap)):
sighted = sighted.replace(cmap[i], c[i])
os.system("ping -c 1 -W .001 "+sighted+" > /dev/null")
time.sleep(0.001)
#print(x, y, sx, sy, sighted)
import subprocess, json, sys
with open("./nodez.json", "r") as f:
nodes = json.loads(f.read())
whoami = subprocess.check_output(["hostname"]).decode("ascii").split(".")[0].strip()
if not whoami in nodes.keys():
print("dyign", whoami, nodes.keys())
sys.exit(1)
print("running openbased on "+whoami+"... ^///.///^")
from PIL import Image
threads = nodes[whoami]["threads"]
import threading
for i in range(threads):
threading.Thread(target=run, args=(i, list(nodes.keys()).index(whoami), threads, len(nodes.keys()))).start()