Skip to content

Instantly share code, notes, and snippets.

View cybergavin's full-sized avatar

cybergavin cybergavin

View GitHub Profile
@cybergavin
cybergavin / terrascan_basics.md
Created December 23, 2024 02:18
Terrascan basics

Config File (.terrascan.toml)

[rules]
    skip-rules = [
        "AC_AWS_0369"
    ]

Usage

@cybergavin
cybergavin / ListDirectoryLatestChange.md
Created November 27, 2024 01:17
List directories with latest change in them
#!/bin/bash
# This script lists the date and time of the latest change to a directory within a list of directories.

# Define the base directory containing the home directories
base_dir="/home"

# Loop through each home directory
for home_dir in "$base_dir"/*; do
 if [ -d "$home_dir" ]; then
@cybergavin
cybergavin / tofu-state-mv.md
Last active October 15, 2024 23:07
Terraform/OpenTofu state migration
for s in $(tofu state list | grep "^aws")
do
 tofu state mv $s module.mft-network.$s
done

List all Azure role assignments

az role assignment list --all --include-inherited --query [].roleDefinitionName --output tsv 2>/dev/null | sort -u
@cybergavin
cybergavin / pfx-certs.md
Created October 1, 2021 02:21
PFX to PEM
  • Extract CA Cert(s)
openssl pkcs12 -in myapp.pfx -cacerts -nokeys -out myapp-ca.crt
  • Extract Server Cert
openssl pkcs12 -in myapp.pfx -clcerts -nokeys -out myapp-server.crt
  • Create Chain Cert
@cybergavin
cybergavin / tf-plan-filter.md
Created August 17, 2021 02:11
Terraform plan filter

Terraform plan output for processing for imports

terraform plan | grep "will be created" | sed 's/\x1b\[[0-9;]*m//g;s/ .#//g;s/"/\\"/g;s/will be created//g'
  • Output above seems more conducive to processing than -out plan
@cybergavin
cybergavin / remove-color-codes.md
Created August 17, 2021 02:02
Remove color codes from text stream
@cybergavin
cybergavin / qemu-img.md
Created July 9, 2021 01:50
QEMU conversion

Convert qcow2 to vmdk

sudo qemu-img convert -p -f qcow2 -O vmdk -o adapter_type=lsilogic test.qcow2 test.vmdk
  • Default adapter_type is ide
@cybergavin
cybergavin / dhcp-lease.md
Created July 9, 2021 01:39
DHCP Lease Time

Linux

Oracle/Red Hat/CentOS 8

sudo dhclient
sudo find / -type f -name "dhclient.leases"
sudo cat /var/lib/dhclient/dhclient.leases
@cybergavin
cybergavin / win-dynport.md
Created June 25, 2021 18:01
Windows-DynamicPortRange
netsh int ipv4 show dynamicport tcp

PS C:\Windows\system32> netsh int ipv4 show dynamicport tcp

Start Port : 49152

Number of Ports : 16384