grimen-rainbow 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/MIT-LICENSE +20 -0
- data/README.textile +36 -0
- data/Rakefile +47 -0
- data/bin/rainbow +10 -0
- data/lib/rainbow.rb +38 -0
- data/rails/init.rb +3 -0
- metadata +59 -0
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Jonas Grimfelt
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.textile
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
h1. Rainbow
|
2
|
+
|
3
|
+
MD5 hash lookup using on one of the biggest rainbow lookup tables available.
|
4
|
+
|
5
|
+
h2. Requirements
|
6
|
+
|
7
|
+
* scrubyt (gem)
|
8
|
+
* nokogiri (gem)
|
9
|
+
* Internet connection =)
|
10
|
+
|
11
|
+
h2. Installation
|
12
|
+
|
13
|
+
<pre><code>
|
14
|
+
sudo gem install grimen-rainbow
|
15
|
+
</code></pre>
|
16
|
+
|
17
|
+
h2. Examples
|
18
|
+
|
19
|
+
h3. Terminal
|
20
|
+
|
21
|
+
<pre><code>
|
22
|
+
$ rainbow 3858f62230ac3c915f300c664312c63f
|
23
|
+
Result: foobar
|
24
|
+
</code></pre>
|
25
|
+
|
26
|
+
h3. In you app
|
27
|
+
|
28
|
+
<pre><code>
|
29
|
+
rainbow = Rainbow.new
|
30
|
+
result = rainbow.lookup('3858f62230ac3c915f300c664312c63f') # => 'foobar'
|
31
|
+
</code></pre>
|
32
|
+
|
33
|
+
h2. TODO
|
34
|
+
|
35
|
+
* Tests
|
36
|
+
* Local lookup (only remote lookup available this point)
|
data/Rakefile
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/testtask'
|
3
|
+
require 'rake/rdoctask'
|
4
|
+
|
5
|
+
GEM = "rainbow"
|
6
|
+
SUMMARY = %Q{MD5 hash lookup using on one of the biggest rainbow lookup tables available.}
|
7
|
+
HOMEPAGE = "http://github.com/grimen/#{GEM}/tree/master"
|
8
|
+
AUTHOR = "Jonas Grimfelt"
|
9
|
+
EMAIL = "grimen@gmail.com"
|
10
|
+
|
11
|
+
begin
|
12
|
+
require 'jeweler'
|
13
|
+
Jeweler::Tasks.new do |s|
|
14
|
+
s.name = GEM
|
15
|
+
s.summary = SUMMARY
|
16
|
+
s.description = SUMMARY
|
17
|
+
s.homepage = HOMEPAGE
|
18
|
+
s.author = AUTHOR
|
19
|
+
s.email = EMAIL
|
20
|
+
|
21
|
+
s.require_paths = %w{lib}
|
22
|
+
s.files = %w(MIT-LICENSE README.textile Rakefile) + Dir.glob(File.join('{rails,bin,lib,test}', '**', '*'))
|
23
|
+
s.executables = %w(rainbow)
|
24
|
+
s.extra_rdoc_files = %w{README.textile}
|
25
|
+
end
|
26
|
+
rescue LoadError
|
27
|
+
puts "Jeweler, or one of its dependencies, is not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
28
|
+
end
|
29
|
+
|
30
|
+
desc %Q{Default: Run unit tests.}
|
31
|
+
task :default => :test
|
32
|
+
|
33
|
+
desc %Q{Run unit tests for "#{GEM}".}
|
34
|
+
Rake::TestTask.new(:test) do |t|
|
35
|
+
t.libs << 'lib'
|
36
|
+
t.pattern = 'test/**/*_test.rb'
|
37
|
+
t.verbose = true
|
38
|
+
end
|
39
|
+
|
40
|
+
desc %Q{Generate documentation for "#{GEM}".}
|
41
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
42
|
+
rdoc.rdoc_dir = 'rdoc'
|
43
|
+
rdoc.title = GEM
|
44
|
+
rdoc.options << '--line-numbers' << '--inline-source' << '--charset=UTF-8'
|
45
|
+
rdoc.rdoc_files.include('README.textile')
|
46
|
+
rdoc.rdoc_files.include(File.join('lib', '**', '*.rb'))
|
47
|
+
end
|
data/bin/rainbow
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# The command line rainbow MD5 lookup.
|
3
|
+
|
4
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
|
5
|
+
require 'rainbow'
|
6
|
+
|
7
|
+
rainbow = Rainbow.new
|
8
|
+
result = rainbow.lookup(ARGV.first)
|
9
|
+
result = '(No solution)' if result.blank?
|
10
|
+
puts "Result: %s" % result
|
data/lib/rainbow.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'scrubyt'
|
3
|
+
require 'nokogiri'
|
4
|
+
|
5
|
+
class Rainbow
|
6
|
+
|
7
|
+
#
|
8
|
+
# Example:
|
9
|
+
#
|
10
|
+
# rainbow = Rainbow.new
|
11
|
+
# puts rainbow.lookup('3858f62230ac3c915f300c664312c63f')
|
12
|
+
#
|
13
|
+
def lookup(md5_hash, options = {})
|
14
|
+
options[:method] = :remote # default, only option supported at this point
|
15
|
+
(options[:method] == :remote) ? lookup_remote(md5_hash) : lookup_local(md5_hash)
|
16
|
+
end
|
17
|
+
|
18
|
+
#
|
19
|
+
# Lookup using remotely stored rainbow table
|
20
|
+
#
|
21
|
+
def lookup_remote(md5_hash)
|
22
|
+
unhash_data = Scrubyt::Extractor.define do
|
23
|
+
fetch "http://gdataonline.com/qkhash.php?mode=txt&hash=#{md5_hash}"
|
24
|
+
unhash "//table/tr[2]/td[2]/b"
|
25
|
+
end
|
26
|
+
|
27
|
+
doc = Nokogiri::HTML.parse(unhash_data.to_xml)
|
28
|
+
doc.xpath('//root/unhash').text.strip rescue nil
|
29
|
+
end
|
30
|
+
|
31
|
+
#
|
32
|
+
# Lookup using locally stored rainbow table - not available
|
33
|
+
#
|
34
|
+
def lookup_local(md5_hash)
|
35
|
+
# TODO: Implement local rainbow table lookup
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
data/rails/init.rb
ADDED
metadata
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: grimen-rainbow
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jonas Grimfelt
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-03-14 00:00:00 -07:00
|
13
|
+
default_executable: rainbow
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: An efficient MD5 hash lookup based on one of the biggest rainbow lookup tables available.
|
17
|
+
email: grimen@gmail.com
|
18
|
+
executables:
|
19
|
+
- rainbow
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files:
|
23
|
+
- README.textile
|
24
|
+
files:
|
25
|
+
- MIT-LICENSE
|
26
|
+
- README.textile
|
27
|
+
- Rakefile
|
28
|
+
- rails/init.rb
|
29
|
+
- bin/rainbow
|
30
|
+
- lib/rainbow.rb
|
31
|
+
has_rdoc: true
|
32
|
+
homepage: http://github.com/grimen/rainbow/tree/master
|
33
|
+
post_install_message:
|
34
|
+
rdoc_options:
|
35
|
+
- --inline-source
|
36
|
+
- --charset=UTF-8
|
37
|
+
require_paths:
|
38
|
+
- lib
|
39
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: "0"
|
44
|
+
version:
|
45
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: "0"
|
50
|
+
version:
|
51
|
+
requirements: []
|
52
|
+
|
53
|
+
rubyforge_project:
|
54
|
+
rubygems_version: 1.2.0
|
55
|
+
signing_key:
|
56
|
+
specification_version: 2
|
57
|
+
summary: An efficient MD5 hash lookup based on one of the biggest rainbow lookup tables available.
|
58
|
+
test_files: []
|
59
|
+
|