From dfaa84ba843884e55186e30ad82c98fe81629593 Mon Sep 17 00:00:00 2001 From: dmur1 <93072266+dmur1@users.noreply.github.com> Date: Sun, 16 Feb 2025 18:17:23 +0000 Subject: [PATCH 1/3] make it so that share works without a gist token fixes: https://github.com/rerrorctf/ret/issues/280 --- commands/share.go | 55 ++++++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 29 deletions(-) diff --git a/commands/share.go b/commands/share.go index e7adba0..a6f47e8 100644 --- a/commands/share.go +++ b/commands/share.go @@ -2,10 +2,8 @@ package commands import ( "fmt" - "log" "os" "ret/config" - "ret/theme" "ret/util" ) @@ -24,46 +22,45 @@ func ShareHelp() string { } 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)}) From 4607acf05d0e129e0fc3a58e1535789d2d02f982 Mon Sep 17 00:00:00 2001 From: dmur1 <93072266+dmur1@users.noreply.github.com> Date: Sun, 16 Feb 2025 18:30:57 +0000 Subject: [PATCH 2/3] make sure that crypto is included in share's SeeAlso --- commands/share.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commands/share.go b/commands/share.go index a6f47e8..f1830a8 100644 --- a/commands/share.go +++ b/commands/share.go @@ -14,7 +14,7 @@ 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 { From 439c14f9595cf395b1eb41e55bc7113b69f82a9e Mon Sep 17 00:00:00 2001 From: dmur1 <93072266+dmur1@users.noreply.github.com> Date: Sun, 16 Feb 2025 18:31:09 +0000 Subject: [PATCH 3/3] improve the readme for share --- README.md | 10 ++++++++++ commands/share.go | 10 +++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) 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 f1830a8..b42cb3f 100644 --- a/commands/share.go +++ b/commands/share.go @@ -4,6 +4,7 @@ import ( "fmt" "os" "ret/config" + "ret/theme" "ret/util" ) @@ -18,7 +19,14 @@ func init() { } 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) {