Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
append(s^i)
s=s^i
append(s^j)
s=s^jp=8935533316664982385690426241789463156779334270200983340957286950060861311077151464930402912151709770833375547368974424564809135614170092179811531622097999
and
q=11379478034699907676633030046472807804044882783405443091999142030427354686298593670992789218031609011985520050382686352162426667346054932520656108554445759plain = b"To test the encryption service, encrypt this file with your company issued secret key and ensure that it results in the ciphertext.txt file."
import base64
enc = base64.b64decode(b"w4bDkMKDw6jDi8Ouw6JQw6jDh8OZwojCmMONw4nDnsKtwqnDk8OiwqLDosKdw6XDhsOVw6rDj8Oew5NcwpTDhMOiw4vCpcOYw5bDoFTCrcOHw6LCpsKUw6PDm8ONw4jClMOdw6TDosKYwpTDmMOjw53CpX/DicObwqHCqcOAw6fCrMKUw6bDpcOUw5jDmcOKwpvDocKVw5fDkcOZw5xTw4rDi8OlVMKaw43DnVPDmcOrw6XDlsOVw5nChsOvw5bCkcOof8Odw5xTw5HDi8OfwqnCpcOTw6xTw53Dq8KSw5XDi8OZwobDnsOXwqDDnMOEw6bDnMKYw5fDmsKawqjCscOTwpnCmcOdw6nDl8KP").decode().encode('latin-1')
def encrypt(num,key):
return (num + key) % 256
key = b""
for char in range(len(enc)):
for possible in range(256):
if enc[char] == encrypt(plain[char],possible):
key += bytes([possible])
break
print(key)
flagenc = base64.b64decode(b"w6TDgsOGw6jDjMO2w5RgwqTDi8OTw5Vmwr7CncOjZcKcwpLDmGjDnMKxw5/ClMOCwqTDlMOaw5tjw7E=").decode().encode('latin-1')
flag = b""
for char in range(len(flagenc)):
for possible in range(256):
if flagenc[char] == encrypt(possible,key[char]):
flag += bytes([possible])
break
print(flag)import socket
from Crypto.Util.number import inverse, GCD
from Crypto.PublicKey import RSA
IP = '95.216.233.106'
PORT = 62467
def dosolve(val):
global cur
if val in cur.keys():
return cur[val]
if val == 'q' or val == 'p':
# Prime solving
# Pretend the prime we want is q and the prime we have is p every time for simplicity.
if 'q' in cur.keys():
cur['p'] = cur['q']
if 'n' in cur.keys():
return cur['n'] // cur['p']
elif 'phi' in cur.keys():
return (cur['phi'] // (cur['p'] - 1)) + 1
elif 'e' in cur.keys() and 'd' in cur.keys():
key = RSA.construct((cur['n'],cur['e'],cur['d']))
primes = [key.p,key.q]
primes.remove(cur['p'])
return primes[0]
elif val == 'd':
cur['p'] = dosolve('p')
cur['q'] = dosolve('q')
phi = (cur['p'] - 1) * (cur['q'] - 1)
d = inverse(cur['e'],phi)
return d
elif val == 'n':
cur['p'] = dosolve('p')
cur['q'] = dosolve('q')
return cur['p'] * cur['q']
elif val == 'ct':
cur['n'] = dosolve('n')
return pow(cur['pt'],cur['e'],cur['n'])
elif val == 'pt':
cur['d'] = dosolve('d')
cur['n'] = dosolve('n')
return pow(cur['ct'],cur['d'],cur['n'])
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((IP, PORT))
s.setblocking(0)
buffer = b''
cur = {}
while True:
# Read until a prompt or line break
try:
chunk = s.recv(4096)
buffer += chunk
print(chunk.decode(), end='')
except BlockingIOError:
pass
if b'\n' not in buffer and not buffer.endswith(b': '):
continue
# Grab the oldest line
buffer = buffer.split(b'\n', 1)
if len(buffer) == 1:
line, buffer = buffer[0], b''
else:
line, buffer = buffer
# Llines start with [<code>]
if line[:1] != b'[':
continue
# Use slicing not indexing because indexing bytes returns ints
mode = line[1:2]
if mode == b'*':
...
elif mode == b'c':
cur = {}
elif mode == b':':
important = line[3:].decode().split(": ")
value = int(important[1])
cur[important[0].strip()] = value
elif mode == b'!':
print(line)
elif mode == b'?':
needed = line[3:].decode().split(": ")[0].strip()
if needed in cur.keys():
s.send(str(cur[needed]).encode() + b'\n')
continue
val = dosolve(needed)
print(val)
print(cur)
s.send(str(val).encode() + b'\n')
else:
...#script that will error but give flag
a = "41 36 37 27 35 38 55 30 40 47 35 34 43 35 29 32 38 37 33 45 39 30 36 27 32 35 36 52 72 54 39 42 30 30 58 27 37 44 72 47 28 46 45 41 48 39 27 27 53 64 32 58 43 23 37 44 32 37 28 50 37 19 51 53 30 41 18 45 79 46 40 42 32 32 46 28 37 30 43 31 26 56 37 41 61 68 44 34 26 24 48 38 50 37 27 31 30 38 34 58 54 39 30 33 38 18 33 52 34 36 31 33 28 36 34 45 55 60 37 48 57 55 35 60 22 36 38 34"
b = a.split(" ")
o = ""
for i in range(len(a)//4):
c = i * 4
d = int(b[c]) + int(b[c+1]) + int(b[c+2]) + int(b[c+3])
e = 255 - d
o += chr(e)
print(o)