forked from hardentools/hardentools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoffice.go
115 lines (94 loc) · 3.16 KB
/
office.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
/*
Hardentools
Copyright (C) 2017 Claudio Guarnieri, Mariano Graziano
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package main
import (
"fmt"
"golang.org/x/sys/windows/registry"
)
var office_versions = []string{
"12.0", // Office 2007
"14.0", // Office 2010
"15.0", // Office 2013
"16.0", // Office 2016
}
var office_apps = []string{"Excel", "PowerPoint", "Word"}
// Office Packager Objects
/*
0 - No prompt from Office when user clicks, object executes
1 - Prompt from Office when user clicks, object executes
2 - No prompt, Object does not execute
*/
func trigger_ole(enable bool) {
var value uint32
if enable {
// Enable Packager
events.AppendText("Enabling Office Packager Objects\n")
value = 1
} else {
// Disable Packager
events.AppendText("Disabling Office Packager Objects\n")
value = 2
}
for _, office_version := range office_versions {
for _, office_app := range office_apps {
path := fmt.Sprintf("SOFTWARE\\Microsoft\\Office\\%s\\%s\\Security", office_version, office_app)
key, _ := registry.OpenKey(registry.CURRENT_USER, path, registry.WRITE)
key.SetDWordValue("PackagerPrompt", value)
key.Close()
}
}
}
// Office Macros
/*
1 - Enable all
2 - Disable with notification
3 - Digitally signed only
4 - Disable all
*/
func trigger_macro(enable bool) {
var value uint32
if enable {
// Enable Macro
events.AppendText("Enabling Office Macros\n")
value = 2
} else {
// Disable Macro
events.AppendText("Disabling Office Macros\n")
value = 4
}
for _, office_version := range office_versions {
for _, office_app := range office_apps {
// TODO: Should we leave Excel enabled?
path := fmt.Sprintf("SOFTWARE\\Microsoft\\Office\\%s\\%s\\Security", office_version, office_app)
key, _ := registry.OpenKey(registry.CURRENT_USER, path, registry.WRITE)
key.SetDWordValue("VBAWarnings", value)
key.Close()
}
}
}
// ActiveX
func trigger_activex(enable bool) {
key, _, _ := registry.CreateKey(registry.CURRENT_USER, "SOFTWARE\\Microsoft\\Office\\Common\\Security", registry.WRITE)
if enable {
// Enable ActiveX
events.AppendText("Enabling ActiveX in Office\n")
key.DeleteValue("DisableAllActiveX")
} else {
// Disable ActiveX
events.AppendText("Disabling ActiveX in Office\n")
key.SetDWordValue("DisableAllActiveX", 1)
}
key.Close()
}