├── Rakefile ├── Enc.gemspec ├── README.markdown ├── bin └── enc-cli ├── test ├── spec_dec.rb └── spec_enc.rb └── lib └── enc ├── dec.rb └── enc.rb /Rakefile: -------------------------------------------------------------------------------- 1 | require 'yard' 2 | require 'rake/clean' 3 | 4 | CLEAN.include('doc/', '*.gem') 5 | 6 | task :buildgem do 7 | puts `gem build Enc.gemspec` 8 | end 9 | 10 | task :install => [:clean, :buildgem] do 11 | puts `gem install Enc-*.gem` 12 | end 13 | 14 | YARD::Rake::YardocTask.new do |t| 15 | t.files = ['lib/enc/enc.rb', 'lib/enc/dec.rb'] 16 | t.options = ['--main', 'README.markdown'] 17 | end 18 | -------------------------------------------------------------------------------- /Enc.gemspec: -------------------------------------------------------------------------------- 1 | # -*- encoding: utf-8 -*- 2 | 3 | Gem::Specification.new do |s| 4 | s.name = %q{Enc} 5 | s.version = "0.0.9" 6 | s.authors = ["Patrick Hof"] 7 | s.date = %q{2012-04-27} 8 | s.email = %q{courts@offensivethinking.org} 9 | s.files = %w(README.markdown Rakefile bin/enc-cli lib/enc/dec.rb lib/enc/enc.rb test/spec_enc.rb test/spec_dec.rb) 10 | s.executables = ["enc-cli"] 11 | s.homepage = %q{http://www.offensivethinking.org} 12 | s.require_paths = ["lib"] 13 | s.summary = %q{A module implementing commonly used string encoders for various occasions.} 14 | s.description = <<-EOF 15 | A module implementing commonly used string encoders for various occasions. 16 | It's intended primary use is to include it in your scripts. A basic command line 17 | client is included. 18 | EOF 19 | end 20 | -------------------------------------------------------------------------------- /README.markdown: -------------------------------------------------------------------------------- 1 | Ruby Enc 2 | ======== 3 | 4 | Author: Patrick Hof 5 | License: [CC0 1.0 Universal License](http://creativecommons.org/publicdomain/zero/1.0/legalcode) 6 | 7 | Download: git clone git@github.com:courts/enc.git 8 | YARD docs: [http://courts.github.com/enc](http://courts.github.com/enc) 9 | 10 | Two modules implementing commonly used string encoders and decoders for various 11 | occasions. Their intended primary use is to include them in your scripts. Basic 12 | command line clients are included. 13 | 14 | Command Line Usage 15 | ------------------ 16 | 17 | There is a basic command line client in the /bin directory. Usage: 18 | 19 | enc-cli [params] 20 | enc-cli -d [params] 21 | 22 | See ``enc-cli -h`` for more information. 23 | 24 | Examples 25 | -------- 26 | enc-cli Std::url <<< 'http://www.example.com?aa=bb&cc=dd' 27 | http%3A%2F%2Fwww.example.com%3Faa%3Dbb%26cc%3Ddd%0A 28 | 29 | enc-cli Std::url true <<< 'http://www.example.com?aa=bb&cc=dd' 30 | %68%74%74%70%3A%2F%2F%77%77%77%2E%65%78%61%6D%70%6C%65%2E%63%6F%6D%3F%61%61%3D%62%62%26%63%63%3D%64%64%0A 31 | 32 | enc-cli -d Std::url <<< 'http%3A%2F%2Fwww.example.com%3Faa%3Dbb%26cc%3Ddd' 33 | http://www.example.com?aa=bb&cc=dd 34 | 35 | Be aware of the trailing newline in the encoding example, which also gets 36 | encoded. To get rid of it, use the ``-n`` option. 37 | 38 | RubyGems 39 | -------- 40 | 41 | A gemspec file is included, so you can build and install Enc as a gem with: 42 | 43 | gem build Enc.gemspec 44 | gem install Enc-x.x.x.gem 45 | 46 | --- 47 | 48 | Inspired by: 49 | 50 | * [wfuzz][1] 51 | * [rbkb][2] 52 | 53 | [1]: http://www.edge-security.com/wfuzz.php 54 | [2]: http://github.com/emonti/rbkb 55 | -------------------------------------------------------------------------------- /bin/enc-cli: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # 3 | # A basic command line client for the Enc module. 4 | # 5 | # This software is licensed under the Creative 6 | # Commons CC0 1.0 Universal License. 7 | # To view a copy of this license, visit 8 | # http://creativecommons.org/publicdomain/zero/1.0/legalcode 9 | # 10 | # @author Patrick Hof 11 | 12 | require 'enc/enc' 13 | require 'enc/dec' 14 | require 'optparse' 15 | 16 | # Returns all methods the given module provides 17 | # 18 | # @param [Module] mod The module the check 19 | # @return [Array] array of strings with the methods 20 | def get_methods(mod) 21 | methods = [] 22 | mod.constants.sort.each do |c| 23 | mod.const_get(c).singleton_methods.sort.each do |m| 24 | methods << "#{c}::#{m}" 25 | end 26 | end 27 | methods 28 | end 29 | 30 | fname = File.basename(__FILE__) 31 | methods = [ 32 | "", 33 | "Available Encoders", 34 | "------------------" 35 | ] 36 | methods += get_methods(Enc) 37 | methods += [ 38 | "", 39 | "Available Decoders", 40 | "------------------" 41 | ] 42 | methods += get_methods(Dec) 43 | methods += [ 44 | "", 45 | "Examples:", 46 | "#{fname} Std::url <<< '