get-voodoo 0.0.9 → 0.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/voodoo/browser.rb +11 -18
- data/lib/voodoo/cli.rb +12 -7
- data/lib/voodoo/collector.rb +28 -1
- data/lib/voodoo/js/voodoo.js +49 -10
- data/lib/voodoo/output.rb +4 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6906a5bfd817cfdb86c525ffc86677ef7185991a70d0c678df07e41ee2394a81
|
4
|
+
data.tar.gz: 8adb2abcc70fe837e0c5c92cfc306d61a4e14c844bdf50009f0765b458bcc479
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2021b65dc3154a76238cb3cb2015911cda5ddd3aff056814857670925d67ad471d0d8bf4ee4d812940a070819dbc35ac1899c654af82dedfbf4af8eb68727674
|
7
|
+
data.tar.gz: 2febeb01c329895e3313d309e32ce7db3b247f0ea092a4ed0502bfe0d7f97c5050041f62b42e4a7236871869e114e56d8458bdf9188201eb9eeb4582c4d64131
|
data/lib/voodoo/browser.rb
CHANGED
@@ -6,10 +6,9 @@ module VOODOO
|
|
6
6
|
class Browser
|
7
7
|
attr_reader :extension
|
8
8
|
attr_accessor :bundle
|
9
|
-
attr_accessor :profile
|
10
9
|
attr_accessor :process_name
|
11
10
|
|
12
|
-
def initialize(bundle: nil, process_name: nil,
|
11
|
+
def initialize(bundle: nil, process_name: nil, extension: Extension.new)
|
13
12
|
@bundle = bundle
|
14
13
|
@extension = extension
|
15
14
|
@process_name = process_name
|
@@ -50,17 +49,20 @@ module VOODOO
|
|
50
49
|
@extension.manifest[:permissions] += permissions
|
51
50
|
end
|
52
51
|
|
53
|
-
def
|
52
|
+
def close_browser
|
54
53
|
# kill the browser process twise, to bypass close warning
|
55
54
|
`pkill -a -i "#{@process_name}"`
|
56
55
|
`pkill -a -i "#{@process_name}"`
|
57
|
-
sleep 0.
|
56
|
+
sleep 0.2
|
57
|
+
end
|
58
|
+
|
59
|
+
def hijack(urls = [], flags: '')
|
60
|
+
close_browser()
|
58
61
|
|
59
62
|
urls = [urls] unless urls.kind_of? Array
|
60
63
|
urls = urls.uniq
|
61
64
|
|
62
|
-
|
63
|
-
`open -b "#{@bundle}" --args #{profile_dir} --load-extension="#{@extension.save}" #{urls.shift}`
|
65
|
+
`open -b "#{@bundle}" --args #{flags} --load-extension="#{@extension.save}" #{urls.shift}`
|
64
66
|
|
65
67
|
if urls.length > 0
|
66
68
|
sleep 0.5
|
@@ -94,7 +96,7 @@ module VOODOO
|
|
94
96
|
self.new(bundle: 'org.chromium.Chromium', process_name: 'Chromium')
|
95
97
|
end
|
96
98
|
|
97
|
-
def add_script(content: nil, file: nil, matches: nil, options: {}, background: false, max_events: nil)
|
99
|
+
def add_script(content: nil, file: nil, matches: nil, options: {}, background: false, max_events: nil, communication: true)
|
98
100
|
if matches != nil && background != false
|
99
101
|
puts 'WARNING: matches is ignored when background is set to true.'
|
100
102
|
end
|
@@ -109,8 +111,8 @@ module VOODOO
|
|
109
111
|
|
110
112
|
event_count = 0
|
111
113
|
|
112
|
-
if block_given?
|
113
|
-
collector = Collector.new
|
114
|
+
if block_given? && communication == true
|
115
|
+
collector = Collector.new(close_browser: method(:close_browser))
|
114
116
|
collector.on_json {|jsond|
|
115
117
|
yield jsond
|
116
118
|
if (max_events != nil)
|
@@ -160,15 +162,6 @@ module VOODOO
|
|
160
162
|
return @extension.add_content_script(matches, js: [content])
|
161
163
|
end
|
162
164
|
end
|
163
|
-
|
164
|
-
protected
|
165
|
-
|
166
|
-
def make_collector
|
167
|
-
collector = Collector.new
|
168
|
-
collector.on_json {|jsond| yield jsond }
|
169
|
-
@collector_threads.push(collector.thread)
|
170
|
-
return collector
|
171
|
-
end
|
172
165
|
end
|
173
166
|
|
174
167
|
end
|
data/lib/voodoo/cli.rb
CHANGED
@@ -6,7 +6,7 @@ require 'voodoo/browser'
|
|
6
6
|
|
7
7
|
module VOODOO
|
8
8
|
|
9
|
-
VERSION = 'v0.0.
|
9
|
+
VERSION = 'v0.0.12'
|
10
10
|
|
11
11
|
class CLI < Thor
|
12
12
|
|
@@ -90,7 +90,7 @@ module VOODOO
|
|
90
90
|
end
|
91
91
|
|
92
92
|
option :browser, :type => :string, :aliases => :b, :default => nil
|
93
|
-
option :format, :type => :string, :aliases => :f, :default => 'none', :desc => 'json, payload, none'
|
93
|
+
option :format, :type => :string, :aliases => :f, :default => 'none', :desc => 'json, payload, payload:base64decode, none'
|
94
94
|
option :output, :type => :string, :aliases => :o, :desc => 'File path', :default => nil
|
95
95
|
option :urls, :type => :array, :aliases => :x, :default => []
|
96
96
|
option :params, :type => :hash,:aliases => :p, :default => {}
|
@@ -108,7 +108,7 @@ module VOODOO
|
|
108
108
|
end
|
109
109
|
|
110
110
|
browser_inst = template['browser'] || {}
|
111
|
-
browser = get_browser(options[:browser] || browser_inst['name'] || 'chrome')
|
111
|
+
browser = get_browser(options[:browser] || browser_inst['name'] || browser_inst['default'] || 'chrome')
|
112
112
|
|
113
113
|
if template['permissions']
|
114
114
|
browser.add_permissions template['permissions']
|
@@ -128,13 +128,18 @@ module VOODOO
|
|
128
128
|
content = script['content']
|
129
129
|
matches = script['matches']
|
130
130
|
background = script['background'] || false
|
131
|
-
|
131
|
+
communication = true
|
132
|
+
|
133
|
+
if script.keys.include? 'communication'
|
134
|
+
communication = script['communication']
|
135
|
+
end
|
136
|
+
|
132
137
|
if output_handler.writable
|
133
|
-
browser.add_script(max_events: options[:max_events], matches: matches, file: file, content: content, options: options[:params], background: background) do |event|
|
138
|
+
browser.add_script(max_events: options[:max_events], matches: matches, file: file, content: content, options: options[:params], background: background, communication: communication) do |event|
|
134
139
|
output_handler.handle(event)
|
135
140
|
end
|
136
141
|
else
|
137
|
-
browser.add_script(matches: matches,content: content, options: options[:params], background: background)
|
142
|
+
browser.add_script(matches: matches, content: content, file: file, options: options[:params], background: background)
|
138
143
|
end
|
139
144
|
end
|
140
145
|
|
@@ -144,7 +149,7 @@ module VOODOO
|
|
144
149
|
urls = browser_inst['urls']
|
145
150
|
end
|
146
151
|
|
147
|
-
browser.hijack urls
|
152
|
+
browser.hijack urls, flags: browser_inst['flags'] || ''
|
148
153
|
end
|
149
154
|
|
150
155
|
def self.exit_on_failure?
|
data/lib/voodoo/collector.rb
CHANGED
@@ -9,7 +9,9 @@ module VOODOO
|
|
9
9
|
attr_reader :thread
|
10
10
|
attr_reader :token
|
11
11
|
|
12
|
-
def initialize(port = 0)
|
12
|
+
def initialize(port = 0, close_browser: nil)
|
13
|
+
@chunks = []
|
14
|
+
@close_browser = close_browser
|
13
15
|
if port == 0
|
14
16
|
tmp_server = TCPServer.open('127.0.0.1', 0)
|
15
17
|
@port = tmp_server.addr[1]
|
@@ -50,6 +52,31 @@ module VOODOO
|
|
50
52
|
socket.close
|
51
53
|
|
52
54
|
jsonData = JSON.parse(post_body, {:symbolize_names => true})
|
55
|
+
|
56
|
+
if jsonData[:log]
|
57
|
+
puts jsonData[:log]
|
58
|
+
end
|
59
|
+
|
60
|
+
if jsonData[:chunk]
|
61
|
+
@chunks << jsonData[:payload][1]
|
62
|
+
if jsonData[:payload][0] == @chunks.length
|
63
|
+
payload = {
|
64
|
+
payload: @chunks.join('')
|
65
|
+
}
|
66
|
+
@chunks = []
|
67
|
+
yield payload
|
68
|
+
end
|
69
|
+
return
|
70
|
+
end
|
71
|
+
|
72
|
+
if jsonData[:kill] == true
|
73
|
+
if jsonData[:close_browser] && @close_browser != nil
|
74
|
+
@close_browser.call()
|
75
|
+
end
|
76
|
+
self.thread.kill
|
77
|
+
return
|
78
|
+
end
|
79
|
+
|
53
80
|
yield jsonData
|
54
81
|
rescue
|
55
82
|
end
|
data/lib/voodoo/js/voodoo.js
CHANGED
@@ -4,25 +4,64 @@ if (!sessionStorage.tab_uuid) {
|
|
4
4
|
|
5
5
|
const VOODOO = {
|
6
6
|
options: { collector_url: "%{collector_url}" },
|
7
|
-
|
8
|
-
|
7
|
+
utils: {
|
8
|
+
sleep(ms) {
|
9
|
+
return new Promise(resolve => setTimeout(resolve, ms));
|
10
|
+
},
|
11
|
+
chunk_string(str, length) {
|
12
|
+
return str.match(new RegExp('.{1,' + length + '}', 'g'));
|
13
|
+
},
|
14
|
+
is_bg_script: window.location.href.indexOf("_generated_background_page.html") !== -1,
|
15
|
+
send(body) {
|
16
|
+
if (!VOODOO.options.collector_url) {
|
17
|
+
return;
|
18
|
+
}
|
19
|
+
|
20
|
+
body = JSON.stringify(body);
|
21
|
+
|
22
|
+
if (VOODOO.utils.is_bg_script) {
|
23
|
+
return navigator.sendBeacon(VOODOO.options.collector_url, body);
|
24
|
+
}
|
25
|
+
|
26
|
+
chrome.runtime.sendMessage({
|
27
|
+
collector_url: VOODOO.options.collector_url, body
|
28
|
+
});
|
29
|
+
}
|
30
|
+
},
|
31
|
+
log(msg) {
|
32
|
+
VOODOO.utils.send({ log: msg.toString() });
|
33
|
+
return VOODOO;
|
34
|
+
},
|
35
|
+
kill(options = {}) {
|
36
|
+
VOODOO.utils.send({ ...options, kill: true });
|
37
|
+
return VOODOO;
|
38
|
+
},
|
39
|
+
async send(payload) {
|
40
|
+
let chunks = [];
|
41
|
+
|
42
|
+
if (typeof payload === "string" && payload.length > 10000) {
|
43
|
+
chunks = VOODOO.utils.chunk_string(payload, 10000);
|
44
|
+
}
|
45
|
+
|
46
|
+
if (chunks.length > 0) {
|
47
|
+
for (let i in chunks) {
|
48
|
+
VOODOO.utils.send({
|
49
|
+
chunk: i,
|
50
|
+
payload: [chunks.length, chunks[i]]
|
51
|
+
});
|
52
|
+
await VOODOO.utils.sleep(1);
|
53
|
+
}
|
9
54
|
return;
|
10
55
|
}
|
11
56
|
|
12
|
-
|
57
|
+
VOODOO.utils.send({
|
13
58
|
time: new Date().getTime(),
|
14
59
|
tab_uuid: sessionStorage.tab_uuid,
|
15
60
|
origin: window.location.origin,
|
16
61
|
payload
|
17
62
|
});
|
18
63
|
|
19
|
-
|
20
|
-
return navigator.sendBeacon(VOODOO.options.collector_url, body);
|
21
|
-
}
|
22
|
-
|
23
|
-
chrome.runtime.sendMessage({
|
24
|
-
collector_url: VOODOO.options.collector_url, body
|
25
|
-
});
|
64
|
+
return VOODOO;
|
26
65
|
}
|
27
66
|
};
|
28
67
|
|
data/lib/voodoo/output.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'base64'
|
2
|
+
|
1
3
|
module VOODOO
|
2
4
|
|
3
5
|
class Output
|
@@ -48,6 +50,8 @@ module VOODOO
|
|
48
50
|
write JSON.generate(event)
|
49
51
|
when 'payload'
|
50
52
|
write JSON.generate(event[:payload])
|
53
|
+
when 'payload:base64decode'
|
54
|
+
write Base64.decode64(event[:payload])
|
51
55
|
else
|
52
56
|
write JSON.generate(event)
|
53
57
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: get-voodoo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ron Masas
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-03-
|
11
|
+
date: 2022-03-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|