Created
December 11, 2021 01:48
-
-
Save stephanGarland/f0a09cb2cccb643192213f96496c5cbe to your computer and use it in GitHub Desktop.
Replaces vulnerable log4j files in a Unifi Controller setup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -e | |
read -p "Enter Unifi controller's container name: " container | |
curl -s https://dlcdn.apache.org/logging/log4j/2.15.0/apache-log4j-2.15.0-bin.tar.gz -o log4j.tar.gz | |
mkdir -p ./log4j && tar xzf log4j.tar.gz -C ./log4j --strip-components=1 | |
cd log4j | |
for file in log4j-{api,core,slf4j-impl}-2.15.0.jar; do | |
docker cp "$file" "$container:/usr/lib/unifi/lib/" | |
done | |
docker exec -it "$container" /bin/bash -c "cd lib && for file in log4j-{api,core,slf4j-impl}-2.15.0.jar; do mv $file $(echo $file | sed 's/2.15.0/2.13.3/g'); done" | |
docker exec -it "$container" /bin/bash -c "cd lib && for file in log4j-{api,core,slf4j-impl}-2.13*.jar; do ls -la $file; done" | |
docker restart "$container" | |
echo "All done!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment