Created
February 26, 2020 15:59
-
-
Save Tasssadar/7424860a2764e3ef42c7dcce7ecfd341 to your computer and use it in GitHub Desktop.
AMD64 linux only
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 ( | |
"fmt" | |
"os" | |
"os/exec" | |
"syscall" | |
"unsafe" | |
) | |
const __NEW_UTS_LEN = 64 | |
type new_utsname struct { | |
sysname [__NEW_UTS_LEN + 1]byte | |
nodename [__NEW_UTS_LEN + 1]byte | |
release [__NEW_UTS_LEN + 1]byte | |
version [__NEW_UTS_LEN + 1]byte | |
machine [__NEW_UTS_LEN + 1]byte | |
domainname [__NEW_UTS_LEN + 1]byte | |
} | |
func main() { | |
fmt.Println("real uname") | |
cmd := exec.Command("uname", "-a") | |
cmd.Stdout = os.Stdout | |
cmd.Stderr = os.Stderr | |
cmd.Run() | |
fmt.Println("\nour uname") | |
var uts new_utsname | |
syscall.Syscall(63, uintptr(unsafe.Pointer(&uts)), 0, 0) | |
fmt.Println("sysname", string(uts.sysname[:])) | |
fmt.Println("nodename", string(uts.nodename[:])) | |
fmt.Println("release", string(uts.release[:])) | |
fmt.Println("version", string(uts.version[:])) | |
fmt.Println("machine", string(uts.machine[:])) | |
fmt.Println("domainname", string(uts.domainname[:])) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment