Class: Ronin::Wordlists::WordlistFile

Inherits:
Object
  • Object
show all
Includes:
WordlistMetadata
Defined in:
lib/ronin/wordlists/wordlist_file.rb

Overview

Represents a wordlist file.

Instance Attribute Summary collapse

Attributes included from WordlistMetadata

#url

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, **kwargs) ⇒ WordlistFile

Initializes the wordlist file.

Parameters:

Options Hash (**kwargs):

  • :url (String, nil)

    The optional URL for the wordlist file.



60
61
62
63
64
65
# File 'lib/ronin/wordlists/wordlist_file.rb', line 60

def initialize(path,**kwargs)
  super(**kwargs)

  @path = path
  @name = File.basename(@path,File.extname(@path))
end

Instance Attribute Details

#nameString (readonly)

The name of the wordlist file.

Returns:

  • (String)


45
46
47
# File 'lib/ronin/wordlists/wordlist_file.rb', line 45

def name
  @name
end

#pathString (readonly)

The path to the wordlist file.

Returns:

  • (String)


40
41
42
# File 'lib/ronin/wordlists/wordlist_file.rb', line 40

def path
  @path
end

Class Method Details

.download(url, dest = Dir.pwd) ⇒ WordlistFile

Downloads a remote wordlist file.

Parameters:

  • url (String, URI::HTTP)

    The http:// or https:// URL for the wordlist file.

  • dest (String) (defaults to: Dir.pwd)

    The directory to download the wordlist file into.

Returns:

Raises:



82
83
84
85
86
87
88
89
90
# File 'lib/ronin/wordlists/wordlist_file.rb', line 82

def self.download(url,dest=Dir.pwd)
  dest_path = begin
                Core::System.download(url,dest)
              rescue Core::System::DownloadFailed => error
                raise(DownloadFailed,error.message)
              end

  return new(dest_path, url: url.to_s)
end

Instance Method Details

#deleteObject

Deletes the wordlist file.



125
126
127
# File 'lib/ronin/wordlists/wordlist_file.rb', line 125

def delete
  File.unlink(@path)
end

#filenameString

The name of the wordlist file.

Returns:

  • (String)


106
107
108
# File 'lib/ronin/wordlists/wordlist_file.rb', line 106

def filename
  File.basename(@path)
end

#to_sString

Converts the wordlist file to a String.

Returns:

  • (String)

    The wordlist file's path.



135
136
137
# File 'lib/ronin/wordlists/wordlist_file.rb', line 135

def to_s
  @path
end

#type:file

The wordlist type.

Returns:

  • (:file)


97
98
99
# File 'lib/ronin/wordlists/wordlist_file.rb', line 97

def type
  :file
end

#updateObject

Updates the wordlist file, if Ronin::Wordlists::WordlistMetadata#url is set.

Raises:



116
117
118
119
120
# File 'lib/ronin/wordlists/wordlist_file.rb', line 116

def update
  if @url
    self.class.download(@url,@path)
  end
end