Skip to content

Commit

Permalink
Updated Linux UUID Retrieval
Browse files Browse the repository at this point in the history
  • Loading branch information
usiegl00 committed Feb 6, 2021
1 parent 46d430f commit fe43536
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions sliver/hostuuid/uuid_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,16 @@ import (
)

func GetUUID() string {
uuid, err := ioutil.ReadFile("/var/lib/dbus/machine-id")
if err != nil {
panic(err)
uuid, err := ioutil.ReadFile("/etc/machine-id")
// UUID length is 32 plus newline
if (err != nil) || (len(uuid) != 33) {
uuid, err = ioutil.ReadFile("/var/lib/dbus/machine-id")
if (err != nil) || (len(uuid) != 33) {
// Randomized on the server
return ""
}
}

return fmt.Sprintf("%s-%s-%s-%s-%s",
uuid[0:8],
uuid[8:12], uuid[12:16], uuid[16:20],
Expand Down

0 comments on commit fe43536

Please sign in to comment.