pingplace/pingplace.py

44 lines
No EOL
1 KiB
Python

from icmplib import *
from PIL import Image
def one_ping(socket, address):
request = ICMPRequest(
destination=address,
id=1,
sequence=1)
print("sending packet to %s" % address)
socket.send(request)
# settings
x=0
y=0
width=512
hight=512
prefix="2a01:4f8:c012:f8e6:1"
# open socket
sock = ICMPv6Socket()
# open image
with Image.open("image.jpg") as imgraw:
img = imgraw.resize((width, hight))
# generate IP list
ips=[]
for w in range(width):
for h in range(hight):
xcoord=x+w
xcoord=f"{xcoord:#05x}".split('x')[-1]
ycoord=hex(y+h).split('x')[-1]
r=img.getpixel((x+w, y+h))[0]
g=img.getpixel((x+w, y+h))[1]
b=img.getpixel((x+w, y+h))[2]
colorr=f"{r:#04x}".split('x')[-1]
colorg=f"{g:#04x}".split('x')[-1]
colorb=f"{b:#04x}".split('x')[-1]
ip=prefix+xcoord+":"+ycoord+":"+colorr+":"+colorg+colorb
ips.append(ip)
for ip in ips:
#print(ip)
one_ping(sock, ip)
print("done with %s ips" % len(ips))