Skip to content

Instantly share code, notes, and snippets.

View bng44270's full-sized avatar

Andy Carlson bng44270

View GitHub Profile
@bng44270
bng44270 / getioc.py
Created April 10, 2020 16:27
Return IoC's from STIX data
#Requires Python 3.6
import xml.etree.ElementTree as ET
from arguments import Arguments
import sys
from os import path
import json
args = Arguments(sys.argv)
@bng44270
bng44270 / gist-client-android.py
Created April 10, 2020 16:28
Minimal Gist client for Android
#qpy:console
#################################
#
# This is a very minimal QPython script to access Github Gists
#
# for a more robust QPython application, check out https://github.com/bng44270/gist-client-android
#
#################################
@bng44270
bng44270 / gister.py
Created April 10, 2020 16:29
Gist Library
##########################################
# gister.py
# Github Gist Library for Python
#
# Usage:
# from gister import Gister
#
# mygist = Gister("bng44270")
#
# mygist.ListGists()
@bng44270
bng44270 / misc.py
Last active October 31, 2022 15:37
Miscellaneous Functions
import requests
from re import sub as regex_sub
from re import match as regex_match
# Return every "i" value in array "x"
everyother = lambda x,i : [a for a in x if x.index(a) % i == 0]
# Similar to the JavaScript slice function. Usage: slice(<array>,<beginning-index>,<length>)
slice = lambda a,i,l : a[i:(i+l)]
@bng44270
bng44270 / pyifttt.py
Last active February 24, 2023 16:18
IFTTT Library
import requests
class PyIFTTT:
"""
Usage:
# Initialize object with IFTTT API Key
myifttt = PyIFTTT('api-key')
"""
def __init__(self,key=""):
@bng44270
bng44270 / risk-calculator.py
Last active April 24, 2020 12:33
ServiceNow Security Incident Response Risk Calculator
from arguments import Arguments
from sys import argv as command_args
from math import ceil as round_up
priority_map = {1:90.0,2:60.0,3:40.0,4:25.0,5:10.0}
severity_map = {1:95.0,2:55.0,3:25.0}
impact_map = {1:80.0,2:60.0,3:40.0}
ARGS = Arguments(command_args)
@bng44270
bng44270 / taxiiclient.py
Created April 10, 2020 16:41
TAXII Client
#***********************
# TaxiiClient class
# Constructor:
# TaxiiClient(discovery_url, auth = None, cert_val = True)
# auth => Set to dictionary to do HTTP auth {'user':'USERNAME','pass':'PASSWORD'}
# cert_val => Sets whether or not to do SSL certificate validation
# Methods:
# do_doscovery()
# - perform TAXII DISCOVERY
# get_urls()
@bng44270
bng44270 / usanalyze.py
Created April 10, 2020 16:41
ServiceNow Update Set Analyzer
# Requires Python 3.6
import xml.etree.ElementTree as ET
from arguments import Arguments
import sys
import re
from os import path, listdir
args = Arguments(sys.argv)
@bng44270
bng44270 / xlscodes.py
Created April 10, 2020 16:42
Generate Excel function to translate field values
from arguments import Arguments
from sys import argv as command_args
def xlsloadcodes(filename):
with open(filename,'r') as f:
filelines = f.readlines()
return [{'code':a.split(' ')[0],'value':a.split(' ')[1].strip()} for a in filelines]
def xlsmakeif(cell,codes):
@bng44270
bng44270 / aem-listpage-package.sh
Created April 15, 2020 16:23
Download AEM packages from listpage tool
#!/bin/bash -x
#########################################################
# This script will take the output from the CQ listpage
# tool and download a package for each node listed
#########################################################
PROTO="http"
SERVER="localhost:4502"
AUTH="admin:admin"