Skip to content

Instantly share code, notes, and snippets.

View Zapotek's full-sized avatar

Tasos Laskos Zapotek

View GitHub Profile
#
# Gets the reverse diff (strings that have not changed) between 2 strings
#
#
# text1 = <<END
# This is the first test.
# Not really sure what else to put here...
# END
#
# text2 = <<END
=begin
Arachni
Copyright (c) 2010-2011 Tasos "Zapotek" Laskos <tasos.laskos@gmail.com>
This is free software; you can copy and distribute and modify
this program under the term of the GPL v2.0 License
(See LICENSE file for details)
=end
@Zapotek
Zapotek / rsa_aes_cbc.rb
Created May 19, 2011 22:33
RSA_AES_CBC
require 'openssl'
require "yaml"
require "base64"
#
# Simple hybrid crypto class using RSA for public key encryption and AES with CBC
# for bulk data encryption/decryption.
#
# RSA is used to encrypt the AES primitives which are used to encrypt the plaintext.
#
@Zapotek
Zapotek / bug.rb
Created October 21, 2011 03:53
EventMachine bug: Incomplete transfers when using TLS with large data.
require 'eventmachine'
module EventMachine::Protocols::ObjectProtocol
def serializer
Marshal
end
def receive_data data
(@buf ||= '') << data
@Zapotek
Zapotek / em.ssl.bug.rb
Created November 2, 2011 04:56
EventMachine bug: ssl_verify_peer() not called on CA mismatch of cert and key.
require 'eventmachine'
class Handler < EventMachine::Connection
def initialize( opts = {} )
@role = opts[:role]
@ssl_opts = opts[:ssl] || {}
@ssl_opts[:verify_peer] = true
end
@Zapotek
Zapotek / arachni_rpc_client_pure.rb
Created November 15, 2011 10:03
Example pure Ruby client of the Arachni-RPC protocol
require 'socket'
require 'openssl'
require 'yaml'
require 'ap'
class Connection
def initialize( opts )
@opts = opts
@Zapotek
Zapotek / js.demo.rb
Created December 4, 2011 17:01
V8 interpreter with basic DOM in Ruby using TheRubyRacer and Taka
require 'v8'
require 'open-uri'
require 'pp'
require 'ap'
require 'taka'
require 'ostruct'
#
# Monkey patch all elements to include a 'style' attribute
#
@Zapotek
Zapotek / arachni_script.rb
Created February 24, 2012 22:17
Arachni scripting example
#
# You need to grab the latest code from:
# https://github.com/Zapotek/arachni/tree/experimental
#
# for this to work.
#
# require_relative '../lib/arachni/ui/cli/output'
# require_relative '../lib/arachni'
@Zapotek
Zapotek / arachni_script.rb
Created June 20, 2012 15:54
Scripting with Arachni
# Helps to see status messages when developing.
#require 'arachni/ui/cli/output'
# Only works with the latest code from the experimental branch.
require 'arachni'
# to avoid having to prefix every object's name with it
include Arachni
include Utilities
@Zapotek
Zapotek / marshal_vs_yaml.rb
Created November 1, 2012 22:52
Simple benchmark of Marshal vs. YAML
#
# Test done on: Intel(R) Core(TM) i7-3930K CPU @ 3.20GHz
#
require 'yaml'
TIMES = 1000
obj = []
500.times { |i| obj << { 'key' * i => [ 'value' * i ] } }