-
Notifications
You must be signed in to change notification settings - Fork 5
/
main.go
89 lines (85 loc) · 3.12 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
package main
import (
"flag"
"fmt"
"os"
"os/signal"
"sync"
h0neytr4p "github.com/pbssubhash/h0neytr4p"
)
func PrintBanner() {
fmt.Println(`
/$$ /$$$$$$ /$$ /$$ /$$
| $$ /$$$_ $$ | $$ | $$ | $$
| $$$$$$$ | $$$$\ $$ /$$$$$$$ /$$$$$$ /$$ /$$ /$$$$$$ /$$$$$$ | $$ | $$ /$$$$$$
| $$__ $$| $$ $$ $$| $$__ $$ /$$__ $$| $$ | $$|_ $$_/ /$$__ $$| $$$$$$$$ /$$__ $$
| $$ \ $$| $$\ $$$$| $$ \ $$| $$$$$$$$| $$ | $$ | $$ | $$ \__/|_____ $$| $$ \ $$
| $$ | $$| $$ \ $$$| $$ | $$| $$_____/| $$ | $$ | $$ /$$| $$ | $$| $$ | $$
| $$ | $$| $$$$$$/| $$ | $$| $$$$$$$| $$$$$$$ | $$$$/| $$ | $$| $$$$$$$/
|__/ |__/ \______/ |__/ |__/ \_______/ \____ $$ \___/ |__/ |__/| $$____/
/$$ | $$ | $$
Built by a Red team, with <3 | $$$$$$/ | $$
h0neytr4p v0.1 \______/ |__/
Built by zer0p1k4chu & g0dsky
https://github.com/pbssubhash/h0neytr4p
`)
}
// Taken from https://stackoverflow.com/questions/35809252/check-if-flag-was-provided-in-go/35809400
func isFlagPassed(name string) bool {
found := false
flag.Visit(func(f *flag.Flag) {
if f.Name == name {
found = true
}
})
return found
}
func main() {
PrintBanner()
var wg sync.WaitGroup
trapsFolder := flag.String("traps", "Default", "Traps folder - It's a string.")
output := flag.String("output", "Default", "Output file - It's a string.")
log := flag.String("log", "Default", "Log file - It's a string.")
cert := flag.String("cert", "Default", "Certificate File")
key := flag.String("key", "Default", "Certificate File")
Verbose := flag.String("verbose", "true", "Use -verbose=false for disabling streaming output; by default it's true")
help := flag.String("help", "Print Help", "Print Help")
flag.Parse()
if *trapsFolder == "Default" || isFlagPassed(*help) || *output == "Default" || *log == "Default" {
fmt.Println("Wrong Arguments.. Exiting Now")
flag.PrintDefaults()
os.Exit(1)
}
trapConfig := h0neytr4p.ParseTraps(*trapsFolder)
h0neytr4p.CreateTrapFile(*output)
h0neytr4p.CreateLogFile(*log, *Verbose)
var ports []string
filteredTraps := make(map[string][]h0neytr4p.Trap)
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt)
go func() {
for sig := range c {
// sig is a ^C, handle it
if sig == os.Interrupt {
fmt.Println("Interrupt received. Gracefully exiting the program.")
os.Exit(1)
}
}
}()
for _, trap := range trapConfig {
v, found := filteredTraps[trap.Basicinfo.Port]
if found {
v = append(v, trap)
filteredTraps[trap.Basicinfo.Port] = v
} else {
v = append(v, trap)
filteredTraps[trap.Basicinfo.Port] = v
ports = append(ports, trap.Basicinfo.Port)
}
}
for _, port := range ports {
wg.Add(1)
go h0neytr4p.StartHandler(port, filteredTraps[port],*cert,*key)
}
wg.Wait()
}