Skip to content

Instantly share code, notes, and snippets.

View bng44270's full-sized avatar

Andy Carlson bng44270

View GitHub Profile
@bng44270
bng44270 / tdf.js
Last active October 22, 2020 12:18
JSON schema/data editor in JavaScript
/*
Tiny Dataset Framework
Replaced by ES6 version (https://gist.github.com/bng44270/61fe2af9313ae750c53c639a178f5e2e)
Provide ablility to define and edit JSON objects
Requires: NewClass.js
Two Options:
@bng44270
bng44270 / GenericUserUtil.js
Last active April 30, 2020 14:17
ServiceNow UserCriteria Script
/*
Usage:
Determine employee has an employee type:
if (new GenericUserUtil().hasEmployeeType("employee-type")) {
//deny or grant access
}
Determine if employee is in a company:
if (new GenericUserUtil().isInCompany("company-sys-id")) {
@bng44270
bng44270 / SecureCatalogValidation.js
Last active August 17, 2020 13:41
Secure Access to RITM/RITM Task in ServiceNow
/*
Uses u_secure_catalog_def table
Fields:
cat_item : reference to sc_cat_item
grant_by : string (can be "user", "group", or "task")
user : reference to sys_user
group : reference to sys_user_group
@bng44270
bng44270 / arguments.py
Last active February 27, 2023 21:11
Easily use command-line arguments with Python
from re import sub as regex_sub
from sys import argv as arglist
class Arguments:
"""
Usage:
# Initialize to read in command arguments
args = Arguments()
"""
@bng44270
bng44270 / arin.py
Created April 10, 2020 16:16
Search ARIN for IP address or ASN
import requests
from arguments import Arguments
from sys import argv as command_arguments
arinjson = lambda x : requests.get("http://whois.arin.net/ui/query.do?queryinput={}".format(x),headers={"Accept":"application/json"},verify=False).json()
# print indented outline-style representation of dictionary object
def dictol(this_dictionary):
try:
prefix = this_dictionary['pf']
@bng44270
bng44270 / asn2ip.py
Created April 10, 2020 16:17
Use ARIN to translate ASN to IP address
import requests
from arguments import Arguments
from sys import argv as command_args
arinjson = lambda x : requests.get("http://whois.arin.net/ui/query.do?queryinput={}".format(x),headers={"Accept":"application/json"},verify=False).json()
ARGS = Arguments(command_args)
if not ARGS.Get('a'):
print "usage: asn2ip.py -a <ASN>"
@bng44270
bng44270 / clamav_check.py
Last active June 1, 2021 14:53
Check for a hash in the current daily or main ClamAV definitions
#Requires Python 3.6
from arguments import Arguments
import requests
import tarfile
import io
import sys
def usage():
print("usage: clamav_check.py -h <hash> -f <daily|main>")
@bng44270
bng44270 / clamav_json_dump.py
Created April 10, 2020 16:23
Dump ClamAV HDB file to JSON
#Requires Python 3.6
from arguments import Arguments
import requests
import tarfile
import io
import re
import sys
def usage():
@bng44270
bng44270 / configfile.py
Last active February 27, 2023 21:50
Manage configuration files
from re import sub as regex_sub
from os import path
class ConfigFile:
"""
Usage:
# Initialize object with no configuration file (must be configured with Read method)
conf = ConfigFile()
@bng44270
bng44270 / ezdb.py
Created April 10, 2020 16:25
SQLite library
##########################################################
#
# ezdb.py - SQLite database functions
#
# NOTE: This only works with data of type text and varchar
#
# Import libraries
# from ezdb import TableDef, DatabaseDef
#
# Create a table object with fields: