Skip to content

Instantly share code, notes, and snippets.

@stephanGarland
Created December 11, 2021 01:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stephanGarland/f0a09cb2cccb643192213f96496c5cbe to your computer and use it in GitHub Desktop.
Save stephanGarland/f0a09cb2cccb643192213f96496c5cbe to your computer and use it in GitHub Desktop.
Replaces vulnerable log4j files in a Unifi Controller setup
#!/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