wordlist 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +3 -0
- data/.gitignore +11 -0
- data/.rspec +1 -0
- data/.yardopts +1 -0
- data/{History.txt → ChangeLog.md} +5 -1
- data/LICENSE.txt +22 -0
- data/README.md +96 -0
- data/Rakefile +30 -17
- data/bin/wordlist +10 -0
- data/gemspec.yml +22 -0
- data/lib/wordlist/builder.rb +144 -25
- data/lib/wordlist/builders/website.rb +184 -12
- data/lib/wordlist/flat_file.rb +15 -4
- data/lib/wordlist/list.rb +63 -32
- data/lib/wordlist/mutator.rb +38 -9
- data/lib/wordlist/parsers.rb +24 -19
- data/lib/wordlist/runners.rb +2 -0
- data/lib/wordlist/runners/list.rb +116 -0
- data/lib/wordlist/runners/runner.rb +67 -0
- data/lib/wordlist/unique_filter.rb +47 -8
- data/lib/wordlist/version.rb +1 -1
- data/scripts/benchmark +43 -2
- data/spec/builder_examples.rb +46 -0
- data/spec/builder_spec.rb +97 -6
- data/spec/classes/parser_class.rb +2 -0
- data/spec/helpers/text.rb +6 -0
- data/spec/helpers/wordlist.rb +23 -0
- data/spec/spec_helper.rb +2 -4
- data/wordlist.gemspec +60 -0
- metadata +106 -62
- data/Manifest.txt +0 -30
- data/README.txt +0 -103
- data/tasks/spec.rb +0 -9
data/spec/builder_spec.rb
CHANGED
@@ -2,19 +2,19 @@ require 'wordlist/builder'
|
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
4
|
require 'helpers/text'
|
5
|
+
require 'helpers/wordlist'
|
5
6
|
require 'builder_examples'
|
6
7
|
|
7
|
-
require 'tempfile'
|
8
|
-
require 'fileutils'
|
9
|
-
|
10
8
|
describe Builder do
|
9
|
+
include Helpers
|
10
|
+
|
11
11
|
describe "new wordlist" do
|
12
12
|
before(:all) do
|
13
13
|
@expected = ['dog', 'cat', 'catx', 'dat']
|
14
14
|
end
|
15
15
|
|
16
16
|
before(:each) do
|
17
|
-
@path =
|
17
|
+
@path = wordlist_tempfile
|
18
18
|
end
|
19
19
|
|
20
20
|
it_should_behave_like "a wordlist Builder"
|
@@ -27,10 +27,101 @@ describe Builder do
|
|
27
27
|
end
|
28
28
|
|
29
29
|
before(:each) do
|
30
|
-
@path =
|
31
|
-
FileUtils.cp(PREVIOUS_WORDLIST,@path)
|
30
|
+
@path = wordlist_tempfile(Helpers::PREVIOUS_WORDLIST)
|
32
31
|
end
|
33
32
|
|
34
33
|
it_should_behave_like "a wordlist Builder"
|
35
34
|
end
|
35
|
+
|
36
|
+
describe "word queue" do
|
37
|
+
before(:all) do
|
38
|
+
@path = wordlist_tempfile
|
39
|
+
end
|
40
|
+
|
41
|
+
before(:each) do
|
42
|
+
@builder = Builder.new(@path, :max_words => 2)
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should act like a queue" do
|
46
|
+
@builder.enqueue('dog')
|
47
|
+
@builder.enqueue('cat')
|
48
|
+
|
49
|
+
@builder.word_queue.should == ['dog', 'cat']
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should have a maximum length of the queue" do
|
53
|
+
@builder.enqueue('dog')
|
54
|
+
@builder.enqueue('cat')
|
55
|
+
@builder.enqueue('log')
|
56
|
+
|
57
|
+
@builder.word_queue.should == ['cat', 'log']
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe "word combinations" do
|
62
|
+
before(:all) do
|
63
|
+
@path = wordlist_tempfile
|
64
|
+
end
|
65
|
+
|
66
|
+
it "should yield only one word when max_words is set to 1" do
|
67
|
+
builder = Builder.new(@path)
|
68
|
+
builder.enqueue('dog')
|
69
|
+
|
70
|
+
builder.word_combinations do |words|
|
71
|
+
words.should == 'dog'
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
it "should include the last seen word in every combination" do
|
76
|
+
builder = Builder.new(@path, :max_words => 2)
|
77
|
+
builder.enqueue('dog')
|
78
|
+
builder.enqueue('cat')
|
79
|
+
builder.enqueue('dat')
|
80
|
+
|
81
|
+
builder.word_combinations do |words|
|
82
|
+
words.split(' ').include?('dat').should == true
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
it "should include a minimum number of words" do
|
87
|
+
builder = Builder.new(@path, :min_words => 2, :max_words => 3)
|
88
|
+
builder.enqueue('dog')
|
89
|
+
builder.enqueue('cat')
|
90
|
+
builder.enqueue('dat')
|
91
|
+
|
92
|
+
builder.word_combinations do |words|
|
93
|
+
words.split(' ').length.should >= 2
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
it "should not include more than a maximum number of words" do
|
98
|
+
builder = Builder.new(@path, :max_words => 2)
|
99
|
+
builder.enqueue('dog')
|
100
|
+
builder.enqueue('cat')
|
101
|
+
builder.enqueue('dat')
|
102
|
+
|
103
|
+
builder.word_combinations do |words|
|
104
|
+
words.split(' ').length.should_not > 2
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
it "should preserve the order words were seen in" do
|
109
|
+
builder = Builder.new(@path, :max_words => 3)
|
110
|
+
builder.enqueue('dog')
|
111
|
+
builder.enqueue('cat')
|
112
|
+
builder.enqueue('dat')
|
113
|
+
|
114
|
+
combinations = []
|
115
|
+
|
116
|
+
builder.word_combinations do |words|
|
117
|
+
combinations << words
|
118
|
+
end
|
119
|
+
|
120
|
+
combinations.should == [
|
121
|
+
'dat',
|
122
|
+
'cat dat',
|
123
|
+
'dog cat dat'
|
124
|
+
]
|
125
|
+
end
|
126
|
+
end
|
36
127
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'tempfile'
|
2
|
+
require 'fileutils'
|
3
|
+
|
4
|
+
module Helpers
|
5
|
+
def wordlist_tempfile(existing_file=nil)
|
6
|
+
path = Tempfile.new('wordlist').path
|
7
|
+
|
8
|
+
FileUtils.cp(existing_file,path) if existing_file
|
9
|
+
return path
|
10
|
+
end
|
11
|
+
|
12
|
+
def should_contain_words(path,expected)
|
13
|
+
words = []
|
14
|
+
|
15
|
+
File.open(path) do |file|
|
16
|
+
file.each_line do |line|
|
17
|
+
words << line.chomp
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
words.sort.should == expected.sort
|
22
|
+
end
|
23
|
+
end
|
data/spec/spec_helper.rb
CHANGED
data/wordlist.gemspec
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'yaml'
|
4
|
+
|
5
|
+
Gem::Specification.new do |gem|
|
6
|
+
gemspec = YAML.load_file('gemspec.yml')
|
7
|
+
|
8
|
+
gem.name = gemspec.fetch('name')
|
9
|
+
gem.version = gemspec.fetch('version') do
|
10
|
+
lib_dir = File.join(File.dirname(__FILE__),'lib')
|
11
|
+
$LOAD_PATH << lib_dir unless $LOAD_PATH.include?(lib_dir)
|
12
|
+
|
13
|
+
require 'wordlist/version'
|
14
|
+
Wordlist::VERSION
|
15
|
+
end
|
16
|
+
|
17
|
+
gem.summary = gemspec['summary']
|
18
|
+
gem.description = gemspec['description']
|
19
|
+
gem.licenses = Array(gemspec['license'])
|
20
|
+
gem.authors = Array(gemspec['authors'])
|
21
|
+
gem.email = gemspec['email']
|
22
|
+
gem.homepage = gemspec['homepage']
|
23
|
+
|
24
|
+
glob = lambda { |patterns| gem.files & Dir[*patterns] }
|
25
|
+
|
26
|
+
gem.files = `git ls-files`.split($/)
|
27
|
+
gem.files = glob[gemspec['files']] if gemspec['files']
|
28
|
+
|
29
|
+
gem.executables = gemspec.fetch('executables') do
|
30
|
+
glob['bin/*'].map { |path| File.basename(path) }
|
31
|
+
end
|
32
|
+
gem.default_executable = gem.executables.first if Gem::VERSION < '1.7.'
|
33
|
+
|
34
|
+
gem.extensions = glob[gemspec['extensions'] || 'ext/**/extconf.rb']
|
35
|
+
gem.test_files = glob[gemspec['test_files'] || '{test/{**/}*_test.rb']
|
36
|
+
gem.extra_rdoc_files = glob[gemspec['extra_doc_files'] || '*.{txt,md}']
|
37
|
+
|
38
|
+
gem.require_paths = Array(gemspec.fetch('require_paths') {
|
39
|
+
%w[ext lib].select { |dir| File.directory?(dir) }
|
40
|
+
})
|
41
|
+
|
42
|
+
gem.requirements = gemspec['requirements']
|
43
|
+
gem.required_ruby_version = gemspec['required_ruby_version']
|
44
|
+
gem.required_rubygems_version = gemspec['required_rubygems_version']
|
45
|
+
gem.post_install_message = gemspec['post_install_message']
|
46
|
+
|
47
|
+
split = lambda { |string| string.split(/,\s*/) }
|
48
|
+
|
49
|
+
if gemspec['dependencies']
|
50
|
+
gemspec['dependencies'].each do |name,versions|
|
51
|
+
gem.add_dependency(name,split[versions])
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
if gemspec['development_dependencies']
|
56
|
+
gemspec['development_dependencies'].each do |name,versions|
|
57
|
+
gem.add_development_dependency(name,split[versions])
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wordlist
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 25
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 1
|
10
|
+
version: 0.1.1
|
5
11
|
platform: ruby
|
6
12
|
authors:
|
7
13
|
- Postmodern
|
@@ -9,115 +15,153 @@ autorequire:
|
|
9
15
|
bindir: bin
|
10
16
|
cert_chain: []
|
11
17
|
|
12
|
-
date:
|
13
|
-
default_executable:
|
18
|
+
date: 2012-06-12 00:00:00 Z
|
14
19
|
dependencies:
|
15
20
|
- !ruby/object:Gem::Dependency
|
16
21
|
name: spidr
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ~>
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 15
|
29
|
+
segments:
|
30
|
+
- 0
|
31
|
+
- 2
|
32
|
+
version: "0.2"
|
17
33
|
type: :runtime
|
18
|
-
|
19
|
-
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: rubygems-tasks
|
37
|
+
prerelease: false
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
20
40
|
requirements:
|
21
|
-
- -
|
41
|
+
- - ~>
|
22
42
|
- !ruby/object:Gem::Version
|
23
|
-
|
24
|
-
|
43
|
+
hash: 9
|
44
|
+
segments:
|
45
|
+
- 0
|
46
|
+
- 1
|
47
|
+
version: "0.1"
|
48
|
+
type: :development
|
49
|
+
version_requirements: *id002
|
25
50
|
- !ruby/object:Gem::Dependency
|
26
51
|
name: rspec
|
27
|
-
|
28
|
-
|
29
|
-
|
52
|
+
prerelease: false
|
53
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
54
|
+
none: false
|
30
55
|
requirements:
|
31
|
-
- -
|
56
|
+
- - ~>
|
32
57
|
- !ruby/object:Gem::Version
|
33
|
-
|
34
|
-
|
35
|
-
-
|
36
|
-
|
58
|
+
hash: 11
|
59
|
+
segments:
|
60
|
+
- 2
|
61
|
+
- 4
|
62
|
+
version: "2.4"
|
37
63
|
type: :development
|
38
|
-
|
39
|
-
|
64
|
+
version_requirements: *id003
|
65
|
+
- !ruby/object:Gem::Dependency
|
66
|
+
name: yard
|
67
|
+
prerelease: false
|
68
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
69
|
+
none: false
|
40
70
|
requirements:
|
41
|
-
- -
|
71
|
+
- - ~>
|
42
72
|
- !ruby/object:Gem::Version
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
email:
|
52
|
-
|
53
|
-
|
54
|
-
|
73
|
+
hash: 27
|
74
|
+
segments:
|
75
|
+
- 0
|
76
|
+
- 8
|
77
|
+
version: "0.8"
|
78
|
+
type: :development
|
79
|
+
version_requirements: *id004
|
80
|
+
description: A Ruby library for generating and working with word-lists. Wordlist allows one to efficiently generate unique word-lists from arbitrary text or other sources, such as website content. Wordlist can also quickly enumerate through words within an existing word-list, applying multiple mutation rules to each word in the list.
|
81
|
+
email: postmodern.mod3@gmail.com
|
82
|
+
executables:
|
83
|
+
- wordlist
|
55
84
|
extensions: []
|
56
85
|
|
57
86
|
extra_rdoc_files:
|
58
|
-
-
|
59
|
-
-
|
60
|
-
- README.
|
61
|
-
- scripts/text/comedy_of_errors.txt
|
87
|
+
- ChangeLog.md
|
88
|
+
- LICENSE.txt
|
89
|
+
- README.md
|
62
90
|
files:
|
63
|
-
-
|
64
|
-
-
|
65
|
-
-
|
91
|
+
- .document
|
92
|
+
- .gitignore
|
93
|
+
- .rspec
|
94
|
+
- .yardopts
|
95
|
+
- ChangeLog.md
|
96
|
+
- LICENSE.txt
|
97
|
+
- README.md
|
66
98
|
- Rakefile
|
99
|
+
- bin/wordlist
|
100
|
+
- gemspec.yml
|
67
101
|
- lib/wordlist.rb
|
68
|
-
- lib/wordlist/unique_filter.rb
|
69
|
-
- lib/wordlist/parsers.rb
|
70
102
|
- lib/wordlist/builder.rb
|
71
103
|
- lib/wordlist/builders.rb
|
72
104
|
- lib/wordlist/builders/website.rb
|
73
|
-
- lib/wordlist/mutator.rb
|
74
|
-
- lib/wordlist/list.rb
|
75
105
|
- lib/wordlist/flat_file.rb
|
106
|
+
- lib/wordlist/list.rb
|
107
|
+
- lib/wordlist/mutator.rb
|
108
|
+
- lib/wordlist/parsers.rb
|
109
|
+
- lib/wordlist/runners.rb
|
110
|
+
- lib/wordlist/runners/list.rb
|
111
|
+
- lib/wordlist/runners/runner.rb
|
112
|
+
- lib/wordlist/unique_filter.rb
|
76
113
|
- lib/wordlist/version.rb
|
77
|
-
- tasks/spec.rb
|
78
114
|
- scripts/benchmark
|
79
115
|
- scripts/text/comedy_of_errors.txt
|
116
|
+
- spec/builder_examples.rb
|
117
|
+
- spec/builder_spec.rb
|
80
118
|
- spec/classes/parser_class.rb
|
81
119
|
- spec/classes/test_list.rb
|
120
|
+
- spec/flat_file_spec.rb
|
121
|
+
- spec/helpers/text.rb
|
122
|
+
- spec/helpers/wordlist.rb
|
123
|
+
- spec/list_spec.rb
|
124
|
+
- spec/mutator_spec.rb
|
125
|
+
- spec/parsers_spec.rb
|
126
|
+
- spec/spec_helper.rb
|
127
|
+
- spec/text/flat_file.txt
|
82
128
|
- spec/text/previous_wordlist.txt
|
83
129
|
- spec/text/sample.txt
|
84
|
-
- spec/text/flat_file.txt
|
85
|
-
- spec/spec_helper.rb
|
86
130
|
- spec/unique_filter_spec.rb
|
87
|
-
- spec/parsers_spec.rb
|
88
|
-
- spec/mutator_spec.rb
|
89
|
-
- spec/builder_spec.rb
|
90
|
-
- spec/list_spec.rb
|
91
|
-
- spec/flat_file_spec.rb
|
92
131
|
- spec/wordlist_spec.rb
|
93
|
-
|
94
|
-
homepage:
|
95
|
-
licenses:
|
96
|
-
|
132
|
+
- wordlist.gemspec
|
133
|
+
homepage: https://github.com/sophsec/wordlist
|
134
|
+
licenses:
|
135
|
+
- MIT
|
97
136
|
post_install_message:
|
98
|
-
rdoc_options:
|
99
|
-
|
100
|
-
- README.txt
|
137
|
+
rdoc_options: []
|
138
|
+
|
101
139
|
require_paths:
|
102
140
|
- lib
|
103
141
|
required_ruby_version: !ruby/object:Gem::Requirement
|
142
|
+
none: false
|
104
143
|
requirements:
|
105
144
|
- - ">="
|
106
145
|
- !ruby/object:Gem::Version
|
146
|
+
hash: 3
|
147
|
+
segments:
|
148
|
+
- 0
|
107
149
|
version: "0"
|
108
|
-
version:
|
109
150
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
151
|
+
none: false
|
110
152
|
requirements:
|
111
153
|
- - ">="
|
112
154
|
- !ruby/object:Gem::Version
|
155
|
+
hash: 3
|
156
|
+
segments:
|
157
|
+
- 0
|
113
158
|
version: "0"
|
114
|
-
version:
|
115
159
|
requirements: []
|
116
160
|
|
117
|
-
rubyforge_project:
|
118
|
-
rubygems_version: 1.
|
161
|
+
rubyforge_project:
|
162
|
+
rubygems_version: 1.8.23
|
119
163
|
signing_key:
|
120
164
|
specification_version: 3
|
121
|
-
summary: A Ruby library for generating and working with word-lists
|
165
|
+
summary: A Ruby library for generating and working with word-lists.
|
122
166
|
test_files: []
|
123
167
|
|