Skip to content

Instantly share code, notes, and snippets.

Avatar
🦬

Jonathan Claudius claudijd

🦬
View GitHub Profile
@claudijd
claudijd / poc.py
Last active Oct 30, 2021
Example method to obtain a bearer token and obtain users uuid
View poc.py
import json
import requests
import pdb
import os
BASE_URL = "https://auth.mozilla.auth0.com"
def get_bearer_token():
url = BASE_URL + '/oauth/token'
View hello.py
log = open("/Users/jclaudius/.aws/config", "r")
for line in log:
print(line)
View clean_downloads.py
import glob
import os
import os.path
import shutil
mydir = "/Users/jclaudius/Downloads/"
filelist = glob.glob(os.path.join(mydir, "*"))
for f in filelist:
if os.path.isdir(f):
View clean_desktop.py
import os
import shutil
path = "/Users/jclaudius/Desktop/"
moveto = "/Users/jclaudius/Desktop/Archive/"
files = os.listdir(path)
files.sort()
for f in files:
if not os.path.isdir(f):
src = path+f
@claudijd
claudijd / example.py
Created Nov 15, 2019
boto => boto3 file upload
View example.py
# In boto
import boto
conn = boto.connect_s3(aws_access_key_id=aws_access_key_id,aws_secret_access_key=aws_secret_access_key)
bucket = conn.get_bucket(bucket_name, validate=False)
key = boto.s3.key.Key(bucket)
key.key = key_name
key.set_contents_from_filename(file_path)
url = "https://{}.s3.amazonaws.com/{}".format(bucket.name, key.name)
View poc.py
import re
# Current
>>> re.search(r"((ssh|https)://)?(git@)?github.com[:/](?P<repo_name>[A-Za-z0-9\/\-_]+)(.git)?", "bananas://github.com:/")
'/'
# Proposed
>>> re.search(r"^((https|ssh)://)?(git@)?github.com/(?P<repo_name>[A-Za-z0-9\/\-_]+)(.git)?$", "https://github.com/org/foo").group("repo_name")
'org/foo'
>>> re.search(r"^((https|ssh)://)?(git@)?github.com/(?P<repo_name>[A-Za-z0-9\/\-_]+)(.git)?$", "https://github.com/org/foo.git").group("repo_name")
@claudijd
claudijd / connections_example.py
Created Sep 17, 2019
Simplistic prototype for connections expiry
View connections_example.py
import datetime
import time
# Simple connections management dict in Python example
connections = {}
class Connection:
def __init__(self):
@claudijd
claudijd / index.js
Created Jul 22, 2019
Example CloudFront Distribution Viewer Response Lambda Function to Get better Observatory Grades!
View index.js
'use strict';
exports.handler = (event, context, callback) => {
const response = event.Records[0].cf.response;
const headers = response.headers;
// See https://wiki.mozilla.org/Security/Guidelines/Web_Security
headers['Strict-Transport-Security'] = [{'key': 'Strict-Transport-Security', 'value': 'max-age=63072000'}];
headers['X-Content-Type-Options'] = [{'key': 'X-Content-Type-Options', 'value': 'nosniff'}];
headers['X-Frame-Options'] = [{'key': 'X-Frame-Options', 'value': 'DENY'}];
@claudijd
claudijd / report.json
Created Jul 10, 2019
example of JSON formatted report
View report.json
{
"overall": "orange",
scanner_reports: {
"ssh_observatory": "green",
"http_observatory": "orange",
"dir_scan": "green",
"ssh_observatory": "green",
"ssh_observatory": "green"
}
}
@claudijd
claudijd / shark.py
Created Jul 3, 2019
demoing global override and comms
View shark.py
thing = "foo"
class Baz():
def override_thing(self):
global thing
thing = 1
def update_thing(self):