-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
98 lines (92 loc) · 2.24 KB
/
main.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
package main
import (
"fmt"
"time"
)
var (
DBFile = "hashes.db"
AESKey = ""
CheckIntervalSeconds = 60
SensitiveFilesAndDirectories = []string{
// System Configuration Files
"/etc/passwd",
"/etc/shadow",
"/etc/group",
"/etc/sudoers",
"/etc/hosts",
"/etc/hostname",
"/etc/ssh/sshd_config",
"/etc/ssh/ssh_config",
"/etc/fstab",
"/etc/sysctl.conf",
"/etc/crontab",
"/etc/cron.*/*",
"/etc/resolv.conf",
"/etc/nsswitch.conf",
"/etc/pam.d/*",
"/etc/security/*",
// Kernel and Boot Configuration
"/boot/grub/grub.cfg",
"/boot/vmlinuz-*",
"/boot/initrd.img-*",
// Network Configuration
"/etc/network/interfaces",
"/etc/netplan/*",
"/etc/sysconfig/network-scripts/*",
"/etc/iptables/*",
"/etc/firewalld/*",
// SSH and Authorized Keys
"/root/.ssh/authorized_keys",
"/home/*/.ssh/authorized_keys",
"/home/*/.bash_history",
"/home/*/.bashrc",
"/home/*/.profile",
// Application and Service Configuration
"/etc/apache2/*",
"/etc/httpd/*",
"/etc/nginx/*",
"/etc/mysql/my.cnf",
"/etc/my.cnf",
"/etc/postgresql/*",
"/etc/redis/redis.conf",
"/etc/samba/smb.conf",
"/etc/mail/*",
// Sensitive User Files
"/root/.bashrc",
"/root/.profile",
"/root/.history",
"/home/*/.config/*",
// Other Sensitive Files and Directories
"/etc/hosts.allow",
"/etc/hosts.deny",
"/etc/gshadow",
"/etc/ld.so.conf",
"/proc/sys/net/*",
"/var/spool/cron/crontabs/*",
}
)
func main() {
fmt.Println("Starting monitoring file integrity...")
for {
// Running
fmt.Println("Checking integrity...")
integrityChanges, err := CheckIntegrity(DBFile, SensitiveFilesAndDirectories)
if err != nil {
fmt.Printf("Error: %v", err)
}
// Result
fmt.Println("Files added:")
for i, v := range integrityChanges.Added {
fmt.Printf("Added file number %v; Path: %v\n", i, v.FilePath)
}
fmt.Println("Files modified:")
for i, v := range integrityChanges.Modified {
fmt.Printf("Modified file number %v; Path: %v\n", i, v.FilePath)
}
fmt.Println("Files removed:")
for i, v := range integrityChanges.Removed {
fmt.Printf("Removed file number %v; Path: %v\n", i, v.FilePath)
}
time.Sleep(time.Duration(CheckIntervalSeconds) * time.Second)
}
}