Skip to content

Instantly share code, notes, and snippets.

@awsvpc
awsvpc / resolve_domain_computers.py
Created February 2, 2025 05:24 — forked from 3xocyte/resolve_domain_computers.py
get /etc/hosts entries for computers in Active Directory
#!/usr/bin/env python
# resolve domain computers by @3xocyte
import argparse
import sys
import string
# requires dnspython and ldap3
import dns.resolver
from ldap3 import Server, Connection, NTLM, ALL, SUBTREE
@awsvpc
awsvpc / create_computer_object.py
Created February 2, 2025 05:22 — forked from lanbugs/create_computer_object.py
Python LDAP3 and Active Directory - Collection of some snippets, helpers ....
# Create computer object in OU
# Written by Maximilian Thoma 2023
# More infos at https://lanbugs.de
from ldap3 import Connection
from ldap3.core.exceptions import LDAPException
import random
BACKEND_USER = "CN=Backend User,CN=Users,DC=ad,DC=local"
BACKEND_PASS = "SuperSecret"
@awsvpc
awsvpc / github_summary.py
Created January 14, 2025 09:19 — forked from hvishwanath/github_summary.py
Code Contributions
import requests
import time
import os
username = os.getenv("GH_UID")
confluentinc = "confluentinc"
token = os.getenv("GH_TOKEN")
# updated may 30 2024
allrepos = ['docs-kafka-connect-aws-cloudwatch-logs', 'cc-system-tests-rbac-extractor', 'terraform-provider-dynamic-config', 'mongo-kafka', 'kafka-connect-dynamodb-cdc', 'se-hiring-questions', 'chatcflt-service', 'cc-docker-trogdor', 'ci-autotasks', 'production-pipeline', 'atlantis-proving-ground', 'demo-scene', 'ce-flink', 'eks-upgrades', 'dtx-template-registry', 'hackday-2023-tools-docs', 'common-docker-local', 'dtx-outpost', 'download-artifacts', 'terraform-provider-rancher2', 'devprod-pain-points', 'jira-org-labels', 'rbac-tech-enablement', 'zstd-kafka-serde', 'use-case-demos', 'cc-telemetry-synthetics', 'it-domain-test', 'obs-telemetry-delivery', 'fedramp-infosec-slack-lambda', 'cc-stream-aggregator', 'avro-random-generator', 'workspace-tools', 'cc-atlas-udf', 'tools-artifactory-automation', 'schema-registry-client-go', 'druid-metrics-catalog', 'cc-struc
@awsvpc
awsvpc / aws-sso-lib.py
Created January 14, 2025 09:17 — forked from asaf400/aws-sso-lib.py
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:
@awsvpc
awsvpc / truncate_dynamodb_table.py
Created December 1, 2024 04:12 — forked from ivgomezarnedo/truncate_dynamodb_table.py
This GIST removes all elements from a DynamoDB table in a batch format (25 items to remove per batch as its the max batch size allowed by DynamoDB).
import boto3
from boto3.dynamodb.conditions import Key
def truncate_table(profile_name, table_name):
session = boto3.Session(profile_name=profile_name, region_name='eu-central-1')
dynamodb = session.resource('dynamodb')
table = dynamodb.Table(table_name)
def delete_items(items):
@awsvpc
awsvpc / check_if_image_exists.py
Created December 1, 2024 04:11 — forked from ivgomezarnedo/check_if_image_exists.py
This GIST checks if a file exists in S3 and prints the size of that file (in KB). As an input it should be passed a JSON file containing the hash of the image to check (file name in s3). The original code also created a SQS event to run again the Image-Puller for the not-found image but that's out of the scope of this snippet.
import json
import os
os.environ['AWS_PROFILE'] = '' # ENVIRONMENT
s3_client = boto3.client('s3')
bucket_name = '' # IMAGE PULLER OUTPUT BUCKET
def get_s3_file_size(bucket_name: str, s3_path: str, s3_client) -> int:
# Get the object metadata
response = s3_client.head_object(Bucket=bucket_name, Key=s3_path)
@awsvpc
awsvpc / list_installed_packages.sh
Created August 17, 2024 07:57 — forked from aleskxyz/list_installed_packages.sh
List of Exclusively Installed Yum Packages
rpm_list=""
package_list=""
for id in $(yum --noplugins history list all 2> /dev/null | grep -v System | sed 's/^ *//;s/ *| */|/g' | grep -E "^[0-9]+\|" | awk -F '|' '$4 == "Install" || $4 ~ /I/' | cut -d '|' -f1); do
result=$(yum --noplugins history info $id 2> /dev/null | awk '/Packages Altered/{flag=1; next} flag' | awk '$1 == "Install"' | awk '{print $2}')
if [ -n "$result" ]; then
rpm_list+="$result"$'\n'
fi
done
@awsvpc
awsvpc / linux-explorer.sh
Created August 17, 2024 07:54 — forked from jfinstrom/linux-explorer.sh
linux-explorer script from unix consultants modified to collect asterisk stuff
#!/bin/bash
##############################################################################
#
#
# FILE : linux-explorer.sh
# Last Change Date : 3-06-2014
# Author(s) : Joe Santoro
# Date Started : 15th April, 2004
# Email : linuxexplo [ at ] unix-consultants.com
# Web : http://www.unix-consultants.com/examples/scripts/linux/linux-explorer
@awsvpc
awsvpc / linux_cheatsheets_+_notes.md
Created August 17, 2024 07:49 — forked from absorber/linux_cheatsheets_+_notes.md
Random personal cheat sheets and notes about various Linux activities.

My Linux cheatsheets and other handy notes


  • If vim paste is messed up, then do :set paste

Oneliners, commands and scripts which are pretty cool but I don't understand yet (fully)

Get the output of grep --color=auto -ril "keyword" . and sort it according to modify date.

find . -type f -exec grep -q keyword {} \; -printf '%T@/%p\0' | sort -zn | while IFS=/ read -rd '' tsamp file; do printf 'timestamp: %s, file: %s\n' "$tsamp" "$file"; done

@awsvpc
awsvpc / update_issues.py
Created July 4, 2024 01:23 — forked from ogawatti/update_issues.py
Update Issues (Create and Update, Close)
# -*- coding: utf-8 -*-
import boto3
import json
import base64
import urllib
import urllib2
import pdb
## lambdaへアップロードする前に書き換えて下さい