Skip to main content
  1. Posts/

How to customize a CTFd Instance without changing the theme in order to show the challenges' difficulty

·337 words·2 mins
Lacroix Raphaël (Chepycou)
Author
Lacroix Raphaël (Chepycou)
I’m Raphaël LACROIX, a French computer scientist developping various applications in my free time ranging from definitely useless to somewhat usefull. I also do quite a lot of Capture the flag and cybersecurity challenges. I am currently looking for a Penetration Tester position in Toulouse (or in full remote).

Why this post ?
#

Because I was in the situation where I had a CTFd instance, no time, no way to change the theme, and wanted the challenges difficulty to appear. Since in our theme (that once again could not be changed) the tags were not shown on the challenges screen (but only when clicking on a specific challenge) I wanted to have a way to show the difficulty on top of having them properly sorted which I already covered last year. I searched online and could not find any out-of-the-box usable code so here this is.

TLDR : How do I do to have them displayed
#

  • define a difficulty scale. This year, mine was
    • “beginner”
    • “easy”
    • “medium”
    • “hard”
    • “insane”
  • use the code below while adapting your text, I have also included a color option although I ended up not using it since it clashed with the “challenge completed” styling.

Detailed explanation :
#

Log in to your CTFd console and click on the admin panel. Once there, get to the Theme section :

alt text

Once you’re there click on the Build CSS button and add the below code in the Theme Header.

alt text

Note that a simpler way would have been to set the difficulty as a number scale (1 to 5 or 1 to 10) and then just compare these after a cast as ints, but I had already the whole CTF with these 5 tags, so I went with the easiest route.
.tag-beginner::after {
    content: "Beginner";
}

/*
Use this if you want to oclor code your tags

.tag-beginner {  
    background-color: #22c55e;
    color: #ffffff;
}
*/

.tag-easy::after {
    content: "Easy";
}

.tag-medium::after {
    content: "Medium";
}
  
.tag-hard::after{
    content: "Hard";
}

.tag-insane::after {
    content: "Insane";
}

Then don’t forget to hit update

And as a bonus if you want to set metadata to have link previews that look like this :

alt text

You can use the same field and paste in here values generated by using https://opengraph.dev/

See you at the THCon or the THCon’s CTF