Intigriti -1337up CTF — Warmup Encoder writeup

1337 up CTF
from sympy import isprime, primeflag = '<redacted>'def Ord(flag):
x0r([ord(i) for i in flag])

def x0r(listt):
ff = []
for i in listt:
if isprime(i) == True:
ff.append(prime(i) ^ 0x1337)
else:
ff.append(i ^ 0x1337)
b1n(ff)
def b1n(listt):
ff = []
for i in listt:
ff.append(int(bin(i)[2:]))
print(ff)

if __name__ == "__main__":
Ord(flag)
'''
OUTPUT :
[1001100000110, 1001100000100, 1001100000100, 1001100000000, 1001101100010, 1001101100111, 1001101001100, 1001101001111, 1001100000111, 1001101000101, 1001101101000, 1001100000011, 1001101011001, 1001101110011, 1001101101000, 1001101110101, 1001101011110, 1001101011001, 1001100000011, 1001011001010, 1001101100101, 1001101001110, 1001101101000, 1001101110010, 1001101011001, 1001001111100, 1001100000111, 1001101010011, 1001100000100, 1001101000101, 1001101101000, 1001100000011, 1001101000101, 1001100000100, 1001101101000, 1001101000011, 1001101111111, 1001100000100, 1001101101000, 1001101100000, 1001100000100, 1001100000011, 1000101111100, 1001100000100, 1001111000110, 1001101000011, 1001101101000, 1001100001111, 1001100000111, 1001100000000, 1001100001110, 1001100000111, 1001100000000, 1001111000110, 1001100000001, 1001101001010]
'''
ff = []
for i in flag:
w = '0b' + str(i)
ff.append(int(w, 2))
 ff1 = []
for i in input:
w = i ^ 0x1337
isthat = get_nth(w) #this returns n if w is nth prime
if isthat == None:
ff1.append(w)
else:
ff1.append(isthat)
 ori_flag = ''
for i in ff2:
ori_flag = ori_flag + chr(i)
print(ori_flag)
from sympy import isprime, primeflag = [1001100000110, 1001100000100, 1001100000100, 1001100000000, 1001101100010, 1001101100111, 1001101001100, 1001101001111, 1001100000111, 1001101000101, 1001101101000, 1001100000011, 1001101011001, 1001101110011, 1001101101000, 1001101110101, 1001101011110, 1001101011001, 1001100000011, 1001011001010, 1001101100101, 1001101001110, 1001101101000, 1001101110010, 1001101011001, 1001001111100, 1001100000111, 1001101010011, 1001100000100, 1001101000101, 1001101101000, 1001100000011, 1001101000101, 1001100000100, 1001101101000, 1001101000011, 1001101111111, 1001100000100, 1001101101000, 1001101100000, 1001100000100, 1001100000011, 1000101111100, 1001100000100, 1001111000110, 1001101000011, 1001101101000, 1001100001111, 1001100000111, 1001100000000, 1001100001110, 1001100000111, 1001100000000, 1001111000110, 1001100000001, 1001101001010]# reverse of b1n()
def rev_b1n(flag):
ff = []
for i in flag:
w = '0b' + str(i)
ff.append(int(w, 2))
rev_x0r(ff)
# reverse of x0r()
def rev_x0r(input):
ff1 = []
for i in input:
w = i ^ 0x1337
isthat = get_nth(w)
if isthat == None:
ff1.append(w)
else:
ff1.append(isthat)
rev_Ord(ff1)
# Returns i if num is ith prime, None otherwise
def get_nth(num):
for i in range(1,200):
if prime(i) == num:
return i
# reverse of rev_0rd()
def rev_Ord(ff2):
ori_flag = ''
for i in ff2:
ori_flag = ori_flag + chr(i)
print(ori_flag)
if __name__ == "__main__":
rev_b1n(flag)

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Subhajit

Subhajit

InfoSec researcher, and a little bit developer.