Skip to content

Instantly share code, notes, and snippets.

View sstelfox's full-sized avatar

Sam Stelfox sstelfox

View GitHub Profile
@sstelfox
sstelfox / gist:70938206c84634fb6f82f144bebfd8ed
Last active March 25, 2017 21:33
I needed ECDSA certs with a chain of custom CAs and client certificates and I already had most of this available. Could be prettier but it works fast and well
#!/usr/bin/env ruby
require 'openssl'
require 'securerandom'
# Work around a broken core library
OpenSSL::PKey::EC.send(:alias_method, :private?, :private_key?)
CERT_DIR = 'generated_certs'
DIGEST = OpenSSL::Digest::SHA384
if RUBY_VERSION =~ /2\.3/
gem 'net-ldap'
gem 'tss'
end
@sstelfox
sstelfox / test_for_eternity.sh
Created March 7, 2017 23:23
Quick script to run tests a bunch of times looking for failing seeds. Was useful while rewriting a large test suite that was secretly dependent on the order of it's tests.
#!/bin/bash
set -o errexit
. ./spec/docker_services.sh
while true; do
rspec --fail-fast
done
@sstelfox
sstelfox / ipc_free_fork_example.rb
Last active March 1, 2017 20:39
Ruby Service Permission Dropping & Fork Examples
#!/usr/bin/env ruby
require 'fcntl'
def set_process_name(name)
$0 = name
end
class Child
attr_accessor :pid, :should_run
@sstelfox
sstelfox / inject.rb
Created February 27, 2017 17:23
Simple PCAPRUB injection...
#!/usr/bin/env ruby
require 'pcaprub'
arp_pkt_str ="\xFF\xFF\xFF\xFF\xFF\xFF\xD0P\x99y\xEC\x8A\x81\x00\x00\n\b\x06" \
"\x00\x01\b\x00\x06\x04\x00\x01\xD0P\x99y\xEC\x8A\xC0\xA8\nq\x00\x00\x00" \
"\x00\x00\x00\xC0\xA8\n\x05".force_encoding(Encoding::BINARY)
interface_handle = Pcap.open_live('eth0', 65535, true, 1)
sent_bytes = interface_handle.inject(arp_pkt_str)

Keybase proof

I hereby claim:

  • I am sstelfox on github.
  • I am sstelfox (https://keybase.io/sstelfox) on keybase.
  • I have a public key ASD4-LBTYi_fB9RG9I5jszrnba-L8YekflfL3wMfUrPuygo

To claim this, I am signing this object:

@sstelfox
sstelfox / converter.rb
Created November 16, 2016 17:36
Quick converter for 16bit signed int complex numbers to 32bit float complex numbers
#!/usr/bin/env ruby
out = File.open(ARGV[1], 'w')
File.open(ARGV[0], 'r') do |f|
until f.eof?
int_bytes = []
int_bytes.push(f.getbyte)
int_bytes.push(f.getbyte)
float_bytes = int_bytes.pack('C').unpack('c').pack('f')
@sstelfox
sstelfox / android_routing_evil_ap.sh
Last active June 16, 2016 14:37
Routing gettings crazy in newer versions of android... We need to do some craziness in the route tables to get additional adapater routing working.
#!/bin/bash
# Unrelated IDs, the same because 31337...
ROUTE_TBL_ID="31337"
ROUTE_TBL_NAME="evil_ap"
FW_MARK_ID="0x31337/0xfffff"
# Create the route table
if ! grep -q ${ROUTE_TBL_NAME} /etc/iproute2/rt_tables; then
echo "${RT_TBL_ID} ${ROUTE_TBL_NAME}" >> /etc/iproute2/rt_tables
#!/bin/bash
set -o errexit
set -o errtrace
set -o pipefail
set -o nounset
BASE_DIRECTORY="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
TEMP_DIRECTORY="$(mktemp -d /tmp/script_working.XXXXX)"
if channel >= 1 && channel <= 13 {
return channel * 5 + 2484
} else if channel == 14 {
return 2484
} else if channel >= 34 && channel <= 165 {
return channel * 5 + 5000
}
return -1