-
Notifications
You must be signed in to change notification settings - Fork 4
/
makeChallenge.py
55 lines (45 loc) · 1.45 KB
/
makeChallenge.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
52
53
54
55
"""
filename: makeChallenge.py
Purpose: To automate the creation of challenges on the repository.
Usage: python3 makeChallenge.py <ChallengeName>
Return(s):
./<ChallengeName>
./<ChallengeName>/challenge
./<ChallengeName>/README.md
--> # <ChallengeName>
"""
import sys
import os
def usage():
print(f"Be sure to have a Challenge Name!")
print(f"Usage:")
print(f"python3 makeChallenge.py <ChallengeName>")
# Quick Function to make a file
makeFile = lambda file: open(file, "x")
# main -> Returns a standardized process for a single challenge
def main(challenge_name):
README = f"{challenge_name}/README.md"
# Creates `./<ChallengeName>`
os.mkdir(f"{challenge_name}")
# Creates `./<ChallengeName>/challenge`
os.mkdir(f"{challenge_name}/challenge")
# Creates `./<ChallengeName>/README.md`
makeFile(f"{README}")
with open(f"{README}", "r+") as f:
f.write(f"# {challenge_name}\n\n")
f.write(f"## Challenge Text\n")
f.write(f"* \n\n")
f.write(f"## Hint\n")
f.write(f"* \n\n")
f.write(f"## Solution\n")
f.write(f"* \n")
f.write(f"* Flag: `jctf{{}}`\n\n")
f.write(f"## Credit\n")
f.write(f"* Developed by [INSERT NAME HERE](INSERT GITHUB PROFILE LINK HERE)")
# Ensures that users are using the program correctly
if __name__ == "__main__":
try:
challenge_name = sys.argv[1]
main(challenge_name)
except:
usage()