Skip to content

Instantly share code, notes, and snippets.

@gcmurphy
gcmurphy / ramdisk.c
Created February 23, 2016 18:40
Create tmpfs mountpoint in c.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <limits.h>
#include <sys/mount.h>
char *
ramdisk(const char *ns, const char *sz)
{
@gcmurphy
gcmurphy / autosave.js
Created September 6, 2012 05:43
Very simple autosave functionality using local storage
var AutoSave = (function(){
var timer = null;
function getEditor(){
var elems = document.getElementsByTagName("textarea")
if (elems.length <= 0)
return null;
@gcmurphy
gcmurphy / c_array_dump.c
Created January 4, 2012 01:23
Raw data to unsigned char C array
/* Dump raw data to a unsigned char array. */
void c_array_dump(FILE *stream, const char *label, unsigned char *data, size_t size)
{
int pos;
fprintf(stream, "const unsigned char %s[] = {\n\t", label);
for (pos = 0; pos < size ; ++pos) {
fprintf(stream, "0x%02X", (unsigned char) data[pos]);
if (pos+1 != size)
fprintf(stream, ", ");
@gcmurphy
gcmurphy / fastly.py
Created August 14, 2022 03:29
check if ip address in fastly public address block
import argparse
import requests
import ipaddress
import sys
parser = argparse.ArgumentParser(description="checks if ip address in fastly ip range")
parser.add_argument("ip", metavar='IP', type=ipaddress.IPv4Address, nargs='+',
help="ip addresses to check")
args = parser.parse_args()
@gcmurphy
gcmurphy / fiber_rego_authz.go
Created February 21, 2022 03:25
experiment using rego as authorization middleware
package main
import(
"context"
"log"
"time"
"os"
"github.com/gofiber/fiber/v2"
"github.com/open-policy-agent/opa/ast"
@gcmurphy
gcmurphy / gen-iac-gh-action.py
Created December 15, 2021 05:17
Generate a IAC step for all the teraform files in a given directory.
import glob
import os
def generate_github_action(source, filename):
"""
Snyk IAC scanning tool currently has the limitation of only scanning
a single file at a time. This script will generate the github
action steps needed to scan all our IAC code.
"""
@gcmurphy
gcmurphy / index.js
Created March 27, 2020 02:03
lighthouse to extract librarie versions
const lighthouse = require('lighthouse');
const chromeLauncher = require('chrome-launcher');
function launchChromeAndRunLighthouse(url, opts, config = null) {
return chromeLauncher.launch({chromeFlags: opts.chromeFlags}).then(chrome => {
opts.port = chrome.port;
return lighthouse(url, opts, config).then(results => {
// use results.lhr for the JS-consumable output
// https://github.com/GoogleChrome/lighthouse/blob/master/types/lhr.d.ts
// use results.report for the HTML/JSON/CSV output as a string
import argparse
import datetime
import random
import socket
import ssl
import string
import time
import traceback
from urllib.parse import urlparse
from pprint import pprint
@gcmurphy
gcmurphy / detect_secrets_assessment.py
Created January 29, 2020 22:30
Harness for recording responses for each finding made by Yelps detect secrets tool.
import argparse
import json
import subprocess
import linecache
import os
import sys
from pprint import pprint
import tempfile
import csv
@gcmurphy
gcmurphy / opendaylight vulnerability process
Last active July 25, 2019 07:15
OpenDaylight Vulnerability Managment
#OpenDaylight - Vulnerability Management
[TOC]
##Motivation
The OpenDaylight project has gained enough momentum and popularity that the responsible management of security issues in the upstream community is warranted. OpenDaylight has in fact had its first [CVE](http://seclists.org/bugtraq/2014/Aug/75) assigned via an independent security researcher, who at the time had no process to follow. This **must** change.