From c95a4ddddc7e086a5e4214aaa0caa802d18b951e Mon Sep 17 00:00:00 2001 From: Ben Boyter Date: Mon, 15 Nov 2021 10:37:14 +1100 Subject: [PATCH] remove audit stuff --- README.md | 2 - hashaudit.json | 206 ---------------------------------------- main.go | 15 --- processor/constants.go | 5 - processor/formatters.go | 111 ---------------------- processor/processor.go | 72 -------------- scripts/include.go | 79 --------------- 7 files changed, 490 deletions(-) delete mode 100644 hashaudit.json delete mode 100644 processor/constants.go delete mode 100644 scripts/include.go diff --git a/README.md b/README.md index e18ef2d..3edcb1e 100644 --- a/README.md +++ b/README.md @@ -49,9 +49,7 @@ Usage: hashit [flags] Flags: - -a, --audit string audit mode, validates argument against known hashes --debug enable debug output - -x, --file-audit enable file audit logic where files will be checked against internal list -f, --format string set output format [text, json, sum, hashdeep] (default "text") -c, --hash strings hashes to be run for each file (set to 'all' for all possible hashes) (default [md5,sha1,sha256,sha512]) --hashes list all supported hashes diff --git a/hashaudit.json b/hashaudit.json deleted file mode 100644 index 7c3af21..0000000 --- a/hashaudit.json +++ /dev/null @@ -1,206 +0,0 @@ -{ - "ubuntu-16.04.6-desktop-amd64.iso": { - "description": "Ubuntu 16.04.6 LTS (Xenial Xerus) Desktop image for 64-bit PC (AMD64) computers", - "date": "2019-02-27", - "version": "16.04.6", - "urls": [ - "http://releases.ubuntu.com/xenial/", - "http://releases.ubuntu.com/xenial/MD5SUMS", - "http://releases.ubuntu.com/xenial/SHA1SUMS", - "http://releases.ubuntu.com/xenial/SHA256SUMS" - ], - "md5": "5416371cc0e990871746ddaac89f1a5e", - "sha1": "a09607901183ab25c675626024aa402663fa2558", - "sha256": "e27d13d089a027601099b050fd6080785aae99c1a8eb7848774b8d44f1f679b9" - }, - "ubuntu-16.04.6-desktop-i386.iso": { - "description": "Ubuntu 16.04.6 LTS (Xenial Xerus) Desktop image for 32-bit PC (i386) computers", - "date": "2019-02-27", - "version": "16.04.6", - "urls": [ - "http://releases.ubuntu.com/xenial/", - "http://releases.ubuntu.com/xenial/MD5SUMS", - "http://releases.ubuntu.com/xenial/SHA1SUMS", - "http://releases.ubuntu.com/xenial/SHA256SUMS" - ], - "md5": "feefb18e7916c9a16bb09923ed98df64", - "sha1": "4e3528f6d45a25692f6f9c1f8acf9a3b7c114c5f", - "sha256": "eecb9c8160cdb08adf0c2f17daa1d403f5a55f14a856a5973f32f267eb9db039" - }, - "ubuntu-16.04.6-server-amd64.iso": { - "description": "Ubuntu 16.04.6 LTS (Xenial Xerus) Server install image for 64-bit PC (AMD64) computers", - "date": "2019-02-27", - "version": "16.04.6", - "urls": [ - "http://releases.ubuntu.com/xenial/", - "http://releases.ubuntu.com/xenial/MD5SUMS", - "http://releases.ubuntu.com/xenial/SHA1SUMS", - "http://releases.ubuntu.com/xenial/SHA256SUMS" - ], - "md5": "ac8a79a86a905ebdc3ef3f5dd16b7360", - "sha1": "056b7c15efc15bbbf40bf1a9ff1a3531fcbf70a2", - "sha256": "16afb1375372c57471ea5e29803a89a5a6bd1f6aabea2e5e34ac1ab7eb9786ac" - }, - "ubuntu-16.04.6-server-i386.iso": { - "description": "Ubuntu 16.04.6 LTS (Xenial Xerus) Server install image for 32-bit PC (i386) computers", - "date": "2019-02-27", - "version": "16.04.6", - "urls": [ - "http://releases.ubuntu.com/xenial/", - "http://releases.ubuntu.com/xenial/MD5SUMS", - "http://releases.ubuntu.com/xenial/SHA1SUMS", - "http://releases.ubuntu.com/xenial/SHA256SUMS" - ], - "md5": "1817138b1a181507c5ebd5ec8a3f40ba", - "sha1": "40343e90c9b8355ee6512e7680486df2f084eb1d", - "sha256": "7509cabb2f9f6ba0a95f8454d432be2ef26679d31ce35baa626acc5321460fab" - }, - "ubuntu-18.04.2-desktop-amd64.iso": { - "description": "Ubuntu 18.04.2 LTS (Bionic Beaver) Desktop image for 64-bit PC (AMD64) computers", - "date": "2019-02-10", - "version": "18.04.2", - "urls": [ - "http://releases.ubuntu.com/bionic/", - "http://releases.ubuntu.com/bionic/MD5SUMS", - "http://releases.ubuntu.com/bionic/SHA1SUMS", - "http://releases.ubuntu.com/bionic/SHA256SUMS" - ], - "md5": "69809dc7e058b81bc781fe3e24d3204f", - "sha1": "bcdb9099024c468047f3f31c7d23e68a35ea4de2", - "sha256": "22580b9f3b186cc66818e60f44c46f795d708a1ad86b9225c458413b638459c4" - }, - "ubuntu-18.04.2-live-server-amd64.iso": { - "description": "Ubuntu 18.04.2 LTS (Bionic Beaver) Server install image for 64-bit PC (AMD64) computers", - "date": "2019-02-14", - "version": "18.04.2", - "urls": [ - "http://releases.ubuntu.com/bionic/", - "http://releases.ubuntu.com/bionic/MD5SUMS", - "http://releases.ubuntu.com/bionic/SHA1SUMS", - "http://releases.ubuntu.com/bionic/SHA256SUMS" - ], - "md5": "fcbcc756a1aa5314d52e882067c4ca6a", - "sha1": "aa9606eb8c0bbce00552907f541547c4c510134f", - "sha256": "ea6ccb5b57813908c006f42f7ac8eaa4fc603883a2d07876cf9ed74610ba2f53" - }, - "ubuntu-18.10-desktop-amd64.iso": { - "description": "Ubuntu 18.10 (Cosmic Cuttlefish) Desktop image for 64-bit PC (AMD64) computers", - "date": "2018-10-17", - "version": "18.10", - "urls": [ - "http://releases.ubuntu.com/cosmic/", - "http://releases.ubuntu.com/cosmic/MD5SUMS", - "http://releases.ubuntu.com/cosmic/SHA1SUMS", - "http://releases.ubuntu.com/cosmic/SHA256SUMS" - ], - "md5": "d40aa9b8043849ecd888e85eade072db", - "sha1": "74dc7526e01fa78bb5b9486b4815364bbc625b12", - "sha256": "818affdaea8d38bbbe620009bfa788a7cbc583c7c61c2d278f61dd3c43e030a0" - }, - "ubuntu-18.10-live-server-amd64.iso": { - "description": "Ubuntu 18.10 (Cosmic Cuttlefish) Server install image for 64-bit PC (AMD64) computers", - "date": "2018-10-17", - "version": "18.10", - "urls": [ - "http://releases.ubuntu.com/cosmic/", - "http://releases.ubuntu.com/cosmic/MD5SUMS", - "http://releases.ubuntu.com/cosmic/SHA1SUMS", - "http://releases.ubuntu.com/cosmic/SHA256SUMS" - ], - "md5": "5850e23b67962d59a3b7cdc50df69e59", - "sha1": "97dc434a27bfcea151179ffc94ee7745f10efe5e", - "sha256": "7b9f670c749f797a0f7481d619ce8807edac052c97e1a0df3b130c95efae4765" - }, - "ubuntu-19.04-desktop-amd64.iso": { - "description": "Ubuntu 19.04 (Disco Dingo) Desktop image for 64-bit PC (AMD64) computers", - "date": "2019-04-16", - "version": "19.04", - "urls": [ - "http://releases.ubuntu.com/disco/", - "http://releases.ubuntu.com/disco/MD5SUMS", - "http://releases.ubuntu.com/disco/SHA1SUMS", - "http://releases.ubuntu.com/disco/SHA256SUMS" - ], - "md5": "6fa9686bc299c19c97d280f79a723868", - "sha1": "47064866141c7729b3f447890dd6d5bc2fc35cf7", - "sha256": "2da6f8b5c65b71b040c5c510311eae1798545b8ba801c9b63e9e3fd3c0457cbe" - }, - "ubuntu-19.04-live-server-amd64.iso": { - "description": "Ubuntu 19.04 (Disco Dingo) Server install image for 64-bit PC (AMD64) computers", - "date": "2019-04-16", - "version": "19.04", - "urls": [ - "http://releases.ubuntu.com/disco/", - "http://releases.ubuntu.com/disco/MD5SUMS", - "http://releases.ubuntu.com/disco/SHA1SUMS", - "http://releases.ubuntu.com/disco/SHA256SUMS" - ], - "md5": "9a659c92b961ef46f5c0fdc04b9269a6", - "sha1": "544ba93f0e0a92c642c3585894da1a59693cc278", - "sha256": "25d483341ccd0d522a6660b00db933787c86c47b42f1845bcf997127f4b61e9d" - }, - "xubuntu-18.04-desktop-amd64.iso": { - "description": "Xubuntu 18.04 is an LTS release which was released in April 2018.", - "date": "2018-04", - "version": "18.04", - "urls": [ - "https://xubuntu.org/release/18-04/", - "http://mirror.exetel.com.au/pub/ubuntu/xubuntu-releases/18.04/release/MD5SUMS", - "http://mirror.exetel.com.au/pub/ubuntu/xubuntu-releases/18.04/release/SHA1SUMS", - "http://mirror.exetel.com.au/pub/ubuntu/xubuntu-releases/18.04/release/SHA256SUMS" - ], - "md5": "1b0bcbad9853cf7a4cade6324e6622f7", - "sha1": "a1bcc46d01387337d4be81ba76e89b495a7b5331", - "sha256": "7c24318d3b1de1efd584b5aea034ce1aafd2d0f06c59812d989a5fc95bf947e3" - }, - "zig-0.4.0.tar.xz": { - "description": "Zig is a general-purpose programming language designed for robustness, optimality, and maintainability.", - "date": "2019-04-08", - "version": "0.4.0", - "urls": [ - "https://ziglang.org/download/", - "https://ziglang.org/download/0.4.0/release-notes.html" - ], - "sha256": "fec1f3f6b359a3d942e0a7f9157b3b30cde83927627a0e1ea95c54de3c526cfc" - }, - "zig-linux-x86_64-0.4.0.tar.xz": { - "description": "Zig is a general-purpose programming language designed for robustness, optimality, and maintainability.", - "date": "2019-04-08", - "version": "0.4.0", - "urls": [ - "https://ziglang.org/download/", - "https://ziglang.org/download/0.4.0/release-notes.html" - ], - "sha256": "fb1954e2fb556a01f8079a08130e88f70084e08978ff853bb2b1986d8c39d84e" - }, - "zig-windows-x86_64-0.4.0.zip": { - "description": "Zig is a general-purpose programming language designed for robustness, optimality, and maintainability.", - "date": "2019-04-08", - "version": "0.4.0", - "urls": [ - "https://ziglang.org/download/", - "https://ziglang.org/download/0.4.0/release-notes.html" - ], - "sha256": "fbc3dd205e064c263063f69f600bedb18e3d0aa2efa747a63ef6cafb6d73f127" - }, - "zig-macos-x86_64-0.4.0.tar.xz": { - "description": "Zig is a general-purpose programming language designed for robustness, optimality, and maintainability.", - "date": "2019-04-08", - "version": "0.4.0", - "urls": [ - "https://ziglang.org/download/", - "https://ziglang.org/download/0.4.0/release-notes.html" - ], - "sha256": "67c932982484d017c5111e54af9f33f15e8e05c6bc5346a55e04052159c964a8" - }, - "zig-freebsd-x86_64-0.4.0.tar.xz": { - "description": "Zig is a general-purpose programming language designed for robustness, optimality, and maintainability.", - "date": "2019-04-08", - "version": "0.4.0", - "urls": [ - "https://ziglang.org/download/", - "https://ziglang.org/download/0.4.0/release-notes.html" - ], - "sha256": "3d557c91ac36d8262eb1733bb5f261c95944f9b635e43386e3d00a3272818c30" - } -} \ No newline at end of file diff --git a/main.go b/main.go index a5b47e2..ef24da0 100644 --- a/main.go +++ b/main.go @@ -6,7 +6,6 @@ import ( "os" ) -//go:generate go run scripts/include.go func main() { //f, _ := os.Create("hashit.pprof") //_ = pprof.StartCPUProfile(f) @@ -46,13 +45,6 @@ func main() { false, "recursive subdirectories are traversed", ) - flags.BoolVarP( - &processor.FileAudit, - "file-audit", - "x", - false, - "enable file audit logic where files will be checked against internal list", - ) flags.BoolVar( &processor.Hashes, "hashes", @@ -66,13 +58,6 @@ func main() { "", "output filename (default stdout)", ) - flags.StringVarP( - &processor.AuditFile, - "audit", - "a", - "", - "audit mode, validates argument against known hashes", - ) flags.BoolVar( &processor.NoStream, "no-stream", diff --git a/processor/constants.go b/processor/constants.go deleted file mode 100644 index 6273e0b..0000000 --- a/processor/constants.go +++ /dev/null @@ -1,5 +0,0 @@ -package processor - -const ( -hashaudit = `ewogICJ1YnVudHUtMTYuMDQuNi1kZXNrdG9wLWFtZDY0LmlzbyI6IHsKICAgICJkZXNjcmlwdGlvbiI6ICJVYnVudHUgMTYuMDQuNiBMVFMgKFhlbmlhbCBYZXJ1cykgRGVza3RvcCBpbWFnZSBmb3IgNjQtYml0IFBDIChBTUQ2NCkgY29tcHV0ZXJzIiwKICAgICJkYXRlIjogIjIwMTktMDItMjciLAogICAgInZlcnNpb24iOiAiMTYuMDQuNiIsCiAgICAidXJscyI6IFsKICAgICAgImh0dHA6Ly9yZWxlYXNlcy51YnVudHUuY29tL3hlbmlhbC8iLAogICAgICAiaHR0cDovL3JlbGVhc2VzLnVidW50dS5jb20veGVuaWFsL01ENVNVTVMiLAogICAgICAiaHR0cDovL3JlbGVhc2VzLnVidW50dS5jb20veGVuaWFsL1NIQTFTVU1TIiwKICAgICAgImh0dHA6Ly9yZWxlYXNlcy51YnVudHUuY29tL3hlbmlhbC9TSEEyNTZTVU1TIgogICAgXSwKICAgICJtZDUiOiAiNTQxNjM3MWNjMGU5OTA4NzE3NDZkZGFhYzg5Z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yMDE5LTA0LTA4IiwKICAgICJ2ZXJzaW9uIjogIjAuNC4wIiwKICAgICJ1cmxzIjogWwogICAgICAiaHR0cHM6Ly96aWdsYW5nLm9yZy9kb3dubG9hZC8iLAogICAgICAiaHR0cHM6Ly96aWdsYW5nLm9yZy9kb3dubG9hZC8wLjQuMC9yZWxlYXNlLW5vdGVzLmh0bWwiCiAgICBdLAogICAgInNoYTI1NiI6ICIzZDU1N2M5MWFjMzZkODI2MmViMTczM2JiNWYyNjFjOTU5NDRmOWI2MzVlNDMzODZlM2QwMGEzMjcyODE4YzMwIgogIH0KfQ==` -) diff --git a/processor/formatters.go b/processor/formatters.go index d97c0e4..c9e58ad 100644 --- a/processor/formatters.go +++ b/processor/formatters.go @@ -4,7 +4,6 @@ import ( "encoding/json" "fmt" "os" - "path/filepath" "strings" "time" ) @@ -174,10 +173,6 @@ func toText(input chan Result) (string, bool) { str.WriteString(" SHA3-512 " + res.Sha3512 + "\n") } - if FileAudit { - valid = auditFile(&str, res) - } - if NoStream == false && FileOutput == "" { fmt.Print(str.String()) str.Reset() @@ -187,112 +182,6 @@ func toText(input chan Result) (string, bool) { return str.String(), valid } -// If audit is enabled then try to identify the file against the internal list -// and if we find a match we want to match the hashes against each other to -// determine if the result is genuine or not -func auditFile(str *strings.Builder, res Result) bool { - str.WriteString("\n") - - identifiedByHash := true - found := findByHashes(res) - if found == "" { - _, found = filepath.Split(res.File) - identifiedByHash = false - } - - valid := true - - if val, ok := hashDatabase[found]; ok { - if identifiedByHash { - str.WriteString(fmt.Sprintf("%s (identified by hash)\n", res.File)) - } else { - str.WriteString(fmt.Sprintf("%s (identified by filename)\n", res.File)) - } - - str.WriteString(fmt.Sprintf("description %s\n", val.Description)) - str.WriteString(fmt.Sprintf(" version %s\n", val.Version)) - str.WriteString(fmt.Sprintf(" date %s\n", val.Date)) - str.WriteString("\n") - - if hasHash(HashNames.MD5) && val.MD5 != "" { - if res.MD5 == val.MD5 { - str.WriteString(" MD5 " + val.MD5 + " pass\n") - } else { - str.WriteString(" MD5 " + val.MD5 + " fail\n") - valid = false - } - } - - if hasHash(HashNames.SHA1) && val.SHA1 != "" { - if res.SHA1 == val.SHA1 { - str.WriteString(" SHA1 " + val.SHA1 + " pass\n") - } else { - str.WriteString(" SHA1 " + val.SHA1 + " fail\n") - valid = false - } - } - - if hasHash(HashNames.SHA256) && val.SHA256 != "" { - if res.SHA256 == val.SHA256 { - str.WriteString(" SHA256 " + val.SHA256 + " pass\n") - } else { - str.WriteString(" SHA256 " + val.SHA256 + " fail\n") - valid = false - } - } - - if hasHash(HashNames.SHA512) && val.SHA512 != "" { - if res.SHA512 == val.SHA512 { - str.WriteString(" SHA512 " + val.SHA512 + " pass\n") - } else { - str.WriteString(" SHA512 " + val.SHA512 + " fail\n") - valid = false - } - } - } else { - str.WriteString(fmt.Sprintf("%s (unknown file cannot audit)\n", res.File)) - } - - return valid -} - -// Tries to identify a result based on the hashes produced for it -func findByHashes(res Result) string { - if val, ok := hashLookup[res.MD5]; ok { - if Verbose { - printVerbose(fmt.Sprintf("md5 match found: %s", val)) - } - return val - } - - if val, ok := hashLookup[res.SHA1]; ok { - if Verbose { - printVerbose(fmt.Sprintf("sha1 match found: %s", val)) - } - return val - } - - if val, ok := hashLookup[res.SHA256]; ok { - if Verbose { - printVerbose(fmt.Sprintf("sha256 match found: %s", val)) - } - return val - } - - if val, ok := hashLookup[res.SHA512]; ok { - if Verbose { - printVerbose(fmt.Sprintf("sha512 match found: %s", val)) - } - return val - } - - if Verbose { - printVerbose(fmt.Sprintf("no hash match found for: %s", res.File)) - } - - return "" -} - func toJSON(input chan Result) string { results := []Result{} for res := range input { diff --git a/processor/processor.go b/processor/processor.go index d4aeca4..dc67c2f 100644 --- a/processor/processor.go +++ b/processor/processor.go @@ -1,8 +1,6 @@ package processor import ( - "encoding/base64" - "encoding/json" "fmt" "io/ioutil" "os" @@ -83,34 +81,6 @@ var hashDatabase = map[string]Result{} // Hash to name lookup var hashLookup = map[string]string{} -// Turns the -// ProcessConstants is responsible for setting up the language features based on the JSON file that is stored in constants -// Needs to be called at least once in order for anything to actually happen -func ProcessConstants() { - hashDatabase = loadDatabase() - - // Put all of the hashes into a large map so we can look up in reverse - startTime := makeTimestampNano() - for name, value := range hashDatabase { - if value.MD5 != "" { - hashLookup[value.MD5] = name - } - if value.SHA1 != "" { - hashLookup[value.SHA1] = name - } - if value.SHA256 != "" { - hashLookup[value.SHA256] = name - } - if value.SHA512 != "" { - hashLookup[value.SHA512] = name - } - } - - if Trace { - printTrace(fmt.Sprintf("nanoseconds build hash to file: %d", makeTimestampNano()-startTime)) - } -} - // Process is the main entry point of the command line it sets everything up and starts running func Process() { // Display the supported hashes then bail out @@ -119,14 +89,6 @@ func Process() { return } - if FileAudit { - ProcessConstants() - } - - if AuditFile != "" { - loadAuditFile() - } - // Check if we are accepting data from stdin stat, _ := os.Stdin.Stat() if (stat.Mode() & os.ModeCharDevice) == 0 { @@ -235,37 +197,3 @@ func hasHash(hash string) bool { return false } -func loadDatabase() map[string]Result { - var database map[string]Result - startTime := makeTimestampMilli() - - data, err := base64.StdEncoding.DecodeString(hashaudit) - if err != nil { - panic(fmt.Sprintf("failed to base64 decode languages: %v", err)) - } - - if err := json.Unmarshal(data, &database); err != nil { - panic(fmt.Sprintf("hash audit json invalid: %v", err)) - } - - if Trace { - printTrace(fmt.Sprintf("milliseconds unmarshal: %d", makeTimestampMilli()-startTime)) - } - - return database -} - -func loadAuditFile() { - content, err := ioutil.ReadFile(AuditFile) - - if err != nil { - printError(fmt.Sprintf("unable to load audit file: %s %s", AuditFile, err.Error())) - os.Exit(1) - } - - if strings.HasPrefix(strings.Trim(string(content), ""), "[{") { - fmt.Println("JSON audit file") - } else { - fmt.Println("HASHDEEP audit file") - } -} diff --git a/scripts/include.go b/scripts/include.go deleted file mode 100644 index 0f753f9..0000000 --- a/scripts/include.go +++ /dev/null @@ -1,79 +0,0 @@ -// SPDX-License-Identifier: MIT - -package main - -import ( - "encoding/base64" - "encoding/json" - "fmt" - "io" - "io/ioutil" - "os" - "strings" -) - -const constantsFile = "./processor/constants.go" - -func fatalf(f string, v ...interface{}) { - fmt.Fprintf(os.Stderr, f+"\n", v...) - os.Exit(1) -} - -// Reads all .json files in the current folder -// and encodes them as strings literals in constants.go -func generateConstants() error { - files, _ := ioutil.ReadDir(".") - out, err := ioutil.TempFile(".", "temp_constants") - if err != nil { - return fmt.Errorf("failed to open temp file: %v", err) - } - defer os.Remove(out.Name()) - - // Open constants - out.Write([]byte("package processor \n\nconst (\n")) - - for _, f := range files { - if strings.HasPrefix(f.Name(), "hashaudit") && strings.HasSuffix(f.Name(), ".json") { - f, err := os.Open(f.Name()) - if err != nil { - return fmt.Errorf("failed to open file '%s': %v", f.Name(), err) - } - - // validate the json by decoding into an empty struct - if err := json.NewDecoder(f).Decode(&struct{}{}); err != nil { - return fmt.Errorf("failed to validate json in file '%s': %v", f.Name(), err) - } - - // Reset position - f.Seek(0, io.SeekStart) - - // The constant variable name - out.Write([]byte(strings.TrimSuffix(f.Name(), ".json") + " = `")) - - enc := base64.NewEncoder(base64.StdEncoding, out) - if _, err := io.Copy(enc, f); err != nil { - return fmt.Errorf("failed to encode file '%s': %v", f.Name(), err) - } - enc.Close() - - out.Write([]byte("`\n")) - } - } - - // Close out constants - out.Write([]byte(")\n")) - out.Close() - - if err := os.Rename(out.Name(), constantsFile); err != nil { - return fmt.Errorf("%v", err) - } - - return nil -} - -func main() { - if err := generateConstants(); err != nil { - fmt.Fprintf(os.Stderr, "failed to generate constants: %v\n", err) - os.Exit(1) - } -}