source stringclasses 1
value | repo stringlengths 5 63 | repo_url stringlengths 24 82 | path stringlengths 5 167 | language stringclasses 1
value | license stringclasses 5
values | stars int64 10 51.4k | ref stringclasses 23
values | size_bytes int64 200 258k | text stringlengths 137 258k |
|---|---|---|---|---|---|---|---|---|---|
github | perfectline/validates_existence | https://github.com/perfectline/validates_existence | Rakefile | Ruby | mit | 94 | master | 1,260 | require "rake"
require "rake/testtask"
require "rake/clean"
require "rdoc/task"
require "rubygems/package_task"
desc "Default: run unit tests."
task :default => :test
begin
require "jeweler"
Jeweler::Tasks.new do |jewel|
jewel.name = "validates_existence"
jewel.summary = "Validates Rails model ... |
github | perfectline/validates_existence | https://github.com/perfectline/validates_existence | validates_existence.gemspec | Ruby | mit | 94 | master | 1,146 | # Generated by jeweler
# DO NOT EDIT THIS FILE DIRECTLY
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
# -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = "validates_existence"
s.version = "0.9.2"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :requi... |
github | perfectline/validates_existence | https://github.com/perfectline/validates_existence | lib/validates_existence.rb | Ruby | mit | 94 | master | 3,257 | require "active_record"
module Perfectline
module ValidatesExistence
module Validator
class ExistenceValidator < ActiveModel::EachValidator
def initialize(options)
# set the default message if its unspecified
options[:message] ||= :existence
options[:both] = true u... |
github | perfectline/validates_existence | https://github.com/perfectline/validates_existence | test/rails31/test_helper.rb | Ruby | mit | 94 | master | 1,366 | require "rubygems"
gem "rails", ">= 3.1.0"
require "rails"
require "sqlite3"
require "test/unit"
require "active_record"
require "active_record/base"
ActiveRecord::Migration.verbose = false
ActiveRecord::Base.establish_connection(
"adapter" => "sqlite3",
"database" => ":memory:"
)
require File.join... |
github | perfectline/validates_existence | https://github.com/perfectline/validates_existence | test/rails31/validates_existence_test.rb | Ruby | mit | 94 | master | 2,927 | require 'test_helper.rb'
class TestValidatesExistence < Test::Unit::TestCase
def setup
ActiveRecord::Schema.define(:version => 1) do
create_table :names, :force => true do |t|
t.column :name, :string
end
create_table :users, :force => true do |t|
t.references :name
t.... |
github | perfectline/validates_existence | https://github.com/perfectline/validates_existence | test/rails3/validates_existence_test.rb | Ruby | mit | 94 | master | 2,776 | require 'test_helper.rb'
class TestValidatesExistence < Test::Unit::TestCase
def setup
ActiveRecord::Schema.define(:version => 1) do
create_table :names, :force => true do |t|
t.column :name, :string
end
create_table :users, :force => true do |t|
t.references :name
t.... |
github | perfectline/validates_existence | https://github.com/perfectline/validates_existence | test/rails3/test_helper.rb | Ruby | mit | 94 | master | 1,366 | require "rubygems"
gem "rails", "~> 3.0.7"
require "rails"
require "sqlite3"
require "test/unit"
require "active_record"
require "active_record/base"
ActiveRecord::Migration.verbose = false
ActiveRecord::Base.establish_connection(
"adapter" => "sqlite3",
"database" => ":memory:"
)
require File.join... |
github | perfectline/validates_existence | https://github.com/perfectline/validates_existence | shoulda/validates_existence.rb | Ruby | mit | 94 | master | 1,211 | # Based on http://github.com/shuber/validates_existence
class Test::Unit::TestCase
def self.should_validate_existence_of(*associations)
allow_nil = get_options!(associations, :allow_nil)
associations.each do |association|
should "require #{association} exists" do
reflection = subject.class.refl... |
github | iSECPartners/tlspretense | https://github.com/iSECPartners/tlspretense | Rakefile | Ruby | mit | 94 | master | 878 | require 'bundler/gem_tasks'
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec) do |spec|
spec.pattern = FileList['spec/**/*_spec.rb']
end
namespace(:spec) do
desc "Create rspec code coverage"
task :coverage do
ENV['COVERAGE'] = 'true'
Rake::Task["spec"].execute
end
end
task :default => :... |
github | iSECPartners/tlspretense | https://github.com/iSECPartners/tlspretense | tlspretense.gemspec | Ruby | mit | 94 | master | 1,242 | require './lib/tlspretense/version'
Gem::Specification.new do |s|
s.name = "tlspretense"
s.version = TLSPretense::VERSION
s.authors = ["William (B.J.) Snow Orvis"]
s.email = "bjorvis@isecpartners.com"
s.date = Time.now.utc.strftime("%Y-%m-%d")
s.homepage = "https://github.com/iSECPartners/tlspretense"
s.... |
github | iSECPartners/tlspretense | https://github.com/iSECPartners/tlspretense | lib/tlspretense.rb | Ruby | mit | 94 | master | 392 | require 'fileutils'
require 'packetthief'
require 'tlspretense/cert_maker/runner'
module TLSPretense
class CleanExitError < StandardError ; end
autoload :App, 'tlspretense/app'
autoload :InitRunner, 'tlspretense/init_runner'
autoload :TestHarness, 'tlspretense/test_harness'
autoload :VERSION, 'tl... |
github | iSECPartners/tlspretense | https://github.com/iSECPartners/tlspretense | lib/packetthief.rb | Ruby | mit | 94 | master | 6,789 | require 'socket'
require 'logger'
require 'eventmachine'
# Framework for intercepting packets, redirecting them to a handler, and doing
# something with the "stolen" connection.
#
# == Description
#
# PacketThief is a little Ruby framework for programatically intercepting network
# traffic. It provides an abstraction... |
github | iSECPartners/tlspretense | https://github.com/iSECPartners/tlspretense | lib/tlspretense/app.rb | Ruby | mit | 94 | master | 1,499 | module TLSPretense
class App
def initialize(args, stdin, stdout)
@args = args
@stdin = stdin
@stdout = stdout
@action_args = args.dup
@action = @action_args.shift
end
def usage
@stdout.puts <<-QUOTE
Usage: #{0} action arguments...
Actions:
init PATH Creates a new ... |
github | iSECPartners/tlspretense | https://github.com/iSECPartners/tlspretense | lib/tlspretense/cert_maker.rb | Ruby | mit | 94 | master | 2,802 | require 'fileutils'
require 'openssl'
require 'yaml'
require 'tlspretense/ext_core/hash_indifferent_fetch'
# Provide a limited version of OpenSSL::PKey.read for older Ruby versions.
require 'tlspretense/ext_compat/openssl_pkey_read'
TLSPretense::ExtCompat::OpenSSLPKeyRead.check_and_apply_patch
module TLSPretense
m... |
github | iSECPartners/tlspretense | https://github.com/iSECPartners/tlspretense | lib/tlspretense/test_harness.rb | Ruby | mit | 94 | master | 1,015 | require 'optparse'
require 'logger'
require 'eventmachine'
require 'termios'
require 'packetthief'
require 'tlspretense/ext_core/io_raw_input'
module TLSPretense
module TestHarness
autoload :AppContext, 'tlspretense/test_harness/app_context'
autoload :CertificateManager, 'tlspretense/test_harness/c... |
github | iSECPartners/tlspretense | https://github.com/iSECPartners/tlspretense | lib/tlspretense/init_runner.rb | Ruby | mit | 94 | master | 3,410 | module TLSPretense
class InitRunner
include FileUtils
class InitError < CleanExitError ; end
def initialize(args, stdin, stdout)
@args = args
@stdin = stdin
@stdout = stdout
end
def run
if @args.length != 1
usage
return
end
path = @args[0]
... |
github | iSECPartners/tlspretense | https://github.com/iSECPartners/tlspretense | lib/tlspretense/cert_maker/subject_alt_name_factory.rb | Ruby | mit | 94 | master | 4,171 | module TLSPretense
module CertMaker
# SubjectAltName, in ASN1, is a sequence comprised of a tag identifying the
# extension type (subjectAltName, which has objectid tag of 6), and then an
# octect string that contains an ASN1 encoded sequence of alternative
# names. Each alternative name is then an AS... |
github | iSECPartners/tlspretense | https://github.com/iSECPartners/tlspretense | lib/tlspretense/cert_maker/runner.rb | Ruby | mit | 94 | master | 490 | require 'tlspretense/cert_maker'
module TLSPretense
module CertMaker
class Runner
include FileUtils
#Checks for a CA, and generates it if needed.
def ca
y = YAML.load_file('config.yml')
CertMaker.make_ca y
end
#Generate a suite of test certificates
def certs
ca
y = Y... |
github | iSECPartners/tlspretense | https://github.com/iSECPartners/tlspretense | lib/tlspretense/cert_maker/certificate_factory.rb | Ruby | mit | 94 | master | 3,610 | module TLSPretense
module CertMaker
class CertificateFactory
attr_accessor :ca, :ca_key
attr_accessor :subject
attr_accessor :not_before, :not_after
attr_accessor :extensions
attr_accessor :key_type
attr_accessor :key_size
attr_accessor :signing_alg
def initialize
self.ca = :se... |
github | iSECPartners/tlspretense | https://github.com/iSECPartners/tlspretense | lib/tlspretense/cert_maker/tasks.rb | Ruby | mit | 94 | master | 461 | namespace :certs do
desc "Checks for a CA, and generates it if needed."
task :ca do
require 'tlspretense/cert_maker/runner'
TLSPretense::CertMaker::Runner.new.ca
end
desc "Generate a suite of test certificates"
task :generate => [ 'certs:ca' ] do
require 'tlspretense/cert_maker/runner'
TLSPr... |
github | iSECPartners/tlspretense | https://github.com/iSECPartners/tlspretense | lib/tlspretense/cert_maker/certificate_suite_generator.rb | Ruby | mit | 94 | master | 4,925 | module TLSPretense
module CertMaker
# Generates a suite of certificates from a configuration.
#
# Config should be a hash-like with each key being the alias to a hash-like
# that describes the certificate. Certificates can then refer to issuers or
# signing_keys by alias, and CertificateSuiteGenerator will en... |
github | iSECPartners/tlspretense | https://github.com/iSECPartners/tlspretense | lib/tlspretense/ext_compat/openssl_pkey_read.rb | Ruby | mit | 94 | master | 1,367 | module TLSPretense
module ExtCompat
# In Ruby versions before 1.9.3, OpenSSL::PKey.read does not exist. It is
# not something that can be easily back-ported (it is written in C with
# OpenSSL functions that are not directly exposed through the Ruby
# library), so this module provides a partial reimple... |
github | iSECPartners/tlspretense | https://github.com/iSECPartners/tlspretense | lib/tlspretense/ext_core/hash_indifferent_fetch.rb | Ruby | mit | 94 | master | 362 | class Hash
# Light extension to hash to add indifferent fetching. Meant to be more
# lightweight than depending on ActiveSupport for HashWithIndifferentAccess.
def indifferent_fetch(key, *extra)
if key.class == Symbol
self.fetch(key, self.fetch(key.to_s, *extra))
else
self.fetch(key, self.fetc... |
github | iSECPartners/tlspretense | https://github.com/iSECPartners/tlspretense | lib/tlspretense/ext_core/io_raw_input.rb | Ruby | mit | 94 | master | 1,180 | require 'termios'
# Extends IO to enable "raw" input on TTYs.
class IO
# Enables raw character input for a TTY. It uses the ruby-termios gem to
# disable ICANON and ECHO functionality. This means that characters will
# become immediately available to IO#gets, IO#getchar, etc. after the user
# presses a button,... |
github | iSECPartners/tlspretense | https://github.com/iSECPartners/tlspretense | lib/tlspretense/test_harness/certificate_manager.rb | Ruby | mit | 94 | master | 702 | module TLSPretense
module TestHarness
# Handles the loading and caching of certificates and private keys.
class CertificateManager
def initialize(certinfo)
@certinfo = certinfo
end
def get_raw_cert(name)
File.read(File.join('certs',name+"cert.pem"))
end
def get_cert(name)
Op... |
github | iSECPartners/tlspretense | https://github.com/iSECPartners/tlspretense | lib/tlspretense/test_harness/test_manager.rb | Ruby | mit | 94 | master | 3,235 | module TLSPretense
module TestHarness
# Tracks testing state and handles reporting for the TestListener.
class TestManager
include PacketThief::Logging
attr_accessor :current_test
attr_reader :remaining_tests
attr_accessor :listener
attr_accessor :goodcacert
attr_accessor :goodcakey
... |
github | iSECPartners/tlspretense | https://github.com/iSECPartners/tlspretense | lib/tlspretense/test_harness/input_handler.rb | Ruby | mit | 94 | master | 998 | module TLSPretense
module TestHarness
# EM handler to handle keyboard input while a test is running.
module InputHandler
def initialize(stdin=$stdin)
@stdin = stdin
@actions = {}
# Set the term to accept keystrokes immediately.
if @stdin.tty?
@stdin.enable_raw_chars
end
... |
github | iSECPartners/tlspretense | https://github.com/iSECPartners/tlspretense | lib/tlspretense/test_harness/ssl_test_case.rb | Ruby | mit | 94 | master | 1,182 | module TLSPretense
module TestHarness
# Represents a single test case.
class SSLTestCase
include PacketThief::Logging
attr_reader :id
attr_reader :description
attr_reader :certchainalias
attr_reader :expected_result
attr_reader :certchain
attr_reader :keychain
attr_reader :hosttote... |
github | iSECPartners/tlspretense | https://github.com/iSECPartners/tlspretense | lib/tlspretense/test_harness/runner.rb | Ruby | mit | 94 | master | 3,988 | module TLSPretense
module TestHarness
# Handles a list of arguments, and uses the arguments to run a sequence of tests.
class Runner
include PacketThief::Logging
attr_reader :results
def initialize(args, stdin, stdout)
options = RunnerOptions.parse(args)
@test_list = options.args
@st... |
github | iSECPartners/tlspretense | https://github.com/iSECPartners/tlspretense | lib/tlspretense/test_harness/ssl_test_report.rb | Ruby | mit | 94 | master | 765 | module TLSPretense
module TestHarness
# Represents an entire report. SSLTestCases add results to it, which it can
# later format.
class SSLTestReport
def initialize
@results = []
end
def add_result(result)
@results << result
end
def print_results(out)
out.puts "Alias ... |
github | iSECPartners/tlspretense | https://github.com/iSECPartners/tlspretense | lib/tlspretense/test_harness/config.rb | Ruby | mit | 94 | master | 1,361 | module TLSPretense
module TestHarness
# Loads and interprets the configuration file.
class Config
DEFAULT = "config.yml"
attr_reader :raw
attr_reader :certs
def self.load_conf(opts)
Config.new(opts)
end
# TODO: do some basic type validation on the config file.
def initialize(op... |
github | iSECPartners/tlspretense | https://github.com/iSECPartners/tlspretense | lib/tlspretense/test_harness/app_context.rb | Ruby | mit | 94 | master | 397 | module TLSPretense
module TestHarness
# Class to hold onto application-wide values in a single place and to track
# application state.
class AppContext
attr_accessor :config
attr_accessor :cert_manager
attr_accessor :logger
def initialize(config, cert_manager, logger)
@config = config
... |
github | iSECPartners/tlspretense | https://github.com/iSECPartners/tlspretense | lib/tlspretense/test_harness/runner_options.rb | Ruby | mit | 94 | master | 1,751 | module TLSPretense
module TestHarness
class RunnerOptions
DEFAULT_OPTS = {
:pause => false,
:config => Config::DEFAULT,
:action => :runtests,
:loglevel => 'INFO',
:logfile => '-'
}
# Parsed command line options.
attr_reader :options
# Any command line arguments th... |
github | iSECPartners/tlspretense | https://github.com/iSECPartners/tlspretense | lib/tlspretense/test_harness/test_listener.rb | Ruby | mit | 94 | master | 5,370 | module TLSPretense
module TestHarness
# TestListener is the real workhorse used by SSLTestCases. It builds on the
# SSLSmartProxy from PacketThief in order to intercept and forward SSL
# connections. It uses SSLSmartProxy because SSLSmartProxy provides a default
# behavior where it grabs the remote certificate... |
github | iSECPartners/tlspretense | https://github.com/iSECPartners/tlspretense | lib/tlspretense/test_harness/ssl_test_result.rb | Ruby | mit | 94 | master | 795 | module TLSPretense
module TestHarness
# SSLTestResults are created by running SSLTestCases. They are then added to
# an SSLTestReport so that they can be included in that report.
class SSLTestResult
attr_reader :id
attr_accessor :description
attr_accessor :expected_result, :actual_result
attr_a... |
github | iSECPartners/tlspretense | https://github.com/iSECPartners/tlspretense | lib/packetthief/impl.rb | Ruby | mit | 94 | master | 424 | module PacketThief
# PacketThief implementations. Each one contains the implementation details
# for working with a given firewall.
module Impl
autoload :Manual, 'packetthief/impl/manual'
autoload :Netfilter, 'packetthief/impl/netfilter'
autoload :Ipfw, 'packetthief/impl/ipfw'
autoload ... |
github | iSECPartners/tlspretense | https://github.com/iSECPartners/tlspretense | lib/packetthief/logging.rb | Ruby | mit | 94 | master | 1,638 | module PacketThief
# Mix-in that provides some private convenience logging functions. Uses the
# logger specified by this module. To set the current logger for all of
# PacketThief:
#
# PacketThief::Logging.logger = Logger.new
module Logging
class << self
# An optional Ruby Logger for debugg... |
github | iSECPartners/tlspretense | https://github.com/iSECPartners/tlspretense | lib/packetthief/util.rb | Ruby | mit | 94 | master | 1,247 | module PacketThief
# Some utility methods, currently just used by the examples.
module Util
class << self
# Extracts all PEM encoded certificates out of a raw string and returns
# each raw PEM encoded certificate in an array.
def split_chain(raw)
chain = []
remaining = raw
... |
github | iSECPartners/tlspretense | https://github.com/iSECPartners/tlspretense | lib/packetthief/redirect_rule.rb | Ruby | mit | 94 | master | 463 | module PacketThief
class RedirectRule
attr_accessor :handler
attr_accessor :rulespec
attr_accessor :redirectspec
def initialize(handler)
@handler = handler
end
# specify an original destination
def where(args)
rule = clone
rule.rulespec = args
rule
end
de... |
github | iSECPartners/tlspretense | https://github.com/iSECPartners/tlspretense | lib/packetthief/handlers.rb | Ruby | mit | 94 | master | 573 | require 'eventmachine'
module PacketThief
module Handlers
autoload :AbstractSSLHandler, 'packetthief/handlers/abstract_ssl_handler'
autoload :SSLClient, 'packetthief/handlers/ssl_client'
autoload :SSLServer, 'packetthief/handlers/ssl_server'
autoload :SSLSmartProxy, 'packetthief/handlers/s... |
github | iSECPartners/tlspretense | https://github.com/iSECPartners/tlspretense | lib/packetthief/impl/ipfw.rb | Ruby | mit | 94 | master | 4,488 | module PacketThief
module Impl
# Use Ipfw to redirect traffic.
#
# Needed in at least Mac OS X 10.6 and later[1]?:
# sysctl -w net.inet.ip.scopedroute=0
#
# [1]: https://trac.macports.org/wiki/howto/SetupInterceptionSquid
#
# Sample rule:
#
# sudo ipfw add 1013 fwd 127.0.0.1,3129 tcp from an... |
github | iSECPartners/tlspretense | https://github.com/iSECPartners/tlspretense | lib/packetthief/impl/pf_divert.rb | Ruby | mit | 94 | master | 5,286 | module PacketThief
module Impl
# Untested and likely broken PacketThief implementation that uses PF's
# divert-to to redirect traffic. It is currently untested, and it requires a
# newer version of PF to redirect traffic than is available in Mac OS X 10.7
# (and probably 10.8)
#
# == Capturing Traffic
#
... |
github | iSECPartners/tlspretense | https://github.com/iSECPartners/tlspretense | lib/packetthief/impl/manual.rb | Ruby | mit | 94 | master | 1,339 | module PacketThief
module Impl
# PacketThief implementation that does apply any firewall rules. Furthermore,
# Manual.original_dest will always return a pre-configured destination address.
class Manual
module NullRuleHandler
include Logging
attr_accessor :active_rules
# Executes a rule ... |
github | iSECPartners/tlspretense | https://github.com/iSECPartners/tlspretense | lib/packetthief/impl/pf_rdr.rb | Ruby | mit | 94 | master | 7,530 | module PacketThief
module Impl
# Implementation that uses PF's +rdr+ (old style rules) and parses pfctl's
# output to interoperate with Mac OS X 10.7 Lion.
#
# It assumes that the system running PacketThief is already set up to
# reroute traffic like a NAT (On Mac OS X, you can do this by enabling... |
github | iSECPartners/tlspretense | https://github.com/iSECPartners/tlspretense | lib/packetthief/impl/netfilter.rb | Ruby | mit | 94 | master | 3,236 | module PacketThief
module Impl
# PacketThief implemented using the Linux kernel's Netfilter.
#
# This is roughly equivalent to:
#
# echo 1 > /proc/sys/net/ipv4/ip_forward
# iptables -t nat -A PREROUTING -p tcp --destination-port <DEST> -j REDIRECT --to-ports <LISTENER>
#
# Currently only implements IPv4... |
github | iSECPartners/tlspretense | https://github.com/iSECPartners/tlspretense | lib/packetthief/handlers/proxy_redirector.rb | Ruby | mit | 94 | master | 579 | module PacketThief
module Handlers
# Instead of forwarding the connection to the original host, forwards it to
# a configured host instead.
class ProxyRedirector < TransparentProxy
def initialize(proxy_host, proxy_port, log=nil)
super(log)
@proxy_host = proxy_host
@proxy_p... |
github | iSECPartners/tlspretense | https://github.com/iSECPartners/tlspretense | lib/packetthief/handlers/ssl_transparent_proxy.rb | Ruby | mit | 94 | master | 7,158 | module PacketThief
module Handlers
# Provides a transparent proxy for any TCP connection.
class SSLTransparentProxy < SSLServer
# Represents a connection out to the original destination.
class SSLProxyConnection < SSLClient
# Boolean that represents whether this handler has started to
... |
github | iSECPartners/tlspretense | https://github.com/iSECPartners/tlspretense | lib/packetthief/handlers/ssl_client.rb | Ruby | mit | 94 | master | 2,675 | module PacketThief
module Handlers
# Basic SSL/TLS Client built on Ruby's OpenSSL objects instead of on
# EventMachine's start_tls. This allows you to manipulate the SSLContext
# and other details of the connection that EM normally doesn't let you
# touch.
#
# Subclass it and override any of ... |
github | iSECPartners/tlspretense | https://github.com/iSECPartners/tlspretense | lib/packetthief/handlers/ssl_smart_proxy.rb | Ruby | mit | 94 | master | 5,220 | module PacketThief
module Handlers
# This SSL proxy needs a CA certificate (or chain) and private key. It then
# uses that information to automatically generate host certificates. It
# creates a host certificate by performing a pre-flight request to the
# original destination to get its certificate. ... |
github | iSECPartners/tlspretense | https://github.com/iSECPartners/tlspretense | lib/packetthief/handlers/ssl_server.rb | Ruby | mit | 94 | master | 5,808 | module PacketThief
module Handlers
# Basic SSL/TLS Server built on Ruby's OpenSSL objects instead of on
# EventMachine's start_tls. This allows you to manipulate the SSLContext
# and other details of the connection that EM normally doesn't let you
# touch.
#
# Subclass it and override any of ... |
github | iSECPartners/tlspretense | https://github.com/iSECPartners/tlspretense | lib/packetthief/handlers/abstract_ssl_handler.rb | Ruby | mit | 94 | master | 7,959 | require 'openssl'
module PacketThief
module Handlers
# Parent class for both SSLServer and SSLClient.
#
# TODO: get_peer_cert, get_peername, etc.
class AbstractSSLHandler < ::EM::Connection
include Logging
# The OpenSSL::SSL::SSLContext. Modify this in post_init or in the
# initia... |
github | iSECPartners/tlspretense | https://github.com/iSECPartners/tlspretense | lib/packetthief/handlers/transparent_proxy.rb | Ruby | mit | 94 | master | 5,707 | module PacketThief
module Handlers
# Provides a transparent proxy for any TCP connection.
class TransparentProxy < ::EM::Connection
include Logging
# Represents a connection out to the original destination.
module ProxyConnection
# Boolean that represents whether this handler has s... |
github | iSECPartners/tlspretense | https://github.com/iSECPartners/tlspretense | packetthief_examples/redirector.rb | Ruby | mit | 94 | master | 517 | #!/usr/bin/env ruby
$: << 'lib'
require 'rubygems'
require 'eventmachine'
require 'packetthief' # needs root
PacketThief.redirect(:to_ports => 54321).where(:protocol => :tcp, :dest_port => 80, :in_interface => 'en1').run
at_exit { puts "Exiting"; PacketThief.revert }
Signal.trap("TERM") do
puts "Received SIGTERM... |
github | iSECPartners/tlspretense | https://github.com/iSECPartners/tlspretense | packetthief_examples/ssl_client_simple.rb | Ruby | mit | 94 | master | 757 | #!/usr/bin/env ruby
# This example just shows how to call the SSLServer class with PacketThief. All
# it does is receive data -- it does not attempt to send data on.
#
# TODO: Make the dest configurable
# TODO: Pull input form stdin
$: << 'lib'
require 'rubygems'
require 'eventmachine'
require 'packetthief' # needs r... |
github | iSECPartners/tlspretense | https://github.com/iSECPartners/tlspretense | packetthief_examples/em_ssl_test.rb | Ruby | mit | 94 | master | 1,508 | #!/usr/bin/env ruby
$: << 'lib'
require 'rubygems'
require 'eventmachine'
require 'packetthief' # needs root
# Note that this does not forward the encrypted traffic at all, so it isn't a
# full proxy. It just demonstrates that we can terminate the SSL connection
# that we have redirected.
#
# Also, you will need to... |
github | iSECPartners/tlspretense | https://github.com/iSECPartners/tlspretense | packetthief_examples/ssl_server_simple.rb | Ruby | mit | 94 | master | 962 | #!/usr/bin/env ruby
# This example just shows how to call the SSLServer class with PacketThief. All
# it does is receive data -- it does not attempt to send data on.
$: << 'lib'
require 'rubygems'
require 'eventmachine'
require 'packetthief' # needs root
if ARGV.length != 2
puts "script chain.pem key.pem"
exit 1... |
github | iSECPartners/tlspretense | https://github.com/iSECPartners/tlspretense | packetthief_examples/transparent_proxy.rb | Ruby | mit | 94 | master | 1,312 | #!/usr/bin/env ruby
$: << 'lib'
require 'rubygems'
require 'eventmachine'
require 'packetthief' # needs root
PacketThief.redirect(:to_ports => 54321).where(:protocol => :tcp, :dest_port => 80, :in_interface => 'en1').run
PacketThief.redirect(:to_ports => 54321).where(:protocol => :tcp, :dest_port => 443, :in_interfa... |
github | iSECPartners/tlspretense | https://github.com/iSECPartners/tlspretense | packetthief_examples/ssl_transparent_proxy.rb | Ruby | mit | 94 | master | 2,091 | #!/usr/bin/env ruby
$: << 'lib'
require 'rubygems'
require 'eventmachine'
require 'packetthief' # needs root
class VerboseProxy < PacketThief::Handlers::SSLTransparentProxy
def client_desc
"Client #{client_host}:#{client_port}->#{dest_host}:#{dest_port} (#{dest_hostname})"
end
def dest_desc
"Dest #{d... |
github | iSECPartners/tlspretense | https://github.com/iSECPartners/tlspretense | packetthief_examples/ssl_smart_proxy.rb | Ruby | mit | 94 | master | 2,923 | #!/usr/bin/env ruby
$: << 'lib'
require 'rubygems'
require 'eventmachine'
require 'packetthief' # needs root
class VerboseProxy < PacketThief::Handlers::SSLSmartProxy
def client_desc
"Client #{client_host}:#{client_port}->#{dest_host}:#{dest_port} (#{dest_hostname})"
end
def dest_desc
"Dest #{dest_ho... |
github | iSECPartners/tlspretense | https://github.com/iSECPartners/tlspretense | spec/spec_helper.rb | Ruby | mit | 94 | master | 1,410 | $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
$LOAD_PATH.unshift(File.dirname(__FILE__))
if ENV["COVERAGE"]
require 'simplecov'
SimpleCov.start do
add_group 'Source', '/lib/'
add_group 'RSpec', '/spec/'
end
end
require 'rspec'
require 'tlspretense'
# Requires supporting files with ... |
github | iSECPartners/tlspretense | https://github.com/iSECPartners/tlspretense | spec/packetthief_spec.rb | Ruby | mit | 94 | master | 1,663 | require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
describe PacketThief do
describe "setting an implementation" do
context "when no implementation has been previously set" do
before(:each) { PacketThief.implementation = nil }
after(:each) { PacketThief.implementation = nil }
it ... |
github | iSECPartners/tlspretense | https://github.com/iSECPartners/tlspretense | spec/packetthief/logging_spec.rb | Ruby | mit | 94 | master | 2,277 | require File.expand_path(File.join(File.dirname(__FILE__),'..','spec_helper'))
module PacketThief
describe Logging do
class LoggingObj
include Logging
end
let(:logger) { Logger.new(nil) }
before(:each) { Logging.logger = logger }
describe "an object that has included PacketThief::Logging"... |
github | iSECPartners/tlspretense | https://github.com/iSECPartners/tlspretense | spec/packetthief/impl/pf_divert_spec.rb | Ruby | mit | 94 | master | 3,555 | require File.expand_path(File.join(File.dirname(__FILE__),'..','..','spec_helper'))
module PacketThief
module Impl
describe PFDivert do
subject { PFDivert }
before(:each) do
subject.stub(:system).and_return(:true)
end
# Either write our current ruleset to a file, or echo it into pfctl.
de... |
github | iSECPartners/tlspretense | https://github.com/iSECPartners/tlspretense | spec/packetthief/impl/ipfw_spec.rb | Ruby | mit | 94 | master | 3,816 | require File.expand_path(File.join(File.dirname(__FILE__),'..','..','spec_helper'))
module PacketThief
module Impl
describe Ipfw do
before(:each) do
Ipfw.stub(:system).and_return(:true)
end
describe ".redirect" do
context "when it is told to redirect TCP port 443 traffic to localhost port 65... |
github | iSECPartners/tlspretense | https://github.com/iSECPartners/tlspretense | spec/packetthief/impl/manual_spec.rb | Ruby | mit | 94 | master | 1,914 | require File.expand_path(File.join(File.dirname(__FILE__),'..','..','spec_helper'))
module PacketThief
module Impl
describe Manual do
before(:each) do
subject.stub(:system).and_return(:true)
end
subject {Manual}
describe ".redirect" do
context "when it is told to redirec... |
github | iSECPartners/tlspretense | https://github.com/iSECPartners/tlspretense | spec/packetthief/impl/pf_rdr_spec.rb | Ruby | mit | 94 | master | 5,772 | require File.expand_path(File.join(File.dirname(__FILE__),'..','..','spec_helper'))
module PacketThief
module Impl
describe PFRdr do
subject { PFRdr }
before(:each) do
subject.stub(:system).and_return(:true)
IO.stub(:popen)
end
# Either write our current ruleset to a fil... |
github | iSECPartners/tlspretense | https://github.com/iSECPartners/tlspretense | spec/packetthief/impl/netfilter_spec.rb | Ruby | mit | 94 | master | 3,008 | require File.expand_path(File.join(File.dirname(__FILE__),'..','..','spec_helper'))
module PacketThief
module Impl
describe Netfilter do
describe ".redirect" do
it { Netfilter.redirect.table.should == 'nat' }
it { Netfilter.redirect.chain.should == 'PREROUTING' }
context "when it is told to re... |
github | iSECPartners/tlspretense | https://github.com/iSECPartners/tlspretense | spec/tlspretense/test_harness/test_manager_spec.rb | Ruby | mit | 94 | master | 10,907 | require File.expand_path(File.join(File.dirname(__FILE__),'..','..','spec_helper'))
module TLSPretense
module TestHarness
describe TestManager do
let(:config) do
double("config",
:dest_port => 443,
:listener_port => 54321,
:hosttotest => "my.hostname.com",
... |
github | iSECPartners/tlspretense | https://github.com/iSECPartners/tlspretense | spec/tlspretense/test_harness/runner_spec.rb | Ruby | mit | 94 | master | 10,709 | require File.expand_path(File.join(File.dirname(__FILE__),'..','..','spec_helper'))
module TLSPretense
module TestHarness
describe Runner do
let(:args) { [] }
let(:stdin) { double("stdin") }
let(:stdout) { double("stdout", :puts => nil) }
let(:test_foo_data) do
{
'alias' => 'foo',
... |
github | iSECPartners/tlspretense | https://github.com/iSECPartners/tlspretense | spec/tlspretense/test_harness/ssl_test_case_spec.rb | Ruby | mit | 94 | master | 3,363 | require File.expand_path(File.join(File.dirname(__FILE__),'..','..','spec_helper'))
module TLSPretense
module TestHarness
describe SSLTestCase do
let(:certchain) { double('certchain') }
let(:keychain) { [ double('firstkey'), double('secondkey'), double('cakey') ] }
let(:goodcacert) { double('goodcacert')... |
github | iSECPartners/tlspretense | https://github.com/iSECPartners/tlspretense | spec/tlspretense/test_harness/config_spec.rb | Ruby | mit | 94 | master | 1,727 | require File.expand_path(File.join(File.dirname(__FILE__),'..','..','spec_helper'))
module TLSPretense
module TestHarness
describe Config do
let(:foo_test) do
{
'alias' => 'foo',
'name' => 'test foo',
'certchain' => [ 'a', 'b' ]
}
end
let(:bar_test) do
{
... |
github | iSECPartners/tlspretense | https://github.com/iSECPartners/tlspretense | spec/tlspretense/test_harness/certificate_manager_spec.rb | Ruby | mit | 94 | master | 12,415 | require File.expand_path(File.join(File.dirname(__FILE__),'..','..','spec_helper'))
module TLSPretense
module TestHarness
describe CertificateManager do
let(:rawfoocert) do (<<-EOF).gsub(/^\s*/,'')
-----BEGIN CERTIFICATE-----
MIIDJTCCAg2gAwIBAgIEHokN5TANBgkqhkiG9w0BAQUFADAiMQswCQYDVQQGEwJV
UzET... |
github | iSECPartners/tlspretense | https://github.com/iSECPartners/tlspretense | spec/tlspretense/test_harness/test_listener_spec.rb | Ruby | mit | 94 | master | 7,674 | require File.expand_path(File.join(File.dirname(__FILE__),'..','..','spec_helper'))
# quick and dirty. just create the fields we need.
def quickcertmaker(hostname, altnames=nil)
cert = OpenSSL::X509::Certificate.new
cert.version = 2
cert.subject = OpenSSL::X509::Name.parse("C=US, CN=#{hostname}")
ef = OpenSSL:... |
github | iSECPartners/tlspretense | https://github.com/iSECPartners/tlspretense | spec/tlspretense/cert_maker/subject_alt_name_factory_spec.rb | Ruby | mit | 94 | master | 2,995 | require File.expand_path(File.join(File.dirname(__FILE__),'..','..','spec_helper'))
module TLSPretense
module CertMaker
describe SubjectAltNameFactory do
describe "the created extension" do
subject { SubjectAltNameFactory.new.create_san_with_dns(arg) }
context "when created with www.isecp... |
github | iSECPartners/tlspretense | https://github.com/iSECPartners/tlspretense | spec/tlspretense/ext_compat/openssl_pkey_read_spec.rb | Ruby | mit | 94 | master | 6,697 | require File.expand_path(File.join(File.dirname(__FILE__),'..','..','spec_helper'))
require 'tlspretense/ext_compat/openssl_pkey_read'
module TLSPretense
module ExtCompat
describe OpenSSLPKeyRead do
subject { a = Object.new ; a.extend(OpenSSLPKeyRead) ; a }
describe "#read" do
context "when ... |
github | bararchy/ruby-SSLscanner | https://github.com/bararchy/ruby-SSLscanner | scanssl.gemspec | Ruby | mit | 94 | master | 856 | # -*- encoding: utf-8 -*
require File.expand_path("../lib/scanssl/version", __FILE__)
Gem::Specification.new do |s|
s.name = 'ScanSSL'
s.version = ScanSSL::VERSION
s.date = '2016-08-30'
s.summary = 'ScanSSL'
s.description = 'A simple and easy to use SSL Cipher scanner'
s.authors =... |
github | bararchy/ruby-SSLscanner | https://github.com/bararchy/ruby-SSLscanner | sslscanner.rb | Ruby | mit | 94 | master | 12,040 | #!/usr/bin/env ruby
require "colorize"
require "getoptlong"
require "openssl"
require "socket"
require "webrick"
require 'optparse'
require 'prawn'
# SSL Scanner by Bar Hofesh (bararchy) bar.hofesh@gmail.com
class Scanner
def initialize(options = {})
@server = options[:server]
@port = op... |
github | bararchy/ruby-SSLscanner | https://github.com/bararchy/ruby-SSLscanner | lib/scanssl.rb | Ruby | mit | 94 | master | 1,643 | require 'colorize'
require 'getoptlong'
require 'openssl'
require 'socket'
require 'webrick'
require 'prawn'
require 'scanssl/version'
require 'scanssl/settings'
require 'scanssl/certInfo'
require 'scanssl/fileExport'
require 'scanssl/scanHost'
module ScanSSL
class Command
def self.call(options = {})
@ser... |
github | bararchy/ruby-SSLscanner | https://github.com/bararchy/ruby-SSLscanner | lib/scanssl/fileExport.rb | Ruby | mit | 94 | master | 334 | module ScanSSL
class Export
def self.pdf(file, data)
Prawn::Document.generate(file) do
text "Hello :-) This is my #{data}"
end
end
def self.txt(file, data)
ftxt = File.open("#{path}/#{file}", "a")
ftxt.write(data)
ftxt.close
end
def self.csv(file, data)
... |
github | bararchy/ruby-SSLscanner | https://github.com/bararchy/ruby-SSLscanner | lib/scanssl/settings.rb | Ruby | mit | 94 | master | 876 | module ScanSSL
class Certificate
NO_SSLV2 = 16777216
NO_SSLV3 = 33554432
NO_TLSV1 = 67108864
NO_TLSV1_1 = 268435456
NO_TLSV1_2 = 134217728
SSLV2 = NO_SSLV3 + NO_TLSV1 + NO_TLSV1_1 + NO_TLSV1_2
SSLV3 = NO_SSLV2 + NO_TLSV1 + NO_TLSV1_1 + NO_TLSV1_2
T... |
github | bararchy/ruby-SSLscanner | https://github.com/bararchy/ruby-SSLscanner | lib/scanssl/certInfo.rb | Ruby | mit | 94 | master | 1,497 | module ScanSSL
class CertInfo < Certificate
def initialize(server, port)
@ssl_context = OpenSSL::SSL::SSLContext.new
@cert_store = OpenSSL::X509::Store.new
@cert_store.set_default_paths
@ssl_context.cert_store = @cert_store
@tcp_socket = TCPSocket.new(server, port)
@socket_dest... |
github | bararchy/ruby-SSLscanner | https://github.com/bararchy/ruby-SSLscanner | lib/scanssl/scanHost.rb | Ruby | mit | 94 | master | 5,153 | module ScanSSL
# I think the best will be to put the result to the hash or array
# and return it to ScanSLL::Command so we can send it to Colorize method
# and sort.
#
class ScanHost < Certificate
def scan(server, port)
ssl2_array = []
ssl3_array = []
tls1_array = []
tls1_1_array =... |
github | c2h2/tts | https://github.com/c2h2/tts | Rakefile | Ruby | mit | 94 | master | 1,163 | # encoding: utf-8
require 'rubygems'
require 'bundler'
begin
Bundler.setup(:default, :development)
rescue Bundler::BundlerError => e
$stderr.puts e.message
$stderr.puts "Run `bundle install` to install missing gems"
exit e.status_code
end
require 'rake'
require 'jeweler'
Jeweler::Tasks.new do |gem|
# gem is... |
github | c2h2/tts | https://github.com/c2h2/tts | tts.gemspec | Ruby | mit | 94 | master | 1,832 | # Generated by jeweler
# DO NOT EDIT THIS FILE DIRECTLY
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
# -*- encoding: utf-8 -*-
# stub: tts 0.7.1 ruby lib
Gem::Specification.new do |s|
s.name = "tts".freeze
s.version = "0.8.2"
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze... |
github | c2h2/tts | https://github.com/c2h2/tts | spec/tts_spec.rb | Ruby | mit | 94 | master | 3,226 | # encoding: utf-8
require File.expand_path("../../lib/tts", __FILE__)
require "rspec"
describe "to_valid_fn method" do
# fn.gsub(/[\x00\/\\:\*\?\"<>\|]/, '_')
it "should replace * with _" do
expect("hello*nice".to_valid_fn).to eq "hello_nice"
expect("hello*nice*hello".to_valid_fn).to eq "hello_nice_hello"
... |
github | c2h2/tts | https://github.com/c2h2/tts | lib/tts.rb | Ruby | mit | 94 | master | 2,964 | # encoding: utf-8
require 'open-uri'
require 'uri'
require 'tempfile'
require 'cgi'
module Tts
@@default_url = "http://translate.google.com/translate_tts"
@@user_agent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.68 Safari/534.24"
@@referer = "http://translat... |
github | blockbridge/blockbridge-docker-volume | https://github.com/blockbridge/blockbridge-docker-volume | Gemfile | Ruby | bsd-3-clause | 94 | master | 906 | # Copyright (c) 2015-2017, Blockbridge Networks LLC. All rights reserved.
# Use of this source code is governed by a BSD-style license, found
# in the LICENSE file.
#
# -*- mode: ruby -*-
source 'https://rubygems.org'
gem 'goliath'
gem 'grape', :github => 'srust/grape', :branch => '1048_dot_in_version_accept_heade... |
github | blockbridge/blockbridge-docker-volume | https://github.com/blockbridge/blockbridge-docker-volume | volume_driver.rb | Ruby | bsd-3-clause | 94 | master | 2,796 | # Copyright (c) 2015-2017, Blockbridge Networks LLC. All rights reserved.
# Use of this source code is governed by a BSD-style license, found
# in the LICENSE file.
require 'bundler/setup'
require 'goliath'
require 'grape'
require_relative 'volume_driver/version'
require_relative 'volume_driver/helpers'
require_rel... |
github | blockbridge/blockbridge-docker-volume | https://github.com/blockbridge/blockbridge-docker-volume | volume_driver/version.rb | Ruby | bsd-3-clause | 94 | master | 271 | # Copyright (c) 2015-2017, Blockbridge Networks LLC. All rights reserved.
# Use of this source code is governed by a BSD-style license, found
# in the LICENSE file.
module Blockbridge
module VolumeDriverVersion
VERSION = ENV['VERSION'] || 'development'
end
end |
github | blockbridge/blockbridge-docker-volume | https://github.com/blockbridge/blockbridge-docker-volume | volume_driver/plugins.rb | Ruby | bsd-3-clause | 94 | master | 216 | # Copyright (c) 2015-2017, Blockbridge Networks LLC. All rights reserved.
# Use of this source code is governed by a BSD-style license, found
# in the LICENSE file.
require 'require_all'
require_rel 'plugins/*.rb' |
github | blockbridge/blockbridge-docker-volume | https://github.com/blockbridge/blockbridge-docker-volume | volume_driver/helpers.rb | Ruby | bsd-3-clause | 94 | master | 828 | # Copyright (c) 2015-2017, Blockbridge Networks LLC. All rights reserved.
# Use of this source code is governed by a BSD-style license, found
# in the LICENSE file.
require 'require_all'
require 'tempfile'
require 'fileutils'
require 'socket'
require 'em-synchrony'
require 'active_support/core_ext/hash'
require 'pp'... |
github | blockbridge/blockbridge-docker-volume | https://github.com/blockbridge/blockbridge-docker-volume | volume_driver/apis.rb | Ruby | bsd-3-clause | 94 | master | 2,170 | # Copyright (c) 2015-2017, Blockbridge Networks LLC. All rights reserved.
# Use of this source code is governed by a BSD-style license, found
# in the LICENSE file.
require 'require_all'
module API; end
class TransportType < Grape::Validations::Base
def validate_param!(attr_name, params)
unless params[attr_na... |
github | blockbridge/blockbridge-docker-volume | https://github.com/blockbridge/blockbridge-docker-volume | volume_driver/help.rb | Ruby | bsd-3-clause | 94 | master | 1,626 | # Copyright (c) 2015-2017, Blockbridge Networks LLC. All rights reserved.
# Use of this source code is governed by a BSD-style license, found
# in the LICENSE file.
module Blockbridge
class HelpBuilder
def initialize(opts = {})
@out = StringIO.new
@opts = opts
end
def string
@out.stri... |
github | blockbridge/blockbridge-docker-volume | https://github.com/blockbridge/blockbridge-docker-volume | volume_driver/helpers/iscsid.rb | Ruby | bsd-3-clause | 94 | master | 1,069 | # Copyright (c) 2015-2017, Blockbridge Networks LLC. All rights reserved.
# Use of this source code is governed by a BSD-style license, found
# in the LICENSE file.
require 'posix/spawn'
module Helpers
module Iscsid
def self.iscsid
@@iscsid ||= nil
end
def self.iscsid=(pid)
@@iscsid = pid
... |
github | blockbridge/blockbridge-docker-volume | https://github.com/blockbridge/blockbridge-docker-volume | volume_driver/helpers/cmd.rb | Ruby | bsd-3-clause | 94 | master | 2,033 | # Copyright (c) 2015-2017, Blockbridge Networks LLC. All rights reserved.
# Use of this source code is governed by a BSD-style license, found
# in the LICENSE file.
module Helpers
module Cmd
def fsfreeze
'/sbin/fsfreeze'
end
def ns_exec
'/bb/bin/nsexec'
end
def ns_exec_mnt
if... |
github | blockbridge/blockbridge-docker-volume | https://github.com/blockbridge/blockbridge-docker-volume | volume_driver/helpers/em_synchrony.rb | Ruby | bsd-3-clause | 94 | master | 390 | # Copyright (c) 2015-2017, Blockbridge Networks LLC. All rights reserved.
# Use of this source code is governed by a BSD-style license, found
# in the LICENSE file.
require 'em-synchrony'
module EventMachine
module Synchrony
def self.run_and_add_periodic_timer(time_s, &blk)
EM::Synchrony.next_tick(&blk)
... |
github | blockbridge/blockbridge-docker-volume | https://github.com/blockbridge/blockbridge-docker-volume | volume_driver/helpers/errors.rb | Ruby | bsd-3-clause | 94 | master | 1,590 | # Copyright (c) 2015-2017, Blockbridge Networks LLC. All rights reserved.
# Use of this source code is governed by a BSD-style license, found
# in the LICENSE file.
module Blockbridge
class Error < StandardError
attr_reader :errors
... |
github | blockbridge/blockbridge-docker-volume | https://github.com/blockbridge/blockbridge-docker-volume | volume_driver/helpers/params.rb | Ruby | bsd-3-clause | 94 | master | 2,119 | # Copyright (c) 2015-2017, Blockbridge Networks LLC. All rights reserved.
# Use of this source code is governed by a BSD-style license, found
# in the LICENSE file.
module Helpers
module Params
def parse_params(params)
return unless params[:Name] && params[:Name].include?('=')
params[:Opts] ||= {}
... |
github | blockbridge/blockbridge-docker-volume | https://github.com/blockbridge/blockbridge-docker-volume | volume_driver/helpers/exec.rb | Ruby | bsd-3-clause | 94 | master | 1,350 | # Copyright (c) 2015-2017, Blockbridge Networks LLC. All rights reserved.
# Use of this source code is governed by a BSD-style license, found
# in the LICENSE file.
module Helpers
module Exec
def as_root_shell(args)
case args
when Array
as_root_user('bash', '-c', "#{args.shelljoin}")
w... |
github | blockbridge/blockbridge-docker-volume | https://github.com/blockbridge/blockbridge-docker-volume | volume_driver/helpers/cache.rb | Ruby | bsd-3-clause | 94 | master | 1,822 | # Copyright (c) 2015-2017, Blockbridge Networks LLC. All rights reserved.
# Use of this source code is governed by a BSD-style license, found
# in the LICENSE file.
module Helpers
module Cache
def self.volumes
@@volumes ||= {}
end
def vol_cache_ref
'docker-volumes-cache'
end
def vo... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.