Class: VOODOO::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/voodoo/cli.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.exit_on_failure?Boolean

Returns:

  • (Boolean)


155
156
157
# File 'lib/voodoo/cli.rb', line 155

def self.exit_on_failure?
    true
end

Instance Method Details

#interceptObject



28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/voodoo/cli.rb', line 28

def intercept
    browser = get_browser options[:browser]
    output_handler = Output.new(file: options[:output], in_format: options[:format], for_command: 'intercept')

    browser.intercept(matches: options[:matches],
                      url_include: options[:url_include],
                      body_include: options[:body_include],
                      max_events: options[:max_events]) do |event|
        output_handler.handle(event)
    end

    browser.hijack options[:urls]
end

#keyloggerObject



83
84
85
86
87
88
89
90
# File 'lib/voodoo/cli.rb', line 83

def keylogger
    browser = get_browser options[:browser]
    output_handler = Output.new(file: options[:output], in_format: options[:format], for_command: 'keylogger')
    browser.keylogger(matches: options[:matches], max_events: options[:max_events]) do |event|
        output_handler.handle(event)
    end
    browser.hijack options[:urls]
end

#script(path_or_js) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/voodoo/cli.rb', line 51

def script(path_or_js)
    browser = get_browser options[:browser]
    browser.add_permissions options[:permissions]
    output_handler = Output.new(file: options[:output], in_format: options[:format], for_command: 'script')

    file = nil
    content = nil

    if File.exists? path_or_js
        file = path_or_js
    else
        content = path_or_js
    end

    if output_handler.writable
        browser.add_script file: file, content: content, options: options[:params], max_events: options[:max_events] do |event|
            output_handler.handle(event)
        end
    else
        browser.add_script file: file, content: content, options: options[:params]
    end

    browser.hijack options[:urls]
end

#template(path) ⇒ Object



99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# File 'lib/voodoo/cli.rb', line 99

def template(path)
    pwd = Dir.pwd

    if File.directory? path
        pwd = File.expand_path(File.join(pwd, path))
        template = YAML.load_file(File.join(path, 'voodoo.yaml'))
    else
        pwd = File.expand_path(File.join(pwd, File.dirname(path)))
        template = YAML.load_file(path)
    end

    browser_inst = template['browser'] || {}
    browser = get_browser(options[:browser] || browser_inst['name'] || browser_inst['default'] || 'chrome')

    if template['permissions']
        browser.add_permissions template['permissions']
    end
    
    output_format = options[:format]
    is_default = output_format == 'none'

    if is_default && template['format']
        output_format = template['format']
    end

    output_handler = Output.new(file: options[:output], in_format: output_format, for_command: 'template')

    template['scripts'].each do |script|
        file = File.expand_path(File.join(pwd, script['file'])) if script['file']
        content = script['content']
        matches = script['matches']
        background = script['background'] || false
        communication = true

        if script.keys.include? 'communication'
            communication = script['communication']
        end

        if output_handler.writable
            browser.add_script(max_events: options[:max_events], matches: matches, file: file, content: content, options: options[:params], background: background, communication: communication) do |event|
                output_handler.handle(event)
            end
        else
            browser.add_script(matches: matches, content: content, file: file, options: options[:params], background: background)
        end
    end

    urls = options[:urls]

    if urls.length == 0 && browser_inst['urls']
        urls = browser_inst['urls']
    end

    browser.hijack urls, flags: browser_inst['flags'] || ''
end

#versionObject



14
15
16
# File 'lib/voodoo/cli.rb', line 14

def version
    puts VERSION
end