Class: CheckerSpelling

Inherits:
Plugin
  • Object
show all
Defined in:
lib/wpstools/plugins/checker/checker_spelling.rb

Instance Attribute Summary

Attributes inherited from Plugin

#author, #registered_options

Instance Method Summary collapse

Methods inherited from Plugin

#register_options

Constructor Details

#initializeCheckerSpelling

Returns a new instance of CheckerSpelling


5
6
7
8
9
# File 'lib/wpstools/plugins/checker/checker_spelling.rb', line 5

def initialize
  super(author: 'WPScanTeam - @ethicalhack3r')

  register_options(['--spellcheck', '--sc', 'Check all files for common spelling mistakes.'])
end

Instance Method Details

#filesObject


66
67
68
69
70
71
72
73
74
# File 'lib/wpstools/plugins/checker/checker_spelling.rb', line 66

def files
  files = Dir['**/*'].reject {|fn| File.directory?(fn) }

  ignore.each do |ignore|
    files.delete_if { |data| data.match(ignore) }
  end

  files
end

#ignoreObject


76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/wpstools/plugins/checker/checker_spelling.rb', line 76

def ignore
  ignore = []

  ignore << File.basename(__FILE__)
  ignore << 'spec/cache/'
  ignore << 'spec/spec_session/'
  ignore << 'cache/'
  ignore << 'coverage/'
  ignore << 'wordlist-iso-8859-1'
  ignore << 'log.txt'
  ignore << 'debug.log'
  ignore << 'wordlist.txt'

  ignore
end

#misspellingsObject


47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/wpstools/plugins/checker/checker_spelling.rb', line 47

def misspellings
  {
    /databse/i    => 'database',
    /whith/i      => 'with',
    /wich/i       => 'which',
    /verions/i    => 'versions',
    /vulnerabilitiy/i => 'vulnerability',
    /unkown/i     => 'unknown',
    /recieved/i   => 'received',
    /acheive/i    => 'achieve',
    /wierd/i      => 'weird',
    /untill/i     => 'until',
    /alot/i       => 'a lot',
    /randomstorm/ => 'RandomStorm',
    /wpscan/      => 'WPScan',
    /Wordpress/   => 'WordPress'
  }
end

#run(options = {}) ⇒ Object


11
12
13
# File 'lib/wpstools/plugins/checker/checker_spelling.rb', line 11

def run(options = {})
  spellcheck if options[:spellcheck]
end

#spellcheckObject


15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/wpstools/plugins/checker/checker_spelling.rb', line 15

def spellcheck
  mistakes = 0

  puts '[+] Checking for spelling mistakes'
  puts

  files.each do |file_name|
    if File.exists?(file_name)
      file = File.open(file_name, 'r')

      misspellings.each_key do |misspelling|
        begin
          file.read.scan(/#{misspelling}/).each do |match|
            mistakes += 1
            puts "[MISSPELLING] File: #{file_name} Bad: #{match} Good: #{misspellings[misspelling]}"
          end
        rescue => e
          puts "Error in #{file_name} #{e}"
          next
        end
      end

      file.close
    end
  end

  puts
  puts "[+] Found #{mistakes} spelling mistakes"

  mistakes
end