Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from __future__ import division
- import math, string, socket, random, Image
- class NioSock:
- def __init__(self):
- self.id = 0
- self.conn = socket.socket();
- self.conn.connect(("207.115.84.38", 8009))
- self.conn.setblocking(0)
- self.onConnect()
- def send_str(self, str):
- self.send_raw(str + "\x00")
- def send_raw(self, data):
- #self.printData(data, False)
- self.conn.send(data);
- def update(self):
- try: data = self.conn.recv(1024)
- except socket.error: pass
- else:
- #self.printData(data, True)
- self.onRecv(data)
- @staticmethod
- def i2s(data, _len):
- ret = ""
- multiplier = 0
- v = data
- _pow = math.pow(127, _len - 1)
- it = 1
- while (it <= _len):
- multiplier = int(math.floor(v / _pow))
- v -= multiplier * _pow
- ret += chr(multiplier + 1)
- if (it != _len):
- _pow /= 127
- it += 1
- return ret
- @staticmethod
- def s2i(data):
- ret = 0
- multiplier = 1
- it = len(data) - 1
- while (it >= 0):
- ret += (ord(data[it]) - 1) * multiplier
- multiplier *= 127
- it -= 1
- return ret
- @staticmethod
- def rgb(r, g, b):
- return 65536 * r + 256 * g + b
- def randrgb(self):
- return self.rgb(random.randint(0, 255), random.randint(0, 255), random.randint(0, 255))
- def onConnect(self):
- self.loginstep = 0
- self.send_str("<policy-file-request/>")
- def dot(self, size, color, x, y):
- Color = self.i2s(color, 4)
- X = self.i2s(x, 3)
- Y = self.i2s(y, 3)
- self.send_raw("\x61\x01\x01\x09" + chr(size+1+3) + Color + X + Y + self.i2s(x+1, 3) + self.i2s(y+1, 3) + "\x00")
- def printData(self, data, incoming):
- n = 16
- chunks = [data[i:i+n] for i in range(0, len(data), n)]
- print((incoming and "RECV" or "SEND") + ": " + str(len(data)) + " bytes")
- for chunk in chunks:
- print(" ".join("{:02x}".format(ord(c)).upper() for c in chunk).ljust(16*2 + 15, " ") + " " + "".join((c in string.printable.replace("\x0A", "").replace("\x09", "")) and c or "." for c in chunk))
- print("")
- def onRecv(self, data):
- if (self.loginstep == 2):
- if (data.startswith("r")):
- self.ink = 9000 * (self.s2i(data[1: 5]) - 1000) / (2000000 - 1000)
- print("INK AVAILABLE: " + str(self.ink))
- print("\n")
- self.send_raw("\x00")
- self.doWork()
- else: self.login(data)
- def login(self, data):
- if (self.loginstep == 1):
- self.loginstep = 2
- it = 0
- pck = b""
- while (it < 7):
- pck += chr(ord("ayylmao"[it]) - (ord(data[it*2])-65))
- it += 1
- self.send_raw(pck + "\x00e\x00i\x00b\x01\x01\x01\x01\x07\x00")
- self.initWork()
- if (data.startswith("<cross-")):
- self.send_str("ayylmao")
- self.loginstep = 1
- def initWork(self):
- self.startX = 30000
- self.startY = 20000
- self.pSize = 10
- self.imageRGB = Image.open("creepy.jpg").convert("RGB")
- self.xIt = 0
- self.yIt = 0
- def doWork(self):
- _w, _h = self.imageRGB.size
- _x, _y, _z = self.imageRGB.getpixel((self.xIt * self.pSize, self.yIt * self.pSize))
- self.dot(self.pSize, self.rgb(_x, _y, _z), self.startX + self.xIt * self.pSize, self.startY + self.yIt * self.pSize)
- self.xIt += 1
- if (self.pSize * self.xIt >= _w):
- self.xIt = 0
- self.yIt += 1
- if (self.pSize * self.yIt >= _h):
- self.yIt = 0
- sock = NioSock()
- while True:
- sock.update()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement