Module: PWN::Corpus
- Defined in:
- lib/pwn/corpus.rb
Overview
Named wordlist and payload corpora under ~/.pwn/corpora.
Constant Summary collapse
- ROOT =
File.join(Dir.home, '.pwn', 'corpora')
- INDEX =
{ subdomains_top1m: { url: 'https://raw.githubusercontent.com/danielmiessler/SecLists/master/Discovery/DNS/subdomains-top1million-5000.txt', sha256: nil }, fuzz_short: { builtin: %w[A ' " < > ` ; | & ${IFS} ../] } }.freeze
Class Method Summary collapse
Class Method Details
.authors ⇒ Object
60 61 62 |
# File 'lib/pwn/corpus.rb', line 60 public_class_method def self. "AUTHOR(S):\n 0day Inc. <[email protected]>\n" end |
.get(opts = {}) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/pwn/corpus.rb', line 23 public_class_method def self.get(opts = {}) opts = { name: opts } unless opts.is_a?(Hash) name = (opts[:name] || opts[:corpus] || opts[:key]).to_s.to_sym spec = INDEX[name] raise ArgumentError, "unknown corpus #{name}" unless spec FileUtils.mkdir_p(ROOT) path = File.join(ROOT, "#{name}.txt") if spec[:builtin] File.write(path, spec[:builtin].join("\n") << "\n") unless File.file?(path) return path end if File.file?(path) verify!(path: path, sha256: spec[:sha256]) return path end offline = opts[:offline] == true || ENV['PWN_CORPUS_OFFLINE'] == '1' raise IOError, "corpus cache miss (offline): #{name}" if offline fetch(url: spec[:url], path: path, sha256: spec[:sha256]) path end |
.help ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/pwn/corpus.rb', line 64 public_class_method def self.help puts "USAGE: # Resolve a named corpus to a local cache path. #{self}.get( name: 'required - corpus symbol such as subdomains_top1m or fuzz_short', corpus: 'optional - alias for name', key: 'optional - alias for name', offline: 'optional - true uses the cache only and raises on miss' ) # Replace a remotely pinned corpus from its source URL. #{self}.update( name: 'required - corpus symbol with a remote URL', corpus: 'optional - alias for name' ) # Print the AUTHOR(S) string for this module. #{self}.authors " end |
.update(opts = {}) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/pwn/corpus.rb', line 46 public_class_method def self.update(opts = {}) opts = { name: opts } unless opts.is_a?(Hash) name = (opts[:name] || opts[:corpus]).to_s.to_sym spec = INDEX[name] raise ArgumentError, "unknown corpus #{name}" unless spec raise ArgumentError, 'builtin corpora have no remote update' if spec[:builtin] path = File.join(ROOT, "#{name}.txt") tmp = "#{path}.tmp" fetch(url: spec[:url], path: tmp, sha256: spec[:sha256]) FileUtils.mv(tmp, path) path end |