Skip to content

Instantly share code, notes, and snippets.

View jayswan's full-sized avatar

Jay Swan jayswan

View GitHub Profile
@jayswan
jayswan / uncipher.py
Created February 29, 2012 04:48
Python: reverse Cisco type 7 passwords with input from argument
"""
Uncipher Cisco type 7 ciphered passwords
Usage: python uncipher.py <pass> where <pass> is the text of the type 7 password
Example:
$ python uncipher.py 094F4F1D1A0403
catcat
"""
import sys
@jayswan
jayswan / gist:b1998ac7226c08a18cb8
Last active November 18, 2016 14:41
.vimrc simple
syntax enable
set ruler
set nobackup
set nocompatible
set encoding=utf-8
set showcmd
set number
set background=dark
"" Indentation
@jayswan
jayswan / add-json.bro
Created April 28, 2016 20:54 — forked from J-Gras/add-json.bro
Additional JSON logging for Bro.
# Add additional JSON logging
module Log;
export {
## Enables JSON-logfiles for all active streams
const enable_all_json = T &redef;
## Streams not to generate JSON-logfiles for
const exclude_json: set[Log::ID] = { } &redef;
## Streams to generate JSON-logfiles for
import requests
import json
from getpass import getpass
"""
A more friendly, bug-fixed version of the Python sample included with
Solarwinds SDK v1.8
Make sure to set a valid nodeID in line 50 before using!
"""
@jayswan
jayswan / uexists.sh
Created September 28, 2016 15:03
pipe-able script to check the existence of a GitHub username; returns 200 if found
#!/bin/sh
# Usage: some_command_that_outputs_usernames | uexists.sh
# subject to anonymous API rate limits
xargs -I {} curl -w "%{http_code}\n" -sI -o /dev/null https://api.github.com/users/{}
@jayswan
jayswan / signed_to_ipv4.py
Created February 11, 2012 04:45
signed 32-bit int to ipv4
def int_to_ip(signed_int):
""" convert a 32-bit signed integer to an IP address"""
# do preventative type checking because I didn't want to check inputs
try:
if type(signed_int) == str or type(signed_int) == int:
signed_int = long(signed_int)
except ValueError:
return "err_ip"
# CUCM occasionally creates CDRs with an IP of '0'. Bug or feature? Beats me.
@jayswan
jayswan / scripted_aggs.md
Created July 10, 2016 16:01
Elasticsearch scripted aggregation with joined fields

This script allows you to do SQL GROUPBY-like aggregations on multiple fields in an Elasticsearch index.

Performance will likely be poor on large data sets.

Saved Groovy script in <elasticsearch_dir>/config/scripts/join-param-list.groovy:

return fields.collect { doc[it].value }.join(delimiter);
@jayswan
jayswan / aws2ipset.sh
Created February 19, 2016 17:08
Convert AWS IP Prefixes to SiLK IP Set
#!/bin/sh
curl -s https://ip-ranges.amazonaws.com/ip-ranges.json | \
jq --raw-output '.prefixes | map(.ip_prefix) | .[]' > prefixes.txt
rwsetbuild prefixes.txt aws.ipset
@jayswan
jayswan / dup_conf.py
Created December 21, 2011 23:44
Python Script to find duplicate Cisco interface configs
import os
def print_dup_info(s):
#split config on ! characters
blocks = s.split('!')
stanza_list = []
interface_dict = {}
for block in blocks:
#get rid of blank lines and split each stanza into a list of lines