may_ctf/tasks/jojo1/JoJo_exploit.py

71 lines
2.3 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import websocket as ws
a=open('glags.txt','r').read().split('\n')[:-1]
global c
c=ws.create_connection('wss://jojo1.ctfmay.sch9.ru/ws/')
c.send('b')
print('recieve:',c.recv())
c.send('b')
s=c.recv()
print('recieve:',s)
print('recieve:',c.recv())
print('recieve:',c.recv())
print('recieve:',c.recv())
print('recieve:',c.recv())
words=[s[s.find('хочу')+5:s.find('чтобы')-1],
s[s.find('чтобы')+6:s.find('а потом')-2],
s[s.find('а потом')+8:s.find('и, будучи')-1],
s[s.find('и, будучи')+33:s.find('тебе,')-1],
s[s.find('пытающийся')+11:s.find('!!!')]]
print('words in phrase:',words)
oidx=[a.index(words[i]) for i in range(5)]
print('indexes in dictionary:',oidx)
c.send('b')
s=c.recv()
print('recieve:',s)
print('recieve:',c.recv())
print('recieve:',c.recv())
print('recieve:',c.recv())
print('recieve:',c.recv())
words=[s[s.find('хочу')+5:s.find('чтобы')-1],
s[s.find('чтобы')+6:s.find('а потом')-2],
s[s.find('а потом')+8:s.find('и, будучи')-1],
s[s.find('и, будучи')+33:s.find('тебе,')-1],
s[s.find('пытающийся')+11:s.find('!!!')]]
print('words in phrase:',words)
idx=[a.index(words[i]) for i in range(5)]
print('indexes in dictionary:',idx)
d=[(idx[i]-oidx[i])%len(a) for i in range(5)]
print('differences:',d)
for i in range(5):
idx[i]+=d[i]
idx[i]%=len(a)
words[i]=a[idx[i]]
for i in range(1000):
c.send(f'Я хочу { words[0] } чтобы \
{ words[1] }, а потом { words[2] } и, будучи \
победителем, приказать { words[3] } тебе, ДжоДжо\
, так сильно пытающийся { words[4] }!!!')
s=c.recv()
print('recieve:',s)
print('recieve:',c.recv())
print('recieve:',c.recv())
print('recieve:',c.recv())
print('words in phrase:',words)
print('idxs:',idx)
for i in range(5):
idx[i]+=d[i]
idx[i]%=len(a)
words[i]=a[idx[i]]
c.send('h')
print('recieve:',c.recv())
print('recieve:',c.recv())
print('recieve:',c.recv())
print('recieve:',c.recv())
print('recieve:',c.recv())
print('recieve:',c.recv())
print('recieve:',c.recv())
print('recieve:',c.recv())