masrt200@home:~$

Ctflearn

RSA Beginner

Points:90

Description:

I found this scribbled on a piece of paper. Can you make sense of it? link

Solution:

Well, we have this file: rsa(1).txt, from the link.

ls

While the description doesn’t hint us much. The filename clearly suggests that its a RSA algorithm decryption challenge. And so does its contents…

cat

If you like maths and its your first time solving RSA, trust me this wikipedia will have you in tour, scratching the basics for some good weeks. OR you can simply use this tool I made D3cryptor.

Once you have gone through the installation, you know that we need to adjust the file format for my tool to accept inputs. Using nano here,

nano

Now simply giving the file to my tool D3crypt0r for decrypting this RSA;

cryptologer -d -R -f 'rsa (1).txt'

RSA

Well there you have it the flag is abctf{rs4_is_aw3s0m3} Cheers!

Q’s Cubes

Points:160

Descripion:

For Christmas, Q received an enormous set of cubes with letters and numbers on them. He decided that rearranging these cubes in a certain way would let him hide a secret message. The way he rearranges them is by folding all of them in half, over and over, until they form a single pillar. This is explained in more detail here: - example - Q leaves us this aerial view (your input) of his cubes here: problem :: What message was Q trying to convey?

Solution:

Was this the only problem with a 5.0 community rating, hmmm? Well this Q guy provides us with a folding algorithm to enwrap his messages. Taking the basic example, we are required to fold his initial cube of text firstly from top to bottom and then from left to right… and then repeat the entire process until we reach a single block of text. Reversing said block is our message.

cube

I wrote this python scipt to solve the problem…

import binascii

f=open('q2.txt','r')
line=f.readline()

a=[]
while line:
	a.append(list(line)[:-1])
	line=f.readline()

for i in a:
	print(i)

while len(a)>1:

	b=[]
	i=0
	while i<len(a)/2:
		n=[]
		j=0
		while j<len(a):
			n.append(a[len(a)-1-i][j]+a[i][j][::-1])
			j+=1
		b.append(n)
		i+=1

	b=b[::-1]

	for i in b:
		print(i)

	a=[]
	i=0
	while i<len(b):
		j=0
		n=[]
		while j<len(b):
			n.append(b[i][len(b)*2-1-j]+b[i][j][::-1])
			j+=1
		a.append(n[::-1])
		i+=1


	for i in a:
		print(i)

print('Final Message:',a[0][0][::-1])

print(binascii.unhexlify(a[0][0][::-1]))

Running it, you will notice that the final message is a hex-string, using binascii we get the result;

cube

cubigami is the flag.

Dawn’s Lawn

Points:60

Description:

Dawn has a magical lawnmower that she uses to mow her square lawn. As soon as she trims the grass, it starts growing quickly. Once the grass grows tall enough, it turns into a flower. Dawn has a lawn that has flowers, grass, and dirt. More details can be found here: examples - You can find Dawn’s actual lawn (your input) here: problem How many flowers are in Dawn’s lawn after she mows it completely?

##Solution:

What more can you say about a challenge that requires programming? Logic maybe?! If you are stuck on scripting the problem, here it is for you. Note: The third example given with the 15x15 lawn is probably incorrect. The correct answer is 70 flowers

f=open('dawn2.txt','r')
line=f.readline()
lawn=[]
lines=0

'''
rules
* : a flower
| : grass 4
/ : grass 3
- : grass 2
# : grass 1
_ : fertile dirt
. : infertile dirt
'''

order=['*','|','/','-','#','_','.']
while line:
	if '\n' in line:
		line=line[:-1]

	line=line.replace("\\",'#')
	lines+=1
	lawn.append(list(line))
	line=f.readline()

for i in lawn:
	print(i)

def grow(cn,p):
	loop_count=(cn-1)//lines
	z=0
	x=p
	while loop_count>0:
		if lawn[x][z]=='.':
			lawn[x][z]='.'
		else:
			if order.index(lawn[x][z])>0:
				lawn[x][z]=order[order.index(lawn[x][z])-1]
			else:
				lawn[x][z]=order[0]

		x=lines-1-p
		p=lines-1-p
		loop_count=loop_count-1
		z+=1

