-
Notifications
You must be signed in to change notification settings - Fork 13
/
main.go
71 lines (64 loc) · 3.54 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
package main
import (
"flag"
"fmt"
"log"
"os"
"os/user"
"github.com/M00NLIG7/ChopChopGo/maps/auditd"
"github.com/M00NLIG7/ChopChopGo/maps/journald"
"github.com/M00NLIG7/ChopChopGo/maps/syslog"
)
func isRoot() bool {
currentUser, err := user.Current()
if err != nil {
log.Fatalf("[isRoot] Unable to get current user: %s", err)
}
return currentUser.Username == "root"
}
func main() {
if !(isRoot()) {
// depending on the file access permissions, we might not need root rights
// especially when targeting logs collected from other systems, we might encounter more lax permissions on the files
fmt.Fprintln(os.Stderr, "Warning: not running as superuser - some accesses might fail!")
}
var target string
var path string
var outputType string
var file string
flag.StringVar(&target, "target", "syslog", "what type of data is to be scanned (auditd, journald, syslog)")
flag.StringVar(&path, "rules", "rules/linux/builtin/syslog", "where to pull the yaml rules youre applying")
flag.StringVar(&outputType, "out", "", "What type of output you want (csv, json, tables)")
flag.StringVar(&file, "file", "", "which specific file should be scanned (falls back to target-specific defaults when left empty)")
flag.Parse()
if !((outputType == "csv") || (outputType == "json")) {
banner := ` ▄████▄ ██░ ██ ▒█████ ██▓███ ▄████▄ ██░ ██ ▒█████ ██▓███ ▄████ ▒█████
▒██▀ ▀█ ▓██░ ██▒▒██▒ ██▒▓██░ ██▒ ▒██▀ ▀█ ▓██░ ██▒▒██▒ ██▒▓██░ ██▒ ██▒ ▀█▒▒██▒ ██▒
▒▓█ ▄ ▒██▀▀██░▒██░ ██▒▓██░ ██▓▒ ▒▓█ ▄ ▒██▀▀██░▒██░ ██▒▓██░ ██▓▒ ▒██░▄▄▄░▒██░ ██▒
▒▓▓▄ ▄██▒░▓█ ░██ ▒██ ██░▒██▄█▓▒ ▒ ▒▓▓▄ ▄██▒░▓█ ░██ ▒██ ██░▒██▄█▓▒ ▒ ░▓█ ██▓▒██ ██░
▒ ▓███▀ ░░▓█▒░██▓░ ████▓▒░▒██▒ ░ ░ ▒ ▓███▀ ░░▓█▒░██▓░ ████▓▒░▒██▒ ░ ░ ░▒▓███▀▒░ ████▓▒░
░ ░▒ ▒ ░ ▒ ░░▒░▒░ ▒░▒░▒░ ▒▓▒░ ░ ░ ░ ░▒ ▒ ░ ▒ ░░▒░▒░ ▒░▒░▒░ ▒▓▒░ ░ ░ ░▒ ▒ ░ ▒░▒░▒░
░ ▒ ▒ ░▒░ ░ ░ ▒ ▒░ ░▒ ░ ░ ▒ ▒ ░▒░ ░ ░ ▒ ▒░ ░▒ ░ ░ ░ ░ ▒ ▒░
░ ░ ░░ ░░ ░ ░ ▒ ░░ ░ ░ ░░ ░░ ░ ░ ▒ ░░ ░ ░ ░ ░ ░ ░ ▒
░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░
░ ░
By Keyboard Cowboys (M00NL1G7)
`
fmt.Println(banner)
}
switch target {
case "auditd":
auditd.Chop(path, outputType, file)
case "syslog":
syslog.Chop(path, outputType, file)
case "journald":
if file == "" {
journald.Chop(path, outputType)
} else {
fmt.Printf("combination of target %v and giving a file not supported", target)
}
default:
fmt.Printf("Invalid Target Type")
return
}
}