Skip to content

Instantly share code, notes, and snippets.

View asaf400's full-sized avatar

Asaf Levy asaf400

View GitHub Profile
#!/bin/bash
mkdir -p output
for file in `ls -l | grep -v ^d | awk '{print $9}'`; do
md5=`md5sum $file | awk '{print $1}'`
firstletter=${file:0:1}
IFS='-' read -ra ADDR <<< "$file"
IFS='_' read -ra firstword <<< "${ADDR[0]}" #firstword
#!/bin/bash
for image in $1; do
IFS='/' read -ra ADDR <<< "$image"
len=${#ADDR[@]}
#echo $(expr $len - 1)
file=${ADDR[$(expr $len - 1)]}
# Stop windows update service
Stop-Service -Name wuauserv;
# Remove 'SoftwarePolicies' WU key
Remove-Item `
-Path HKLM:\SoftwarePolicies\Microsoft\Windows\WindowsUpdate `
-Force `
-Recurse `
-ErrorAction SilentlyContinue;
const { VoipList } = require('twilio/lib/rest/api/v2010/account/availablePhoneNumber/voip');
var express = require('express');
require('dotenv').config()
const accountSid = process.env.TWILIO_ACCOUNT_SID;
const authToken = process.env.TWILIO_AUTH_TOKEN;
const twilio_callback_url = process.env.TWILIO_CALLBACK_URL;
const twilio_from = process.env.TWILIO_FROM
@asaf400
asaf400 / aerospike_security_ext
Created June 3, 2021 13:24
Aerospike Security Grok patterns
# Aerospike Security GROK Patterns Extensions - author asaf.levy (@asaf400 github)
# Meant to extend the existing patterns: https://github.com/aerospike/aerospike-elk/blob/master/logstash/patterns/aerospike
# And then can be loded within the match stenza of 'aerospike_logstash.conf' file
# grok {
# tag_on_failure => ["patterns_filter_failure"]
# patterns_dir => ["/etc/logstash/conf.d/patterns"]
# match => {
# "message" => ["%{AS_NS}","%{AS_TICK}","%{AS_NSUP}","%{AS_XDR}","%{AS_SINDEX}","%{AS_ERR}","%{AS_SEC}","%{AS_LOG}"]
# }
# }
import pathlib
import zipfile
from shutil import copyfile
java_classes = ['org/apache/log4j/net/JMSAppender.class']
# from six import string_types # would be better here,
# but I wanted something without external deps
try:
basestring
@asaf400
asaf400 / foobar.sh
Created June 15, 2022 16:26
Aerospike security.smd user&password stuff
pip install bcrypt
python3 -c 'import bcrypt; print(bcrypt.hashpw(b"PASSWORD", bcrypt.gensalt(rounds=10)).decode("ascii"))'
htpasswd -bnBC 10 "" password | tr -d ':\n' | sed 's/$2y/$2a/'
aerospike_users=cat security.smd | jq '.[] | select(has("key")? and (.key | contains("|P"))) | .key | sub("\\|P"; "")' -r
@asaf400
asaf400 / kafka-stats.sh
Created June 15, 2022 16:30
Kafka Topic Statistics
#!/bin/bash
kafkajson='{"bootstrapserver":"kafka-staging-us-east-1..com:9092","sets":[{"name":"abc","topic":"def"}]}'
for topic in $(jq -r '.sets[] | .topic' <<<"$kafkajson" | tr '\n' ' '); do
echo "Working on Topic: $topic"
echo "running: kcat -e -b acid-kafka-staging-us-east-1.isappcloud.com:9092 -t $topic -f '%T %S\n' -o beginning"
#kcat -e -b acid-kafka-staging-us-east-1.isappcloud.com:9092 -t $topic -f '%T %S\n' -o beginning > "$topic"
cut -d' ' -f2 <"$topic" > "$topic""_bytes"
cut -d' ' -f1 <"$topic" > "$topic""_timestamps"
#!/bin/bash
# AUTHOR: github.com/asaf400
# This script iterates over all S3 objects in terraform state,
# in order to import any S3 resource that has been split from the main aws_s3_bucket resource
# following the terraform aws v4 breaking changes which requires existing s3 attributes to exists as 'linked' resources
# The script assumes that the hcl files has already been modifed to reflect the v4 change,
# and it is useful for allowing terraform to import the new resources which already existed in aws.
# SCRIPT IS DISTRIBUTED AS IS, NOT SUPPORT REQUESTS.
# The resources are:
@asaf400
asaf400 / aws-sso-lib.py
Last active January 14, 2025 09:17
This script is meant to be used as a backup, restore and convertion tool for AWS SSO (Identity Store & Identity Center)
#!/bin/env python
# AUTHOR: github.com/asaf400
# This script is meant to be used as a backup, restore and convertion tool for AWS SSO (Identity Store & Identity Center)
# Currently AWS does not provide any way to backup the following resources:
# Users & Groups in the Identity Store API,
# The Principal Assignment with an AWS Account and PermissionSet in the SSO Admin API
# The Permissions sets and their inline policies
# hench I created this script which allows for a backup in a relatively Human Readble JSON format
# it is able to backup to: