/
main.go
72 lines (59 loc) · 1.59 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
package main
import (
"flag"
"fmt"
"log"
"os"
"os/user"
"regexp"
"github.com/hambyhacks/CTFRecon-Go/scripts"
)
func main() {
// Initialize Flags
ip := flag.String("i", "", "IP Address.")
dir := flag.String("d", "", "Directory to be created.")
platform := flag.String("p", "", "Extension to be added to /etc/hosts file.")
wordlist := flag.String("w", "common.txt", "Wordlist for Directory Busting.")
flag.Parse()
// Variables
dir_list := []string{"exploit", "loot", "scans", "ss"}
u, err := user.Current()
if err != nil {
log.Fatal(err)
os.Exit(1)
}
regex_txt, err := regexp.MatchString(".txt", *wordlist)
if err != nil {
log.Fatal(err)
os.Exit(1)
}
// GoRecon Usage
if os.Args[1] == "-h" || os.Args[1] == "" {
flag.PrintDefaults()
os.Exit(1)
}
// Check args count, current user, and wordlist if it has `.txt` in it.
if len(os.Args) < 1 || u.Username != "root" || !regex_txt {
flag.PrintDefaults()
log.Fatal("Possible Errors: ", u.Username, len(os.Args), regex_txt)
os.Exit(1)
}
// Create directories.
for _, i := range dir_list {
os.MkdirAll(*dir+"/"+*ip+"/"+i, 0755)
os.Chown(*dir+"/"+*ip+"/"+i, 1000, 1000)
}
// Append IP to /etc/hosts file.
f, err := os.OpenFile("/etc/hosts", os.O_APPEND|os.O_WRONLY, 0600)
if err != nil {
log.Fatal(err)
}
defer f.Close()
f.WriteString(*ip + " " + *dir + "." + *platform + "\n")
// Run Scripts
fmt.Println("Scripts are now running...")
go scripts.Nmap(*ip, *dir)
scripts.GoBuster(*ip, *dir, *wordlist)
fmt.Println("[i] Nmap: Done (Check /scans folder)")
fmt.Println("[i] GoBuster: Done (Check /scans folder)")
}