/
hipreport.sh
executable file
·444 lines (426 loc) · 11.5 KB
/
hipreport.sh
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
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
#!/bin/sh
# openconnect will call this script with the follow command-line
# arguments, which are needed to populate the contents of the
# HIP report:
#
# --cookie: a URL-encoded string, as output by openconnect
# --authenticate --protocol=gp, which includes parameters
# from the /ssl-vpn/login.esp response
#
# --client-ip{,v6}: IPv4/6 addresses allocated by the GlobalProtect
# VPN for this client (included in
# /ssl-vpn/getconfig.esp response)
#
# --md5: The md5 digest to encode into this HIP report. I'm not sure
# exactly what this is the md5 digest *of*, but all that
# really matters is that the value in the HIP report
# submission should match the value in the HIP report check.
#
# --client-os: The platform name in GlobalProtect's format (known
# values are 'Linux', 'Mac' or 'Windows' ). Defaults to
# 'Windows'.
#
# Sending these parameters as --long-options was a mistake (see
# comments on run_hip_script in gpst.c for more details). New
# parameters should be sent as environment variables instead:
#
# APP_VERSION: client software version, labeled here in the HIP
# report as '<client-version>', but as 'app-version' or as
# 'clientgpversion' elsewhere in the GlobalProtect wire protocol.
#
# This hipreport.sh does not work as-is on Android. The large here-doc
# (cat <<EOF) does not appear to work with Android's /system/bin/sh,
# likely due to an insufficient read buffer size.
# Try hipreport-android.sh instead.
# Read command line arguments into variables
COOKIE=
IP=
IPv6=
MD5=
CLIENTOS=Windows
while [ "$1" ]; do
if [ "$1" = "--cookie" ]; then shift; COOKIE="$1"; fi
if [ "$1" = "--client-ip" ]; then shift; IP="$1"; fi
if [ "$1" = "--client-ipv6" ]; then shift; IPV6="$1"; fi
if [ "$1" = "--md5" ]; then shift; MD5="$1"; fi
if [ "$1" = "--client-os" ]; then shift; CLIENTOS="$1"; fi
shift
done
if [ -z "$COOKIE" -o -z "$MD5" -o -z "$IP$IPV6" ]; then
echo "Parameters --cookie, --md5, and --client-ip and/or --client-ipv6 are required" >&2
exit 1;
fi
# Extract username and domain and computer from cookie
USER=$(echo "$COOKIE" | sed -rn 's/(.+&|^)user=([^&]+)(&.+|$)/\2/p')
DOMAIN=$(echo "$COOKIE" | sed -rn 's/(.+&|^)domain=([^&]+)(&.+|$)/\2/p')
COMPUTER=$(echo "$COOKIE" | sed -rn 's/(.+&|^)computer=([^&]+)(&.+|$)/\2/p')
case $CLIENTOS in
Linux)
OS="Linux Fedora 32"
OS_VENDOR="Linux"
NETWORK_INTERFACE_NAME="virbr0"
NETWORK_INTERFACE_DESCRIPTION="virbr0"
# Not currently used for Linux
ENCDRIVE='/'
;;
Mac)
# set to desired default OS version if not actually running on MacOS
OS_VERSION=$(sw_vers --productVersion 2> /dev/null || echo 10.16.0)
OS="Apple Mac OS X ${OS_VERSION}"
OS_VENDOR="Apple"
NETWORK_INTERFACE_NAME="en0"
NETWORK_INTERFACE_DESCRIPTION="en0"
# Not currently used for MacOS
ENCDRIVE='/'
;;
*)
OS="Microsoft Windows 10 Pro , 64-bit"
OS_VENDOR="Microsoft"
NETWORK_INTERFACE_NAME="{DEADBEEF-DEAD-BEEF-DEAD-BEEFDEADBEEF}"
NETWORK_INTERFACE_DESCRIPTION="PANGP Virtual Ethernet Adapter #2"
# Many VPNs seem to require trailing backslash, others don't accept it
ENCDRIVE='C:\\'
;;
esac
# If default/made-up values are not accepted, these values may need to be extracted from the
# HIP report sent by an official GlobalProtect client.
HOST_ID="deadbeef-dead-beef-dead-beefdeadbeef"
if [ -z "$APP_VERSION" ]; then APP_VERSION=5.1.5-8; fi
# Timestamp in the format expected by GlobalProtect server
NOW=$(date +'%m/%d/%Y %H:%M:%S')
DAY=$(date +'%d')
MONTH=$(date +'%m')
YEAR=$(date +'%Y')
cat <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<hip-report name="hip-report">
<md5-sum>$MD5</md5-sum>
<user-name>$USER</user-name>
<domain>$DOMAIN</domain>
<host-name>$COMPUTER</host-name>
<host-id>$HOST_ID</host-id>
<ip-address>$IP</ip-address>
<ipv6-address>$IPV6</ipv6-address>
<generate-time>$NOW</generate-time>
<hip-report-version>4</hip-report-version>
<categories>
<entry name="host-info">
<client-version>$APP_VERSION</client-version>
<os>$OS</os>
<os-vendor>$OS_VENDOR</os-vendor>
<domain>$DOMAIN.internal</domain>
<host-name>$COMPUTER</host-name>
<host-id>$HOST_ID</host-id>
<network-interface>
<entry name="$NETWORK_INTERFACE_NAME">
<description>$NETWORK_INTERFACE_DESCRIPTION</description>
<mac-address>01-02-03-00-00-01</mac-address>
<ip-address>
<entry name="$IP"/>
</ip-address>
<ipv6-address>
<entry name="$IPV6"/>
</ipv6-address>
</entry>
</network-interface>
</entry>
EOF
case $CLIENTOS in
Linux)
;;
Mac)
;;
*) cat <<EOF
<entry name="antivirus">
<list>
<entry>
<ProductInfo>
<Prod name="McAfee VirusScan Enterprise" version="8.8.0.1804" defver="8682.0" prodType="1" engver="5900.7806" osType="1" vendor="McAfee, Inc." dateday="$DAY" dateyear="$YEAR" datemon="$MONTH">
</Prod>
<real-time-protection>yes</real-time-protection>
<last-full-scan-time>$NOW</last-full-scan-time>
</ProductInfo>
</entry>
<entry>
<ProductInfo>
<Prod name="Windows Defender" version="4.11.15063.332" defver="1.245.683.0" prodType="1" engver="1.1.13804.0" osType="1" vendor="Microsoft Corp." dateday="$DAY" dateyear="$YEAR" datemon="$MONTH">
</Prod>
<real-time-protection>no</real-time-protection>
<last-full-scan-time>n/a</last-full-scan-time>
</ProductInfo>
</entry>
</list>
</entry>
EOF
;;
esac
case $CLIENTOS in
Linux) cat <<EOF
<entry name="anti-malware">
<list/>
</entry>
EOF
;;
Mac) cat <<EOF
<entry name="anti-malware">
<list>
<entry>
<ProductInfo>
<Prod vendor="Apple Inc." name="Xprotect" version="2167" defver="235000000000000" engver="" datemon="$MONTH" dateday="$DAY" dateyear="$YAR" prodType="3" osType="4"/>
<real-time-protection>yes</real-time-protection>
<last-full-scan-time>n/a</last-full-scan-time>
</ProductInfo>
</entry>
<entry>
<ProductInfo>
<Prod vendor="Apple Inc." name="Gatekeeper" version="${OS_VERSION}" defver="" engver="" datemon="$MONTH" dateday="$DAY" dateyear="$YEAR" prodType="3" osType="4"/>
<real-time-protection>yes</real-time-protection>
<last-full-scan-time>n/a</last-full-scan-time>
</ProductInfo>
</entry>
</list>
</entry>
EOF
;;
*) cat <<EOF
<entry name="anti-spyware">
<list>
<entry>
<ProductInfo>
<Prod name="McAfee VirusScan Enterprise" version="8.8.0.1804" defver="8682.0" prodType="2" engver="5900.7806" osType="1" vendor="McAfee, Inc." dateday="$DAY" dateyear="$YEAR" datemon="$MONTH">
</Prod>
<real-time-protection>yes</real-time-protection>
<last-full-scan-time>$NOW</last-full-scan-time>
</ProductInfo>
</entry>
<entry>
<ProductInfo>
<Prod name="Windows Defender" version="4.11.15063.332" defver="1.245.683.0" prodType="2" engver="1.1.13804.0" osType="1" vendor="Microsoft Corp." dateday="$DAY" dateyear="$YEAR" datemon="$MONTH">
</Prod>
<real-time-protection>no</real-time-protection>
<last-full-scan-time>n/a</last-full-scan-time>
</ProductInfo>
</entry>
</list>
</entry>
EOF
;;
esac
case $CLIENTOS in
Linux) cat <<EOF
<entry name="disk-backup">
<list/>
</entry>
EOF
;;
Mac) cat <<EOF
<entry name="disk-backup">
<list>
<entry>
<ProductInfo>
<Prod vendor="Apple Inc." name="Time Machine" version="1.3"/>
<last-backup-time>n/a</last-backup-time>
</ProductInfo>
</entry>
</list>
</entry>
EOF
;;
*) cat <<EOF
<entry name="disk-backup">
<list>
<entry>
<ProductInfo>
<Prod name="Windows Backup and Restore" version="10.0.15063.0" vendor="Microsoft Corp.">
</Prod>
<last-backup-time>n/a</last-backup-time>
</ProductInfo>
</entry>
</list>
</entry>
EOF
;;
esac
case $CLIENTOS in
Mac) cat <<EOF
<entry name="disk-encryption">
<list>
<entry>
<ProductInfo>
<Prod vendor="Apple Inc." name="FileVault" version="${OS_VERSION}"/>
<drives>
<entry>
<drive-name>Macintosh HD</drive-name>
<enc-state>encrypted</enc-state>
</entry>
<entry>
<drive-name>Data</drive-name>
<enc-state>encrypted</enc-state>
</entry>
<entry>
<drive-name>All</drive-name>
<enc-state>encrypted</enc-state>
</entry>
</drives>
</ProductInfo>
</entry>
</list>
</entry>
EOF
;;
Linux) cat <<EOF
<entry name="disk-encryption">
<list>
<entry>
<ProductInfo>
<Prod name="cryptsetup" version="2.3.3" vendor="GitLab Inc.">
</Prod>
<drives>
<entry>
<drive-name>/</drive-name>
<enc-state>encrypted</enc-state>
</entry>
</drives>
</ProductInfo>
</entry>
</list>
</entry>
EOF
;;
*) cat <<EOF
<entry name="disk-encryption">
<list>
<entry>
<ProductInfo>
<Prod name="Windows Drive Encryption" version="10.0.15063.0" vendor="Microsoft Corp.">
</Prod>
<drives>
<entry>
<drive-name>$ENCDRIVE</drive-name>
<enc-state>full</enc-state>
</entry>
</drives>
</ProductInfo>
</entry>
</list>
</entry>
EOF
;;
esac
case $CLIENTOS in
Mac) cat <<EOF
<entry name="firewall">
<list>
<entry>
<ProductInfo>
<Prod vendor="Apple Inc." name="Mac OS X Builtin Firewall" version="${OS_VERSION}"/>
<is-enabled>yes</is-enabled>
</ProductInfo>
</entry>
<entry>
<ProductInfo>
<Prod vendor="OpenBSD" name="Packet Filter" version="${OS_VERSION}"/>
<is-enabled>no</is-enabled>
</ProductInfo>
</entry>
</list>
</entry>
EOF
;;
Linux) cat <<EOF
<entry name="firewall">
<list>
<entry>
<ProductInfo>
<Prod name="IPTables" version="1.8.4" vendor="IPTables">
</Prod>
<is-enabled>no</is-enabled>
</ProductInfo>
</entry>
<entry>
<ProductInfo>
<Prod name="nftables" version="0.9.3" vendor="The Netfilter Project">
</Prod>
<is-enabled>n/a</is-enabled>
</ProductInfo>
</entry>
</list>
</entry>
EOF
;;
*) cat <<EOF
<entry name="firewall">
<list>
<entry>
<ProductInfo>
<Prod name="Microsoft Windows Firewall" version="10.0" vendor="Microsoft Corp.">
</Prod>
<is-enabled>yes</is-enabled>
</ProductInfo>
</entry>
</list>
</entry>
EOF
;;
esac
case $CLIENTOS in
Mac) cat <<EOF
<entry name="patch-management">
<list>
<entry>
<ProductInfo>
<Prod vendor="Apple Inc." name="Software Update" version="3.0"/>
<is-enabled>yes</is-enabled>
</ProductInfo>
</entry>
</list>
<missing-patches>
</missing-patches>
</entry>
EOF
;;
Linux) cat <<EOF
<entry name="patch-management">
<list>
<entry>
<ProductInfo>
<Prod name="Dandified Yum" version="4.2.23" vendor="Red Hat, Inc.">
</Prod>
<is-enabled>yes</is-enabled>
</ProductInfo>
</entry>
</list>
<missing-patches/>
</entry>
EOF
;;
*) cat <<EOF
<entry name="patch-management">
<list>
<entry>
<ProductInfo>
<Prod name="McAfee ePolicy Orchestrator Agent" version="5.0.5.658" vendor="McAfee, Inc.">
</Prod>
<is-enabled>yes</is-enabled>
</ProductInfo>
</entry>
<entry>
<ProductInfo>
<Prod name="Microsoft Windows Update Agent" version="10.0.15063.0" vendor="Microsoft Corp.">
</Prod>
<is-enabled>yes</is-enabled>
</ProductInfo>
</entry>
</list>
<missing-patches/>
</entry>
EOF
;;
esac
cat <<EOF
<entry name="data-loss-prevention">
<list/>
</entry>
</categories>
</hip-report>
EOF