Created
January 17, 2019 13:57
-
-
Save kohnakagawa/2cefc29c8e30095bb6a1e1f17d750b01 to your computer and use it in GitHub Desktop.
tlsh example in Go lang
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
tlsh "github.com/glaslos/tlsh" | |
"fmt" | |
"os" | |
"io/ioutil" | |
) | |
func readBinary(fname string) ([]byte, error) { | |
file, err := os.Open(fname) | |
if err != nil { | |
return nil, err | |
} | |
bytes, err := ioutil.ReadAll(file) | |
if err != nil{ | |
return nil, err | |
} | |
return bytes, nil | |
} | |
func main() { | |
bytes0, err := readBinary("notepad.exe") | |
if err != nil { | |
fmt.Println(err.Error()) | |
} | |
bytes1, err := readBinary("calc.exe") | |
if err != nil { | |
fmt.Println(err.Error()) | |
} | |
tlsh0, err := tlsh.HashBytes(bytes0) | |
if err != nil { | |
fmt.Println(err.Error()) | |
} | |
tlshStr0 := tlsh0.String() | |
tlsh1, err := tlsh.HashBytes(bytes1) | |
if err != nil { | |
fmt.Println(err.Error()) | |
} | |
tlshStr1 := tlsh1.String() | |
fmt.Println(tlshStr0) | |
fmt.Println(tlshStr1) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
string -> tlsh.TLSH
に変換するための関数がないので、それだけは自作する必要がありそう。