Skip to content

Instantly share code, notes, and snippets.

import boto3
def main():
organizations_client = boto3.client("organizations")
list_accounts_object = organizations_client.list_accounts()
all_accounts = []
accounts = list_accounts_object["Accounts"]
while "NextToken" in list_accounts_object:
#!/usr/bin/python
import os, socket, sys, time
socket.setdefaulttimeout(10)
start = time.time()
subnets = ['140.107.42','140.107.43','140.107.88','140.107.89','140.107.134',\
'140.107.135','140.107.52','140.107.53','140.107.152','140.107.153',\
'140.107.170','140.107.171']
scanips = []; hosts = []; vhosts = []; free = []; vfree = []; reclaim = []; squatters = []
#!/usr/bin/env python3
"""
Alternate account naming rules
Rule 1: firstname + lastname is less 18 or less characters long total
== firstname + "." + lastname (john.doe)
if conflict, check if rule 2 format (below) is available. If so use it
== firstname_initial + "." + lastname (j.doe)
if not, append an integer (starting with 2) to the end of the username
=== firstname + "." + lastname + int (john.doe2)
@robert-mcdermott
robert-mcdermott / FHCC-username-generator.py
Created December 2, 2021 02:58
Username and Email address generation script
#!/usr/bin/env python3
"""
Account naming rules
Rule 1: firstname + lastname is less 18 or less characters long total
== firstname + "." + lastname (john.doe)
if conflict append an integer (starting with 2) to the end of the username
=== firstname + "." + lastname + int (john.doe2)
Rule 2: firstname + lastname is greater than 18 characters long total *and*
@robert-mcdermott
robert-mcdermott / separate-them.py
Last active May 13, 2020 17:23
separate-them.py
from PIL import Image
def main():
images = [[] for p in range(num_people)]
im = Image.open(image)
im = im.convert("RGB")
size = im.size
data = list(im.getdata())
for _ in range(int(len(data)/num_people)):
@robert-mcdermott
robert-mcdermott / contact-tracing.py
Created April 24, 2020 16:45
SITHVID20 Contract Tracing Challenge
from math import sqrt
from PIL import Image
def main():
img = Image.open("contact-tracing.png")
infected = get_color_coords(img, Ic)
healthy = get_color_coords(img, Hc)
contact = []
for i in infected:
@robert-mcdermott
robert-mcdermott / SimpleAuthServer.py
Created January 11, 2017 19:44 — forked from fxsjy/SimpleAuthServer.py
SimpleAuthServer: A SimpleHTTPServer with authentication
import BaseHTTPServer
from SimpleHTTPServer import SimpleHTTPRequestHandler
import sys
import base64
key = ""
class AuthHandler(SimpleHTTPRequestHandler):
''' Main class to present webpages and authentication. '''
def do_HEAD(self):
@robert-mcdermott
robert-mcdermott / FindLatestWinAMI.py
Created July 12, 2016 20:52
Find AMI image ID of latest Amazon Windows 2012R2 image
def find_image(region):
"""
Finds the latest Windows 2012R2 offical Amazon AMI and returns the ID
"""
sys.stdout.write("\nFinding latest Windows 2012R2 image...")
ec2 = boto3.resource('ec2', region_name = "{0}".format(region))
images = ec2.images.filter(
Owners=['amazon'],
Filters=[
{'Name': 'name','Values': ['Windows_Server-2012-R2_RTM-English-64Bit-Base-*']},