Skip to content

Instantly share code, notes, and snippets.

@swt02026
Last active November 13, 2018 00:13
Show Gist options
  • Save swt02026/5d1404a93b5a7febe9f50826ff83fc57 to your computer and use it in GitHub Desktop.
Save swt02026/5d1404a93b5a7febe9f50826ff83fc57 to your computer and use it in GitHub Desktop.
from fontTools.ttLib import TTFont
from base64 import b64decode
from pyquery import PyQuery as pq
import requests
import re
d = pq('https://hidden-island-93990.squarectf.com/ea6c95c6d0ff24545cad')
plain = '()1*-+275639840'
font_bytes = d('style').text()
m=re.match(r'@.*base64,(.*)\'', font_bytes)
font_bytes = b64decode(m.group(1))
open('b.ttf','wb').write(font_bytes)
font = TTFont('b.ttf')
font._getGlyphNamesFromCmap()
a=font.getGlyphSet()
k=a.keys()
k.remove('.notdef')
print font.getGlyphNames()
def getFeature(i):
global a
if hasattr(a[i]._glyph,'xMax'):
return (a[i]._glyph.xMax, a[i]._glyph.xMin, a[i]._glyph.yMax, a[i]._glyph.yMin, i)
return None
b=list(map(getFeature, k))
b.sort()
c = dict(zip(map(lambda i : i[4], b),plain))
p_tag = ''.join(d('p').text().split())
token = d("input[name='token']").attr('value')
g = eval(''.join([c[i] for i in p_tag]))
r=requests.post('https://hidden-island-93990.squarectf.com/ea6c95c6d0ff24545cad', {'answer':str(g), 'token':token})
print r.text
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment