Skip to content

Commit cba95f5

Browse files
committedFeb 21, 2022
init: Add basic CTF tooling
Signed-off-by: Sam Stuewe <[email protected]>
0 parents  commit cba95f5

File tree

6 files changed

+759
-0
lines changed

6 files changed

+759
-0
lines changed
 

‎LICENSE

+674
Large diffs are not rendered by default.

‎Makefile

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
MKDIR = mkdir -p --
2+
NEXT ?= $(shell find . -type d -iname '[0-9][0-9][0-9]' -printf '%f\n' | sort -rn | awk '{printf "%03d", $$1 + 1; exit}')
3+
4+
PROBLEMS = $(shell find . -maxdepth 1 -type d -regex '.*[0-9]+')
5+
6+
.PHONY: all clean next
7+
8+
all:
9+
(for i in $(PROBLEMS); do (pushd "$$i"; $(MAKE)); done)
10+
11+
clean:
12+
(for i in $(PROBLEMS); do $(MAKE) -C $$i clean; done)
13+
14+
next:
15+
$(MKDIR) $(NEXT)
16+
cp skel/mk $(NEXT)/Makefile
17+
cp skel/cxx $(NEXT)/main.cxx
18+
cp skel/hxx $(NEXT)/main.hxx
19+
20+
$(V).SILENT:

‎README.md

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Self-paced CTF Tooling
2+
3+
Self-paced CTFs (like [Project Euler](https://projecteuler.net/), [cryptohack](https://cryptohack.org/), etc.) can be excellent source of skills-honing and practice, the process around diving in can sometimes be daunting.
4+
5+
This repository includes the skeleton I use as tooling to begin/keep working on a CTF.
6+
In particular, this tooling was initially created while going through Project Euler using C++; however, it should be (and has been) easily adapted for other languages/CTFs.
7+
8+
# Usage
9+
10+
```console
11+
$ make NEXT=001 next # NEXT defaults to the numeric successor of the highest-numbered directory in $PWD
12+
$ cd 001
13+
$ make edit # launch editor with all relevant files open
14+
```
15+
16+
To modify this for another language, you'll need to update `skel` to include the appropriate set of files, and `skel/mk` to reflect the rules you'd like to start with (e.g., replacing the recipes for your language).
17+
18+
# Status
19+
20+
This code was all made purely to make CTFs more pleasant for myself; it doesn't include any helpful tooling to set it up for other languages (adaptations must currently be done manually).
21+
However, I will keep updating it as my tooling wants grow; and I will happily accept changes from anyone wanting to make it more flexible.

‎skel/cxx

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#include "main.hxx"
2+
3+
signed
4+
main () {
5+
6+
return 0;
7+
}

‎skel/hxx

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#if !defined(MAIN_HXX)
2+
#define MAIN_HXX
3+
4+
#pragma once
5+
6+
#include <fstream>
7+
#include <iostream>
8+
#include <string>
9+
#include <vector>
10+
11+
#endif

‎skel/mk

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
PROG := $(shell basename "$$PWD")
2+
3+
MKDIR ?= mkdir -p --
4+
RM := rm -rf --
5+
6+
CXX ?= g++
7+
CXXFLAGS ?= -g -ggdb -O0 -Wall -Wextra -Wpedantic -std=gnu++20
8+
LDFLAGS := #$(shell pkg-config --libs )
9+
10+
.PHONY: all run edit clean
11+
12+
all: $(PROG)
13+
14+
$(PROG): main.cxx main.hxx
15+
$(CXX) $(CXXFLAGS) -o $@ $< $(LDFLAGS)
16+
17+
run: $(PROG)
18+
./$(PROG)
19+
20+
edit:
21+
vis '+vsplit main.hxx' Makefile main.cxx
22+
23+
clean:
24+
$(RM) $(PROG)
25+
26+
$(V).SILENT:

0 commit comments

Comments
 (0)
Please sign in to comment.