diff --git a/README.md b/README.md index 1bd22c4..76be2aa 100644 --- a/README.md +++ b/README.md @@ -417,6 +417,16 @@ $ ret share share task progress with ret +if you have captured a flag with the `capture` command this will be sent using the `chat` command + +if you have a valid `"gisttoken"` this command will also make a gist and include the url in the chat message + +the gist will attempt to include the following files: + +1. the pwn script, which uses `"pwnscriptname"`, and is typically generated with the `pwn` command +2. the crypto script, which uses `"cryptoscriptname"`, and is typically generated with the `crypto` command +3. the notes, which are saved in the .ret/notes.json file, and are typically populated with the `notes` command +4. the flag, which is saved in the .ret/flag.json file, and is typically set with the `capture` command 🔗 https://github.com/rerrorctf/ret/blob/main/commands/share.go diff --git a/commands/share.go b/commands/share.go index e7adba0..b42cb3f 100644 --- a/commands/share.go +++ b/commands/share.go @@ -2,7 +2,6 @@ package commands import ( "fmt" - "log" "os" "ret/config" "ret/theme" @@ -16,54 +15,60 @@ func init() { Func: Share, Help: ShareHelp, Arguments: nil, - SeeAlso: []string{"notes", "capture", "chat", "gist", "pwn"}}) + SeeAlso: []string{"notes", "capture", "chat", "gist", "pwn", "crypto"}}) } func ShareHelp() string { - return "share task progress with ret\n\n" + return "share task progress with ret\n\n" + + "if you have captured a flag with the " + theme.ColorGreen + "`capture`" + theme.ColorReset + " command this will be sent using the " + theme.ColorGreen + "`chat`" + theme.ColorReset + " command\n\n" + + "if you have a valid " + theme.ColorYellow + "`\"gisttoken\"`" + theme.ColorReset + " this command will also make a gist and include the url in the chat message\n\n" + + "the gist will attempt to include the following files:\n\n" + + "1. the pwn script, which uses " + theme.ColorYellow + "`\"pwnscriptname\"`" + theme.ColorReset + ", and is typically generated with the " + theme.ColorGreen + "`pwn`" + theme.ColorReset + " command\n" + + "2. the crypto script, which uses " + theme.ColorYellow + "`\"cryptoscriptname\"`" + theme.ColorReset + ", and is typically generated with the " + theme.ColorGreen + "`crypto`" + theme.ColorReset + " command\n" + + "3. the notes, which are saved in the " + theme.ColorCyan + ".ret/notes.json" + theme.ColorReset + " file, and are typically populated with the " + theme.ColorGreen + "`notes`" + theme.ColorReset + " command\n" + + "4. the flag, which is saved in the " + theme.ColorCyan + ".ret/flag.json" + theme.ColorReset + " file, and is typically set with the " + theme.ColorGreen + "`capture`" + theme.ColorReset + " command\n" } func Share(args []string) { - if len(config.GistToken) == 0 { - log.Fatalf("💥 " + theme.ColorRed + "error" + theme.ColorReset + ": no gist token in ~/.config/ret\n") + flag, err := util.GetCurrentFlag() + if err != nil { + flag = config.FlagFormat } - files := map[string]interface{}{} + gistUrl := "" - buffer, err := os.ReadFile(config.PwnScriptName) - if err == nil { - files[config.PwnScriptName] = map[string]interface{}{ - "content": string(buffer), + if len(config.GistToken) > 0 { + files := map[string]interface{}{} + + buffer, err := os.ReadFile(config.PwnScriptName) + if err == nil { + files[config.PwnScriptName] = map[string]interface{}{ + "content": string(buffer), + } } - } - buffer, err = os.ReadFile(config.CryptoScriptName) - if err == nil { - files[config.CryptoScriptName] = map[string]interface{}{ - "content": string(buffer), + buffer, err = os.ReadFile(config.CryptoScriptName) + if err == nil { + files[config.CryptoScriptName] = map[string]interface{}{ + "content": string(buffer), + } } - } - buffer, err = os.ReadFile(config.NotesFileName) - if err == nil { - // does not like .ret/notes.json - files["notes.json"] = map[string]interface{}{ - "content": string(buffer), + buffer, err = os.ReadFile(config.NotesFileName) + if err == nil { + // does not like .ret/notes.json + files["notes.json"] = map[string]interface{}{ + "content": string(buffer), + } } - } - flag, err := util.GetCurrentFlag() - if err != nil { - flag = config.FlagFormat - } else { files["flag.txt"] = map[string]interface{}{ "content": string(flag), } - } - gistUrl := "" - if len(files) > 0 { - gistUrl = "**" + util.Gist(files) + "**" + if len(files) > 0 { + gistUrl = "**" + util.Gist(files) + "**" + } } Chat([]string{fmt.Sprintf("🏁 `%s`\n%s", flag, gistUrl)})