Skip to content

Instantly share code, notes, and snippets.

View mikesmullin's full-sized avatar
🛴
woot!

Mike Smullin mikesmullin

🛴
woot!
View GitHub Profile
@mikesmullin
mikesmullin / beacon.asm
Last active February 13, 2021 23:03
ctf wargame beacon.asm Windows 32-bit Winsock API (static; no dependencies) 2,560 bytes
; compile with MASM32
; C:\masm32\bin\ml /c /Zd /coff beacon.asm
; C:\masm32\bin\Link /SUBSYSTEM:WINDOWS beacon.obj
; beacon.exe
;
.386
.model flat, stdcall
option casemap :none
include C:\masm32\include\windows.inc
include C:\masm32\include\kernel32.inc
@mikesmullin
mikesmullin / trace.js
Created November 24, 2017 23:21
Node.JS print filename and line number prefixed to console log output
const path = require('path');
function trace(s) {
const orig = Error.prepareStackTrace;
Error.prepareStackTrace = (_, stack) => stack;
const err = new Error();
Error.captureStackTrace(err, arguments.callee);
Error.prepareStackTrace = orig;
const callee = err.stack[0];
process.stdout.write(`${path.relative(process.cwd(), callee.getFileName())}:${callee.getLineNumber()}: ${s}\n`);
@mikesmullin
mikesmullin / rpn_calc.coffee
Last active March 25, 2017 17:05
Reverse Polish Notation Calculator (in CoffeeScript)
# Reverse Polish Notation Calculator (in CoffeeScript)
# authored by Mike Smullin <[email protected]>
#
# see also:
# https://en.wikipedia.org/wiki/Polish_notation
# http://www.calculator.org/rpn.aspx
# http://blog.reverberate.org/2013/07/ll-and-lr-parsing-demystified.html
# http://stackoverflow.com/questions/5975741/what-is-the-difference-between-ll-and-lr-parsing
# https://www.amazon.com/Definitive-ANTLR-4-Reference/dp/1934356999
@mikesmullin
mikesmullin / loop.sh
Created June 21, 2014 21:18
Bash Process Loop
#!/bin/bash
# Process Loop
# Author: Mike Smullin <[email protected]>
# License: MIT
# Usage:
#
# ./loop node --debug app.js
#
# Ctrl+C Restarts
# Ctrl+\ Quits
@mikesmullin
mikesmullin / tcpflow-1.4.4_wrapper.coffee
Last active November 8, 2017 11:42
wrapper for tcpflow which enhances its stdout output to include easily parsed timestamp format, incl. milliseconds, tz offset, and packaged in flat json one-object-per-row ideal for mapreducing on
#!/usr/bin/env coffee
#
# install on ubuntu:
# sudo apt-get install automake autoconf libpcap-dev zlib1g-dev libboost-dev libcairo2-dev
#
# cd /tmp/
# git clone --recursive -b tcpflow-1.4.4 [email protected]:simsong/tcpflow.git tcpflow/
# cd tcpflow/
#
# sh bootstrap.sh
@mikesmullin
mikesmullin / arc4.coffee
Last active August 29, 2015 14:00
A CoffeeScript implementation of RC4
# A CoffeeScript implementation of RC4
class ARC4
i: 0
j: 0
psize: 256
S: null
constructor: (key=null) ->
@S = new Buffer(@psize)
if key
@init key
@mikesmullin
mikesmullin / vboxmanage.bat
Created January 12, 2014 18:28
virtualbox vboxmanage commands equivalent to vagrant (or even better, borg)
"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" help import
"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" list natnets
"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" showvminfo "sfs01"
"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" list dhcpservers
"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" natnetwork stop -t NatNetwork
"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" natnetwork start -t NatNetwork
"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" dhcpserver add --netname xm_slc_routed --ip 172.16.2.1 --netmask 255.255.0.0 --lowerip 172.16.2.4 --upperip 172.16.2.254 --enable
"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" dhcpserver modify --netname xm_slc_routed --ip 172.16.0.1 --netmask 255.255.0.0 --lowerip 172.16.0.4 --upperip 172.16.0.254 --enable
"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" dhcpserver remove --netname xm_slc
@mikesmullin
mikesmullin / Que.coffee
Last active January 2, 2016 23:59
Que asynchronous flow control coffeescript micro library
Que = new: ->
Q = []
Q.then = (fn, args...) -> Q.push(-> args.push Q.next; fn.apply null, args); @
Q.next = (err) -> Q.splice 0, Q.length-1 if err; Q.shift()?.apply null, arguments
Q.finally = (fn, args...) -> Q.push(-> fn.apply null, args); Q.next()
Q
# --
Q = Que.new()
@mikesmullin
mikesmullin / watch.sh
Last active April 26, 2023 05:20
watch is a linux bash script to monitor file modification recursively and execute bash commands as changes occur
#!/usr/bin/env bash
# script: watch
# author: Mike Smullin <[email protected]>
# license: GPLv3
# description:
# watches the given path for changes
# and executes a given command when changes occur
# usage:
# watch <path> <cmd...>
#
@mikesmullin
mikesmullin / c.cpp
Last active December 22, 2015 01:59
moar_fun_language_experimentation
#include <GL/glfw.h>
#include <iostream>
#define GLFW_INCLUDE_GLU
using namespace std;
int main()
{