-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathsecurity_controller.php
executable file
·259 lines (243 loc) · 7.94 KB
/
security_controller.php
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
<?php
/**
* Security module class
*
* @package munkireport
* @author tuxudo
**/
class Security_controller extends Module_controller
{
/*** Protect methods with auth! ****/
function __construct()
{
// Store module path
$this->module_path = dirname(__FILE__);
}
/**
* Default method
* @author AvB
*
**/
function index()
{
echo "You've loaded the security module!";
}
/**
* Get Activation Lock statistics data in json format
*
* @return void
* @author eholtam/tuxudo
**/
public function get_activation_lock_stats()
{
jsonView(
Security_model::selectRaw("COUNT(CASE WHEN `activation_lock` = 'activation_lock_enabled' THEN 1 END) AS 'Enabled'")
->selectRaw("COUNT(CASE WHEN `activation_lock` = 'activation_lock_disabled' THEN 1 END) AS 'Disabled'")
->selectRaw("COUNT(CASE WHEN `activation_lock` = 'not_supported' THEN 1 END) AS 'Notsupported'")
->filter()
->first()
->toLabelCount()
);
}
/**
* Get SIP statistics data in json format
*
* @return void
* @author rickheil/tuxudo
**/
public function get_sip_stats()
{
jsonView(
Security_model::selectRaw("COUNT(CASE WHEN `sip` = 'Active' THEN 1 END) AS 'Active'")
->selectRaw("COUNT(CASE WHEN `sip` = 'Disabled' THEN 1 END) AS 'Disabled'")
->filter()
->first()
->toLabelCount()
);
}
/**
* Get Gatekeeper statistics data in json format
*
* @return void
* @author rickheil/tuxudo
**/
public function get_gatekeeper_stats()
{
jsonView(
Security_model::selectRaw("COUNT(CASE WHEN `gatekeeper` = 'Active' THEN 1 END) AS 'Active'")
->selectRaw("COUNT(CASE WHEN `gatekeeper` = 'Disabled' THEN 1 END) AS 'Disabled'")
->filter()
->first()
->toLabelCount()
);
}
/**
* Get firmware statistics data in json format
*
* @return void
* @author rickheil/tuxudo
**/
public function get_firmwarepw_stats()
{
jsonView(
Security_model::selectRaw("COUNT(CASE WHEN `firmwarepw` = 'Yes' THEN 1 END) AS 'enabled'")
->selectRaw("COUNT(CASE WHEN `firmwarepw` = 'No' THEN 1 END) AS 'disabled'")
->selectRaw("COUNT(CASE WHEN `firmwarepw` = 'Not Supported' THEN 1 END) AS 'notsupported'")
->filter()
->first()
->toLabelCount()
);
}
/**
* Get firewall state data in json format
*
* @return void
* @author rickheil/tuxudo
**/
public function get_firewall_state_stats()
{
jsonView(
Security_model::selectRaw("COUNT(CASE WHEN `firewall_state` = '2' THEN 1 END) AS 'blockall'")
->selectRaw("COUNT(CASE WHEN `firewall_state` = '1' THEN 1 END) AS 'enabled'")
->selectRaw("COUNT(CASE WHEN `firewall_state` = '0' THEN 1 END) AS 'disabled'")
->filter()
->first()
->toLabelCount()
);
}
/**
* Get Secure Kernel Extension Loading ("SKEL") data in json format
*
* @return void
* @author rickheil/tuxudo
**/
public function get_skel_stats()
{
jsonView(
Security_model::selectRaw("COUNT(CASE WHEN `skel_state` = '0' THEN 1 END) AS 'disabled'")
->selectRaw("COUNT(CASE WHEN `skel_state` = '1' THEN 1 END) AS 'enabled'")
->filter()
->first()
->toLabelCount()
);
}
/**
* Get SSH data in json format
*
* @return void
* @author eholtam/tuxudo
**/
public function get_ssh_stats()
{
jsonView(
Security_model::selectRaw("COUNT(CASE WHEN `ssh_users` <> 'SSH Disabled' THEN 1 END) AS 'enabled'")
->selectRaw("COUNT(CASE WHEN `ssh_users` = 'SSH Disabled' THEN 1 END) AS 'disabled'")
->filter()
->first()
->toLabelCount()
);
}
/**
* Get root user data in json format
*
* @return void
* @author rickheil/tuxudo
**/
public function get_root_user_stats()
{
jsonView(
Security_model::selectRaw("COUNT(CASE WHEN `root_user` = '0' THEN 1 END) AS 'disabled'")
->selectRaw("COUNT(CASE WHEN `root_user` = '1' THEN 1 END) AS 'enabled'")
->filter()
->first()
->toLabelCount()
);
}
/**
* Get secure boot data in json format
*
* @return void
* @author eholtam/tuxudo
**/
public function get_secureboot_stats()
{
jsonView(
Security_model::selectRaw("COUNT(CASE WHEN `t2_secureboot` = 'SECUREBOOT_FULL' THEN 1 END) AS 'securebootfull'")
->selectRaw("COUNT(CASE WHEN `t2_secureboot` = 'SECUREBOOT_MEDIUM' THEN 1 END) AS 'securebootmedium'")
->selectRaw("COUNT(CASE WHEN `t2_secureboot` = 'SECUREBOOT_OFF' THEN 1 END) AS 'securebootoff'")
->selectRaw("COUNT(CASE WHEN `t2_secureboot` = 'SECUREBOOT_UNKNOWN' THEN 1 END) AS 'securebootunknown'")
->selectRaw("COUNT(CASE WHEN `t2_secureboot` = 'SECUREBOOT_UNSUPPORTED' THEN 1 END) AS 'securebootunsupported'")
->filter()
->first()
->toLabelCount()
);
}
/**
* Get external boot data in json format
*
* @return void
* @author eholtam/tuxudo
**/
public function get_externalboot_stats()
{
jsonView(
Security_model::selectRaw("COUNT(CASE WHEN `t2_externalboot` = 'EXTERNALBOOT_ON' THEN 1 END) AS 'externalbooton'")
->selectRaw("COUNT(CASE WHEN `t2_externalboot` = 'EXTERNALBOOT_OFF' THEN 1 END) AS 'externalbootoff'")
->selectRaw("COUNT(CASE WHEN `t2_externalboot` = 'EXTERNALBOOT_UNKNOWN' THEN 1 END) AS 'externalbootunknown'")
->selectRaw("COUNT(CASE WHEN `t2_externalboot` = 'EXTERNALBOOT_UNSUPPORTED' THEN 1 END) AS 'externalbootunsupported'")
->filter()
->first()
->toLabelCount()
);
}
/**
* Get security mode data in json format
*
* @return void
* @author tuxudo
**/
public function get_security_mode_stats()
{
jsonView(
Security_model::selectRaw("COUNT(CASE WHEN `as_security_mode` = 'FULL_SECURITY' THEN 1 END) AS 'full'")
->selectRaw("COUNT(CASE WHEN `as_security_mode` = 'REDUCED_SECURITY' THEN 1 END) AS 'reduced'")
->selectRaw("COUNT(CASE WHEN `as_security_mode` = 'PERMISSIVE_SECURITY' THEN 1 END) AS 'permissive'")
->selectRaw("COUNT(CASE WHEN `as_security_mode` = 'UNKNOWN' THEN 1 END) AS 'unknown'")
->selectRaw("COUNT(CASE WHEN `as_security_mode` = 'SECURITYMODE_UNSUPPORTED' THEN 1 END) AS 'unsupported'")
->filter()
->first()
->toLabelCount()
);
}
/**
* Get FileVault data in json format
*
* @return void
* @author tuxudo
**/
public function get_filevault_status()
{
jsonView(
Security_model::selectRaw("COUNT(CASE WHEN `filevault_status` = 1 THEN 1 END) AS 'On'")
->selectRaw("COUNT(CASE WHEN `filevault_status` = 0 THEN 1 END) AS 'Off'")
->selectRaw("COUNT(CASE WHEN `filevault_status` IS NULL THEN 1 END) AS 'Unknown'")
->filter()
->first()
->toLabelCount()
);
}
/**
* Retrieve data in json format
*
**/
public function get_data($serial_number)
{
jsonView(
Security_model::select()
->where('security.serial_number', $serial_number)
->filter()
->get()
->toArray()
);
}
} // End class Security_controller