-
Notifications
You must be signed in to change notification settings - Fork 10
/
main.go
84 lines (71 loc) · 2.57 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
package main
import (
"fmt"
"io/ioutil"
"time"
"github.com/krishpranav/exploit-framework/lib/cli/dispatcher"
"github.com/krishpranav/exploit-framework/lib/context"
"github.com/krishpranav/exploit-framework/lib/util/config"
"github.com/krishpranav/exploit-framework/lib/util/fs"
"github.com/krishpranav/exploit-framework/lib/util/log"
"github.com/krishpranav/exploit-framework/lib/util/resource"
"github.com/krishpranav/exploit-framework/lib/util/update"
"github.com/pkg/browser"
"gopkg.in/yaml.v2"
)
func main() {
// Detect and create config file
configFilename := fmt.Sprintf("config-v%s.yml", update.Version)
if !fs.FileExists(configFilename) {
content, _ := resource.Asset("lib/runtime/config.example.yml")
ioutil.WriteFile(configFilename, content, 0644)
}
// Read config file
var config config.Config
content, _ := ioutil.ReadFile(configFilename)
err := yaml.Unmarshal(content, &config)
if err != nil {
log.Error("Read config file failed, please check syntax of file `%s`, or just delete the `%s` to force regenerate config file", configFilename, configFilename)
return
}
// Display exploit-framework information
log.Success("exploit-framework %s started with config file: %s", update.Version, configFilename)
// Create context
context.CreateContext()
context.Ctx.Config = &config
// Detect new version
if config.Update {
update.ConfirmAndSelfUpdate()
}
// Init distributor server from config file
rh := config.Distributor.Host
rp := config.Distributor.Port
distributor := context.CreateDistributorServer(rh, rp)
go distributor.Run(fmt.Sprintf("%s:%d", rh, rp))
// Init RESTful Server from config file
if config.RESTful.Enable {
rh := config.RESTful.Host
rp := config.RESTful.Port
rest := context.CreateRESTfulAPIServer()
go rest.Run(fmt.Sprintf("%s:%d", rh, rp))
log.Success("Web FrontEnd started at: http://%s:%d/", rh, rp)
log.Success("You can use Web FrontEnd to manager all your clients with any web browser.")
log.Success("RESTful API EndPoint at: http://%s:%d/api/", rh, rp)
log.Success("You can use PythonSDK to manager all your clients automatically.")
context.Ctx.RESTful = rest
}
// Init servers from config file
for _, s := range config.Servers {
server := context.CreateTCPServer(s.Host, uint16(s.Port), s.HashFormat, s.Encrypted, s.DisableHistory)
if server != nil {
// avoid terminal being disrupted
time.Sleep(0x100 * time.Millisecond)
go (*server).Run()
}
}
if config.OpenBrowser {
browser.OpenURL(fmt.Sprintf("http://%s:%d/", config.RESTful.Host, config.RESTful.Port))
}
// Run main loop
dispatcher.Run()
}