forked from marco-lancini/goscan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
68 lines (59 loc) · 1.71 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
package main
import (
"fmt"
"github.com/c-bata/go-prompt"
"github.com/fatih/color"
"github.com/thelouiselawrence/goscan/goscan/core/cli"
"github.com/thelouiselawrence/goscan/goscan/core/utils"
"strings"
)
var (
author string
version string
)
// ---------------------------------------------------------------------------------------
// INIT
// ---------------------------------------------------------------------------------------
func showBanner() {
name := fmt.Sprintf("goscan (v.%s)", version)
banner := `
_________ ___________________________ __
__ ____/_______ ___/_ ____/__ |__ | / /
_ / __ _ __ \____ \_ / __ /| |_ |/ /
/ /_/ / / /_/ /___/ // /___ _ ___ | /| /
\____/ \____//____/ \____/ /_/ |_/_/ |_/
`
// Shell width
all_lines := strings.Split(banner, "\n")
w := len(all_lines[1])
// Print Centered
fmt.Println(banner)
color.Green(fmt.Sprintf("%[1]*s", -w, fmt.Sprintf("%[1]*s", (w+len(name))/2, name)))
color.Blue(fmt.Sprintf("%[1]*s", -w, fmt.Sprintf("%[1]*s", (w+len(author))/2, author)))
fmt.Println()
}
func initCore() {
// Check sudo
utils.CheckSudo()
// Show banner
showBanner()
// Initialize global config (db, logger, etc.)
// From now on it will be accessible as utils.Config
utils.InitConfig()
}
// ---------------------------------------------------------------------------------------
// MAIN
// ---------------------------------------------------------------------------------------
func main() {
// Setup core
initCore()
// Start CLI
p := prompt.New(
cli.Executor,
cli.Completer,
prompt.OptionTitle("goscan: Interactive Network Scanner"),
prompt.OptionPrefix("[goscan] > "),
prompt.OptionInputTextColor(prompt.White),
)
p.Run()
}