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,109 @@
|
|
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/cli/command'
|
22
|
+
require 'ronin/wordlists/cli/wordlist_dir_option'
|
23
|
+
require 'ronin/wordlists/cli/wordlist_index'
|
24
|
+
|
25
|
+
require 'ronin/core/cli/logging'
|
26
|
+
|
27
|
+
module Ronin
|
28
|
+
module Wordlists
|
29
|
+
class CLI
|
30
|
+
module Commands
|
31
|
+
#
|
32
|
+
# Downloads a wordlist.
|
33
|
+
#
|
34
|
+
# ## Usage
|
35
|
+
#
|
36
|
+
# ronin-wordlists download [options] {NAME | URL}
|
37
|
+
#
|
38
|
+
# ## Options
|
39
|
+
#
|
40
|
+
# -d, --wordlist-dir DIR The wordlist directory
|
41
|
+
# -h, --help Print help information
|
42
|
+
#
|
43
|
+
# ## Arguments
|
44
|
+
#
|
45
|
+
# NAME | URL The wordlist name or URL to download
|
46
|
+
#
|
47
|
+
class Download < Command
|
48
|
+
|
49
|
+
include WordlistDirOption
|
50
|
+
include Core::CLI::Logging
|
51
|
+
|
52
|
+
usage '[options] {NAME | URL}'
|
53
|
+
|
54
|
+
argument :name_or_url, required: true,
|
55
|
+
usage: 'NAME | URL',
|
56
|
+
desc: 'The wordlist name or URL to download'
|
57
|
+
|
58
|
+
description 'Downloads a wordlist'
|
59
|
+
|
60
|
+
man_page 'ronin-wordlists-download.1'
|
61
|
+
|
62
|
+
#
|
63
|
+
# Runs the `ronin-wordlists download` command.
|
64
|
+
#
|
65
|
+
# @param [String] name_or_url
|
66
|
+
# The wordlist name or URL to download.
|
67
|
+
#
|
68
|
+
def run(name_or_url)
|
69
|
+
if name_or_url =~ %r{\A(?:git|http|https)://}
|
70
|
+
url = name_or_url
|
71
|
+
|
72
|
+
download(url)
|
73
|
+
else
|
74
|
+
index = WordlistIndex.load
|
75
|
+
name = name_or_url
|
76
|
+
|
77
|
+
if (entry = index[name])
|
78
|
+
download(entry.url)
|
79
|
+
else
|
80
|
+
print_error "unknown wordlist: #{name}"
|
81
|
+
exit(1)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
#
|
87
|
+
# Downloads a wordlist from the URL.
|
88
|
+
#
|
89
|
+
# @param [String] url
|
90
|
+
# The URL to download from.
|
91
|
+
#
|
92
|
+
def download(url)
|
93
|
+
log_info "Downloading wordlist #{url} ..."
|
94
|
+
|
95
|
+
begin
|
96
|
+
downloaded_wordlist = wordlist_dir.download(url)
|
97
|
+
|
98
|
+
log_info "Wordlist #{downloaded_wordlist.name} downloaded"
|
99
|
+
rescue DownloadFailed => error
|
100
|
+
log_error error.message
|
101
|
+
exit(2)
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
@@ -0,0 +1,79 @@
|
|
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/cli/command'
|
22
|
+
require 'ronin/wordlists/cli/wordlist_dir_option'
|
23
|
+
require 'ronin/wordlists'
|
24
|
+
|
25
|
+
module Ronin
|
26
|
+
module Wordlists
|
27
|
+
class CLI
|
28
|
+
module Commands
|
29
|
+
#
|
30
|
+
# Lists installed wordlists on the system.
|
31
|
+
#
|
32
|
+
# ## Usage
|
33
|
+
#
|
34
|
+
# ronin-wordlists list [options] [NAME]
|
35
|
+
#
|
36
|
+
# ## Options
|
37
|
+
#
|
38
|
+
# -d, --wordlist-dir DIR The wordlist directory
|
39
|
+
# -h, --help Print help information
|
40
|
+
#
|
41
|
+
# ## Arguments
|
42
|
+
#
|
43
|
+
# [NAME] Optional wordlist name to search for
|
44
|
+
#
|
45
|
+
class List < Command
|
46
|
+
|
47
|
+
include WordlistDirOption
|
48
|
+
|
49
|
+
usage '[options] [NAME]'
|
50
|
+
|
51
|
+
argument :name, required: false,
|
52
|
+
usage: 'NAME',
|
53
|
+
desc: 'Optional wordlist name to search for'
|
54
|
+
|
55
|
+
description 'Lists installed wordlists on the system'
|
56
|
+
|
57
|
+
man_page 'ronin-wordlists-list.1'
|
58
|
+
|
59
|
+
#
|
60
|
+
# Runs the `ronin-wordlists list` command.
|
61
|
+
#
|
62
|
+
# @param [String, nil] name
|
63
|
+
# The optional wordlist name.
|
64
|
+
#
|
65
|
+
def run(name=nil)
|
66
|
+
wordlists = if name then wordlist_dir.list(name)
|
67
|
+
else wordlist_dir.list
|
68
|
+
end
|
69
|
+
|
70
|
+
wordlists.each do |wordlist|
|
71
|
+
puts " #{wordlist}"
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,60 @@
|
|
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/cli/command'
|
22
|
+
require 'ronin/wordlists/cli/wordlist_dir_option'
|
23
|
+
|
24
|
+
module Ronin
|
25
|
+
module Wordlists
|
26
|
+
class CLI
|
27
|
+
module Commands
|
28
|
+
#
|
29
|
+
# Purges all cached wordlists.
|
30
|
+
#
|
31
|
+
# ## Usage
|
32
|
+
#
|
33
|
+
# ronin-wordlists purge [options]
|
34
|
+
#
|
35
|
+
# ## Options
|
36
|
+
#
|
37
|
+
# -d, --wordlist-dir DIR The wordlist directory
|
38
|
+
# -h, --help Print help information
|
39
|
+
#
|
40
|
+
class Purge < Command
|
41
|
+
|
42
|
+
include WordlistDirOption
|
43
|
+
|
44
|
+
description 'Purges all downloaded wordlists'
|
45
|
+
|
46
|
+
man_page 'ronin-wordlists-purge.1'
|
47
|
+
|
48
|
+
#
|
49
|
+
# Runs the `ronin-wordlists purge` command.
|
50
|
+
#
|
51
|
+
def run
|
52
|
+
cache_dir = CacheDir.new
|
53
|
+
cache_dir.purge
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,74 @@
|
|
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/cli/command'
|
22
|
+
require 'ronin/wordlists/cli/wordlist_dir_option'
|
23
|
+
|
24
|
+
require 'ronin/core/cli/logging'
|
25
|
+
|
26
|
+
module Ronin
|
27
|
+
module Wordlists
|
28
|
+
class CLI
|
29
|
+
module Commands
|
30
|
+
#
|
31
|
+
# Removes a wordlist from the cache directory.
|
32
|
+
#
|
33
|
+
# ## Usage
|
34
|
+
#
|
35
|
+
# ronin-wordlists remove [options] NAME
|
36
|
+
#
|
37
|
+
# ## Options
|
38
|
+
#
|
39
|
+
# -d, --wordlist-dir DIR The wordlist directory
|
40
|
+
# -h, --help Print help information
|
41
|
+
#
|
42
|
+
# ## Arguments
|
43
|
+
#
|
44
|
+
# NAME The wordlist to remove
|
45
|
+
#
|
46
|
+
class Remove < Command
|
47
|
+
|
48
|
+
include WordlistDirOption
|
49
|
+
include Core::CLI::Logging
|
50
|
+
|
51
|
+
usage '[options] NAME'
|
52
|
+
|
53
|
+
argument :name, required: true,
|
54
|
+
desc: 'The wordlist to remove'
|
55
|
+
|
56
|
+
description 'Deletes a wordlist from the cache directory'
|
57
|
+
|
58
|
+
man_page 'ronin-wordlists-remove.1'
|
59
|
+
|
60
|
+
#
|
61
|
+
# Runs the `ronin-wordlists remove` command.
|
62
|
+
#
|
63
|
+
def run(name)
|
64
|
+
wordlist_dir.remove(name)
|
65
|
+
rescue WordlistNotFound
|
66
|
+
print_error "no such wordlist: #{name}"
|
67
|
+
exit(1)
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,145 @@
|
|
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/cli/command'
|
22
|
+
require 'ronin/wordlists/cli/wordlist_index'
|
23
|
+
|
24
|
+
require 'set'
|
25
|
+
|
26
|
+
module Ronin
|
27
|
+
module Wordlists
|
28
|
+
class CLI
|
29
|
+
module Commands
|
30
|
+
#
|
31
|
+
# Lists wordlists available for download or installation.
|
32
|
+
#
|
33
|
+
# ## Usage
|
34
|
+
#
|
35
|
+
# ronin-wordlists search [options]
|
36
|
+
#
|
37
|
+
# ## Options
|
38
|
+
#
|
39
|
+
# -c, --category NAME Filters wordlists by a specific category
|
40
|
+
# -h, --help Print help information
|
41
|
+
#
|
42
|
+
# Arguments:
|
43
|
+
# [KEYWORD] Optional search keyword
|
44
|
+
#
|
45
|
+
class Search < Command
|
46
|
+
|
47
|
+
usage '[options] [KEYWORD]'
|
48
|
+
|
49
|
+
option :category, short: '-c',
|
50
|
+
value: {
|
51
|
+
type: String,
|
52
|
+
usage: 'NAME'
|
53
|
+
},
|
54
|
+
desc: 'Filters wordlists by a specific category' do |category|
|
55
|
+
@categories << category
|
56
|
+
end
|
57
|
+
|
58
|
+
argument :keyword, required: false,
|
59
|
+
desc: 'Optional search keyword'
|
60
|
+
|
61
|
+
description 'Lists wordlists available for download or installation'
|
62
|
+
|
63
|
+
man_page 'ronin-wordlists-search.1'
|
64
|
+
|
65
|
+
# Wordlist categories to filter by.
|
66
|
+
#
|
67
|
+
# @return [Set<String>]
|
68
|
+
attr_reader :categories
|
69
|
+
|
70
|
+
#
|
71
|
+
# Initializes the `ronin-wordlists search` command.
|
72
|
+
#
|
73
|
+
# @param [Hash{Symbol => Object}] kwargs
|
74
|
+
# Additional keyword arguments for the command.
|
75
|
+
#
|
76
|
+
def initialize(**kwargs)
|
77
|
+
super(**kwargs)
|
78
|
+
|
79
|
+
@categories = Set.new
|
80
|
+
end
|
81
|
+
|
82
|
+
#
|
83
|
+
# Runs the `ronin-wordlists search` command.
|
84
|
+
#
|
85
|
+
# @param [String, nil] keyword
|
86
|
+
# The optional search keyword.
|
87
|
+
#
|
88
|
+
def run(keyword=nil)
|
89
|
+
search(keyword, categories: @categories).each do |entry|
|
90
|
+
print_entry(entry)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
#
|
95
|
+
# Searches for matching entries in the wordlist index file.
|
96
|
+
#
|
97
|
+
# @param [String, nil] keyword
|
98
|
+
# The optional search keyword.
|
99
|
+
#
|
100
|
+
# @param [Set<String>, nil] categories
|
101
|
+
# The optional set of categories to filter by.
|
102
|
+
#
|
103
|
+
# @return [Enumerator::Lazy]
|
104
|
+
# The filtered wordlist index entries.
|
105
|
+
#
|
106
|
+
def search(keyword=nil, categories: Set.new)
|
107
|
+
entries = WordlistIndex.load.lazy
|
108
|
+
|
109
|
+
unless categories.empty?
|
110
|
+
entries = entries.filter do |entry|
|
111
|
+
categories.subset?(entry.categories)
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
if keyword
|
116
|
+
entries = entries.filter do |entry|
|
117
|
+
entry.name.include?(keyword) ||
|
118
|
+
entry.summary.include?(keyword) ||
|
119
|
+
entry.categories.include?(keyword)
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
return entries
|
124
|
+
end
|
125
|
+
|
126
|
+
#
|
127
|
+
# Prints an entry from the wordlist index file.
|
128
|
+
#
|
129
|
+
# @param [WordlistIndex::Entry] entry
|
130
|
+
# An entry from the wordlist index file.
|
131
|
+
#
|
132
|
+
def print_entry(entry)
|
133
|
+
puts "[ #{entry.name} ]"
|
134
|
+
puts
|
135
|
+
puts " * URL: #{entry.url}"
|
136
|
+
puts " * Categories: #{entry.categories.join(', ')}"
|
137
|
+
puts " * Summary: #{entry.summary}"
|
138
|
+
puts
|
139
|
+
end
|
140
|
+
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
@@ -0,0 +1,98 @@
|
|
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/cli/command'
|
22
|
+
require 'ronin/wordlists/cache_dir'
|
23
|
+
|
24
|
+
require 'ronin/core/cli/logging'
|
25
|
+
|
26
|
+
module Ronin
|
27
|
+
module Wordlists
|
28
|
+
class CLI
|
29
|
+
module Commands
|
30
|
+
#
|
31
|
+
# Updates a wordlist or all wordlists.
|
32
|
+
#
|
33
|
+
# ## Usage
|
34
|
+
#
|
35
|
+
# ronin-wordlists update [options] [WORDLISt]
|
36
|
+
#
|
37
|
+
# ## Options
|
38
|
+
#
|
39
|
+
# -h, --help Print help information
|
40
|
+
#
|
41
|
+
# ## Arguments
|
42
|
+
#
|
43
|
+
# [WORDLIST] The optional wordlist to update
|
44
|
+
#
|
45
|
+
class Update < Command
|
46
|
+
|
47
|
+
include Core::CLI::Logging
|
48
|
+
|
49
|
+
usage '[options] [WORDLISt]'
|
50
|
+
|
51
|
+
argument :wordlist, required: false,
|
52
|
+
desc: 'The optional wordlist to update'
|
53
|
+
|
54
|
+
description 'Updates a wordlist or all wordlists'
|
55
|
+
|
56
|
+
man_page 'ronin-wordlists-update.1'
|
57
|
+
|
58
|
+
#
|
59
|
+
# Runs the `ronin-wordlists update` command.
|
60
|
+
#
|
61
|
+
# @param [String, nil] name
|
62
|
+
# The optional wordlist name to update.
|
63
|
+
#
|
64
|
+
def run(name=nil)
|
65
|
+
cache_dir = CacheDir.new
|
66
|
+
|
67
|
+
if name
|
68
|
+
begin
|
69
|
+
update(cache_dir[name])
|
70
|
+
rescue WordlistNotFound
|
71
|
+
print_error "no such wordlist: #{name}"
|
72
|
+
exit(1)
|
73
|
+
end
|
74
|
+
else
|
75
|
+
cache_dir.each(&method(:update))
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
#
|
80
|
+
# Updates a wordlist.
|
81
|
+
#
|
82
|
+
# @param [WordlistFile, WordlistRepo] wordlist
|
83
|
+
# The wordlist file or git repository to update.
|
84
|
+
#
|
85
|
+
def update(wordlist)
|
86
|
+
log_info "Updating wordlist #{wordlist.name} from #{wordlist.url} ..."
|
87
|
+
begin
|
88
|
+
wordlist.update
|
89
|
+
rescue DownloadFailed => error
|
90
|
+
log_error error.message
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
@@ -0,0 +1,64 @@
|
|
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/wordlist_dir'
|
23
|
+
|
24
|
+
module Ronin
|
25
|
+
module Wordlists
|
26
|
+
class CLI
|
27
|
+
#
|
28
|
+
# Adds the `--wordlist-dir DIR` option to a command.
|
29
|
+
#
|
30
|
+
module WordlistDirOption
|
31
|
+
#
|
32
|
+
# Adds the `--wordlist-dir DIR` option to the command including
|
33
|
+
# {WordlistDirOption}.
|
34
|
+
#
|
35
|
+
# @param [Class<Command>] command
|
36
|
+
# The command class including {WordlistDirOption}.
|
37
|
+
#
|
38
|
+
def self.included(command)
|
39
|
+
command.option :wordlist_dir, short: '-d',
|
40
|
+
value: {
|
41
|
+
type: String,
|
42
|
+
usage: 'DIR'
|
43
|
+
},
|
44
|
+
desc: 'The wordlist directory'
|
45
|
+
end
|
46
|
+
|
47
|
+
#
|
48
|
+
# The wordlist directory.
|
49
|
+
#
|
50
|
+
# @return [CacheDir, WordlistDir]
|
51
|
+
# The {WordlistDir} if the `--wordlist-dir` option was specified or
|
52
|
+
# {CacheDir}.
|
53
|
+
#
|
54
|
+
def wordlist_dir
|
55
|
+
@wordlist_dir ||= if options[:wordlist_dir]
|
56
|
+
WordlistDir.new(options[:wordlist_dir])
|
57
|
+
else
|
58
|
+
CacheDir.new
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|