-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathavoid_log4stash.sh
67 lines (63 loc) · 3.55 KB
/
avoid_log4stash.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
#!/usr/bin/qsh
# ---------------------------------------------------------------------------------------------------
# Important notes
# ---------------------------------------------------------------------------------------------------
#
# - Please see avoid_log4shell.sh for the current version! When I first published, I borked up the name,
# but I am leaving this here in case anyone references it. OOPS!!
# The properly-named version is at https://github.com/ThePrez/IBMiOSS-utils/blob/master/avoid_log4shell.sh
#
# - This script comes with no form of warranty or guarantee. Please reference below license.
#
# - This script is intended to serve as a part of a containment and mitigation activity for the
# Log4Stash vulnerability. IT IS NOT A COMPLETE FIX! Some versions of log4j will still be exposed.
# See https://www.fastly.com/blog/digging-deeper-into-log4shell-0day-rce-exploit-found-in-log4j
# for more details
#
# - This script assumes you are not utilizing JAVA_TOOL_OPTIONS to set Java options today. This
# will overwrite the value if you are setting the environment variable system-wide.
#
# ---------------------------------------------------------------------------------------------------
# License
# ---------------------------------------------------------------------------------------------------
#
# Copyright (c) 2021 Jesse Gorzinski
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
# ---------------------------------------------------------------------------------------------------
# Instructions
# ---------------------------------------------------------------------------------------------------
# If you have wget, you can do the following to download and run:
# wget https://github.com/ThePrez/IBMiOSS-utils/raw/master/avoid_log4shell.sh
# chmod +x ./avoid_log4shell.sh
# ./avoid_log4shell.sh
#
# Otherwise, download https://github.com/ThePrez/IBMiOSS-utils/raw/master/avoid_log4stash.sh manually and
# place in IFS and run:
# chmod +x ./avoid_log4shell.sh && ./avoid_log4shell.sh
#
# Otherwise, as a last resort, just copy/paste the non-commented lines in this file.
# Use the LOG4J_FORMAT_MSG_NO_LOOKUPS to disable log4j lookup capability
system -k "ADDENVVAR ENVVAR(LOG4J_FORMAT_MSG_NO_LOOKUPS) VALUE('true') REPLACE(*YES) LEVEL(*SYS)"
# This is a redundant backup in case the ENVVAR is accidentally removed or overwritten (works for JV1 Java only)
qsh -c 'touch -C 37 /QIBM/UserData/Java400/SystemDefault.properties'
qsh -c 'echo "log4j2.formatMsgNoLookups=true" >> /QIBM/UserData/Java400/SystemDefault.properties'
echo " "
echo "COMPLETE"