@@ -3,8 +3,10 @@ package cmd
3
3
import (
4
4
"context"
5
5
"fmt"
6
- "github.com/liamg/traitor/internal/version"
7
6
"os"
7
+ "os/user"
8
+
9
+ "github.com/liamg/traitor/internal/version"
8
10
9
11
"github.com/liamg/traitor/pkg/logger"
10
12
"github.com/liamg/traitor/pkg/state"
@@ -30,8 +32,8 @@ var rootCmd = &cobra.Command{
30
32
Long : `An extensible privilege escalation framework for Linux
31
33
Complete documentation is available at https://github.com/liamg/traitor` ,
32
34
Args : cobra .ExactArgs (0 ),
33
- PreRun : func (_ * cobra.Command , args [] string ){
34
- fmt .Printf ("\x1b [34m" + `
35
+ PreRun : func (_ * cobra.Command , args [] string ) {
36
+ fmt .Printf ("\x1b [34m" + `
35
37
36
38
888 d8b 888
37
39
888 Y8P 888
@@ -41,7 +43,7 @@ var rootCmd = &cobra.Command{
41
43
888 888 .d888888 888 888 888 888 888
42
44
Y88b. 888 888 888 888 Y88b. Y88..88P 888
43
45
"Y888 888 "Y888888 888 "Y888 "Y88P" 888
44
- ` + "\x1b [31m" + ` %s | https://github.com/liamg/traitor
46
+ ` + "\x1b [31m" + ` %s | https://github.com/liamg/traitor
45
47
46
48
` , version .Version )
47
49
},
@@ -50,6 +52,11 @@ var rootCmd = &cobra.Command{
50
52
ctx := context .Background ()
51
53
baseLog := logger .New ()
52
54
55
+ if user , err := user .Current (); err == nil && user .Uid == "0" {
56
+ baseLog .Printf ("You are already root." )
57
+ return
58
+ }
59
+
53
60
baseLog .Printf ("Assessing machine state..." )
54
61
localState := state .New ()
55
62
localState .HasPassword = promptForPassword
@@ -95,7 +102,7 @@ var rootCmd = &cobra.Command{
95
102
}
96
103
if exploitName != "" && ! found {
97
104
baseLog .Printf ("No exploit found for '%s'" , exploitName )
98
- }else if ! vulnFound {
105
+ } else if ! vulnFound {
99
106
baseLog .Printf ("Nothing found to exploit." )
100
107
}
101
108
},
0 commit comments