-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.go
99 lines (88 loc) · 2.22 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
99
package main
import (
"github.com/fatih/color"
"go-osint/domain"
"go-osint/keywords"
"go-osint/username"
"os"
)
func showUsage() {
color.Red("Usage: go-osint [type] [term] (platform)")
color.Yellow("- [type]: \"username\", \"keywords\", or \"domain\"")
color.Yellow("- [term]: The [type] to search for")
color.Yellow("- (platform): The platform to search for the username on (optional)")
}
func main() {
if len(os.Args) < 3 {
showUsage()
return
}
searchType := os.Args[1]
searchTerm := os.Args[2]
var outputFile string
var urls []string
// Check for output argument
for i, arg := range os.Args {
if (arg == "--output" || arg == "-o") && i+1 < len(os.Args) {
outputFile = os.Args[i+1]
}
}
switch searchType {
case "username":
if len(os.Args) == 4 {
platform := os.Args[3]
ptr := username.Search(searchTerm, platform)
if ptr != nil {
urls = append(urls, *ptr)
}
} else {
ptr := username.SearchAll(searchTerm)
if ptr != nil {
urls = append(urls, *ptr...)
}
}
case "keywords":
ptr := keywords.Search(searchTerm)
if ptr != nil {
urls = append(urls, *ptr...)
for _, url := range urls {
color.Green("[OK] Found URL: %s", url)
}
}
case "domain":
domainInfo, err := domain.Search(searchTerm)
if err != nil {
color.Red("Error searching domain: %v", err)
return
}
if domainInfo != nil {
color.Green("[OK] Domain Info for %s:", searchTerm)
color.Blue("Owner Name: %s", domainInfo.OwnerName)
color.Blue("Registrar: %s", domainInfo.Registrar)
color.Blue("Creation Date: %s", domainInfo.CreationDate)
color.Blue("Expiration Date: %s", domainInfo.ExpirationDate)
color.Blue("Status: %s", domainInfo.Status)
} else {
color.Yellow("[INFO] No information found for domain: %s", searchTerm)
}
default:
showUsage()
}
if outputFile != "" {
file, err := os.Create(outputFile)
if err != nil {
color.Red("Failed to create output file: %v", err)
return
}
defer func(file *os.File) {
err := file.Close()
if err != nil {
color.Red("Failed to close output file: %v", err)
}
}(file)
for _, url := range urls {
_, _ = file.WriteString(url + "\n")
}
color.Green("[OK] Wrote %d (found) URLs to %s", len(urls), outputFile)
}
}