Skip to content

Instantly share code, notes, and snippets.

View duckythescientist's full-sized avatar

Sean Murphy duckythescientist

View GitHub Profile
@duckythescientist
duckythescientist / worklog.sh
Created December 15, 2018 00:15
Quick notes by date
#!/usr/bin/env bash
worklog_dir="worklog"
editor="subl"
show_usage () {
cat <<-EOF
Create a diary text file by week in the $worklog_dir subdirectory
by the year and month. Automagically adds a heading to the file
and opens the file with $editor to the current* date.
@duckythescientist
duckythescientist / entropy_crib.py
Created July 16, 2018 03:57
Plot the entropy of the xor of two texts as one is shifted against the other. Good for finding key length for xor encryption.
#!/usr/bin/env python3
import math
import numpy as np
import matplotlib.pyplot as plt
# def string_shannon(data):
# '''Performs a Shannon entropy analysis on a given block of data.
@duckythescientist
duckythescientist / pprimes.py
Last active March 4, 2018 21:28
Permutable Primes
#!/usr/bin/env python3
# Or python2
import itertools
import collections
# @profile
def get_primes(nMax):
"""Return a set of prime numbers under nMax
#!/usr/bin/env python3
from heapq import heappush, heappop
median = None
heap_lower = []
heap_upper = []
len_lower = 0
@duckythescientist
duckythescientist / lololps1.bash
Last active October 11, 2023 04:13
Rainbow colored bash prompt PS1 string
# https://stackoverflow.com/a/52465819
function readline_ANSI_escape() {
if [[ $# -ge 1 ]]; then
echo "$*"
else
cat # Read string from STDIN
fi | \
perl -pe 's/(?:(?<!\x1)|(?<!\\\[))(\x1b\[[0-9;]*[mG])(?!\x2|\\\])/\x1\1\x2/g'
}
@duckythescientist
duckythescientist / tqdm_longrun.py
Created October 9, 2017 14:18
Tqdm wrapper and decorator to give a long-running function a progress bar
#/usr/bin/env python3
import time
import threading
import functools
import tqdm
def long_running_function(*args, **kwargs):
@duckythescientist
duckythescientist / badjump.c
Last active September 23, 2017 15:23
PoC for the incorrect 66 instruction prefix found by xoreaxeaxeax/sandsifter
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/mman.h>
@duckythescientist
duckythescientist / solve_minesweeper.py
Last active February 27, 2017 19:25
BKP CTF 2017 Minesweeper Solution
#!/usr/bin/env python2
import math
from pwn import *
"""
Read this: https://inst.eecs.berkeley.edu/~cs191/fa07/lectures/lecture22_fa07.pdf
I don't really know much about quantum computers.
Credit goes to [bobert](https://github.com/rstrand2357) for figuring out how to solve this.
@duckythescientist
duckythescientist / solve_a_strong_feeling.py
Created August 26, 2016 16:19
IceCTF A Strong Feeling Solution
#!/usr/bin/env python2
"""
Angr would probably be the nice way to solve this. Oh well.
Brute force worked for me.
Trying different inputs, it seems the length doesn't matter.
The output changes depending on how many characters at the beginning match the key.
Brute force possible keys watching for output changes (to know when we got the right letter)
@duckythescientist
duckythescientist / usbcap_to_ascii.py
Created August 26, 2016 16:07
IceCTF Intercepted 1 Writeup
#!/usr/bin/env python2
"""
The pcap is a capture of a USB keyboard.
The proper way to tell is by finding the VID/PID combination during enumeration then looking up the device from that.
The easy way is just to have looked at enough USB stuffs to recognize that it's a keyboard. :)
The keyboard data exists in the USB Leftover section. `tshark` is our friend for extracting this.
tshark -r ./intercept.pcapng -T fields -e usb.capdata -Y usb.capdata 2>/dev/null
This has some trailing data that we don't care about it, so use tail to skip the beginning 6 lines.