Skip to content

Instantly share code, notes, and snippets.

View LukeMurphey's full-sized avatar

Luke LukeMurphey

View GitHub Profile
@LukeMurphey
LukeMurphey / parseKindleMetadata.py
Created April 3, 2022 00:56
Creates a CSV of your Kindle books.
import xml.dom.minidom
import csv
# Get the Kindle meta-data by:
# 1. Installing and running the Kindle app
# 2. Viewing the file in %appdata% at AppData\Local\Amazon\Kindle\Cache\KindleSyncMetadataCache.xml'
kindleMetaDataPath = 'KindleSyncMetadataCache.xml'
csvOutputPath = 'KindleBooks.csv'
@LukeMurphey
LukeMurphey / server.conf
Created October 23, 2019 17:52
Server.conf for faking a cloud instance of Splunk on-prem
# You can determine if the Splunk install is Splunk cloud by looking at the /services/server/info/server-info (e.g. https://127.0.0.1:8089/services/server/info/server-info) endpoint.
# If the install is running on Splunk Cloud, it will have a field named "instance_type" that has a value of "cloud".
# $SPLUNK_HOME/etc/system/local/server.conf that sets the instance type to cloud, like this:
[general]
instanceType = cloud
"""
This class makes creating a REST handler for Splunk easier.
The class will automatically call a function within the class based on the path and the method.
For example, if a GET call is made to the path "ping", then this class will call the function
get_ping().
Below is an example.
@LukeMurphey
LukeMurphey / rest_handler.py
Last active October 19, 2022 08:32
A simple helper library for making a generic REST handler for Splunk #splunk
"""
This class makes creating a REST handler for Splunk easier.
The class will automatically call a function within the class based on the path and the method.
For example, if a GET call is made to the path "ping", then this class will call the function
get_ping().
Below is an example.
@LukeMurphey
LukeMurphey / get_notables.py
Last active April 6, 2023 14:45
A script showing how to connect to Splunk to get a list of notable events #splunk
"""
This script shows how to get notable events from a Splunk instance running Enterprise Security.
This script runs using the libraries built into Splunk. You can run it like this:
/opt/splunk/bin/splunk cmd python get_notables.py
"""
import splunk.auth
import splunk.search
@LukeMurphey
LukeMurphey / get_asset.py
Last active October 22, 2018 17:30
A script to get ES (Enterprise Security) asset info via Python in Splunk #splunk
import splunk.auth
import splunk.search
import time
def get_asset(host, session_key):
# Declare some static vars
search = '| stats count | eval asset="%s" | fields asset | `get_asset(asset)`' % host
latest_time = "now"
earliest_time = "0"
@LukeMurphey
LukeMurphey / makefile.py
Last active September 12, 2018 21:26
A script for making a file of a given size
import sys
if len(sys.argv) != 3:
print 'Incorrect number of arguments; provide the file-name followed by the file-size.\ne.g. you can make a 1 GB file named "newfile" by calling:\n\n %s newfile 1073741824' % (sys.argv[0])
exit()
filename = sys.argv[1]
size = int(sys.argv[2])
with open(filename, "wb") as f:
@LukeMurphey
LukeMurphey / splunk_amazon_spent_history
Last active June 29, 2018 16:55
A Splunk snippet for examining how much you spend on Amazon per year downloaded from https://www.amazon.com/gp/b2b/reports #splunk
source="01-Jan-2006_to_29-Jun-2018.csv"
| eval _time=strptime('Shipment Date',"%m/%d/%y")
| rex field="Purchase Price Per Unit" "(?<price>[0-9.]+)"
| rex field="Shipment Date" "[0-9][0-9]/[0-9][0-9]/(?<year>([0-9][0-9]))"
| stats sum(price) as spent by year
@LukeMurphey
LukeMurphey / scroll_left_right_to_tab_next_back.json
Created June 27, 2018 17:55
A karabiner rule for using the mouse left and right scroll wheel to the previous and next tab
"rules": [
{
"description": "Mouse right scroll to ctrl+tab (next tab)",
"manipulators": [
{
"from": {
"pointing_button": "button5"
},
"to": [
{
@LukeMurphey
LukeMurphey / jira_convert_attached_tickets_to_table.js
Created January 26, 2018 20:52
A snippet of JS that converts the list of tickets attached to a table (in JIRA formatting)
$('#ghx-issues-in-epic-table td:nth-child(2)').text().replace(/\s+/gi, " | | | \n |")