diff --git a/README.md b/README.md
index 4f4e626..1ea617c 100644
--- a/README.md
+++ b/README.md
@@ -198,7 +198,6 @@ checks for the following:
3) ida
4) ghidra
5) gcloud
-6) 7z
🔗 https://github.com/rerrorctf/ret/blob/main/commands/check.go
@@ -248,28 +247,7 @@ the ctftime url will be used to aid in the generation of writeups with the `writ
---
-### 🤏 decompress
-
-```
-$ ret decompress file1 [file2 file3...]
-```
-
-decompress one or more files with ret
-
-will first check if the file has a valid extension
-valid extensions are `.gzip`, `.gz`, `.zip`, `.xz`, `.7z` and `.tar`
-
-if the file has a valid extension decompress will then check if the file has a valid magic
-
-if the file has a valid extension and magic it will be decompressed with 7z as if the following was executed:
-
-`$ 7z e filename -y`
-
-🔗 https://github.com/rerrorctf/ret/blob/main/commands/decompress.go
-
----
-
-### 🐋 docker
+### 🐋 docker
```
$ ret docker [ip] [port]
diff --git a/commands/check.go b/commands/check.go
index 485782d..4a8ad5b 100644
--- a/commands/check.go
+++ b/commands/check.go
@@ -23,8 +23,7 @@ func CheckHelp() string {
theme.ColorGray + "2) " + theme.ColorReset + "pwntools\n" +
theme.ColorGray + "3) " + theme.ColorReset + "ida\n" +
theme.ColorGray + "4) " + theme.ColorReset + "ghidra\n" +
- theme.ColorGray + "5) " + theme.ColorReset + "gcloud\n" +
- theme.ColorGray + "6) " + theme.ColorReset + "7z\n"
+ theme.ColorGray + "5) " + theme.ColorReset + "gcloud\n"
}
func testCommand(command string, args ...string) bool {
@@ -58,6 +57,4 @@ func Check(args []string) {
if !testCommand("stat", "/opt/ida/ida64") {
suggestLink("https://hex-rays.com/ida-free/")
}
-
- testCommand("7z", "--help")
}
diff --git a/commands/decompress.go b/commands/decompress.go
deleted file mode 100644
index 37287d3..0000000
--- a/commands/decompress.go
+++ /dev/null
@@ -1,53 +0,0 @@
-package commands
-
-import (
- "fmt"
- "log"
- "ret/theme"
- "ret/util"
-)
-
-func init() {
- Commands = append(Commands, Command{
- Name: "decompress",
- Emoji: "🤏",
- Func: Decompress,
- Help: DecompressHelp,
- Arguments: []Argument{
- {
- Name: "file",
- Optional: false,
- List: true,
- },
- }})
-}
-
-func DecompressHelp() string {
- return "decompress one or more files with ret\n\n" +
- "will first check if the file has a valid extension\n" +
- "valid extensions are " +
- theme.ColorPurple + "`.gzip`" + theme.ColorReset + ", " +
- theme.ColorPurple + "`.gz`" + theme.ColorReset + ", " +
- theme.ColorPurple + "`.zip`" + theme.ColorReset + ", " +
- theme.ColorPurple + "`.xz`" + theme.ColorReset + ", " +
- theme.ColorPurple + "`.7z` " + theme.ColorReset + "and " + theme.ColorPurple + "`.tar`" + theme.ColorReset + "\n\n" +
- "if the file has a valid extension decompress will then check if the file has a valid magic\n\n" +
- "if the file has a valid extension and magic it will be decompressed with 7z as if the following was executed:\n\n" +
- theme.ColorGray + "`$ " + theme.ColorBlue + "7z e filename -y`\n" + theme.ColorReset
-}
-
-func Decompress(args []string) {
- if len(args) == 0 {
- log.Fatalf("💥 " + theme.ColorRed + "error" + theme.ColorReset + ": expected 1 or more arguments\n")
- }
-
- for _, file := range args {
- decompressed := util.DecompressFile(file)
-
- if decompressed {
- fmt.Printf("🤏 "+theme.ColorGreen+"decompressed"+theme.ColorReset+":\"%s\"\n", file)
- } else {
- fmt.Printf("😰 "+theme.ColorYellow+"unable to decompress"+theme.ColorReset+":\"%s\"\n", file)
- }
- }
-}
diff --git a/util/decompress.go b/util/decompress.go
deleted file mode 100644
index 99eaef4..0000000
--- a/util/decompress.go
+++ /dev/null
@@ -1,112 +0,0 @@
-package util
-
-import (
- "fmt"
- "os"
- "os/exec"
- "ret/theme"
- "strings"
-)
-
-const (
- GZIP string = "gz"
- ZIP string = "zip"
- XZ string = "xz"
- VIIZ string = "7z"
- TAR string = "tar"
-)
-
-var magics = map[string][]byte{
- GZIP: {0x1F, 0x8b},
- ZIP: {0x50, 0x4B, 0x03, 0x04},
- XZ: {0xFD, 0x37, 0x7A, 0x58, 0x5A, 0x00},
- VIIZ: {0x37, 0x7A, 0xBC, 0xAF, 0x27, 0x1C},
- TAR: {0x75, 0x73, 0x74, 0x61, 0x72},
-}
-
-var validExtensions = map[string][]string{
- GZIP: {"gzip", "gz"},
- ZIP: {"zip"},
- XZ: {"xz"},
- VIIZ: {"7z"},
- TAR: {"tar"},
-}
-
-func IsDecompressable(path string) (string, bool) {
- splits := strings.Split(path, ".")
- if len(splits) < 2 {
- return "", false
- }
-
- extension := splits[len(splits)-1]
-
- fileType := ""
- for fType, exts := range validExtensions {
- for _, ext := range exts {
- if extension == ext {
- fileType = fType
- }
- }
- }
-
- // note: we test for extension validity to avoid decompressing things like APKs and epubs
- if fileType == "" {
- return "", false
- }
-
- buffer, err := os.ReadFile(path)
- if err != nil {
- // TODO: handle error?
- return "", false
- }
-
- magic := magics[fileType]
-
- if fileType == TAR {
- if len(buffer) < (0x101 + len(magic)) {
- return "", false
- }
- for i, b := range magic {
- // tar magic starts in the middle of the file
- if buffer[i+0x101] != b {
- return "", false
- }
- }
- } else {
- if len(buffer) < len(magic) {
- return "", false
- }
- for i, b := range magic {
- if buffer[i] != b {
- return "", false
- }
- }
- }
-
- return fileType, true
-}
-
-func decompressFile7z(path string) {
- sevenZipX := exec.Command("7z", "e", path, "-y")
-
- sevenZipXOutput, err := sevenZipX.Output()
- if err != nil {
- fmt.Printf("%s", sevenZipXOutput)
- fmt.Printf("💥 "+theme.ColorRed+"error: "+theme.ColorReset+"%v\n", err)
- return
- }
-}
-
-func DecompressFile(path string) bool {
- fileType, decompressable := IsDecompressable(path)
- if !decompressable {
- return false
- }
-
- switch fileType {
- case GZIP, ZIP, XZ, VIIZ, TAR:
- decompressFile7z(path)
- }
-
- return true
-}