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 / rack_files.rb
Created March 22, 2010 03:04
Please stop writing your own HTTP parsers, consider Rack next time.
#!/usr/bin/env ruby
require 'rack'
FILES = {
'/index.html' => 'index.html'
}
Rack::Handler.get('Thin').run proc { |env|
path = env['PATH_INFO']
@postmodern
postmodern / dm_country_model.rb
Created March 20, 2010 00:38
A DataMapper model for representing Countries.
require 'dm-core'
require 'dm-validations'
require 'dm-predefined'
class Country
include DataMapper::Resource
include DataMapper::Migrations
include DataMapper::Predefined
@postmodern
postmodern / countries.rb
Created March 20, 2010 00:17
A module containing Country names and codes
# Country Code List: ISO 3166-1993 (E)
module Countries
Mexico = 'MX'
GuineaBissau = 'GW'
Afghanistan = 'AF'
Ethiopia = 'ET'
SyrianArabRepublic = 'SY'
SvalbardJanMayenIslands = 'SJ'
Tonga = 'TO'
Pakistan = 'PK'
@postmodern
postmodern / web_scanner.rb
Created December 1, 2009 23:25
A simple script for calling Ronin::Scanners::Web
#!/usr/bin/env ruby
require 'ronin/scanners/web'
require 'ronin/sql/scanner'
require 'ronin/php/lfi/scanner'
require 'ronin/php/rfi/scanner'
if ARGV.empty?
STDERR.puts "usage: #{$0} HOST ..."
#!/usr/bin/env ruby
require 'ronin/dorks'
module SophSec
module Twitter
def Twitter.private_mesgs_dork(user_name)
dork = Ronin::Web::Dorks.search(:site => "twitter.com/#{user_name}")
end
@postmodern
postmodern / enforce_ssl.rb
Created October 12, 2009 02:32
A Rack middleware app that enforces certain paths be requested over HTTPS.
require 'rack/utils'
module Rack
#
# EnforceSSL is a Rack middleware app that enforces that users visit
# specific paths via HTTPS. If a sensitive path is requested over
# plain-text HTTP, a 307 Redirect will be issued leading to the HTTPS
# version of the Requested URI.
#
# MIT License - Hal Brodigan (postmodern.mod3 at gmail.com)
@postmodern
postmodern / ban_hammer.rb
Created October 12, 2009 01:24
A Rack middleware app that bans specified IPv4/IPv6 addresses and ranges.
require 'ipaddr'
module Rack
#
# BanHammer is a Rack middleware app that restricts access to your server
# using a black-list of IPv4/IPv6 addresses and ranges.
#
# MIT License - Hal Brodigan (postmodern.mod3 at gmail.com)
#
class BanHammer
@postmodern
postmodern / referer_control.rb
Created October 12, 2009 00:53
A Rack middleware app to control access to paths based on the Referer header.
module Rack
#
# RefererControl is a Rack middleware app which restricts access to paths
# based on the Referer header. Using RefererControl you can make sure
# users follow the intended flow of a website. If a controlled path is
# visited with an unacceptable Referer URI, then a simple 307 Redirect
# response is returned.
#
# RefererControl should also make Cross Site Request Forgery (CSRF) a
# little more difficult to exploit; but not impossible using JavaScript.
@postmodern
postmodern / lie_server.rb
Created October 12, 2009 00:06
A Rack middleware app to spoof the Server header.
module Rack
#
# The LieServer is a simple Rack middleware app which allows one to spoof
# the +Server+ header in responses for every request, requests to certain
# sub-directories or paths which match a regular expression.
#
# Be deceitful to would be attackers, tell them your running IIS 3.0.
#
# MIT License - Hal Brodigan (postmodern.mod3 at gmail.com)
#
@postmodern
postmodern / sophsec_twitter.rb
Created September 27, 2009 03:04
Watches tweets in real-time using TweetStream, and can save them using TokyoCabinet
require 'tweetstream'
require 'rufus/tokyo'
module SophSec
module Twitter
#
# Watches tweets using the TweetStream library.
#
# @param [Hash] options
#