ronin-web-browser 0.1.0.rc1
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 +7 -0
- data/.document +4 -0
- data/.github/workflows/ruby.yml +51 -0
- data/.gitignore +13 -0
- data/.rspec +1 -0
- data/.rubocop.yml +12 -0
- data/.ruby-version +1 -0
- data/.yardopts +1 -0
- data/COPYING.txt +165 -0
- data/ChangeLog.md +13 -0
- data/Gemfile +32 -0
- data/README.md +186 -0
- data/Rakefile +35 -0
- data/gemspec.yml +28 -0
- data/lib/ronin/web/browser/agent.rb +430 -0
- data/lib/ronin/web/browser/cookie.rb +140 -0
- data/lib/ronin/web/browser/cookie_file.rb +91 -0
- data/lib/ronin/web/browser/version.rb +28 -0
- data/lib/ronin/web/browser.rb +148 -0
- data/ronin-web-browser.gemspec +60 -0
- metadata +109 -0
@@ -0,0 +1,148 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
#
|
3
|
+
# ronin-web-browser - An automated Chrome API.
|
4
|
+
#
|
5
|
+
# Copyright (c) 2022-2024 Hal Brodigan (postmodern.mod3@gmail.com)
|
6
|
+
#
|
7
|
+
# ronin-web-browser is free software: you can redistribute it and/or modify
|
8
|
+
# it under the terms of the GNU Lesser General Public License as published
|
9
|
+
# by the Free Software Foundation, either version 3 of the License, or
|
10
|
+
# (at your option) any later version.
|
11
|
+
#
|
12
|
+
# ronin-web-browser is distributed in the hope that it will be useful,
|
13
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
+
# GNU Lesser General Public License for more details.
|
16
|
+
#
|
17
|
+
# You should have received a copy of the GNU Lesser General Public License
|
18
|
+
# along with ronin-web-browser. If not, see <https://www.gnu.org/licenses/>.
|
19
|
+
#
|
20
|
+
|
21
|
+
require 'ronin/web/browser/agent'
|
22
|
+
require 'ronin/web/browser/version'
|
23
|
+
|
24
|
+
module Ronin
|
25
|
+
module Web
|
26
|
+
#
|
27
|
+
# Automates a Chrome web browser.
|
28
|
+
#
|
29
|
+
# ## Examples
|
30
|
+
#
|
31
|
+
# Initialize a headless browser:
|
32
|
+
#
|
33
|
+
# ```ruby
|
34
|
+
# browser = Ronin::Web::Browser.new
|
35
|
+
# # ...
|
36
|
+
# browser.quit
|
37
|
+
# ```
|
38
|
+
#
|
39
|
+
# Initialize a visible browser:
|
40
|
+
#
|
41
|
+
# ```ruby
|
42
|
+
# browser = Ronin::Web::Browser.new(visible: true)
|
43
|
+
# # ...
|
44
|
+
# browser.quit
|
45
|
+
# ```
|
46
|
+
#
|
47
|
+
# Opening a temporary browser and automatically quitting:
|
48
|
+
#
|
49
|
+
# ```ruby
|
50
|
+
# Ronin::Web::Browser.open do |browser|
|
51
|
+
# # ...
|
52
|
+
# end
|
53
|
+
# ```
|
54
|
+
#
|
55
|
+
# Initializing the browser with a proxy:
|
56
|
+
#
|
57
|
+
# ```ruby
|
58
|
+
# browser = Ronin::Web::Browser.new(proxy: "http://proxy.example.com:8080")
|
59
|
+
# # ...
|
60
|
+
# ```
|
61
|
+
#
|
62
|
+
# Go to and screenshot a webpage:
|
63
|
+
#
|
64
|
+
# ```ruby
|
65
|
+
# Ronin::Web::Browser.open do |browser|
|
66
|
+
# browser.go_to("https://google.com")
|
67
|
+
# browser.screenshot(path: "google.png")
|
68
|
+
# end
|
69
|
+
# ```
|
70
|
+
#
|
71
|
+
# Intercept all requests:
|
72
|
+
#
|
73
|
+
# ```ruby
|
74
|
+
# browser = Ronin::Web::Browser.new
|
75
|
+
# browser.network.intercept
|
76
|
+
# browser.on(:request) do |request|
|
77
|
+
# puts "> #{request.method} #{request.url}"
|
78
|
+
# request.continue
|
79
|
+
# end
|
80
|
+
#
|
81
|
+
# browser.go_to("https://twitter.com/login")
|
82
|
+
# ```
|
83
|
+
#
|
84
|
+
# Intercept all responses for all requests:
|
85
|
+
#
|
86
|
+
# ```ruby
|
87
|
+
# browser = Ronin::Web::Browser.new
|
88
|
+
# browser.on(:response) do |exchange|
|
89
|
+
# puts "> #{exchange.request.method} #{exchange.request.url}"
|
90
|
+
#
|
91
|
+
# puts "< HTTP #{exchange.response.status}"
|
92
|
+
#
|
93
|
+
# exchange.response.headers.each do |name,value|
|
94
|
+
# puts "< #{name}: #{value}"
|
95
|
+
# end
|
96
|
+
#
|
97
|
+
# puts exchange.response.body
|
98
|
+
# end
|
99
|
+
#
|
100
|
+
# browser.go_to("https://twitter.com/login")
|
101
|
+
# ```
|
102
|
+
#
|
103
|
+
# See [ferrum] for additional documentation.
|
104
|
+
#
|
105
|
+
# [ferrum]: https://github.com/rubycdp/ferrum#readme
|
106
|
+
#
|
107
|
+
module Browser
|
108
|
+
#
|
109
|
+
# Initializes the browser agent.
|
110
|
+
#
|
111
|
+
# @param [Hash{Symbol => Object}] kwargs
|
112
|
+
# Keyword arguments for {Agent#initialize}.
|
113
|
+
#
|
114
|
+
# @option kwargs [Boolean] :visible (false)
|
115
|
+
# Controls whether the browser will start in visible or headless mode.
|
116
|
+
#
|
117
|
+
# @option kwargs [Boolean] headless (true)
|
118
|
+
# Controls whether the browser will start in headless or visible mode.
|
119
|
+
#
|
120
|
+
# @option kwargs [String, URI::HTTP, Addressible::URI, Hash, nil] :proxy (Ronin::Support::Network::HTTP.proxy)
|
121
|
+
# The proxy to send all browser requests through.
|
122
|
+
#
|
123
|
+
# @return [Agent]
|
124
|
+
# A new instance of a headless or visible Chrome browser.
|
125
|
+
#
|
126
|
+
def self.new(**kwargs)
|
127
|
+
Agent.new(**kwargs)
|
128
|
+
end
|
129
|
+
|
130
|
+
#
|
131
|
+
# Opens a new browser.
|
132
|
+
#
|
133
|
+
# @yield [browser]
|
134
|
+
# If a block is given, it will be passed the new browser object.
|
135
|
+
# Once the block returns, `quit` will be called on the browser object.
|
136
|
+
#
|
137
|
+
# @yieldparam [Agent] browser
|
138
|
+
# The newly created browser object.
|
139
|
+
#
|
140
|
+
# @return [Agent]
|
141
|
+
# A new instance of a headless or visible Chrome browser.
|
142
|
+
#
|
143
|
+
def self.open(**kwargs,&block)
|
144
|
+
Agent.open(**kwargs,&block)
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'yaml'
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gemspec = YAML.load_file('gemspec.yml')
|
6
|
+
|
7
|
+
gem.name = gemspec.fetch('name')
|
8
|
+
gem.version = gemspec.fetch('version') do
|
9
|
+
lib_dir = File.join(File.dirname(__FILE__),'lib')
|
10
|
+
$LOAD_PATH << lib_dir unless $LOAD_PATH.include?(lib_dir)
|
11
|
+
|
12
|
+
require 'ronin/web/browser/version'
|
13
|
+
Ronin::Web::Browser::VERSION
|
14
|
+
end
|
15
|
+
|
16
|
+
gem.summary = gemspec['summary']
|
17
|
+
gem.description = gemspec['description']
|
18
|
+
gem.licenses = Array(gemspec['license'])
|
19
|
+
gem.authors = Array(gemspec['authors'])
|
20
|
+
gem.email = gemspec['email']
|
21
|
+
gem.homepage = gemspec['homepage']
|
22
|
+
|
23
|
+
glob = ->(patterns) { gem.files & Dir[*patterns] }
|
24
|
+
|
25
|
+
gem.files = `git ls-files`.split($/)
|
26
|
+
gem.files = glob[gemspec['files']] if gemspec['files']
|
27
|
+
gem.files += Array(gemspec['generated_files'])
|
28
|
+
# exclude test files from the packages gem
|
29
|
+
gem.files -= glob[gemspec['test_files'] || 'spec/{**/}*']
|
30
|
+
|
31
|
+
gem.executables = gemspec.fetch('executables') do
|
32
|
+
glob['bin/*'].map { |path| File.basename(path) }
|
33
|
+
end
|
34
|
+
|
35
|
+
gem.extensions = glob[gemspec['extensions'] || 'ext/**/extconf.rb']
|
36
|
+
gem.extra_rdoc_files = glob[gemspec['extra_doc_files'] || '*.{txt,md}']
|
37
|
+
|
38
|
+
gem.require_paths = Array(gemspec.fetch('require_paths') {
|
39
|
+
%w[ext lib].select { |dir| File.directory?(dir) }
|
40
|
+
})
|
41
|
+
|
42
|
+
gem.requirements = gemspec['requirements']
|
43
|
+
gem.required_ruby_version = gemspec['required_ruby_version']
|
44
|
+
gem.required_rubygems_version = gemspec['required_rubygems_version']
|
45
|
+
gem.post_install_message = gemspec['post_install_message']
|
46
|
+
|
47
|
+
split = ->(string) { string.split(/,\s*/) }
|
48
|
+
|
49
|
+
if gemspec['dependencies']
|
50
|
+
gemspec['dependencies'].each do |name,versions|
|
51
|
+
gem.add_dependency(name,split[versions])
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
if gemspec['development_dependencies']
|
56
|
+
gemspec['development_dependencies'].each do |name,versions|
|
57
|
+
gem.add_development_dependency(name,split[versions])
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
metadata
ADDED
@@ -0,0 +1,109 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ronin-web-browser
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0.rc1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Postmodern
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2024-06-23 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: ronin-support
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: ferrum
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.13'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.13'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.0'
|
55
|
+
description: |
|
56
|
+
ronin-web-browser is a Ruby library for automating the Chrome web browser.
|
57
|
+
ronin-web-browser builds on the ferrum gem, and adds additional API methods
|
58
|
+
that are useful to security researchers.
|
59
|
+
email: postmodern.mod3@gmail.com
|
60
|
+
executables: []
|
61
|
+
extensions: []
|
62
|
+
extra_rdoc_files:
|
63
|
+
- COPYING.txt
|
64
|
+
- ChangeLog.md
|
65
|
+
- README.md
|
66
|
+
files:
|
67
|
+
- ".document"
|
68
|
+
- ".github/workflows/ruby.yml"
|
69
|
+
- ".gitignore"
|
70
|
+
- ".rspec"
|
71
|
+
- ".rubocop.yml"
|
72
|
+
- ".ruby-version"
|
73
|
+
- ".yardopts"
|
74
|
+
- COPYING.txt
|
75
|
+
- ChangeLog.md
|
76
|
+
- Gemfile
|
77
|
+
- README.md
|
78
|
+
- Rakefile
|
79
|
+
- gemspec.yml
|
80
|
+
- lib/ronin/web/browser.rb
|
81
|
+
- lib/ronin/web/browser/agent.rb
|
82
|
+
- lib/ronin/web/browser/cookie.rb
|
83
|
+
- lib/ronin/web/browser/cookie_file.rb
|
84
|
+
- lib/ronin/web/browser/version.rb
|
85
|
+
- ronin-web-browser.gemspec
|
86
|
+
homepage: https://ronin-rb.dev/
|
87
|
+
licenses:
|
88
|
+
- LGPL-3.0
|
89
|
+
metadata: {}
|
90
|
+
post_install_message:
|
91
|
+
rdoc_options: []
|
92
|
+
require_paths:
|
93
|
+
- lib
|
94
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - ">="
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: 3.0.0
|
99
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
requirements: []
|
105
|
+
rubygems_version: 3.3.27
|
106
|
+
signing_key:
|
107
|
+
specification_version: 4
|
108
|
+
summary: A Ruby library for automating the Chrome web browser
|
109
|
+
test_files: []
|