Skip to content

Instantly share code, notes, and snippets.

View aharonh's full-sized avatar

Aharon Haravon aharonh

View GitHub Profile
@aharonh
aharonh / patch-all-containers-for-cve-2021-44228.py
Created December 15, 2021 12:39
patch all deployments and stateful sets containers in your kubernetes cluster for log4shell CVE-2021-44228 by appending environment variable that prevents the exploit. .
# patch all deployments and stateful sets containers in your kubernetes cluster for
# log4shell CVE-2021-44228 by appending environment variable that prevents the exploit.
from kubernetes import client, config
config.load_kube_config()
apps_api = client.AppsV1Api()
deployments = apps_api.list_deployment_for_all_namespaces()
stateful_sets = apps_api.list_stateful_set_for_all_namespaces()
@aharonh
aharonh / scan-jvm-versions-for-cve-2021-44228.py
Last active December 15, 2021 12:37
check if any JVMs in kubernetes cluster are vulnerable to log4shell CVE-2021-44228. only checks java versions for those exploitable using the initial exploit. be aware that there are other exploits that can work on any java version.
# check if any JVMs in kubernetes cluster are vulnerable to CVE-2021-44228
# only checks java versions. use on your own responsibility.
from kubernetes import client, config
from kubernetes.stream import stream
import re
java_version_regex = re.compile('"(.*)"')
def is_java_version_vulnerable(java_version):

this script automates the required update of temporary access credentials required when MFA is configured for aws cli authentication. it is meant to be run each time (cca once a day) the temporary tokens expired so it will renew them. it was tested on both linux and windows with python3. below is a short explanation on how to use.

let's assume you there is an aws profile named 'root' configured for access and you have enabled MFA for aws cli. Then you should add profile called root-mfa in both ~/.aws/config and ~/.aws/credentials as follows:

config

[profile root-mfa]
region = us-east-1

Keybase proof

I hereby claim:

  • I am aharonh on github.
  • I am aharon (https://keybase.io/aharon) on keybase.
  • I have a public key ASDAztxIKklqxRV_phoAYo52QIeyH0-YC-Ywz2k3tSCtmgo

To claim this, I am signing this object:

@aharonh
aharonh / backup-all-docker-images.sh
Created February 17, 2018 14:04 — forked from jrenggli/backup-all-docker-images.sh
Backup/Save all Docker Images to a compressed file
docker images | tail -n +2 | grep -v "none" | awk '{printf("%s:%s\n", $1, $2)}' | while read IMAGE; do
echo $IMAGE
filename="${IMAGE//\//-}"
filename="${filename//:/-}.docker-image.gz"
docker save ${IMAGE} | pigz --stdout --best > $filename
done