new algo
This commit is contained in:
28
udod.py
28
udod.py
@@ -1,26 +1,30 @@
|
||||
import asyncio
|
||||
import base64
|
||||
import socket
|
||||
|
||||
def shift(b, s):
|
||||
r = b + s
|
||||
if r >= 256:
|
||||
r -= 256
|
||||
elif r < 0:
|
||||
r += 256
|
||||
return r
|
||||
|
||||
def shift_seq(seq, byte_shift):
|
||||
result = bytearray(seq)
|
||||
for i in range(len(seq)):
|
||||
for i in range(min(len(seq),128)):
|
||||
result[i] = (result[i] + byte_shift) & 0xff
|
||||
return result
|
||||
|
||||
|
||||
def encrypt(data):
|
||||
return shift_seq(data, 15)
|
||||
|
||||
|
||||
def decrypt(data):
|
||||
return shift_seq(data, -15)
|
||||
|
||||
|
||||
class Duplex:
|
||||
def __init__(self, s1, s1_remote, s1_transform,
|
||||
s2, s2_remote, s2_transform,
|
||||
loop, mtu):
|
||||
def __init__(self, s1, s1_remote, s1_transform, s2, s2_remote, s2_transform, loop, mtu):
|
||||
self.mtu = mtu
|
||||
self.loop = loop
|
||||
|
||||
@@ -31,11 +35,11 @@ class Duplex:
|
||||
print("Starting stream", rx.getsockname(), '>>', tx_addr)
|
||||
while True:
|
||||
data = await self.loop.sock_recv(rx, self.mtu)
|
||||
# print(rx.getsockname(),'>>', tx_addr, len(data),
|
||||
# data[:20].hex(), transform(data)[:20].hex())
|
||||
#print(rx.getsockname(),'>>', tx_addr, len(data), data[:20].hex(), transform(data)[:20].hex())
|
||||
await self.loop.sock_sendto(tx, transform(data), tx_addr)
|
||||
|
||||
|
||||
|
||||
async def main():
|
||||
rx = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
rx.setblocking(False)
|
||||
@@ -53,13 +57,11 @@ async def main():
|
||||
if addr in connections.keys():
|
||||
tx = connections[addr]
|
||||
else:
|
||||
connections[addr] = socket.socket(
|
||||
socket.AF_INET, socket.SOCK_DGRAM)
|
||||
connections[addr] = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
tx = connections[addr]
|
||||
tx.setblocking(False)
|
||||
tx.bind(tx.getsockname())
|
||||
Duplex(rx, addr, RX_ALGO, connections[addr],
|
||||
(TX_IP, TX_PORT), TX_ALGO, loop, RX_MTU)
|
||||
Duplex(rx, addr, RX_ALGO, connections[addr], (TX_IP, TX_PORT), TX_ALGO, loop, RX_MTU)
|
||||
|
||||
try:
|
||||
tx.sendto(TX_ALGO(data), (TX_IP, TX_PORT))
|
||||
@@ -75,7 +77,7 @@ if __name__ == '__main__':
|
||||
RX_ALGO = encrypt
|
||||
|
||||
TX_IP = "194.135.105.21"
|
||||
TX_PORT = 5005
|
||||
TX_PORT = 25565
|
||||
TX_ALGO = decrypt
|
||||
|
||||
asyncio.run(main())
|
||||
|
||||
Reference in New Issue
Block a user