File tree 1 file changed +18
-0
lines changed
1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -11,13 +11,15 @@ import (
11
11
"os"
12
12
"strconv"
13
13
"strings"
14
+ "bytes"
14
15
15
16
//"syscall"
16
17
"syscall"
17
18
"time"
18
19
19
20
portscanner "github.com/anvie/port-scanner"
20
21
"github.com/jackpal/gateway"
22
+ "golang.org/x/crypto/ssh"
21
23
)
22
24
23
25
// GetGlobalIp is used to return the global Ip address of the machine.
@@ -305,4 +307,20 @@ func Url2Lines(url string) []string {
305
307
lns = append (lns , scn .Text ())
306
308
}
307
309
return lns
310
+ }
311
+
312
+ // Checks if an SSH client connection has a root context
313
+ func CheckRootSSH (client ssh.Client ) bool {
314
+ uid0_session := false
315
+ session , err := client .NewSession ()
316
+ defer session .Close ()
317
+ Check (err )
318
+ var user_id bytes.Buffer
319
+ session .Stdout = & user_id
320
+ if (session .Run ("id" ) != nil ){
321
+ if (ContainsAny (user_id .String (), []string {"uid=0" , "gid=0" , "root" })){
322
+ uid0_session = true
323
+ }
324
+ }
325
+ return uid0_session
308
326
}
You can’t perform that action at this time.
0 commit comments