diff --git a/main.py b/main.py index cf50562..19fe751 100644 --- a/main.py +++ b/main.py @@ -92,4 +92,56 @@ def ecsc(): # cattheflag() # imaginaryctf() # rootme() -# ecsc() \ No newline at end of file +# ecsc() + +def main(): + """ + Main function that prompts for a challenge URL and processes it based on the platform + """ + print("Welcome to the Writeup Generator!") + url = input("Please enter the challenge URL: ").strip() + + output_path = Path("./writeups") + + if "hackropole.fr" in url: + platform = HackropolePlatform() + elif "theblackside.fr" in url: + platform = TheBlackSidePlatform(cookies_file="./config/theblackside.cookies.json") + elif "crackmes.one" in url: + platform = CrackmesPlatform() + elif "crackmy.app" in url: + platform = CrackmyPlatform() + elif "cattheflag.org" in url: + platform = CatTheFlagPlatform(config_file="./config/catthefile.json") + elif "root-me.org" in url: + platform = RootMePlatform(config_file="./config/rootme.json") + elif "challenges.ecsc.eu" in url: + platform = ECSCPlatform() + elif "imaginaryctf.org" in url: + platform = ImaginaryCTFPlatform() + challenge_name = input("Please enter the challenge name: ").strip() + url = challenge_name.lower().replace(' ', '-') + else: + print("Unsupported platform or invalid URL") + return + + try: + generator = WriteupGenerator(platform, output_path) + + if isinstance(platform, (CatTheFlagPlatform, ImaginaryCTFPlatform)): + generator.fetch_challenges() + + generator.fetch_challenge(challenge_url=url) + + print("\nFound challenges:") + print(generator.challenges) + + print("\nGenerating writeup structure...") + generator.generate_writeup_structure(hugo_header=True, translated=True) + print("\nWriteup structure generated successfully!") + + except Exception as e: + print(f"An error occurred: {str(e)}") + +if __name__ == "__main__": + main() \ No newline at end of file