-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
93 lines (79 loc) Β· 2.39 KB
/
Copy pathmain.go
File metadata and controls
93 lines (79 loc) Β· 2.39 KB
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
package main
import (
"embed"
"fmt"
"io/fs"
"log"
"net/http"
"os/exec"
"runtime"
goflag "flag"
"auditor/server"
)
//go:embed ui
var uiFiles embed.FS
func main() {
addr := goflag.String("addr", ":8080", "EndereΓ§o do servidor web (ex: :8080 ou 0.0.0.0:8080)")
noBrowser := goflag.Bool("no-browser", false, "NΓ£o abrir o browser automaticamente")
goflag.Parse()
stripped, err := fs.Sub(uiFiles, "ui")
if err != nil {
log.Fatal(err)
}
mux := http.NewServeMux()
// Static UI
mux.Handle("/", http.FileServer(http.FS(stripped)))
// API
mux.HandleFunc("/api/info", server.HandleInfo)
mux.HandleFunc("/api/hash", server.HandleHashExtended)
mux.HandleFunc("/api/crack", server.HandleCrack)
mux.HandleFunc("/api/stop", server.HandleStop)
mux.HandleFunc("/api/progress", server.HandleSSE)
mux.HandleFunc("/api/encode", server.HandleEncode)
mux.HandleFunc("/api/identify", server.HandleIdentifyHash)
mux.HandleFunc("/api/chrome", server.HandleChromeDecrypt)
url := buildURL(*addr)
fmt.Printf("ββββββββββββββββββββββββββββββββββββββββ\n")
fmt.Printf("β Cipher Scope Dashboard β\n")
fmt.Printf("β βββββββββββββββββββββββββββββββββββββββ£\n")
fmt.Printf("β URL: %-31sβ\n", url)
fmt.Printf("ββββββββββββββββββββββββββββββββββββββββ\n")
if !*noBrowser {
go openBrowser(url)
}
log.Fatal(http.ListenAndServe(*addr, mux))
}
// buildURL monta a URL de acesso correta a partir do addr configurado.
//
// ":8080" β "http://localhost:8080"
// "0.0.0.0:8080" β "http://localhost:8080"
// "192.168.0.5:8080" β "http://192.168.0.5:8080"
func buildURL(addr string) string {
host := addr
port := ""
for i := len(addr) - 1; i >= 0; i-- {
if addr[i] == ':' {
host = addr[:i]
port = addr[i:] // inclui ":"
break
}
}
if host == "" || host == "0.0.0.0" {
host = "localhost"
}
return fmt.Sprintf("http://%s%s", host, port)
}
func openBrowser(url string) {
var cmd *exec.Cmd
switch runtime.GOOS {
case "linux":
cmd = exec.Command("xdg-open", url)
case "darwin":
cmd = exec.Command("open", url)
case "windows":
cmd = exec.Command("rundll32", "url.dll,FileProtocolHandler", url)
default:
return
}
cmd.Start()
}