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:
parent
749318ead6
commit
02d518db5c
@ -3,6 +3,7 @@ package security
|
||||
import (
|
||||
"os/exec"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
"github.com/senorprogrammer/wtf/wtf"
|
||||
)
|
||||
@ -19,6 +20,8 @@ func WifiEncryption() string {
|
||||
return wifiEncryptionLinux()
|
||||
case "darwin":
|
||||
return wifiEncryptionMacOS()
|
||||
case "windows":
|
||||
return wifiEncryptionWindows()
|
||||
default:
|
||||
return ""
|
||||
}
|
||||
@ -30,6 +33,8 @@ func WifiName() string {
|
||||
return wifiNameLinux()
|
||||
case "darwin":
|
||||
return wifiNameMacOS()
|
||||
case "windows":
|
||||
return wifiNameWindows()
|
||||
default:
|
||||
return ""
|
||||
}
|
||||
@ -82,3 +87,36 @@ func matchStr(data [][]string) string {
|
||||
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"
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user