-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
73 lines (60 loc) · 1.34 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
package main
import (
"bufio"
"flag"
"fmt"
"os"
"github.com/chzyer/readline"
"github.com/The-Cracker-Technology/fiesta/pkg/core"
)
type fiestaPrompt struct {
I *readline.Instance
CompleterRoot *readline.PrefixCompleter
CompleterUse *readline.PrefixCompleter
magic printMagic
Attack string
exit bool
c core.Core
}
func main() {
var p fiestaPrompt
var e error
// Parse params
var rcFile string
flag.StringVar(&rcFile, "r", "", "Execute resource file (- for stdin)")
flag.Parse()
// Read commands from resource file (if any)
var rcCommands []string
if len(rcFile) > 0 {
file, errFile := os.Open(rcFile)
if errFile != nil {
fmt.Printf("File %s does not exist or could not be opened\n", rcFile)
}
defer file.Close()
scanner := bufio.NewScanner(file)
scanner.Split(bufio.ScanLines)
for scanner.Scan() {
rcCommands = append(rcCommands, scanner.Text())
}
}
// Show banner
p.Banner()
p.magic.PrintStatus("Are you ready for the FIESTA? ;)")
p.magic.NewLine()
// Prepare Prompt
p.PrepareCompleter()
p.I, e = readline.NewEx(&readline.Config{
AutoComplete: p.CompleterRoot,
HistorySearchFold: true,
})
if e != nil {
panic(e)
}
defer p.I.Close()
// Insert RC commands into ReadLine
for _, s := range rcCommands {
p.I.WriteStdin([]byte(s + "\n"))
}
// Run interactive prompt
p.Run()
}