Skip to content

Instantly share code, notes, and snippets.

View jsanders's full-sized avatar

James Sanders jsanders

View GitHub Profile
@jsanders
jsanders / shellcode.asm
Last active December 26, 2015 04:56
Generally useful, well-documented, and small shellcode generator. Based on work I did for level05 of Stripe's original CTF, but much nicer.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; A nice, small 32-bit x86 execve shellcode template. ;
; execve("//bin/sh", [ "//bin/sh", NULL ], [ NULL ]). ;
; Shellcode itself is 25 bytes. ;
; Provide definitions of PayloadSize and JumpAddress ;
; to generate a self-contained buffer of the desired ;
; size and with the desired address to jump to. ;
; Build with "nasm -f bin -o shellcode shellcode.asm" ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@jsanders
jsanders / level06_exploit.py
Last active December 22, 2015 16:48
Exploit in python for level 6 of Stripe's first CTF.
from os import pipe, write, close
from subprocess import Popen, PIPE
import select
import string
import sys
PIPE_MAX = 1<<16 # 64k
WELCOME_LEN = len("Welcome to the password checker!\n")
def args(guess):
@jsanders
jsanders / stripe-ctf-1.0.md
Last active May 26, 2017 16:22
Work-through of the Stripe CTF 1.0 focused more on system-level than web-level security.

Stripe CTF 1.0

Level 1

Ok, start by ssh-ing to level01@ec2-23-22-123-94.compute-1.amazonaws.com with password w5kjAsSKEjCT. Our goal is to read the file .password from the level02 user's home directory: /home/level02. Let's look for low-hanging fruit - maybe we can just read the file directly:

@jsanders
jsanders / LICENSE
Last active August 17, 2018 23:38
32-bit x86 SHA1 implementation.
MIT License
Copyright (c) 2017 Martin Buberl
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@jsanders
jsanders / blob.rb
Last active December 21, 2015 02:19
WIP Blob library for working with arbitrary unstructured binary data, and SHA1 implementation demonstrating its use.
# Public: Represent and manipulate arbitrary data.
class Blob
# Public: Create Blob from an array of bytes.
#
# bytes - The Array of numbers in the range [0, 255]
#
# Examples
# Blob.new([ 97, 98, 99, 100 ]).to_str
# # => "abcd"
# Blob.from_str([ 97, 98, 99, 100 ]).to_hex
@jsanders
jsanders / aes_ctr_cbc.rb
Last active October 8, 2021 10:45
Implementation of AES with counter (CTR) and cipher-block-chaining (CBC) modes. Based on spec at http://csrc.nist.gov/publications/fips/fips197/fips-197.pdf. ** Disclaimer: For educational purposes only. Obviously, nobody should ever use a hacky un-vetted non-standard (not to mention, non-optimized) implementation of crypto like this **
require File.expand_path('../../utilities', __FILE__)
require 'openssl'
# Set to true to see debug output
DEBUG = false
def debug_puts(s=nil); puts(s) if DEBUG; end
def debug_print(s=nil); print(s) if DEBUG; end
# Encrypt data using given `mode`, `key_b`, `iv_b` and `data_b`, all as byte arrays
# Only uses padding in CBC mode
@jsanders
jsanders / gist:5551350
Created May 9, 2013 23:19
Go get issue
$ GOPATH=$HOME/go go get github.com/burke/zeus/go/cmd/zeus
../../../go/src/github.com/burke/zeus/go/cmd/zeus/zeus.go:14:2: no Go source files in /Users/james/go/src/github.com/burke/zeus/go/zeusversion
@jsanders
jsanders / subsets.clj
Created May 7, 2013 21:24
Clojure subsets
(use 'clojure.contrib.combinatorics)
(def small-numbers [ 1 2 3 4 6 ])
(def large-numbers [ 3 4 9 14 15 19 28 37 47 50 54 56 59 61 70 73 78 81 92 95 97 99 ])
(defn largest-sum-of-rest?
[ col ]
(let [ [ largest & others ] (reverse (sort col)) ]
(= largest (reduce + others))))
@jsanders
jsanders / Gemfile
Last active December 12, 2015 06:19
Sidekiq profiling
source 'https://rubygems.org'
gem 'sidekiq'
@jsanders
jsanders / Gemfile
Last active December 12, 2015 05:59
Resque memory test
source 'https://rubygems.org'
gem 'json'
gem 'resque', '1.19.0'