Innoctf: 'Hex64' 'R' "" '/N' '' 'Innoctf (' 'Base64' 'Hex'
Innoctf: 'Hex64' 'R' "" '/N' '' 'Innoctf (' 'Base64' 'Hex'
Innoctf: 'Hex64' 'R' "" '/N' '' 'Innoctf (' 'Base64' 'Hex'
Hex64
Download the the attachment
it is a big file name Hex64 with text in it. one can easily recognize by Looking at it that its a Base64.
decode using : cat Hex64 | base64 -d in terminal gives us a hex which decoded to base64 again
it seems like flag is encrypted multiple time with base64 then hex combination.
SO i write a python script to perform the task
my scipt was
f=open('Hex64','r')
c=""
for line in f:
c+=line.replace('\n','')
while 'InnoCTF{' not in c:
try:
h=c.decode('base64')
c = h.decode('hex')
except:
print c
break
print c
graphity
challenge at : nc 188.130.155.66 4999
connecting to port we get edges of a tree in (src,dest,distance) format and we also get point A and point B.
our task is to find the shortest path from A to B and send the distance back to server.
repeat this for several times to get the flag.
So i write python script with implementation of Dijkastra algorithm.
python3:
1/8
from collections import deque, namedtuple
from pwn import *
from ast import literal_eval as make_tuple
# we'll use infinity as a default distance to nodes.
inf = float('inf')
Edge = namedtuple('Edge', 'start, end, cost')
host='188.130.155.66'
port=4999
class Graph:
def __init__(self, edges):
# let's check that the data is right
wrong_edges = [i for i in edges if len(i) not in [2, 3]]
if wrong_edges:
raise ValueError('Wrong edges data: {}'.format(wrong_edges))
@property
def vertices(self):
return set(
sum(
([edge.start, edge.end] for edge in self.edges), []
)
)
@property
def neighbours(self):
neighbours = {vertex: set() for vertex in self.vertices}
for edge in self.edges:
neighbours[edge.start].add((edge.end, edge.cost))
return neighbours
while vertices:
current_vertex = min(
vertices, key=lambda vertex: distances[vertex])
2/8
vertices.remove(current_vertex)
if distances[current_vertex] == inf:
break
for neighbour, cost in self.neighbours[current_vertex]:
alternative_route = distances[current_vertex] + cost
if alternative_route < distances[neighbour]:
distances[neighbour] = alternative_route
previous_vertices[neighbour] = current_vertex
sh=remote(host,port)
sh.recvuntil('Lets start!\n')
while 1:
o=sh.recvuntil('\n')
p=((o.decode(encoding='utf-8', errors='strict')))
points=make_tuple(p)
print(points)
gra=[]
g1=[]
for p in points:
i='("'+chr(p[0]+ord('A'))+'", "'+chr(p[1]+ord('A'))+'", '+str(p[2])+')'
j='("'+chr(p[1]+ord('A'))+'", "'+chr(p[0]+ord('A'))+'", '+str(p[2])+')'
#print(i)
#print(make_tuple(i))
gra.append(make_tuple(i))
gra.append(make_tuple(j))
for p in points:
i='("'+chr(p[0]+ord('A'))+'", "'+chr(p[1]+ord('A'))+'", '+str(p[2])+')'
#j='("'+chr(p[1]+ord('A'))+'", "'+chr(p[0]+ord('A'))+'", '+str(p[2])+')'
#print(i)
#print(make_tuple(i))
g1.append(make_tuple(i))
#gra.append(make_tuple(j))
print(gra)
graph = Graph(gra)
o=(sh.recvuntil('\n').decode(encoding='utf-8', errors='strict')).split(' ')
#print(int(o[4]),int(o[7]))
src=chr(ord('A')+int(o[4]))
dst=chr(ord('A')+int(o[7]))
#print(src,dst)
path=(graph.dijkstra(src,dst))
print(path)
a=path.popleft()
distance=0
for e in g1:
if e[0]==src and e[1]==dst:
distance=e[2]
if distance > 0:
print(distance)
else:
while len(path)!=0:
b=path.popleft()
for e in gra:
if e[0]==a and e[1]==b:
distance+=e[2]
break
a=b
#print(distance)
sh.sendline(str(distance))
print(sh.recv())
python2:
3/8
from collections import *
import re
import time
from pwn import *
class Graph:
def __init__(self):
self.nodes = set()
self.edges = defaultdict(list)
self.distances = {}
nodes = set(graph.nodes)
while nodes:
min_node = None
for node in nodes:
if node in visited:
if min_node is None:
min_node = node
elif visited[node] < visited[min_node]:
min_node = node
if min_node is None:
break
nodes.remove(min_node)
current_weight = visited[min_node]
def process(string):
return str(string.count('(')) + '\n' + '\n'.join(map(lambda
t:t.replace(',',''), re.findall('[0-9 ]+,[0-9 ]+,[0-9 ]+', string)))
time.sleep(2)
boo = 0
while True:
if boo == 0:
u = p.recvuntil('Lets start!\n')
boo = 1
r = p.recv()
print (r)
if 'CTF' in r:
print (r)
open('flag1','w').write(str(r))
break
# if 'No!' in r:
# break
cp = r.split('\n')
print cp
4/8
print "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
if cp[0]=='Right!':
cp.remove('Right!')
if cp[0] == '':
r = p.recv()
cp = r.split('\n')
print cp
cp = cp[-3:-1]
print "Processing:", cp[0]
open('abc','w').write(str(process(cp[0])))
g = Graph()
f = open('abc','r')
for i in range(int(f.readline().strip())):
a, b, c = map(int, f.readline().strip().split())
# a, b = sorted([a, b])
if c == 0: continue
g.add_node(a)
g.add_node(b)
g.add_edge(a, b, c)
g.add_edge(b, a, c)
time.sleep(1)
although there are some issue with python3 algo... if found please fix
look_ahead
this challenge is in misc category
we get a pcapng file . Opening that in wireshark we get lots of packets info.
There were TCP,TLS,DNS,HTTP streams in file. Ichecked all stream using right click and follow option in wire shark.
Found intresting things in HTTP stream.
5/8
the host was : http://spbctf.ppctf.net:43317/
I was quite sure that i was on right track then a member of my team suggest its related to etags og html streams... After
checking for http streams, he was right... flags was in etags of all http streams b/w Src: 78.46.101.237, Dst: 192.168.0.5
6/8
you can see that etag in above two images combines for ‘In’
similarly follow the all http streams i get the flag InnoCTF{h34ders_h4ve_Secr3ts_To0_1296d}
It matches
We get a flag file with many flags in it plus a hint how the correct flag looks like for us it was
Flag is of 2 words
upper+nums+lower and lower+nums
7/8
a friend suggest me to use regex101
you can see regex used here is InnoCTF{[[:alnum:]]*_([[:lower:]]|[[:digit:]])*}
and at the right side we have a match InnoCTF{p0W3rFUl_r3g3xp} which was also the flag
back in time
we have a website
visiting it just show a backgroubd image and some text
looking at the source code i found assets folder which is reached using this
exploring it doen't get me anywhere. A friend told me its related to git and send me this link
command used
it downloaded all objects and then i use grep to find flag in those files
sorry for bad clarification as i used /tmp folder and everything wiped when the system rebooted and challenge sites are
down so i can't post actual screenshots of POC
8/8