CTFd / ctfcli

ctfcli is a tool to manage Capture The Flag events and challenges
https://ctfd.io/
Apache License 2.0
165 stars 67 forks source link

Challenge cloning #141

Closed TPGamesNL closed 3 weeks ago

TPGamesNL commented 8 months ago

Implements challenge cloning functionality: allows you to pull challenges from a CTFd instance that are possibly not on your local environment yet. Will either create & add them if they don't exist locally, or update (mirror) them if they do exist locally.

The name of the directory where the challenge will be saved is formed with the challenge's category and name, with slugify (e.g. pwn/stuff). However, there is an option to instead prompt the user for the name of the directory. It will then ask the user for input on where to store the challenge (with the generated name as the default).

Some concerns regarding current implementation:

Closes https://github.com/CTFd/ctfcli/issues/6

ColdHeat commented 4 months ago

@TPGamesNL Could you possibly adapt this PR to work on top of the mirror command? Maybe something like ctf challenge mirror --all ?

ColdHeat commented 4 months ago

@MilyMilo I had a need for this capability and I assumed the mirror command would do it. What do you think would be a good way to combine this clone command with mirror?

ColdHeat commented 4 months ago

I just noticed this didn't pull flags from the remote CTFd instance as well.

MilyMilo commented 4 months ago

Overall I had a hard time coming up with a rationale for this, because I don't think we should reinforce a pattern for using CTFd to manage the ctfcli project - because that defeats the purpose of using ctfcli from the beginning. Mirror was meant for quick fixes during the event which you'd like to reflect in the project.

However I think this could be useful for converting challenges to ctfcli format, a case where you've run an event, it was a success, and now you want to convert it to a reproducible format. There would be still manual labor involved as you'd need to manually create repositories for challenges, or just throw the code inside the challenge subdirectory, but I agree this would provide a nice starting point.

So, I agree with @ColdHeat, I'd see this more as a switch to the mirror command, perhaps something like --create.

lukkymike commented 1 month ago

Has this been implemented in one way or another? I've just installed CTFCLI for the first time and attempting to clone or mirror my CTFd hosted instance to a local structure on my laptop and 'ctf challenge mirror' doesn't seem to mirror any challenges or create a folder structure even though it says 'Success! All Challenges mirrored!'.

ColdHeat commented 1 month ago

I believe the implementation of mirror only copies challenges which exist on both the remote and the local.

I think I like the idea of --create.

ColdHeat commented 3 weeks ago

@TPGamesNL Looks like I don't have access to modify your fork so I'll have to continue in a new branch here. If you want credit for the PR just allow collaborator access on the PR and I'll be able to update this to merge it in.

TPGamesNL commented 3 weeks ago

@ColdHeat sorry first of all for my lack of response, I wanted to update the PR but haven't found the time to do so. As I have opened the PR from an organisation's fork, I cannot allow you collaborator access. Feel free to continue this on a new branch and close this PR. Thank you for taking the time for this feature!