-
Notifications
You must be signed in to change notification settings - Fork 0
/
standaloneLogScans.go
72 lines (60 loc) · 2.22 KB
/
standaloneLogScans.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
package main
import (
"os"
"fmt"
"time"
)
func getApache2LogsStandalone(filePath string) {
time := time.Now()
reportPath := filePath + "sherlock-apache2-log-scan-report-" + time.Format("01-02-2006") + "/"
runCommand("mkdir " + reportPath)
possibleLogFileLocations := []string{"/var/log/apache/access.log", "/var/log/apache2/access.log", "/etc/httpd/logs/access_log"}
// check to see where the access logs are and if found then copy them to desired file path
for _, file := range possibleLogFileLocations {
if _, err := os.Stat(file); err == nil {
fmt.Println("The Apache access log exists at " + file)
runCommand("chmod 777 " + reportPath)
runCommand("cp -r " + file + " " + reportPath)
} else {
errorPrint("The Apache access log does not exist at " + file)
}
}
}
func getNginxLogsStandalone(filePath string) {
time := time.Now()
reportPath := filePath + "sherlock-nginx-log-scan-report-" + time.Format("01-02-2006") + "/"
runCommand("mkdir " + reportPath)
possibleLogFileLocations := []string{"/var/log/nginx/access.log", "/var/log/nginx/error.log"}
for _, file := range possibleLogFileLocations {
if _, err := os.Stat(file); err == nil {
fmt.Println("The Nginx log exists at " + file)
runCommand("chmod 777 " + reportPath)
runCommand("cp -r " + file + " " + reportPath)
} else {
errorPrint("The Nginx log does not exist at " + file)
}
}
}
func getAuthLogsStandalone(filePath string) {
time := time.Now()
reportPath := filePath + "sherlock-auth-log-scan-report-" + time.Format("01-02-2006") + "/"
runCommand("mkdir " + reportPath)
if _, err := os.Stat("/var/log/auth.log"); err == nil {
fmt.Println("The system authentication log exists!")
runCommand("cp /var/log/auth.log " + reportPath)
} else {
fmt.Println("The system authentication log does NOT exist!")
fmt.Println("sus :thinking:")
}
}
func getDpkgLogsStandalone(filePath string) {
time := time.Now()
reportPath := filePath + "sherlock-dpkg-log-scan-report-" + time.Format("01-02-2006") + "/"
runCommand("mkdir " + reportPath)
if _, err := os.Stat("/var/log/dpkg.log"); err == nil {
fmt.Println("The dpkg log exists!")
runCommand("cp /var/log/dpkg.log " + reportPath)
} else {
fmt.Println("The dpkg log does NOT exist!")
}
}