j=0
i=0
cn=0
while j<lines:
	if i==0:
		while i<lines:
			try:
				lawn[i][j]=order[order.index(lawn[i][j])+2]
			except:
				lawn[i][j]=order[6]
			cn+=1
			grow(cn,i)
			i+=1
	elif i==lines:
		while i>0:
			i-=1
			try:
				lawn[i][j]=order[order.index(lawn[i][j])+2]
			except:
				lawn[i][j]=order[6]
			cn+=1
			grow(cn,lines-1-i)
	j+=1

print('\n\n')
flowers=0
for k in lawn:
	for j in k:
		if j=='*':
			flowers+=1
	print(k)

print('Flowers',flowers)

I used ‘#’ instead of ‘/’ for better clarity… Running it we will get 194 as the solution.

Image Magic

Points:70

Description:

It looks like someone messed up my picture! Can anyone reorganize the pixels? The python module PIL (Python Imaging Library) might be useful! link

Update: I think whoever messed up my image took every column of pixels and put them side by side. Update: I think the width of the image was 304 before they messed with it.

Solution:

Another programming one, well Images are always fun. PIL module is your best friend for this. Here’s your script for free…

from PIL import Image

im=Image.open('out copy.jpg','r')

im1=Image.new('RGB',(92,304))
pixels=im1.load()

data=[]
j=0
while j<27968:
	column=[]
	for i in range(92):
		column.append(im.getpixel((j,0)))
		j+=1

	data.append(column)

for i in range(92):
	for j in range(304):
		pixels[i,j]=data[j][i]

im1.save("flag.jpg")
im1.show()

It pops up this image~

Image

flag{cool_right?} was all you needed.

OLD MEMORIES

Points:80

Description:

General RONX was cleaning up his cupboard last night, when he finds this archive out of the blue. He recalls that it was something about what he loves immensely. But the old General does not remember what it was. He sent this to me but I don’t know what to do with it. Can you find it out? problem

Solution:

The description itself gives us the hint ‘XNOR’ which gives us a rough idea as to what to do. The downloaded zip gives us two image files… well, what? We have to XOR or XNOR them and thats its…

Write a script?! Nah, using the Image Combiner of Stegsolve tool in this case…

stegsolve

Load the first image and then use Image combiner and load the second image.

flag

CTF{I_L0V3_PYTH0N} is the flag

Bit by Bit

Points:60

Description:

Tib Weis split his bit kit into a pit. They all fit, but his lack of wit made him miss the fact that it was lit! Tib wanted to admit that he was a misfit, but instead, he wants you commit and submit his refined tidbit. Tib also says, “Don’t quit!” - Tib’s tool kit for bit kits: detail - The original code to retransmit: YmluYXJ5cmVmaW5lcnl8JiY+PnxeXl4mJnx8fg== :: Did you solve it? What value was spit?

Solution:

Another scripting one, eh?! I seem to be loving these. The base64 string here gives binaryrefinery|&&»|^^^&&||~

If you followed the steps and logic properly, you shouldn’t face any problem. Silly mistakes and laziness are a different matter though.

import operator

string='binaryrefinery'
operations='|&&>|^^^&&||~'
bitwise={'|':operator.or_,'&':operator.and_,'>':operator.irshift,'^':operator.xor,'~':operator.invert}

start=[]
for i in string:
	start.append(ord(i)**3)
	
v0=start[0]
i=1
while i<len(string):
	j=i
	while j<len(string):
		char=operations[j-1]
		if char not in '~':
			v0=bitwise[char](v0,start[j])
		else:
			v0=bitwise[char](v0)
		j+=1
	i+=1

print(v0)

Without any cost again, the answer is 1498952. Peace!

Read in Color

Points:70

Description:

I was sent this picture by an unknown individual, and after putting it through a hex editor, I found nothing out of the ordinary hidden inside. A message came with the image saying, “Can You Read Me?” Could you help me figure out what the hidden message says?? I can’t figure out another way to read the image! Maybe Python’s Pillow library can help you out? problem

Solution:

