-
Notifications
You must be signed in to change notification settings - Fork 0
/
standaloneSystemScans.go
75 lines (60 loc) · 2.53 KB
/
standaloneSystemScans.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package main
import (
// "os"
"fmt"
"time"
"github.com/fatih/color"
)
func firewallScanStandalone(filePath, ipVersion string) {
time := time.Now()
reportPath := filePath + "sherlock-firewall-scan-report-" + time.Format("01-02-2006") + "/"
fmt.Println("Starting firewall scan now!")
runCommand("mkdir " + reportPath)
runCommand("chmod 777 " + reportPath)
fmt.Println("Saving all files to " + reportPath)
if ipVersion == "ipv4" {
runCommand("touch " + reportPath + "IPv4IptablesRules.txt")
runCommand("iptables -S > " + reportPath + "IPv4IptablesRules.txt")
} else if ipVersion == "ipv6" {
runCommand("touch " + reportPath + "IPv6IptablesRules.txt")
runCommand("ip6tables -S > " + reportPath + "IPv6IptablesRules.txt")
}
}
func suidScanStandalone(filePath string) {
time := time.Now()
reportPath := filePath + "sherlock-suid-scan-report-" + time.Format("01-02-2006") + "/"
fmt.Println("Starting SUID scan now!")
runCommand("mkdir " + reportPath)
runCommand("chmod 777 " + reportPath)
fmt.Println("Saving all files to " + reportPath)
runCommand("touch " + reportPath + "SUIDfiles.txt")
runCommand("sudo find / -perm /4000 2>/dev/null > " + reportPath + "SUIDfiles.txt")
}
func sgidScanStandalone(filePath string) {
time := time.Now()
reportPath := filePath + "sherlock-sgid-scan-report-" + time.Format("01-02-2006") + "/"
fmt.Println("Starting SGID scan now!")
runCommand("mkdir " + reportPath)
runCommand("chmod 777 " + reportPath)
fmt.Println("Saving all files to " + reportPath)
runCommand("touch " + reportPath + "SGIDfiles.txt")
runCommand("sudo find / -perm /2000 2>/dev/null > " + reportPath + "SGIDfiles.txt")
}
func criticalSystemFileBackupStandalone(filePath string) {
time := time.Now()
reportPath := filePath + "sherlock-critical-files-backup" + time.Format("01-02-2006") + "/"
paths := []string{"/etc/passwd", "/etc/shadow", "/etc/group", "/etc/login.defs", "/etc/shells", "/bin/su", "/etc/hosts.allow", "/etc/hosts.deny", "/etc/hosts", "/etc/fstab"}
blue := color.New(color.FgBlue, color.Bold).SprintFunc()
green := color.New(color.FgGreen, color.Bold).SprintFunc()
red := color.New(color.FgRed, color.Bold).SprintFunc()
runCommand("mkdir " + reportPath)
for _, file := range paths {
if checkFileExist(file) == true {
fmt.Printf("[%s] Saving file to specified path\n", green("FOUND"))
runCommand("cp " + file + " " + reportPath)
} else {
fmt.Printf("[%s] Cannot save the file to specified path", red("NOT FOUND"))
}
}
fmt.Printf("[%s] Cannot save the file to specified path\n", blue("COMPLETE"))
}