Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
alpkeskin
GitHub Repository: alpkeskin/mosint
Path: blob/master/v3/pkg/engine/engine.go
689 views
1
/*
2
Copyright © 2023 github.com/alpkeskin
3
*/
4
package engine
5
6
import (
7
"fmt"
8
"os"
9
"strings"
10
11
"github.com/alpkeskin/mosint/v3/internal/config"
12
. "github.com/alpkeskin/mosint/v3/internal/config"
13
"github.com/alpkeskin/mosint/v3/internal/output"
14
"github.com/alpkeskin/mosint/v3/internal/runner"
15
"github.com/alpkeskin/mosint/v3/pkg/verification"
16
"github.com/dimiro1/banner"
17
"github.com/fatih/color"
18
"github.com/mattn/go-colorable"
19
"github.com/spf13/cobra"
20
)
21
22
var rootCmd = &cobra.Command{
23
Use: "mosint [email]",
24
Short: "\nAn automated e-mail OSINT tool ",
25
Long: "\nAn automated e-mail OSINT tool written in Go with a focus on simplicity and performance.",
26
Run: magic,
27
Version: "v3.0.0",
28
}
29
30
var (
31
cfgFile string
32
outputPath string
33
silent bool
34
coffee bool
35
)
36
37
func Start() {
38
err := rootCmd.Execute()
39
if err != nil {
40
panic(err)
41
}
42
}
43
44
func magic(cmd *cobra.Command, args []string) {
45
if coffee {
46
c := `
47
( (
48
) )
49
........
50
| |]
51
\ /
52
'----'
53
54
enjoy your coffee ☕️
55
`
56
fmt.Println(c)
57
os.Exit(0)
58
}
59
60
if len(args) < 1 {
61
cmd.Help()
62
return
63
}
64
65
Cfg = config.New()
66
if !Cfg.Exists(cfgFile) {
67
msg := fmt.Sprintf(configHelp(), color.YellowString(".mosint.yaml"))
68
println(msg)
69
os.Exit(1)
70
}
71
72
err := Cfg.Parse(cfgFile)
73
74
if err != nil {
75
panic(err)
76
}
77
78
email := args[0]
79
fmt.Println("Target Email:", color.YellowString(email), color.GreenString("✓"))
80
println()
81
82
verification := verification.New()
83
if !verification.Syntax(email) {
84
color.Red("Email syntax is not valid! Process stopped.")
85
os.Exit(1)
86
}
87
88
runner := runner.New(email)
89
runner.Start()
90
91
if !silent {
92
runner.Print()
93
}
94
95
if !strings.EqualFold(outputPath, "") {
96
output := output.New()
97
output.SetFilePath(outputPath)
98
output.JSON(runner)
99
}
100
}
101
102
func configHelp() string {
103
return `
104
You must create a config file in your home directory named %s
105
Or you can use --config flag to specify a config file
106
107
You can find an example config file in the repository:
108
https://github.com/alpkeskin/mosint/blob/master/example-config.yaml
109
`
110
}
111
112
func init() {
113
template := `{{ .Title "mosint" "" 2 }}
114
{{ .AnsiColor.BrightWhite }}v3.0{{ .AnsiColor.Default }}
115
{{ .AnsiColor.BrightCyan }}https://github.com/alpkeskin/{{ .AnsiColor.Default }}
116
Now: {{ .Now "Monday, 2 Jan 2006" }}`
117
118
banner.InitString(colorable.NewColorableStdout(), true, true, template)
119
println()
120
121
rootCmd.PersistentFlags().BoolVar(&coffee, "coffee", false, "☕️")
122
rootCmd.PersistentFlags().StringVarP(&cfgFile, "config", "c", "", "config file (default is $HOME/.mosint.yaml)")
123
rootCmd.PersistentFlags().StringVarP(&outputPath, "output", "o", "", "output file (.json)")
124
rootCmd.PersistentFlags().BoolVarP(&silent, "silent", "s", false, "silent mode (only output file)")
125
}
126
127