Skip to content

Instantly share code, notes, and snippets.

View postmodern's full-sized avatar
🚀
releasing new versions

Postmodern postmodern

🚀
releasing new versions
View GitHub Profile
@postmodern
postmodern / shell_server.rb
Created February 5, 2012 02:14
A WEBrick shell server with async output
require 'webrick'
class Server < WEBrick::HTTPServlet::AbstractServlet
def self.start(port,host=nil)
server = WEBrick::HTTPServer.new(:Host => host, :Port => port)
server.mount '/', self
trap('INT') { server.shutdown }
@postmodern
postmodern / gist:1708391
Created January 31, 2012 02:45
jruby 1.6.6 --1.9 mode failures wrt enum_for
$ git clone git://github.com/ronin-ruby/ronin.git
$ cd ronin/
$ bundle install
$ bundle show rspec
/home/hal/.rvm/gems/jruby-1.6.6/gems/rspec-2.8.0
$ jruby --1.9 -S rake spec
Failures:
1) Ronin::IPAddress extract should extract multiple IP Addresses from text
@postmodern
postmodern / bump_copyright.rb
Created January 3, 2012 02:18
Automatically bump the year in the Copyright-notice headers of Ruby files.
@postmodern
postmodern / local_shell.rb
Created November 29, 2011 08:10
Example of a Ronin Shellcode payload, written in pure Ruby.
#!/usr/bin/env ronin-payload -f
require 'ronin/payloads/shellcode'
Ronin::Payloads::Shellcode.object do
cache do
self.name = 'local_shell'
self.description = %{
Shellcode that spawns a local /bin/sh shell
@postmodern
postmodern / bin_sh.rb
Created November 29, 2011 07:44
Example of using Assemble DSL in ronin-exploits to write Shellcode in Ruby
require 'ronin/code/asm'
require 'ronin/formatting/binary'
program = Ronin::Code.asm(:arch => :x86) do
xor eax, eax
push eax
push 0x68732f2f
push 0x6e69622f
mov esp, ebx
push eax
@postmodern
postmodern / mysql_brute.rb
Created November 21, 2011 03:39
MySQL Bruteforcer

Configuration

  • mysql: 14.14 Distrib 5.5.14
  • host: 127.0.0.1
  • port: 3306
  • user: victim
  • password: 56789

Install

@postmodern
postmodern / dm_eager_loader.rb
Created October 27, 2011 01:34
Fork of d11wtq's DataMapper EagerLoader plugin
module DataMapper
class Collection
#
# EagerLoader takes a QueryPath object and loads all relationships
# referenced in the path, into an existing Collection.
#
# Using eager-loading allows you to optimize out the classic "n+1"
# query problem, when you intend to iterate over several arbitrarily deeply
# nested relationships. One query per relationship is executed,
# vs one query per record.
@postmodern
postmodern / gist:1141488
Created August 12, 2011 04:55
Convert Markdown slides (separated by ------------- dividers) into divs for slippy.js
$(function() {
var $slides = $("#slides");
var $currentSlide = null;
function newSlide() {
$currentSlide = $('<div class="slide"></div>')
$currentSlide.appendTo($slides);
}
newSlide();
@postmodern
postmodern / register.rb
Created July 28, 2011 07:17
Example of what is possible with RSpec2

Install RSpec

$ gem install rspec

Run it!

$ rspec --color --format=d register.rb
CashRegister
  when empty

items

@postmodern
postmodern / gist:1071496
Created July 8, 2011 10:01
A bug in Module.methods with Ruby 1.8 and 1.9?
module Test
def Test.mytest
end
end
Test.methods(false)
# => ["mytest"]
Test.method_defined?("mytest")
# => false