1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00

Adding English Windows support to the wifi module.

This commit is contained in:
Woodward 2018-07-30 16:27:40 -05:00
parent 749318ead6
commit 02d518db5c

View File

@ -3,6 +3,7 @@ package security
import ( import (
"os/exec" "os/exec"
"runtime" "runtime"
"strings"
"github.com/senorprogrammer/wtf/wtf" "github.com/senorprogrammer/wtf/wtf"
) )
@ -19,6 +20,8 @@ func WifiEncryption() string {
return wifiEncryptionLinux() return wifiEncryptionLinux()
case "darwin": case "darwin":
return wifiEncryptionMacOS() return wifiEncryptionMacOS()
case "windows":
return wifiEncryptionWindows()
default: default:
return "" return ""
} }
@ -30,6 +33,8 @@ func WifiName() string {
return wifiNameLinux() return wifiNameLinux()
case "darwin": case "darwin":
return wifiNameMacOS() return wifiNameMacOS()
case "windows":
return wifiNameWindows()
default: default:
return "" return ""
} }
@ -82,3 +87,36 @@ func matchStr(data [][]string) string {
return data[1][1] return data[1][1]
} }
} }
//Windows
func wifiEncryptionWindows() string {
return parseWlanNetsh("Authentication")
}
func wifiNameWindows() string {
return parseWlanNetsh("SSID")
}
func parseWlanNetsh(target string) string {
cmd := exec.Command("netsh.exe", "wlan", "show", "interfaces")
out, err := cmd.Output()
if err != nil {
return ""
}
splits := strings.Split(string(out), "\n")
var words []string
for _, line := range splits {
token := strings.Split(string(line), ":")
for _, word := range token {
words = append(words, strings.TrimSpace(word))
}
}
for i, token := range words {
switch token {
case target:
return words[i+1]
i++
}
}
return "N/A"
}