-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenfromctfd.py
51 lines (39 loc) · 928 Bytes
/
genfromctfd.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import json
data = json.load(open('ctfd.json'))
# transform a title into urlsafe title
def title_to_url(title):
title = title.lower()
l = []
for c in title:
if c.isalpha():
l.append(c)
elif c.isnumeric():
l.append(c)
else:
l.append('-')
return ''.join(l)
myformat = """<a name="%s"></a>
## %s
Description:
```
%s
```"""
mardown_format = """* [%s](#%s)"""
markdown_table = []
s = []
for chall in data['data']:
title = chall['name']
points = chall['value']
solves = chall['solves']
category = chall['category']
if category != 'Web':
continue
url = title_to_url(title)
title = f'{title} ({points} pts, {solves} {"solve" if solves == 1 else "solves"}) - {category}'
s.append(url)
markdown_table.append(
mardown_format % (title, url)
)
print(myformat % (url, title, ''))
print()
print('\n'.join(markdown_table))