Module: Uirusu::Scanner
- Defined in:
- lib/uirusu/scanner.rb
Class Method Summary collapse
-
.process_file(file) ⇒ Object
Processes a file, hashing it with MD5.
-
.recurse(file_name) ⇒ Object
Recursively lists all files in a directory calling process_file on each file.
-
.scan(directory) ⇒ Array
Enumerates a directory recursively then returns the hash list.
Class Method Details
.process_file(file) ⇒ Object
Processes a file, hashing it with MD5
47 48 49 50 51 52 53 54 55 |
# File 'lib/uirusu/scanner.rb', line 47 def Scanner.process_file file begin digest = Digest::MD5.hexdigest(File.read(file)) @hash_list << digest rescue Exception puts "[!] Cannot read #{file}" end end |
.recurse(file_name) ⇒ Object
Recursively lists all files in a directory calling process_file on each file
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/uirusu/scanner.rb', line 32 def Scanner.recurse file_name Dir.new("#{file_name}").each do |file| next if file.match(/^\.+/) path = "#{file_name}/#{file}" if FileTest.directory?("#{path}") recurse("#{path}") else process_file(path) end end end |
.scan(directory) ⇒ Array
Enumerates a directory recursively then returns the hash list
60 61 62 63 64 |
# File 'lib/uirusu/scanner.rb', line 60 def Scanner.scan directory recurse(directory) return @hash_list end |