Skip to content

Instantly share code, notes, and snippets.

View cwells's full-sized avatar

Cliff Wells cwells

  • Portland, Oregon USA
  • 04:24 (UTC -07:00)
View GitHub Profile
#!/bin/env python3
#
# Create ~/.aws/aws-mfa.yaml with the following content:
#
# ---
# default:
# account: 1234567890
# username: phil@veridiandynamics.com
# aws_profile: production
def dig(d, keys, *args):
"""Locate a value in a nested dictionary.
Args:
d (dict): the dictionary
keys (list): list of keys to index the dictionary with
default (value|callable): value or callable to return in case of missing key
Returns:
Value at `d[k0][k1][...]` if all keys are present
#!/usr/bin/env python3
import sys
import os
import getpass
import socket
import select
import threading
import logging
import yaml
#!/usr/bin/python3
import os
import re
import logging
import boto3
from queue import Queue
from threading import Thread
from datetime import datetime, timedelta, timezone
@cwells
cwells / github.css
Last active December 16, 2017 08:12
Grey theme for FF 57+ / matching Stylish theme for slack.com, github.com
body {
background-color: #eeeeee;
}
a {
color: #333333;
text-decoration: none;
}
.server-stats {
@cwells
cwells / correlate.py
Created October 26, 2017 22:01
Create new CSV file by combining results of directory traversal + original CSV file
#!/usr/bin/python
import csv
import os
from datetime import datetime
skipped = open('no-target.csv', 'w')
targets = {}
with open('file_mapping.csv') as csvfile:
@cwells
cwells / auth.py
Created October 26, 2017 03:59
Gets username from YAML file, password from keyring, otherwise prompt user via click
try:
config = yaml.load(open(CONFIGFILE).read())
except:
config = None
if not config: config = {}
username = config.get('username', None)
password = keyring.get_password(PROGRAM, username) if username else None
#!/usr/bin/env python
from OpenSSL import crypto
import click
def validate_country(ctx, param, value):
try:
assert len(value) == 2
except AssertionError:
raise click.BadParameter('{} must be two letters'.format(param.name))
#!/usr/bin/python
from __future__ import print_function
import os
import OpenSSL
import pem
import click
def get_cn(cert_pem):
#!/usr/bin/python
from __future__ import print_function
import sys
from datetime import datetime
import certifi
import pem
import OpenSSL
from acme import crypto_util as acme_crypto_util