Skip to content

Instantly share code, notes, and snippets.

@RezaAmbler
RezaAmbler / gist:32a6f5f78c1851550c3bba352a490ecb
Created April 4, 2024 21:11
aws report ec2 instances and size
# script generates a CSV file listing details of all EC2 instances across AWS regions, including instance ID, type, associated EBS volume IDs,
# sizes, types, the instance name from its tags, and all other tags, outputting this information into a structured format.
echo "Region,Instance ID,Instance Type,Volume IDs,Volume Sizes,Volume Types,Instance Name,Tags" > /tmp/ec2-data.csv
aws ec2 describe-regions --query "Regions[].RegionName" --output text | tr '\t' '\n' | while read region; do
# Fetch volume details (including size and type) and store in a file
aws ec2 describe-volumes --region "$region" --query 'Volumes[]' --output json | jq -r 'reduce .[] as $item ({}; .[$item.VolumeId] = {"Size": ($item.Size | tostring), "Type": $item.VolumeType})' > /tmp/volumeDetails.json
# Fetch instance details and include volume size and type along with the instance name
aws ec2 describe-instances --region "$region" --query 'Reservations[].Instances[]' --output json | jq -r --arg region "$region" --slurpfile volumeD
@RezaAmbler
RezaAmbler / getInventory.py
Created February 14, 2024 19:17
getInventory.py
# Write some notes here
# what this does
# example output
from scrapli.driver.core import IOSXRDriver
from scrapli.exceptions import ScrapliException
import getpass
import os
from collections import defaultdict
@RezaAmbler
RezaAmbler / rpc-test-srx.yml
Created July 6, 2022 12:05
rpc call with attributes
show system snapshot media internal | display xml rpc
<rpc-reply xmlns:junos="http://xml.juniper.net/junos/20.2R0/junos">
<rpc>
<get-snapshot-information>
<media>internal</media>
</get-snapshot-information>
</rpc>
<cli>
<banner></banner>
</cli>
@RezaAmbler
RezaAmbler / ntp-disable-port.j2
Created June 16, 2022 17:06
ntp disable on port
<ntp xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-ip-ntp-cfg">
<interface-tables>
<interface-table>
<vrf-name>default</vrf-name>
<interface>
<interface>{{ PORTNAME }}</interface>
<disable/>
</interface>
</interface-table>
</interface-tables>
RT_FLOW_SESSION_CREATE Grok pattern
Trying to extract data from message into , leaving the original intact.
Condition
Will only attempt to run if the message matches the regular expression RT_FLOW_SESSION_CREATE
Configuration
grok_pattern: %{HOSTNAME} %{WORD:RT_FLOW_NAME}: %{WORD:RT_FLOW_TYPE}: session created %{IP:source_address}/%{NUMBER:source_port}->%{IP:destination_address}/%{NUMBER:destination_port} %{WORD:connection_tag} %{DATA:service_name} %{IP:nat_source_ip}/%{NUMBER:nat_source_port}->%{IP:nat_dest_ip}/%{NUMBER:nat_dest_port} %{DATA:src_nat_rule_name} %{DATA:dest_nat_rule_name} %{NUMBER:protocol_id} %{DATA:policy_name} %{DATA:source_zone} %{DATA:dest_zone} %{NUMBER:session_id} %{DATA:username} %{DATA:packet_incoming_interface} %{DATA}
@RezaAmbler
RezaAmbler / tcp_flags.txt
Created February 24, 2021 17:15 — forked from tuxfight3r/tcp_flags.txt
tcpdump - reading tcp flags
##TCP FLAGS##
Unskilled Attackers Pester Real Security Folks
==============================================
TCPDUMP FLAGS
Unskilled = URG = (Not Displayed in Flag Field, Displayed elsewhere)
Attackers = ACK = (Not Displayed in Flag Field, Displayed elsewhere)
Pester = PSH = [P] (Push Data)
Real = RST = [R] (Reset Connection)
Security = SYN = [S] (Start Connection)
import os
import subprocess
import json
from bottle import route, run, template
@route('/hello/<name>')
def index(name):
out = subprocess.Popen(['/usr/bin/mtr', '-j', '-Z', '1', '-c', '1', '1.1.1.1'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
stdout,stderr = out.communicate()
d = json.loads(stdout)
@RezaAmbler
RezaAmbler / ipv6names.py
Created January 26, 2021 17:42
ipv6 spell things
# made by OMGKitteh on #juniper
import requests
from string import maketrans
import re
words_url = 'https://github.com/dwyl/english-words/blob/master/words.txt?raw=true'
letters = {
"a": "4",
@RezaAmbler
RezaAmbler / 50-cloud-init.yaml
Created January 3, 2021 01:42 — forked from svetlio/50-cloud-init.yaml
Netplan config bridge - ubuntu-server-18.04, and ex. default lxd profile
# located at /etc/netplan/
# $ sudo netplan apply
network:
version: 2
renderer: networkd
ethernets:
enp5s0f0:
dhcp4: false
bridges:
br0:
@RezaAmbler
RezaAmbler / aws.zshrc
Created September 2, 2020 15:06
aws choose profile
# Set aws profile in shell
414 alias ap=aws_profile
415 read_ini() {
416 local file=$1
417 local section=$2
418 cat $1 | grep -n1 "$2" | grep "region" | awk '{print $3}'
419 }
420 aws_profile() {
421 unset AWS_PROFILE AWS_REGION AWS_DEFAULT_REGION
422 if [[ -n $1 ]]; then