Skip to content

Instantly share code, notes, and snippets.

View cwells's full-sized avatar

Cliff Wells cwells

  • Portland, Oregon USA
  • 15:29 (UTC -07:00)
View GitHub Profile
@cwells
cwells / netmap.py
Last active December 27, 2016 20:03
#!/usr/bin/env python
import os
import yaml
import glob
import re
import logging
import colorsys
import random
logger = logging.getLogger(__name__)
#!/usr/bin/python
from __future__ import print_function
import os
import OpenSSL
import pem
import click
def get_cn(cert_pem):
#define _CRT_SECURE_NO_WARNINGS // turn off SAFE COMMANDS
// ############################
// Written By: Cristian Colocho
// Date Written: March, 14, 2015
// Purpose: Loop Menu and Switch
// ############################
#include <stdio.h>
#include <stdlib.h>
int enter(int n) {
#!/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))
@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
@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 / 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 {
#!/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
#!/usr/bin/env python3
import sys
import os
import getpass
import socket
import select
import threading
import logging
import yaml
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