diff --git a/README.md b/README.md index 6dacbf6..8ee638f 100644 --- a/README.md +++ b/README.md @@ -203,7 +203,7 @@ the ctftime urls will be used to aid in the generation of writeups with the `wri --- -### 🌹 description +### 🗣️ description ``` $ ret description [task-description] @@ -521,13 +521,6 @@ 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. 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 -5. uses the `"username"` from `~/.config/ret` to attribute to this writeup to you -6. inserts a date stamp for today's date using yyyy/mm/dd format - 🔗 https://github.com/rerrorctf/ret/blob/main/commands/writeup.go --- diff --git a/commands/category.go b/commands/category.go index 8c77d4c..5d62ed7 100644 --- a/commands/category.go +++ b/commands/category.go @@ -20,7 +20,7 @@ func init() { List: false, }, }, - SeeAlso: nil}) + SeeAlso: []string{"name", "description", "event", "remote", "writeup"}}) } func CategoryHelp() string { diff --git a/commands/description.go b/commands/description.go index 42e6341..9b64cfd 100644 --- a/commands/description.go +++ b/commands/description.go @@ -10,7 +10,7 @@ import ( func init() { Commands = append(Commands, Command{ Name: "description", - Emoji: "🌹", // a rose by any other name would smell as 1337 + Emoji: "🗣️", // a rose by any other name would smell as 1337 Func: Description, Help: DescriptionHelp, Arguments: []Argument{ @@ -20,7 +20,7 @@ func init() { List: false, }, }, - SeeAlso: nil}) + SeeAlso: []string{"name", "category", "event", "remote", "writeup"}}) } func DescriptionHelp() string { @@ -36,16 +36,16 @@ func displayCurrentTaskDescription() { return } - fmt.Printf("🌹 "+theme.ColorBlue+"%s"+theme.ColorReset+"\n", description) + fmt.Printf("🗣️ "+theme.ColorBlue+"%s"+theme.ColorReset+"\n", description) } func setCurrentTaskDescription(newDescription string) { oldDescription := util.GetCurrentTaskDescription() if len(oldDescription) > 0 { - fmt.Printf(theme.ColorGray+"🌹 changing description from: "+theme.ColorRed+"%s"+theme.ColorGray+" to: "+theme.ColorGreen+"%s"+theme.ColorReset+"\n", oldDescription, newDescription) + fmt.Printf(theme.ColorGray+"🗣️ changing description from: "+theme.ColorRed+"%s"+theme.ColorGray+" to: "+theme.ColorGreen+"%s"+theme.ColorReset+"\n", oldDescription, newDescription) } else { - fmt.Printf(theme.ColorGray+"🌹 setting description to: "+theme.ColorGreen+"%s"+theme.ColorReset+"\n", newDescription) + fmt.Printf(theme.ColorGray+"🗣️ setting description to: "+theme.ColorGreen+"%s"+theme.ColorReset+"\n", newDescription) } util.SetCurrentTaskDescription(newDescription) diff --git a/commands/event.go b/commands/event.go index 992ac57..8ad3df4 100644 --- a/commands/event.go +++ b/commands/event.go @@ -20,7 +20,7 @@ func init() { List: false, }, }, - SeeAlso: nil}) + SeeAlso: []string{"name", "category", "description", "remote", "writeup"}}) } func EventHelp() string { diff --git a/commands/name.go b/commands/name.go index 298656c..efd6700 100644 --- a/commands/name.go +++ b/commands/name.go @@ -20,7 +20,7 @@ func init() { List: false, }, }, - SeeAlso: nil}) + SeeAlso: []string{"event", "category", "description", "remote", "writeup"}}) } func NameHelp() string { diff --git a/commands/remote.go b/commands/remote.go index 02e1e30..44ac3bc 100644 --- a/commands/remote.go +++ b/commands/remote.go @@ -27,7 +27,7 @@ func init() { Default: "9001", }, }, - SeeAlso: nil}) + SeeAlso: []string{"name", "event", "category", "description", "writeup"}}) } func RemoteHelp() string { diff --git a/commands/writeup.go b/commands/writeup.go index 1025e86..785148e 100644 --- a/commands/writeup.go +++ b/commands/writeup.go @@ -1,12 +1,10 @@ package commands import ( - "encoding/json" "fmt" "log" "os" "ret/config" - "ret/data" "ret/theme" "ret/util" "time" @@ -19,20 +17,14 @@ func init() { Func: Writeup, Help: WriteupHelp, Arguments: nil, - SeeAlso: []string{"notes", "pwn", "capture", "ctftime"}}) + SeeAlso: []string{"name", "category", "event", "remote", "description", "pwn", "capture"}}) } func WriteupHelp() string { return "create a markdown writeup using a template with ret\n\n" + "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. 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" + - "5. uses the " + theme.ColorYellow + "`\"username\"`" + theme.ColorReset + " from " + theme.ColorCyan + "`~/.config/ret`" + theme.ColorReset + " to attribute to this writeup to you\n" + - "6. inserts a date stamp for today's date using yyyy/mm/dd format\n" + "there is a small window for a time-of-check/time-of-use race here - you have been warned!\n" } func Writeup(args []string) { @@ -44,57 +36,54 @@ func Writeup(args []string) { log.Fatalf("💥 "+theme.ColorRed+"error"+theme.ColorReset+": \"%s\" already exists!\n", filePath) } - urls := "" - if len(config.CtfTimeUrls) > 0 { - urls = config.CtfTimeUrls[0] + event := util.GetCurrentTaskEvent() + if len(event) == 0 { + event = "https://ctftime.link.goes.here" } - for _, ctfTimeUrl := range config.CtfTimeUrls[1:] { - urls += "\n" + name := util.GetCurrentTaskName() + if len(name) == 0 { + name = "NAME" } - if urls == "" { - urls = "https://ctftime.link.goes.here" + category := util.GetCurrentTaskCategory() + if len(category) == 0 { + category = "CATEGORY" } - flag := util.GetCurrentTaskFlag() - if len(flag) == 0 { - flag = config.FlagFormat + description := util.GetCurrentTaskDescription() + if len(description) == 0 { + description = "DESCRIPTION" } - notesStr := "" + ip := util.GetCurrentTaskIp() + port := util.GetCurrentTaskPort() - jsonData, err := os.ReadFile(config.NotesFileName) - if err == nil { - var notes data.Notes - err = json.Unmarshal(jsonData, ¬es) - if err == nil { - for _, note := range notes.Notes { - notesStr += fmt.Sprintf("%s\n\n", note.Note) - } - } + script, _ := os.ReadFile("./" + config.PwnScriptName) + flag := util.GetCurrentTaskFlag() + if len(flag) == 0 { + flag = config.FlagFormat } - script, _ := os.ReadFile("./" + config.PwnScriptName) - - name := config.Username - if name == "" { - name = "YOUR-NAME-GOES-HERE" + username := config.Username + if username == "" { + username = "YOUR-NAME-GOES-HERE" } date := time.Now().Format("2006/01/02") template := fmt.Sprintf( "%s\n\n"+ - "# NAME (CATEGORY)\n\n"+ - "%s"+ + "# %s (%s)\n\n"+ + "%s\n\n"+ + "nc %s %d\n\n"+ "## Solution\n\n"+ "```python\n"+ "%s"+ "```\n\n"+ "## Flag\n`%s`\n\n"+ - "%s %s\n", urls, notesStr, script, flag, name, date) + "%s %s\n", event, name, category, description, ip, port, script, flag, username, date) err = os.WriteFile(filePath, []byte(template), 0644)