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

only get linux firewall if root

This commit is contained in:
TheRedSpy15 2018-10-14 20:44:10 -04:00 committed by GitHub
parent 7b422cc3f3
commit c3baf05b20
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5,6 +5,7 @@ import (
"runtime" "runtime"
"strings" "strings"
"bytes" "bytes"
"os/user"
"github.com/senorprogrammer/wtf/wtf" "github.com/senorprogrammer/wtf/wtf"
) )
@ -38,19 +39,23 @@ func FirewallStealthState() string {
/* -------------------- Unexported Functions -------------------- */ /* -------------------- Unexported Functions -------------------- */
func firewallStateLinux() string { // might be very Ubuntu specific func firewallStateLinux() string { // might be very Ubuntu specific
cmd := exec.Command("ufw, "status") user, _ := user.Current()
var o bytes.Buffer
if (strings.Contains(user.Username, "root") {
cmd := exec.Command("ufw, "status")
var o bytes.Buffer
cmd.Stdout = &o cmd.Stdout = &o
if err := cmd.Run(); err != nil { if err := cmd.Run(); err != nil {
return "[red]NA[white] return "[red]NA[white]
} }
if strings.Contains(o.String(), "active") { if strings.Contains(o.String(), "active") {
return "[green]Enabled[white]" return "[green]Enabled[white]"
} else { } else {
return "[red]Disabled[white]" return "[red]Disabled[white]"
}
} }
} }