chromate-rb 0.0.1.pre → 0.0.2.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -0
- data/CHANGELOG.md +54 -3
- data/README.md +33 -6
- data/Rakefile +48 -16
- data/docker_root/Gemfile +4 -0
- data/docker_root/Gemfile.lock +28 -0
- data/docker_root/TestInDocker.gif +0 -0
- data/docker_root/app.rb +92 -0
- data/dockerfiles/Dockerfile +21 -7
- data/dockerfiles/README.md +49 -0
- data/docs/README.md +74 -0
- data/docs/browser.md +149 -92
- data/docs/element.md +289 -0
- data/lib/bot_browser/downloader.rb +52 -0
- data/lib/bot_browser/installer.rb +81 -0
- data/lib/bot_browser.rb +39 -0
- data/lib/chromate/actions/dom.rb +28 -9
- data/lib/chromate/actions/navigate.rb +4 -5
- data/lib/chromate/actions/screenshot.rb +30 -11
- data/lib/chromate/actions/stealth.rb +47 -0
- data/lib/chromate/browser.rb +64 -12
- data/lib/chromate/c_logger.rb +7 -0
- data/lib/chromate/client.rb +40 -18
- data/lib/chromate/configuration.rb +31 -14
- data/lib/chromate/element.rb +65 -15
- data/lib/chromate/elements/select.rb +59 -7
- data/lib/chromate/hardwares/keyboard_controller.rb +34 -0
- data/lib/chromate/hardwares/keyboards/virtual_controller.rb +65 -0
- data/lib/chromate/hardwares/mouse_controller.rb +47 -11
- data/lib/chromate/hardwares/mouses/linux_controller.rb +124 -21
- data/lib/chromate/hardwares/mouses/mac_os_controller.rb +6 -6
- data/lib/chromate/hardwares/mouses/virtual_controller.rb +95 -7
- data/lib/chromate/hardwares/mouses/x11.rb +36 -0
- data/lib/chromate/hardwares.rb +16 -0
- data/lib/chromate/helpers.rb +22 -15
- data/lib/chromate/user_agent.rb +39 -15
- data/lib/chromate/version.rb +1 -1
- data/lib/chromate.rb +2 -0
- data/logo.png +0 -0
- data/results/bot.png +0 -0
- data/results/brotector.png +0 -0
- data/results/cloudflare.png +0 -0
- data/results/headers.png +0 -0
- data/results/pixelscan.png +0 -0
- metadata +20 -2
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'chromate/helpers'
|
4
|
-
|
4
|
+
require_relative 'x11'
|
5
5
|
|
6
6
|
module Chromate
|
7
7
|
module Hardwares
|
@@ -17,23 +17,29 @@ module Chromate
|
|
17
17
|
raise InvalidPlatformError, 'MouseController is only supported on Linux' unless linux?
|
18
18
|
|
19
19
|
super
|
20
|
+
@display = X11.XOpenDisplay(nil)
|
21
|
+
raise 'Impossible d\'ouvrir l\'affichage X11' if @display.null?
|
22
|
+
|
23
|
+
@root_window = X11.XDefaultRootWindow(@display)
|
20
24
|
end
|
21
25
|
|
22
26
|
def hover
|
23
27
|
focus_chrome_window
|
24
|
-
|
25
|
-
|
26
|
-
current_mouse_position
|
28
|
+
smooth_move_to(target_x, target_y)
|
29
|
+
update_mouse_position(target_x, target_y)
|
27
30
|
end
|
28
31
|
|
29
32
|
def click
|
30
33
|
hover
|
31
34
|
simulate_button_event(LEFT_BUTTON, true)
|
35
|
+
sleep(rand(CLICK_DURATION_RANGE))
|
32
36
|
simulate_button_event(LEFT_BUTTON, false)
|
33
37
|
end
|
34
38
|
|
35
39
|
def right_click
|
40
|
+
hover
|
36
41
|
simulate_button_event(RIGHT_BUTTON, true)
|
42
|
+
sleep(rand(CLICK_DURATION_RANGE))
|
37
43
|
simulate_button_event(RIGHT_BUTTON, false)
|
38
44
|
end
|
39
45
|
|
@@ -43,35 +49,132 @@ module Chromate
|
|
43
49
|
click
|
44
50
|
end
|
45
51
|
|
52
|
+
def drag_and_drop_to(element)
|
53
|
+
hover
|
54
|
+
|
55
|
+
target_x = element.x + (element.width / 2)
|
56
|
+
target_y = element.y + (element.height / 2)
|
57
|
+
start_x = position_x
|
58
|
+
start_y = position_y
|
59
|
+
steps = rand(25..50)
|
60
|
+
duration = rand(0.1..0.3)
|
61
|
+
|
62
|
+
# Generate a Bézier curve for natural movement
|
63
|
+
points = bezier_curve(steps: steps, start_x: start_x, start_y: start_y, t_x: target_x, t_y: target_y)
|
64
|
+
|
65
|
+
# Step 1: Press the left mouse button
|
66
|
+
simulate_button_event(LEFT_BUTTON, true)
|
67
|
+
sleep(rand(CLICK_DURATION_RANGE))
|
68
|
+
|
69
|
+
# Step 2: Drag the element
|
70
|
+
points.each do |point|
|
71
|
+
move_mouse_to(point[:x], point[:y])
|
72
|
+
sleep(duration / steps)
|
73
|
+
end
|
74
|
+
|
75
|
+
# Step 3: Release the left mouse button
|
76
|
+
simulate_button_event(LEFT_BUTTON, false)
|
77
|
+
|
78
|
+
# Update the mouse position
|
79
|
+
update_mouse_position(target_x, target_y)
|
80
|
+
|
81
|
+
self
|
82
|
+
end
|
83
|
+
|
46
84
|
private
|
47
85
|
|
48
|
-
def
|
49
|
-
|
50
|
-
|
86
|
+
def smooth_move_to(dest_x, dest_y)
|
87
|
+
start_x = position_x
|
88
|
+
start_y = position_y
|
89
|
+
|
90
|
+
steps = rand(25..50)
|
91
|
+
duration = rand(0.1..0.3)
|
51
92
|
|
52
|
-
|
53
|
-
|
93
|
+
# Build a Bézier curve for natural movement
|
94
|
+
points = bezier_curve(steps: steps, start_x: start_x, start_y: start_y, t_x: dest_x, t_y: dest_y)
|
95
|
+
|
96
|
+
# Move the mouse along the Bézier curve
|
97
|
+
points.each do |point|
|
98
|
+
move_mouse_to(point[:x], point[:y])
|
99
|
+
sleep(duration / steps)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
def move_mouse_to(x_target, y_target)
|
104
|
+
X11.XWarpPointer(@display, 0, @root_window, 0, 0, 0, 0, x_target.to_i, y_target.to_i)
|
105
|
+
X11.XFlush(@display)
|
106
|
+
end
|
107
|
+
|
108
|
+
def focus_chrome_window
|
109
|
+
chrome_window = find_window_by_name(@root_window, 'Chrome')
|
110
|
+
if chrome_window.zero?
|
111
|
+
Chromate::CLogger.log('No Chrome window found')
|
54
112
|
else
|
55
|
-
|
56
|
-
|
113
|
+
X11.XRaiseWindow(@display, chrome_window)
|
114
|
+
X11.XSetInputFocus(@display, chrome_window, X11::REVERT_TO_PARENT, 0)
|
115
|
+
X11.XFlush(@display)
|
57
116
|
end
|
58
117
|
end
|
59
118
|
|
60
|
-
def
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
119
|
+
def find_window_by_name(window, name) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
120
|
+
root_return = FFI::MemoryPointer.new(:ulong)
|
121
|
+
parent_return = FFI::MemoryPointer.new(:ulong)
|
122
|
+
children_return = FFI::MemoryPointer.new(:pointer)
|
123
|
+
nchildren_return = FFI::MemoryPointer.new(:uint)
|
124
|
+
|
125
|
+
status = X11.XQueryTree(@display, window, root_return, parent_return, children_return, nchildren_return)
|
126
|
+
return 0 if status.zero?
|
127
|
+
|
128
|
+
nchildren = nchildren_return.read_uint
|
129
|
+
children_ptr = children_return.read_pointer
|
130
|
+
|
131
|
+
return 0 if nchildren.zero? || children_ptr.null?
|
132
|
+
|
133
|
+
children = children_ptr.get_array_of_ulong(0, nchildren)
|
134
|
+
found_window = 0
|
135
|
+
|
136
|
+
children.each do |child|
|
137
|
+
window_name_ptr = FFI::MemoryPointer.new(:pointer)
|
138
|
+
status = X11.XFetchName(@display, child, window_name_ptr)
|
139
|
+
if status != 0 && !window_name_ptr.read_pointer.null?
|
140
|
+
window_name = window_name_ptr.read_pointer.read_string
|
141
|
+
if window_name.include?(name)
|
142
|
+
X11.XFree(window_name_ptr.read_pointer)
|
143
|
+
found_window = child
|
144
|
+
break
|
145
|
+
end
|
146
|
+
X11.XFree(window_name_ptr.read_pointer)
|
147
|
+
end
|
148
|
+
# Recursive search for the window
|
149
|
+
found_window = find_window_by_name(child, name)
|
150
|
+
break if found_window != 0
|
67
151
|
end
|
68
152
|
|
69
|
-
|
153
|
+
X11.XFree(children_ptr)
|
154
|
+
found_window
|
155
|
+
end
|
156
|
+
|
157
|
+
def current_mouse_position
|
158
|
+
root_return = FFI::MemoryPointer.new(:ulong)
|
159
|
+
child_return = FFI::MemoryPointer.new(:ulong)
|
160
|
+
root_x = FFI::MemoryPointer.new(:int)
|
161
|
+
root_y = FFI::MemoryPointer.new(:int)
|
162
|
+
win_x = FFI::MemoryPointer.new(:int)
|
163
|
+
win_y = FFI::MemoryPointer.new(:int)
|
164
|
+
mask_return = FFI::MemoryPointer.new(:uint)
|
165
|
+
|
166
|
+
X11.XQueryPointer(@display, @root_window, root_return, child_return, root_x, root_y, win_x, win_y, mask_return)
|
167
|
+
|
168
|
+
{ x: root_x.read_int, y: root_y.read_int }
|
70
169
|
end
|
71
170
|
|
72
171
|
def simulate_button_event(button, press)
|
73
|
-
|
74
|
-
|
172
|
+
Xtst.XTestFakeButtonEvent(@display, button, press ? 1 : 0, 0)
|
173
|
+
X11.XFlush(@display)
|
174
|
+
end
|
175
|
+
|
176
|
+
def finalize
|
177
|
+
X11.XCloseDisplay(@display) if @display && !@display.null?
|
75
178
|
end
|
76
179
|
end
|
77
180
|
end
|
@@ -85,7 +85,7 @@ module Chromate
|
|
85
85
|
system_point = CGEventGetLocation(event)
|
86
86
|
CFRelease(event)
|
87
87
|
|
88
|
-
#
|
88
|
+
# Convert the system coordinates to browser coordinates
|
89
89
|
browser_x = system_point[:x] / @scale_factor
|
90
90
|
browser_y = (@display_height - system_point[:y]) / @scale_factor
|
91
91
|
|
@@ -94,7 +94,7 @@ module Chromate
|
|
94
94
|
y: browser_y
|
95
95
|
}
|
96
96
|
|
97
|
-
#
|
97
|
+
# Return the browser coordinates
|
98
98
|
CGPoint.new.tap do |p|
|
99
99
|
p[:x] = system_point[:x]
|
100
100
|
p[:y] = system_point[:y]
|
@@ -102,7 +102,7 @@ module Chromate
|
|
102
102
|
end
|
103
103
|
|
104
104
|
def convert_coordinates(browser_x, browser_y)
|
105
|
-
#
|
105
|
+
# Convert the browser coordinates to system coordinates
|
106
106
|
system_x = browser_x * @scale_factor
|
107
107
|
system_y = @display_height - (browser_y * @scale_factor)
|
108
108
|
|
@@ -113,12 +113,12 @@ module Chromate
|
|
113
113
|
end
|
114
114
|
|
115
115
|
def determine_scale_factor
|
116
|
-
#
|
117
|
-
#
|
116
|
+
# Determine the scale factor for the display
|
117
|
+
# By default, the scale factor is 2.0 for Retina displays
|
118
118
|
|
119
119
|
`system_profiler SPDisplaysDataType | grep -i "retina"`.empty? ? 1.0 : 2.0
|
120
120
|
rescue StandardError
|
121
|
-
2.0 #
|
121
|
+
2.0 # Default to 2.0 if the scale factor cannot be determined
|
122
122
|
end
|
123
123
|
end
|
124
124
|
end
|
@@ -4,11 +4,19 @@ module Chromate
|
|
4
4
|
module Hardwares
|
5
5
|
module Mouses
|
6
6
|
class VirtualController < Chromate::Hardwares::MouseController
|
7
|
-
def hover
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
def hover # rubocop:disable Metrics/AbcSize
|
8
|
+
# Define the target position
|
9
|
+
target_x = element.x + (element.width / 2) + rand(-20..20)
|
10
|
+
target_y = element.y + (element.height / 2) + rand(-20..20)
|
11
|
+
start_x = mouse_position[:x]
|
12
|
+
start_y = mouse_position[:y]
|
13
|
+
steps = rand(25..50)
|
14
|
+
duration = rand(0.1..0.3)
|
11
15
|
|
16
|
+
# Generate a Bézier curve for natural movement
|
17
|
+
points = bezier_curve(steps: steps, start_x: start_x, start_y: start_y, t_x: target_x, t_y: target_y)
|
18
|
+
|
19
|
+
# Move the mouse along the Bézier curve
|
12
20
|
points.each do |point|
|
13
21
|
dispatch_mouse_event('mouseMoved', point[:x], point[:y])
|
14
22
|
sleep(duration / steps)
|
@@ -35,12 +43,53 @@ module Chromate
|
|
35
43
|
dispatch_mouse_event('mouseReleased', target_x, target_y, button: 'right', click_count: 1)
|
36
44
|
end
|
37
45
|
|
46
|
+
# @param [Chromate::Element] element
|
47
|
+
# @return [self]
|
48
|
+
def drag_and_drop_to(element) # rubocop:disable Metrics/AbcSize
|
49
|
+
hover
|
50
|
+
|
51
|
+
target_x = element.x + (element.width / 2)
|
52
|
+
target_y = element.y + (element.height / 2)
|
53
|
+
start_x = mouse_position[:x]
|
54
|
+
start_y = mouse_position[:y]
|
55
|
+
steps = rand(25..50)
|
56
|
+
duration = rand(0.1..0.3)
|
57
|
+
|
58
|
+
# Generate a Bézier curve for natural movement
|
59
|
+
points = bezier_curve(steps: steps, start_x: start_x, start_y: start_y, t_x: target_x, t_y: target_y)
|
60
|
+
|
61
|
+
# Step 1: Start the drag (dragStart, dragEnter)
|
62
|
+
move_mouse_to(start_x, start_y)
|
63
|
+
dispatch_drag_event('dragEnter', start_x, start_y)
|
64
|
+
|
65
|
+
# Step 2: Drag the element (dragOver)
|
66
|
+
points.each do |point|
|
67
|
+
move_mouse_to(point[:x], point[:y])
|
68
|
+
dispatch_drag_event('dragOver', point[:x], point[:y])
|
69
|
+
sleep(duration / steps)
|
70
|
+
end
|
71
|
+
|
72
|
+
# Step 3: Drop the element (drop)
|
73
|
+
move_mouse_to(target_x, target_y)
|
74
|
+
dispatch_drag_event('drop', target_x, target_y)
|
75
|
+
|
76
|
+
# Step 4: End the drag (dragEnd)
|
77
|
+
dispatch_drag_event('dragEnd', target_x, target_y)
|
78
|
+
|
79
|
+
update_mouse_position(target_x, target_y)
|
80
|
+
|
81
|
+
self
|
82
|
+
end
|
83
|
+
|
38
84
|
private
|
39
85
|
|
86
|
+
# @return [self]
|
40
87
|
def click!
|
41
88
|
dispatch_mouse_event('mousePressed', target_x, target_y, button: 'left', click_count: 1)
|
42
89
|
sleep(rand(CLICK_DURATION_RANGE))
|
43
90
|
dispatch_mouse_event('mouseReleased', target_x, target_y, button: 'left', click_count: 1)
|
91
|
+
|
92
|
+
self
|
44
93
|
end
|
45
94
|
|
46
95
|
# @param [String] type mouseMoved, mousePressed, mouseReleased
|
@@ -64,9 +113,48 @@ module Chromate
|
|
64
113
|
client.send_message('Input.dispatchMouseEvent', params)
|
65
114
|
end
|
66
115
|
|
67
|
-
|
68
|
-
|
69
|
-
|
116
|
+
# @param [Integer] steps
|
117
|
+
# @param [Integer] x
|
118
|
+
# @param [Integer] y
|
119
|
+
# @return [Array<Hash>]
|
120
|
+
def dispatch_drag_event(type, x, y) # rubocop:disable Naming/MethodParameterName
|
121
|
+
params = {
|
122
|
+
type: type,
|
123
|
+
x: x,
|
124
|
+
y: y,
|
125
|
+
data: {
|
126
|
+
items: [
|
127
|
+
{
|
128
|
+
mimeType: 'text/plain',
|
129
|
+
data: 'dragged'
|
130
|
+
}
|
131
|
+
],
|
132
|
+
dragOperationsMask: 1
|
133
|
+
}
|
134
|
+
}
|
135
|
+
|
136
|
+
client.send_message('Input.dispatchDragEvent', params)
|
137
|
+
end
|
138
|
+
|
139
|
+
# @param [Integer] x_target
|
140
|
+
# @param [Integer] y_target
|
141
|
+
# @return [self]
|
142
|
+
def move_mouse_to(x_target, y_target)
|
143
|
+
params = {
|
144
|
+
type: 'mouseMoved',
|
145
|
+
x: x_target,
|
146
|
+
y: y_target,
|
147
|
+
button: 'none',
|
148
|
+
clickCount: 0,
|
149
|
+
deltaX: 0,
|
150
|
+
deltaY: 0,
|
151
|
+
modifiers: 0,
|
152
|
+
timestamp: (Time.now.to_f * 1000).to_i
|
153
|
+
}
|
154
|
+
|
155
|
+
client.send_message('Input.dispatchMouseEvent', params)
|
156
|
+
|
157
|
+
self
|
70
158
|
end
|
71
159
|
end
|
72
160
|
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'ffi'
|
4
|
+
require 'chromate/helpers'
|
5
|
+
|
6
|
+
module X11
|
7
|
+
extend FFI::Library
|
8
|
+
ffi_lib 'X11'
|
9
|
+
|
10
|
+
# Types
|
11
|
+
typedef :ulong, :Window
|
12
|
+
typedef :pointer, :Display
|
13
|
+
|
14
|
+
# X11 functions
|
15
|
+
attach_function :XOpenDisplay, [:string], :pointer
|
16
|
+
attach_function :XCloseDisplay, [:pointer], :int
|
17
|
+
attach_function :XDefaultRootWindow, [:pointer], :ulong
|
18
|
+
attach_function :XWarpPointer, %i[pointer ulong ulong int int uint uint int int], :int
|
19
|
+
attach_function :XQueryPointer, %i[pointer ulong pointer pointer pointer pointer pointer pointer pointer], :bool
|
20
|
+
attach_function :XFlush, [:pointer], :int
|
21
|
+
attach_function :XQueryTree, %i[pointer ulong pointer pointer pointer pointer], :int
|
22
|
+
attach_function :XFetchName, %i[pointer ulong pointer], :int
|
23
|
+
attach_function :XFree, [:pointer], :int
|
24
|
+
attach_function :XRaiseWindow, %i[pointer ulong], :int
|
25
|
+
attach_function :XSetInputFocus, %i[pointer ulong int ulong], :int
|
26
|
+
|
27
|
+
# Constants
|
28
|
+
REVERT_TO_PARENT = 2
|
29
|
+
end
|
30
|
+
|
31
|
+
module Xtst
|
32
|
+
extend FFI::Library
|
33
|
+
ffi_lib 'Xtst'
|
34
|
+
|
35
|
+
attach_function :XTestFakeButtonEvent, %i[pointer uint int ulong], :int
|
36
|
+
end
|
data/lib/chromate/hardwares.rb
CHANGED
@@ -1,14 +1,20 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'chromate/c_logger'
|
4
|
+
require 'chromate/hardwares/keyboard_controller'
|
4
5
|
require 'chromate/hardwares/mouse_controller'
|
5
6
|
require 'chromate/hardwares/mouses/virtual_controller'
|
7
|
+
require 'chromate/hardwares/keyboards/virtual_controller'
|
6
8
|
require 'chromate/helpers'
|
7
9
|
|
8
10
|
module Chromate
|
9
11
|
module Hardwares
|
10
12
|
extend Helpers
|
11
13
|
|
14
|
+
# @param [Hash] args
|
15
|
+
# @option args [Chromate::Client] :client
|
16
|
+
# @option args [Chromate::Element] :element
|
17
|
+
# @return [Chromate::Hardwares::MouseController]
|
12
18
|
def mouse(**args)
|
13
19
|
browser = args[:client].browser
|
14
20
|
if browser.options[:native_control]
|
@@ -29,5 +35,15 @@ module Chromate
|
|
29
35
|
end
|
30
36
|
end
|
31
37
|
module_function :mouse
|
38
|
+
|
39
|
+
# @param [Hash] args
|
40
|
+
# @option args [Chromate::Client] :client
|
41
|
+
# @option args [Chromate::Element] :element
|
42
|
+
# @return [Chromate::Hardwares::KeyboardController]
|
43
|
+
def keyboard(**args)
|
44
|
+
Chromate::CLogger.log('⌨️ Loading Virtual keyboard controller')
|
45
|
+
Keyboards::VirtualController.new(**args)
|
46
|
+
end
|
47
|
+
module_function :keyboard
|
32
48
|
end
|
33
49
|
end
|
data/lib/chromate/helpers.rb
CHANGED
@@ -1,23 +1,30 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'rbconfig'
|
4
|
-
module Helpers
|
5
|
-
def linux?
|
6
|
-
RbConfig::CONFIG['host_os'] =~ /linux|bsd/i
|
7
|
-
end
|
8
4
|
|
9
|
-
|
10
|
-
|
11
|
-
|
5
|
+
module Chromate
|
6
|
+
module Helpers
|
7
|
+
# @return [Boolean]
|
8
|
+
def linux?
|
9
|
+
RbConfig::CONFIG['host_os'] =~ /linux|bsd/i
|
10
|
+
end
|
12
11
|
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
# @return [Boolean]
|
13
|
+
def mac?
|
14
|
+
RbConfig::CONFIG['host_os'] =~ /darwin/i
|
15
|
+
end
|
16
|
+
|
17
|
+
# @return [Boolean]
|
18
|
+
def windows?
|
19
|
+
RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/i
|
20
|
+
end
|
16
21
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
+
# @return [Integer]
|
23
|
+
def find_available_port
|
24
|
+
server = TCPServer.new('127.0.0.1', 0)
|
25
|
+
port = server.addr[1]
|
26
|
+
server.close
|
27
|
+
port
|
28
|
+
end
|
22
29
|
end
|
23
30
|
end
|
data/lib/chromate/user_agent.rb
CHANGED
@@ -2,26 +2,25 @@
|
|
2
2
|
|
3
3
|
module Chromate
|
4
4
|
class UserAgent
|
5
|
+
# @return [String]
|
5
6
|
def self.call
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36'
|
7
|
+
case os
|
8
|
+
when 'Linux'
|
9
|
+
linux_agent
|
10
|
+
when 'Mac'
|
11
|
+
mac_agent
|
12
|
+
when 'Windows'
|
13
|
+
windows_agent
|
14
|
+
else
|
15
|
+
raise 'Unknown OS'
|
16
|
+
end
|
17
17
|
end
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
def find_os
|
19
|
+
# @return [String<'Mac', 'Linux', 'Windows', 'Unknown'>]
|
20
|
+
def self.os
|
22
21
|
case RUBY_PLATFORM
|
23
22
|
when /darwin/
|
24
|
-
'
|
23
|
+
'Mac'
|
25
24
|
when /linux/
|
26
25
|
'Linux'
|
27
26
|
when /mswin|msys|mingw|cygwin|bccwin|wince|emc/
|
@@ -30,5 +29,30 @@ module Chromate
|
|
30
29
|
'Unknown'
|
31
30
|
end
|
32
31
|
end
|
32
|
+
|
33
|
+
def self.os_version
|
34
|
+
case os
|
35
|
+
when 'Linux'
|
36
|
+
'5.15'
|
37
|
+
when 'Mac'
|
38
|
+
'13.0'
|
39
|
+
when 'Windows'
|
40
|
+
'10.0'
|
41
|
+
else
|
42
|
+
raise 'Unknown OS'
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.linux_agent
|
47
|
+
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36'
|
48
|
+
end
|
49
|
+
|
50
|
+
def self.mac_agent
|
51
|
+
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36'
|
52
|
+
end
|
53
|
+
|
54
|
+
def self.windows_agent
|
55
|
+
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36'
|
56
|
+
end
|
33
57
|
end
|
34
58
|
end
|
data/lib/chromate/version.rb
CHANGED
data/lib/chromate.rb
CHANGED
@@ -6,10 +6,12 @@ require_relative 'chromate/configuration'
|
|
6
6
|
|
7
7
|
module Chromate
|
8
8
|
class << self
|
9
|
+
# @yield [Chromate::Configuration]
|
9
10
|
def configure
|
10
11
|
yield configuration
|
11
12
|
end
|
12
13
|
|
14
|
+
# @return [Chromate::Configuration]
|
13
15
|
def configuration
|
14
16
|
@configuration ||= Configuration.new
|
15
17
|
end
|
data/logo.png
ADDED
Binary file
|
data/results/bot.png
ADDED
Binary file
|
data/results/brotector.png
CHANGED
Binary file
|
data/results/cloudflare.png
CHANGED
Binary file
|
data/results/headers.png
ADDED
Binary file
|
Binary file
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chromate-rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2.pre
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eth3rnit3
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-11-
|
11
|
+
date: 2024-11-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi
|
@@ -54,13 +54,24 @@ files:
|
|
54
54
|
- LICENSE.txt
|
55
55
|
- README.md
|
56
56
|
- Rakefile
|
57
|
+
- docker_root/Gemfile
|
58
|
+
- docker_root/Gemfile.lock
|
59
|
+
- docker_root/TestInDocker.gif
|
60
|
+
- docker_root/app.rb
|
57
61
|
- dockerfiles/Dockerfile
|
62
|
+
- dockerfiles/README.md
|
58
63
|
- dockerfiles/docker-entrypoint.sh
|
64
|
+
- docs/README.md
|
59
65
|
- docs/browser.md
|
66
|
+
- docs/element.md
|
67
|
+
- lib/bot_browser.rb
|
68
|
+
- lib/bot_browser/downloader.rb
|
69
|
+
- lib/bot_browser/installer.rb
|
60
70
|
- lib/chromate.rb
|
61
71
|
- lib/chromate/actions/dom.rb
|
62
72
|
- lib/chromate/actions/navigate.rb
|
63
73
|
- lib/chromate/actions/screenshot.rb
|
74
|
+
- lib/chromate/actions/stealth.rb
|
64
75
|
- lib/chromate/browser.rb
|
65
76
|
- lib/chromate/c_logger.rb
|
66
77
|
- lib/chromate/client.rb
|
@@ -69,15 +80,22 @@ files:
|
|
69
80
|
- lib/chromate/elements/select.rb
|
70
81
|
- lib/chromate/exceptions.rb
|
71
82
|
- lib/chromate/hardwares.rb
|
83
|
+
- lib/chromate/hardwares/keyboard_controller.rb
|
84
|
+
- lib/chromate/hardwares/keyboards/virtual_controller.rb
|
72
85
|
- lib/chromate/hardwares/mouse_controller.rb
|
73
86
|
- lib/chromate/hardwares/mouses/linux_controller.rb
|
74
87
|
- lib/chromate/hardwares/mouses/mac_os_controller.rb
|
75
88
|
- lib/chromate/hardwares/mouses/virtual_controller.rb
|
89
|
+
- lib/chromate/hardwares/mouses/x11.rb
|
76
90
|
- lib/chromate/helpers.rb
|
77
91
|
- lib/chromate/user_agent.rb
|
78
92
|
- lib/chromate/version.rb
|
93
|
+
- logo.png
|
94
|
+
- results/bot.png
|
79
95
|
- results/brotector.png
|
80
96
|
- results/cloudflare.png
|
97
|
+
- results/headers.png
|
98
|
+
- results/pixelscan.png
|
81
99
|
- sig/chromate.rbs
|
82
100
|
homepage: http://github.com/Eth3rnit3/chromate
|
83
101
|
licenses:
|