Skip to content

Commit

Permalink
Actually commit the files
Browse files Browse the repository at this point in the history
  • Loading branch information
rkervella committed Jul 3, 2019
1 parent 0faae28 commit 23e7987
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 0 deletions.
1 change: 1 addition & 0 deletions sliver/version/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package version
5 changes: 5 additions & 0 deletions sliver/version/version_darwin.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package version

func GetVersion() string {
return ""
}
29 changes: 29 additions & 0 deletions sliver/version/version_linux.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package version

import (
"fmt"
"log"
"strings"
"syscall"
)

func getString(input [65]int8) string {
var buf [65]byte
for i, b := range input {
buf[i] = byte(b)
}
ver := string(buf[:])
if i := strings.Index(ver, "\x00"); i != -1 {
ver = ver[:i]
}
return ver
}

// GetVersion returns the os version information
func GetVersion() string {
var uname syscall.Utsname
if err := syscall.Uname(&uname); err != nil {
log.Fatal(err)
}
return fmt.Sprintf("%s %s %s", getString(uname.Sysname), getString(uname.Nodename), getString(uname.Release))
}
34 changes: 34 additions & 0 deletions sliver/version/version_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package version

import (
"fmt"
"log"
"syscall"
"unsafe"
)

type osVersionInfoEx struct {
osVersionInfoSize uint32
major uint32
minor uint32
build uint32
platformID uint32
csdVersion [128]uint16
servicePackMajor uint16
servicePackMinor uint16
suiteMask uint16
productType byte
wReserved byte
}

func GetVersion() string {
kernel32 := syscall.MustLoadDLL("ntdll.dll")
procGetProductInfo := kernel32.MustFindProc("RtlGetVersion")
osVersion := osVersionInfoEx{}
osVersion.osVersionInfoSize = uint32(unsafe.Sizeof(osVersion))
r1, _, err := procGetProductInfo.Call(uintptr(unsafe.Pointer(&osVersion)))
if r1 != 0 {
log.Fatal(err)
}
return fmt.Sprintf("%d.%d build %d", osVersion.major, osVersion.minor, osVersion.build)
}

0 comments on commit 23e7987

Please sign in to comment.