ronin-wordlists 0.1.0.rc1
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.
- checksums.yaml +7 -0
- data/.document +4 -0
- data/.github/workflows/ruby.yml +43 -0
- data/.gitignore +14 -0
- data/.rspec +1 -0
- data/.rubocop.yml +18 -0
- data/.ruby-version +1 -0
- data/.yardopts +1 -0
- data/COPYING.txt +165 -0
- data/ChangeLog.md +10 -0
- data/Gemfile +37 -0
- data/README.md +180 -0
- data/Rakefile +45 -0
- data/bin/ronin-wordlists +34 -0
- data/data/completions/ronin-wordlists +107 -0
- data/data/completions/ronin-wordlists.yml +7 -0
- data/data/wordlists.yml +260 -0
- data/gemspec.yml +40 -0
- data/lib/ronin/wordlists/cache_dir.rb +257 -0
- data/lib/ronin/wordlists/cli/command.rb +40 -0
- data/lib/ronin/wordlists/cli/commands/completion.rb +61 -0
- data/lib/ronin/wordlists/cli/commands/download.rb +109 -0
- data/lib/ronin/wordlists/cli/commands/list.rb +79 -0
- data/lib/ronin/wordlists/cli/commands/purge.rb +60 -0
- data/lib/ronin/wordlists/cli/commands/remove.rb +74 -0
- data/lib/ronin/wordlists/cli/commands/search.rb +145 -0
- data/lib/ronin/wordlists/cli/commands/update.rb +98 -0
- data/lib/ronin/wordlists/cli/wordlist_dir_option.rb +64 -0
- data/lib/ronin/wordlists/cli/wordlist_index.rb +178 -0
- data/lib/ronin/wordlists/cli/wordlist_option.rb +66 -0
- data/lib/ronin/wordlists/cli.rb +56 -0
- data/lib/ronin/wordlists/exceptions.rb +47 -0
- data/lib/ronin/wordlists/mixin.rb +106 -0
- data/lib/ronin/wordlists/root.rb +28 -0
- data/lib/ronin/wordlists/search_paths.rb +153 -0
- data/lib/ronin/wordlists/version.rb +26 -0
- data/lib/ronin/wordlists/wordlist_dir.rb +194 -0
- data/lib/ronin/wordlists/wordlist_file.rb +141 -0
- data/lib/ronin/wordlists/wordlist_metadata.rb +43 -0
- data/lib/ronin/wordlists/wordlist_repo.rb +167 -0
- data/lib/ronin/wordlists.rb +96 -0
- data/man/ronin-wordlists-completion.1 +76 -0
- data/man/ronin-wordlists-completion.1.md +78 -0
- data/man/ronin-wordlists-download.1 +47 -0
- data/man/ronin-wordlists-download.1.md +48 -0
- data/man/ronin-wordlists-list.1 +42 -0
- data/man/ronin-wordlists-list.1.md +44 -0
- data/man/ronin-wordlists-purge.1 +39 -0
- data/man/ronin-wordlists-purge.1.md +39 -0
- data/man/ronin-wordlists-remove.1 +43 -0
- data/man/ronin-wordlists-remove.1.md +44 -0
- data/man/ronin-wordlists-search.1 +37 -0
- data/man/ronin-wordlists-search.1.md +37 -0
- data/man/ronin-wordlists-update.1 +43 -0
- data/man/ronin-wordlists-update.1.md +44 -0
- data/man/ronin-wordlists.1 +65 -0
- data/man/ronin-wordlists.1.md +64 -0
- data/ronin-wordlists.gemspec +62 -0
- data/scripts/setup +58 -0
- metadata +154 -0
@@ -0,0 +1,194 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
#
|
3
|
+
# ronin-wordlists - A library and tool for managing wordlists.
|
4
|
+
#
|
5
|
+
# Copyright (c) 2023-2024 Hal Brodigan (postmodern.mod3@gmail.com)
|
6
|
+
#
|
7
|
+
# ronin-wordlists is free software: you can redistribute it and/or modify
|
8
|
+
# it under the terms of the GNU Lesser General Public License as published
|
9
|
+
# by the Free Software Foundation, either version 3 of the License, or
|
10
|
+
# (at your option) any later version.
|
11
|
+
#
|
12
|
+
# ronin-wordlists is distributed in the hope that it will be useful,
|
13
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
+
# GNU Lesser General Public License for more details.
|
16
|
+
#
|
17
|
+
# You should have received a copy of the GNU Lesser General Public License
|
18
|
+
# along with ronin-wordlists. If not, see <https://www.gnu.org/licenses/>.
|
19
|
+
#
|
20
|
+
|
21
|
+
require 'ronin/wordlists/wordlist_file'
|
22
|
+
require 'ronin/wordlists/wordlist_repo'
|
23
|
+
require 'ronin/wordlists/exceptions'
|
24
|
+
|
25
|
+
require 'wordlist'
|
26
|
+
|
27
|
+
module Ronin
|
28
|
+
module Wordlists
|
29
|
+
#
|
30
|
+
# Represents a directory of wordlists.
|
31
|
+
#
|
32
|
+
# ## Example
|
33
|
+
#
|
34
|
+
# wordlist_dir = Wordlists::WordlistDir.new('/path/to/wordlists')
|
35
|
+
# wordlist_dir.find('passwords.txt')
|
36
|
+
# # => "/path/to/wordlists/passwords.txt"
|
37
|
+
# wordlist_dir.find('passwords')
|
38
|
+
# # => "/path/to/wordlists/passwords.txt"
|
39
|
+
# wordlist_dir.open('passwords.txt')
|
40
|
+
# # => #<Wordlist::File:...>
|
41
|
+
# wordlist_dir.open('passwords')
|
42
|
+
# # => #<Wordlist::File:...>
|
43
|
+
#
|
44
|
+
# @api public
|
45
|
+
#
|
46
|
+
class WordlistDir
|
47
|
+
|
48
|
+
# The path to the wordlist directory.
|
49
|
+
#
|
50
|
+
# @return [String]
|
51
|
+
attr_reader :path
|
52
|
+
|
53
|
+
#
|
54
|
+
# Initializes the wordlist directory.
|
55
|
+
#
|
56
|
+
# @param [String] path
|
57
|
+
# The path to the wordlist directory.
|
58
|
+
#
|
59
|
+
def initialize(path)
|
60
|
+
@path = path
|
61
|
+
end
|
62
|
+
|
63
|
+
#
|
64
|
+
# Enumerates over every wordlist in the wordlist directory.
|
65
|
+
#
|
66
|
+
# @yield [path]
|
67
|
+
# The given block will be passed each path to each wordlist.
|
68
|
+
#
|
69
|
+
# @yieldparam [String] path
|
70
|
+
# A path to a wordlist within the wordlist directory.
|
71
|
+
#
|
72
|
+
# @return [Enumerator]
|
73
|
+
# If no block is given, an Enumerator will be returned.
|
74
|
+
#
|
75
|
+
def each(&block)
|
76
|
+
return enum_for unless block
|
77
|
+
|
78
|
+
Dir.glob(File.join(@path,'**','*.{txt,gz,bz2,xz}'),&block)
|
79
|
+
end
|
80
|
+
|
81
|
+
#
|
82
|
+
# Looks up a wordlist within the wordlist directory.
|
83
|
+
#
|
84
|
+
# @param [String] name
|
85
|
+
# The wordlist file name.
|
86
|
+
#
|
87
|
+
# @return [String, nil]
|
88
|
+
# The path to the wordlist or `nil` if the wordlist could not be found.
|
89
|
+
#
|
90
|
+
# @example
|
91
|
+
# wordlist_dir.find('passwords.txt')
|
92
|
+
# # => "/path/to/wordlists/passwords.txt"
|
93
|
+
# wordlist_dir.find('passwords')
|
94
|
+
# # => "/path/to/wordlists/passwords.txt"
|
95
|
+
#
|
96
|
+
def find(name)
|
97
|
+
path = File.join(@path,name)
|
98
|
+
|
99
|
+
# check for an exact filename match first
|
100
|
+
if File.file?(path)
|
101
|
+
path
|
102
|
+
else
|
103
|
+
# fallback to search for the wordlist file by name
|
104
|
+
Dir.glob(File.join(@path,'**',"#{name}.{txt,gz,bz2,xz}")).first
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
#
|
109
|
+
# Lists the wordlists in the wordlist directory.
|
110
|
+
#
|
111
|
+
# @param [String] name
|
112
|
+
# Optional file name to search for.
|
113
|
+
#
|
114
|
+
# @return [Array<String>]
|
115
|
+
# The wordlist files within the wordlist directory.
|
116
|
+
#
|
117
|
+
def list(name='*')
|
118
|
+
Dir.glob("{**/}#{name}.{txt,gz,bz2,xz}", base: @path)
|
119
|
+
end
|
120
|
+
|
121
|
+
#
|
122
|
+
# Opens a wordlist from the wordlist directory.
|
123
|
+
#
|
124
|
+
# @param [String] name
|
125
|
+
# The wordlist file name.
|
126
|
+
#
|
127
|
+
# @return [Wordlist::File]
|
128
|
+
# The opened wordlist file.
|
129
|
+
#
|
130
|
+
# @raise [WordlistNotFound]
|
131
|
+
# No wordlist with the given name.
|
132
|
+
#
|
133
|
+
# @example
|
134
|
+
# wordlist_dir.open('passwords.txt')
|
135
|
+
# # => #<Wordlist::File:...>
|
136
|
+
# wordlist_dir.open('passwords')
|
137
|
+
# # => #<Wordlist::File:...>
|
138
|
+
#
|
139
|
+
def open(name)
|
140
|
+
if (path = find(name))
|
141
|
+
Wordlist.open(path)
|
142
|
+
else
|
143
|
+
raise(WordlistNotFound,"wordlist not found: #{name.inspect}")
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
#
|
148
|
+
# Downloads a wordlist from the given URL into the wordlist directory.
|
149
|
+
#
|
150
|
+
# @param [String, URI::HTTP] url
|
151
|
+
# The URL of the wordlist to downloaded.
|
152
|
+
#
|
153
|
+
# @return [WordlistFile, WordlistRepo]
|
154
|
+
# The downloaded wordlist. A {WordlistRepo} will be returned for git
|
155
|
+
# URLs and {WordlistFile} for `http://` or `https://` URLs.
|
156
|
+
#
|
157
|
+
# @raise [DownloadFailed]
|
158
|
+
# The download of the wordlist file or repository failed.
|
159
|
+
#
|
160
|
+
def download(url)
|
161
|
+
uri = URI(url)
|
162
|
+
|
163
|
+
wordlist_class = if uri.scheme == 'git' || uri.path.end_with?('.git')
|
164
|
+
WordlistRepo
|
165
|
+
else
|
166
|
+
WordlistFile
|
167
|
+
end
|
168
|
+
|
169
|
+
FileUtils.mkdir_p(@path)
|
170
|
+
return wordlist_class.download(url,@path)
|
171
|
+
end
|
172
|
+
|
173
|
+
#
|
174
|
+
# Deletes a wordlist file from the wordlist directory.
|
175
|
+
#
|
176
|
+
# @param [String] name
|
177
|
+
# The wordlist name to delete.
|
178
|
+
#
|
179
|
+
# @raise [ArgumentError]
|
180
|
+
# No wordlist with the given name.
|
181
|
+
#
|
182
|
+
def delete(name)
|
183
|
+
if (path = find(name))
|
184
|
+
File.unlink(path)
|
185
|
+
|
186
|
+
return path
|
187
|
+
else
|
188
|
+
raise(WordlistNotFound,"unknown wordlist: #{name.inspect}")
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
end
|
193
|
+
end
|
194
|
+
end
|
@@ -0,0 +1,141 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
#
|
3
|
+
# ronin-wordlists - A library and tool for managing wordlists.
|
4
|
+
#
|
5
|
+
# Copyright (c) 2023-2024 Hal Brodigan (postmodern.mod3@gmail.com)
|
6
|
+
#
|
7
|
+
# ronin-wordlists is free software: you can redistribute it and/or modify
|
8
|
+
# it under the terms of the GNU Lesser General Public License as published
|
9
|
+
# by the Free Software Foundation, either version 3 of the License, or
|
10
|
+
# (at your option) any later version.
|
11
|
+
#
|
12
|
+
# ronin-wordlists is distributed in the hope that it will be useful,
|
13
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
+
# GNU Lesser General Public License for more details.
|
16
|
+
#
|
17
|
+
# You should have received a copy of the GNU Lesser General Public License
|
18
|
+
# along with ronin-wordlists. If not, see <https://www.gnu.org/licenses/>.
|
19
|
+
#
|
20
|
+
|
21
|
+
require 'ronin/wordlists/wordlist_metadata'
|
22
|
+
require 'ronin/wordlists/exceptions'
|
23
|
+
require 'ronin/core/system'
|
24
|
+
|
25
|
+
require 'net/https'
|
26
|
+
require 'uri'
|
27
|
+
|
28
|
+
module Ronin
|
29
|
+
module Wordlists
|
30
|
+
#
|
31
|
+
# Represents a wordlist file.
|
32
|
+
#
|
33
|
+
class WordlistFile
|
34
|
+
|
35
|
+
include WordlistMetadata
|
36
|
+
|
37
|
+
# The path to the wordlist file.
|
38
|
+
#
|
39
|
+
# @return [String]
|
40
|
+
attr_reader :path
|
41
|
+
|
42
|
+
# The name of the wordlist file.
|
43
|
+
#
|
44
|
+
# @return [String]
|
45
|
+
attr_reader :name
|
46
|
+
|
47
|
+
#
|
48
|
+
# Initializes the wordlist file.
|
49
|
+
#
|
50
|
+
# @param [String] path
|
51
|
+
# The path to the wordlist file.
|
52
|
+
#
|
53
|
+
# @param [Hash{Symbol => Object}] kwargs
|
54
|
+
# Additional metadata keyword arguments for
|
55
|
+
# {WordlistMetadata#initialize}.
|
56
|
+
#
|
57
|
+
# @option kwargs [String, nil] :url
|
58
|
+
# The optional URL for the wordlist file.
|
59
|
+
#
|
60
|
+
def initialize(path,**kwargs)
|
61
|
+
super(**kwargs)
|
62
|
+
|
63
|
+
@path = path
|
64
|
+
@name = File.basename(@path,File.extname(@path))
|
65
|
+
end
|
66
|
+
|
67
|
+
#
|
68
|
+
# Downloads a remote wordlist file.
|
69
|
+
#
|
70
|
+
# @param [String, URI::HTTP] url
|
71
|
+
# The `http://` or `https://` URL for the wordlist file.
|
72
|
+
#
|
73
|
+
# @param [String] dest
|
74
|
+
# The directory to download the wordlist file into.
|
75
|
+
#
|
76
|
+
# @raise [DownloadFailed]
|
77
|
+
# Failed to download the wordlist file.
|
78
|
+
#
|
79
|
+
# @return [WordlistFile]
|
80
|
+
# The wordlist file.
|
81
|
+
#
|
82
|
+
def self.download(url,dest=Dir.pwd)
|
83
|
+
dest_path = begin
|
84
|
+
Core::System.download(url,dest)
|
85
|
+
rescue Core::System::DownloadFailed => error
|
86
|
+
raise(DownloadFailed,error.message)
|
87
|
+
end
|
88
|
+
|
89
|
+
return new(dest_path, url: url.to_s)
|
90
|
+
end
|
91
|
+
|
92
|
+
#
|
93
|
+
# The wordlist type.
|
94
|
+
#
|
95
|
+
# @return [:file]
|
96
|
+
#
|
97
|
+
def type
|
98
|
+
:file
|
99
|
+
end
|
100
|
+
|
101
|
+
#
|
102
|
+
# The name of the wordlist file.
|
103
|
+
#
|
104
|
+
# @return [String]
|
105
|
+
#
|
106
|
+
def filename
|
107
|
+
File.basename(@path)
|
108
|
+
end
|
109
|
+
|
110
|
+
#
|
111
|
+
# Updates the wordlist file, if {#url} is set.
|
112
|
+
#
|
113
|
+
# @raise [DownloadFailed]
|
114
|
+
# Failed to download the wordlist.
|
115
|
+
#
|
116
|
+
def update
|
117
|
+
if @url
|
118
|
+
self.class.download(@url,@path)
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
#
|
123
|
+
# Deletes the wordlist file.
|
124
|
+
#
|
125
|
+
def delete
|
126
|
+
File.unlink(@path)
|
127
|
+
end
|
128
|
+
|
129
|
+
#
|
130
|
+
# Converts the wordlist file to a String.
|
131
|
+
#
|
132
|
+
# @return [String]
|
133
|
+
# The wordlist file's path.
|
134
|
+
#
|
135
|
+
def to_s
|
136
|
+
@path
|
137
|
+
end
|
138
|
+
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
#
|
3
|
+
# ronin-wordlists - A library and tool for managing wordlists.
|
4
|
+
#
|
5
|
+
# Copyright (c) 2023-2024 Hal Brodigan (postmodern.mod3@gmail.com)
|
6
|
+
#
|
7
|
+
# ronin-wordlists is free software: you can redistribute it and/or modify
|
8
|
+
# it under the terms of the GNU Lesser General Public License as published
|
9
|
+
# by the Free Software Foundation, either version 3 of the License, or
|
10
|
+
# (at your option) any later version.
|
11
|
+
#
|
12
|
+
# ronin-wordlists is distributed in the hope that it will be useful,
|
13
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
+
# GNU Lesser General Public License for more details.
|
16
|
+
#
|
17
|
+
# You should have received a copy of the GNU Lesser General Public License
|
18
|
+
# along with ronin-wordlists. If not, see <https://www.gnu.org/licenses/>.
|
19
|
+
#
|
20
|
+
|
21
|
+
module Ronin
|
22
|
+
module Wordlists
|
23
|
+
#
|
24
|
+
# Common wordlist metadata attributes.
|
25
|
+
#
|
26
|
+
module WordlistMetadata
|
27
|
+
# The optional URL for the wordlist.
|
28
|
+
#
|
29
|
+
# @return [String, nil]
|
30
|
+
attr_reader :url
|
31
|
+
|
32
|
+
#
|
33
|
+
# Initializes the wordlist metadata attributes.
|
34
|
+
#
|
35
|
+
# @param [String, nil] url
|
36
|
+
# The optional URL of the wordlist.
|
37
|
+
#
|
38
|
+
def initialize(url: nil)
|
39
|
+
@url = url
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,167 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
#
|
3
|
+
# ronin-wordlists - A library and tool for managing wordlists.
|
4
|
+
#
|
5
|
+
# Copyright (c) 2023-2024 Hal Brodigan (postmodern.mod3@gmail.com)
|
6
|
+
#
|
7
|
+
# ronin-wordlists is free software: you can redistribute it and/or modify
|
8
|
+
# it under the terms of the GNU Lesser General Public License as published
|
9
|
+
# by the Free Software Foundation, either version 3 of the License, or
|
10
|
+
# (at your option) any later version.
|
11
|
+
#
|
12
|
+
# ronin-wordlists is distributed in the hope that it will be useful,
|
13
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
+
# GNU Lesser General Public License for more details.
|
16
|
+
#
|
17
|
+
# You should have received a copy of the GNU Lesser General Public License
|
18
|
+
# along with ronin-wordlists. If not, see <https://www.gnu.org/licenses/>.
|
19
|
+
#
|
20
|
+
|
21
|
+
require 'ronin/wordlists/wordlist_metadata'
|
22
|
+
require 'ronin/wordlists/exceptions'
|
23
|
+
|
24
|
+
require 'fileutils'
|
25
|
+
require 'uri'
|
26
|
+
|
27
|
+
module Ronin
|
28
|
+
module Wordlists
|
29
|
+
#
|
30
|
+
# Represents a git repository of wordlists.
|
31
|
+
#
|
32
|
+
class WordlistRepo
|
33
|
+
|
34
|
+
include WordlistMetadata
|
35
|
+
|
36
|
+
# The path to the wordlist repository.
|
37
|
+
#
|
38
|
+
# @return [String]
|
39
|
+
attr_reader :path
|
40
|
+
|
41
|
+
# The name of the wordlist repository.
|
42
|
+
#
|
43
|
+
# @return [String]
|
44
|
+
attr_reader :name
|
45
|
+
|
46
|
+
#
|
47
|
+
# Initializes the wordlist repository.
|
48
|
+
#
|
49
|
+
# @param [String] path
|
50
|
+
# The path to the wordlist repository.
|
51
|
+
#
|
52
|
+
# @param [Hash{Symbol => Object}] kwargs
|
53
|
+
# Additional metadata keyword arguments for
|
54
|
+
# {WordlistMetadata#initialize}.
|
55
|
+
#
|
56
|
+
# @option kwargs [String, nil] :url
|
57
|
+
# The optional URL of the wordlist repository.
|
58
|
+
# If no URL is given, {#url} will infer it from the git repository.
|
59
|
+
#
|
60
|
+
def initialize(path,**kwargs)
|
61
|
+
super(**kwargs)
|
62
|
+
|
63
|
+
@path = path
|
64
|
+
@name = File.basename(@path)
|
65
|
+
end
|
66
|
+
|
67
|
+
#
|
68
|
+
# Clones a wordlist repository from the given git URL.
|
69
|
+
#
|
70
|
+
# @param [String, URI::HTTP] url
|
71
|
+
# The git URL for the wordlist repository.
|
72
|
+
#
|
73
|
+
# @param [String] dest_dir
|
74
|
+
# The directory to clone the wordlist repository into.
|
75
|
+
#
|
76
|
+
# @return [WordlistRepo]
|
77
|
+
# The newly cloned wordlist repository.
|
78
|
+
#
|
79
|
+
# @raise [DownloadFailed]
|
80
|
+
# The `git clone --depth 1` command failed or `git` was not installed on
|
81
|
+
# the system.
|
82
|
+
#
|
83
|
+
def self.download(url,dest_dir=Dir.pwd)
|
84
|
+
uri = URI(url)
|
85
|
+
url = url.to_s
|
86
|
+
repo_name = File.basename(uri.path,'.git')
|
87
|
+
repo_path = File.join(dest_dir,repo_name)
|
88
|
+
|
89
|
+
case system('git','clone','--depth','1','--',url,repo_path)
|
90
|
+
when true
|
91
|
+
new(repo_path, url: url)
|
92
|
+
when false
|
93
|
+
raise(DownloadFailed,"git command failed: git clone --depth 1 -- #{url} #{repo_path}")
|
94
|
+
when nil
|
95
|
+
raise(DownloadFailed,"git is not installed on the system")
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
#
|
100
|
+
# The wordlist type.
|
101
|
+
#
|
102
|
+
# @return [:git]
|
103
|
+
#
|
104
|
+
def type
|
105
|
+
:git
|
106
|
+
end
|
107
|
+
|
108
|
+
#
|
109
|
+
# Determines if the wordlist repository uses Git.
|
110
|
+
#
|
111
|
+
# @return [Boolean]
|
112
|
+
#
|
113
|
+
def git?
|
114
|
+
File.directory?(File.join(@path,'.git'))
|
115
|
+
end
|
116
|
+
|
117
|
+
#
|
118
|
+
# The name of the wordlist repository directory.
|
119
|
+
#
|
120
|
+
# @return [String]
|
121
|
+
#
|
122
|
+
def filename
|
123
|
+
File.basename(@path)
|
124
|
+
end
|
125
|
+
|
126
|
+
#
|
127
|
+
# The URL of the wordlist repository.
|
128
|
+
#
|
129
|
+
# @return [String, nil]
|
130
|
+
#
|
131
|
+
def url
|
132
|
+
@url ||= if git?
|
133
|
+
Dir.chdir(@path) do
|
134
|
+
`git config --get remote.origin.url`.chomp
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
#
|
140
|
+
# Updates the wordlist repository.
|
141
|
+
#
|
142
|
+
# @raise [DownloadFailed]
|
143
|
+
# The `git pull -C` command failed or `git` was not installed on the
|
144
|
+
# system.
|
145
|
+
#
|
146
|
+
def update
|
147
|
+
if git?
|
148
|
+
case system('git','pull','-C',@path)
|
149
|
+
when true then true
|
150
|
+
when false
|
151
|
+
raise(DownloadFailed,"git command failed: git pull -C #{@path}")
|
152
|
+
when nil
|
153
|
+
raise(DownloadFailed,"git is not installed on the system")
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
#
|
159
|
+
# Deletes the wordlist repository.
|
160
|
+
#
|
161
|
+
def delete
|
162
|
+
FileUtils.rm_rf(@path)
|
163
|
+
end
|
164
|
+
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
@@ -0,0 +1,96 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
#
|
3
|
+
# ronin-wordlists - A library and tool for managing wordlists.
|
4
|
+
#
|
5
|
+
# Copyright (c) 2023-2024 Hal Brodigan (postmodern.mod3@gmail.com)
|
6
|
+
#
|
7
|
+
# ronin-wordlists is free software: you can redistribute it and/or modify
|
8
|
+
# it under the terms of the GNU Lesser General Public License as published
|
9
|
+
# by the Free Software Foundation, either version 3 of the License, or
|
10
|
+
# (at your option) any later version.
|
11
|
+
#
|
12
|
+
# ronin-wordlists is distributed in the hope that it will be useful,
|
13
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
+
# GNU Lesser General Public License for more details.
|
16
|
+
#
|
17
|
+
# You should have received a copy of the GNU Lesser General Public License
|
18
|
+
# along with ronin-wordlists. If not, see <https://www.gnu.org/licenses/>.
|
19
|
+
#
|
20
|
+
|
21
|
+
require 'ronin/wordlists/cache_dir'
|
22
|
+
require 'ronin/wordlists/search_paths'
|
23
|
+
|
24
|
+
module Ronin
|
25
|
+
#
|
26
|
+
# Top-level methods for `ronin-wordlists`.
|
27
|
+
#
|
28
|
+
module Wordlists
|
29
|
+
@cache_dir = CacheDir.new
|
30
|
+
@search_paths = SearchPaths[
|
31
|
+
@cache_dir.wordlist_dir.path,
|
32
|
+
'/usr/local/share/wordlists',
|
33
|
+
'/usr/share/wordlists'
|
34
|
+
]
|
35
|
+
|
36
|
+
#
|
37
|
+
# Downloads a new wordlist.
|
38
|
+
#
|
39
|
+
# @param [String, URI::HTTP] url
|
40
|
+
# The URL of the wordlist to download.
|
41
|
+
#
|
42
|
+
# @api public
|
43
|
+
#
|
44
|
+
def self.download(url)
|
45
|
+
@cache_dir.download(url)
|
46
|
+
end
|
47
|
+
|
48
|
+
#
|
49
|
+
# Finds a wordlist.
|
50
|
+
#
|
51
|
+
# @param [String] name
|
52
|
+
# The wordlist file name.
|
53
|
+
#
|
54
|
+
# @return [String, nil]
|
55
|
+
# The path to the wordlist file.
|
56
|
+
#
|
57
|
+
# @api public
|
58
|
+
#
|
59
|
+
def self.find(name)
|
60
|
+
@search_paths.find(name)
|
61
|
+
end
|
62
|
+
|
63
|
+
#
|
64
|
+
# Lists all wordlists on the system.
|
65
|
+
#
|
66
|
+
# @param [String] pattern
|
67
|
+
# Optional glob pattern to search for within the wordlist directory.
|
68
|
+
#
|
69
|
+
# @return [Set<String>]
|
70
|
+
# The wordlist files within the wordlist directories.
|
71
|
+
#
|
72
|
+
# @api public
|
73
|
+
#
|
74
|
+
def self.list(pattern='*')
|
75
|
+
@search_paths.list(pattern)
|
76
|
+
end
|
77
|
+
|
78
|
+
#
|
79
|
+
# Opens a wordlist.
|
80
|
+
#
|
81
|
+
# @param [String] name
|
82
|
+
# The wordlist file name.
|
83
|
+
#
|
84
|
+
# @return [Wordlist::File]
|
85
|
+
# The opened wordlist file.
|
86
|
+
#
|
87
|
+
# @raise [WordlistNotFound]
|
88
|
+
# No wordlist with the given name.
|
89
|
+
#
|
90
|
+
# @api public
|
91
|
+
#
|
92
|
+
def self.open(name)
|
93
|
+
@search_paths.open(name)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
.\" Generated by kramdown-man 1.0.1
|
2
|
+
.\" https://github.com/postmodern/kramdown-man#readme
|
3
|
+
.TH ronin-wordlists-completion 1 "2024-01-01" Ronin Wordlists "User Manuals"
|
4
|
+
.SH NAME
|
5
|
+
.PP
|
6
|
+
ronin\-wordlists\-completion \- Manages shell completion rules for \fBronin\-wordlists\fR
|
7
|
+
.SH SYNOPSIS
|
8
|
+
.PP
|
9
|
+
\fBronin\-wordlists completion\fR \[lB]\fIoptions\fP\[rB]
|
10
|
+
.SH DESCRIPTION
|
11
|
+
.PP
|
12
|
+
The \fBronin\-wordlists completion\fR command can print, install, or uninstall shell
|
13
|
+
completion rules for the \fBronin\-wordlists\fR command\.
|
14
|
+
.PP
|
15
|
+
Supports installing completion rules for Bash or Zsh shells\.
|
16
|
+
Completion rules for the Fish shell is currently not supported\.
|
17
|
+
.SS ZSH SUPPORT
|
18
|
+
.PP
|
19
|
+
Zsh users will have to add the following lines to their \fB\[ti]\[sl]\.zshrc\fR file in
|
20
|
+
order to enable Zsh\[cq]s Bash completion compatibility layer:
|
21
|
+
.PP
|
22
|
+
.RS 4
|
23
|
+
.EX
|
24
|
+
autoload \-Uz \[pl]X compinit && compinit
|
25
|
+
autoload \-Uz \[pl]X bashcompinit && bashcompinit
|
26
|
+
.EE
|
27
|
+
.RE
|
28
|
+
.SH OPTIONS
|
29
|
+
.TP
|
30
|
+
\fB\-\-print\fR
|
31
|
+
Prints the shell completion file\.
|
32
|
+
.TP
|
33
|
+
\fB\-\-install\fR
|
34
|
+
Installs the shell completion file\.
|
35
|
+
.TP
|
36
|
+
\fB\-\-uninstall\fR
|
37
|
+
Uninstalls the shell completion file\.
|
38
|
+
.TP
|
39
|
+
\fB\-h\fR, \fB\-\-help\fR
|
40
|
+
Prints help information\.
|
41
|
+
.SH ENVIRONMENT
|
42
|
+
.TP
|
43
|
+
\fIPREFIX\fP
|
44
|
+
Specifies the root prefix for the file system\.
|
45
|
+
.TP
|
46
|
+
\fIHOME\fP
|
47
|
+
Specifies the home directory of the user\. Ronin will search for the
|
48
|
+
\fB\[ti]\[sl]\.cache\[sl]ronin\-wordlists\fR cache directory within the home directory\.
|
49
|
+
.TP
|
50
|
+
\fIXDG\[ru]DATA\[ru]HOME\fP
|
51
|
+
Specifies the data directory to use\. Defaults to \fB\[Do]HOME\[sl]\.local\[sl]share\fR\.
|
52
|
+
.SH FILES
|
53
|
+
.TP
|
54
|
+
\fB\[ti]\[sl]\.local\[sl]share\[sl]bash\-completion\[sl]completions\[sl]\fR
|
55
|
+
The user\-local installation directory for Bash completion files\.
|
56
|
+
.TP
|
57
|
+
\fB\[sl]usr\[sl]local\[sl]share\[sl]bash\-completion\[sl]completions\[sl]\fR
|
58
|
+
The system\-wide installation directory for Bash completions files\.
|
59
|
+
.TP
|
60
|
+
\fB\[sl]usr\[sl]local\[sl]share\[sl]zsh\[sl]site\-functions\[sl]\fR
|
61
|
+
The installation directory for Zsh completion files\.
|
62
|
+
.SH EXAMPLES
|
63
|
+
.TP
|
64
|
+
\fBronin\-wordlists completion \-\-print\fR
|
65
|
+
Prints the shell completion rules instead of installing them\.
|
66
|
+
.TP
|
67
|
+
\fBronin\-wordlists completion \-\-install\fR
|
68
|
+
Installs the shell completion rules for \fBronin\-wordlists\fR\.
|
69
|
+
.TP
|
70
|
+
\fBronin\-wordlists completion \-\-uninstall\fR
|
71
|
+
Uninstalls the shell completion rules for \fBronin\-wordlists\fR\.
|
72
|
+
.SH AUTHOR
|
73
|
+
.PP
|
74
|
+
Postmodern
|
75
|
+
.MT postmodern\.mod3\[at]gmail\.com
|
76
|
+
.ME
|