I know it’s just me but these scripting challenges are becoming more easy and fun as I solve them. Anyway this one required joining the ascii characters of the RGB values of all the unique colours(taken once) as the appear

from PIL import Image
im=Image.open('color_img.png')
pixels=im.load()
colors=[]

for i in range(im.height):
	for j in range(im.width):
		a=pixels[j,i]
		if a not in colors:
			colors.append(a)
n=''
for i in colors:
	for j in i:
		n+=chr(j)
print(n)

#Pillow is great! flag{c0l0r_c0d3d} thats for you.

Adventures of Boris Ivanov Part 2

Points:80

Description:

The KGB agent Boris Ivanov found the place where one of the criminals was hiding for a long time. Unfortunately the criminal disappeared and more than that he shredded the piece of paper with important information. Help Boris to restore it. Here is a bin with the strips of paper: problem. Boris is an experienced agent and he instantly realized that the size of the sheet was 500x500

Solution:

CTFs takes the sleep out of you ~. Another fun challenge, just needed to align all image strips together. Running this…

from PIL import Image

im1=Image.new('RGB',(500,500))
pix=im1.load()

n=0
while n<500:
	im=Image.open('%i.png'%n)
	pixels=im.load()
	for j in range(500):
		pix[j,n]=pixels[j,0]

	n+=1

im1.save('soln.png')
im1.show()

You will get this…

adventure

Converting the hex string visible, 666c61677b7468335f4b47425f6c307633735f4354467d to ascii we get the flag: flag{th3_KGB_l0v3s_CTF}

Adventure of Boris Ivanov Part 1

Points:60

Description:

The KGB agent Boris Ivanov got information about an attempt to sell classified data. He quickly reacted and intercepted the correspondence. Help Boris understand what exactly they were trying to sell. Here is the interception data: link

Solution:

This one felt more of a challenge. Using stegsolve to its fullest… the image itself gives using hints like ‘KGB’~‘RGB’ and and the strip of pixelated data below tells us that we will need image manipulation using planes.

Changing the planes doesn’t give us anything… but there’s this offset thing too in stegsolve. It allows upto 1000 offsets so maybe we have a shot.

Found it on the second try; there it was clearly on offset 898…

f_flag

flag{d0nt_m3s5_w1th_th3_KGB} was the culprit.

Jumping Chain Hash

Points:100

Description:

Jim designed a new way to encode strings of purely lowercase letters through the Jumping Chain Hash (JCH). He tested it on several strings and was very happy with the result! Jim was so confident that he decided to encode his bitcoin account password, but then his decryption algorithm broke! Luckily, Jim documented the JCH here: - example - His encrypted password (your input) is here: problem - Can you help Jim recover his bitcoin account?

Solution:

There are a lot of rules which if you read, may send you into frenzy and you will end up with something like this…

import math
alphabet='abcdefghijklmnopqrstuvwxyz'
f=open('kip2.txt','r')
enc=f.read()
f.close()
length=(-1+int(math.sqrt(1+8*len(enc))))/4

n=[]
for i in range(len(enc)/length):
	n.append(enc[i*length:i*length+length])

block=n[int(math.floor(len(n)/2))]
#-----------Neccessary_Part------------------
N=[]

i=0
while i<length:
	prod=1
	chain=i
	for k in range(2): 
		pos=0
		for j in n[chain]:
			pos+=alphabet.index(j)

		prod*=pos
		chain=len(n)-1-chain

	N.append(prod)
	i+=1

orders=[]
i=1
index=len(N)//2
orders.append(N[index])
while i<len(N):
	b=i*(-1)**i
	index=index+b
	add=N[index]
	orders.append(add)
	i+=1

for i in orders:
	new=''
	for j in block:
		new+=alphabet[(alphabet.index(j)-i)%26]

	block=new

print(block)

Running this you will get the flag but its too much work. I realized this later on but you can just find the main block of text (seperated by comment in the code)… and bruteforce the caeser cipher on it to gain the final solution. It’s because we are just adding chunk to the entire block which means simply shifting it!

pile_peeps

Don’t do old school, try university level; check for the possibility of a solution and then solve… Alas, theblockchainwillconsumeyou feels happy!