Skip to content

during writeup; if there are multiple ctftime urls insert the rest as… #268

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ the writeup will be saved in a file called `writeup.md`
if a file called `writeup.md` already exists the command will abort
there is a small window for a time-of-check/time-of-use race here - you have been warned!

1. uses the first url from `"ctftimeurls"` to insert a url at the top of the writeup
1. uses the first url from `"ctftimeurls"` to insert a url at the top of the writeup. inserts the rest as comments if there are more than one
2. imports all notes taken with the `notes` command into the description area
3. creates a space for a python script and then imports the script created by `pwn` if it exists
4. imports the flag captured with the `capture` command if it exists
Expand Down
17 changes: 10 additions & 7 deletions commands/writeup.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func WriteupHelp() string {
"the writeup will be saved in a file called `writeup.md`\n\n" +
"if a file called `writeup.md` already exists the command will abort\n" +
"there is a small window for a time-of-check/time-of-use race here - you have been warned!\n\n" +
"1. uses the first url from " + theme.ColorYellow + "`\"ctftimeurls\"`" + theme.ColorReset + " to insert a url at the top of the writeup\n" +
"1. uses the first url from " + theme.ColorYellow + "`\"ctftimeurls\"`" + theme.ColorReset + " to insert a url at the top of the writeup. inserts the rest as comments if there are more than one\n" +
"2. imports all notes taken with the " + theme.ColorGreen + "`notes`" + theme.ColorReset + " command into the description area\n" +
"3. creates a space for a python script and then imports the script created by " + theme.ColorGreen + "`pwn`" + theme.ColorReset + " if it exists\n" +
"4. imports the flag captured with the " + theme.ColorGreen + "`capture`" + theme.ColorReset + " command if it exists\n" +
Expand All @@ -44,14 +44,17 @@ func Writeup(args []string) {
log.Fatalf("💥 "+theme.ColorRed+"error"+theme.ColorReset+": \"%s\" already exists!\n", filePath)
}

url := ""
urls := ""
if len(config.CtfTimeUrls) > 0 {
// we should do better than this
url = config.CtfTimeUrls[0]
urls = config.CtfTimeUrls[0]
}

if url == "" {
url = "https://ctftime.link.goes.here"
for _, ctfTimeUrl := range config.CtfTimeUrls[1:] {
urls += "\n<!-- " + ctfTimeUrl + " -->"
}

if urls == "" {
urls = "https://ctftime.link.goes.here"
}

flag, err := util.GetCurrentFlag()
Expand Down Expand Up @@ -91,7 +94,7 @@ func Writeup(args []string) {
"%s"+
"```\n\n"+
"## Flag\n`%s`\n\n"+
"%s %s\n", url, notesStr, script, flag, name, date)
"%s %s\n", urls, notesStr, script, flag, name, date)

err = os.WriteFile(filePath, []byte(template), 0644)

Expand Down