shelenium 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +21 -0
  3. data/lib/shelenium.rb +64 -0
  4. data/shelenium.gemspec +15 -0
  5. metadata +75 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e41468ba2e53e30082ca2ed28b6473bc0cc582b9
4
+ data.tar.gz: 740fece0aed09bfc95c10c0a16c0b3d141226e21
5
+ SHA512:
6
+ metadata.gz: 409294bb4d47a759e69695da0d1128773db880014f5f77f21a31fb68b037932cdfe82e5c5623c263241a584a91e358f0d3516dae5c9e1e528e8e163a598de9bf
7
+ data.tar.gz: a0644d6a0e905a20f653a9e9a0d5f95c29a2f82b074cddc3c5f785835de9232ed5d6d177bbd03f82aecfb7fe8cda456e92de7d7e2449555f97ac4ec3fb0a7498
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 Victor Maslov
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/lib/shelenium.rb ADDED
@@ -0,0 +1,64 @@
1
+ module Shelenium
2
+
3
+ @@browser
4
+ def self.new
5
+ begin
6
+ # this archive was repacked from Chrome Store on 17 Oct 2021
7
+ require "tempfile"
8
+ tempfile = Tempfile.new "secure_shell.zip"
9
+ require "open-uri"
10
+ File.binwrite tempfile, (Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.5") ? Kernel : URI).open("http://md5.nakilon.pro/0f83810b3b3fb1978db3803dee52ac5e", &:read)
11
+ require "zip"
12
+ Zip::File.open tempfile do |zipfile|
13
+ zipfile.each do |entry|
14
+ "iodihamcpbpeioajjeobimgagajmlibd/#{File.dirname entry.name}".tap do |dir|
15
+ FileUtils.mkdir_p dir
16
+ zipfile.extract entry, "iodihamcpbpeioajjeobimgagajmlibd/#{entry.name}"
17
+ end
18
+ end
19
+ end
20
+ ensure
21
+ tempfile.close
22
+ tempfile.unlink
23
+ end unless File.exist? "iodihamcpbpeioajjeobimgagajmlibd"
24
+ require "ferrum"
25
+ @@browser = Ferrum::Browser.new( headless: false, browser_options: {
26
+ "disable-extensions-except" => "#{File.expand_path Dir.pwd}/iodihamcpbpeioajjeobimgagajmlibd/0.43_0",
27
+ "load-extension" => "#{File.expand_path Dir.pwd}/iodihamcpbpeioajjeobimgagajmlibd/0.43_0",
28
+ } ).tap do |browser|
29
+ browser.go_to "chrome://extensions/?id=iodihamcpbpeioajjeobimgagajmlibd"
30
+ browser.evaluate("document.getElementsByTagName('extensions-manager')[0].shadowRoot.querySelector('extensions-detail-view').shadowRoot.querySelector('#allow-incognito').shadowRoot.querySelector('[role=button]')").click
31
+ sleep 1
32
+ end
33
+ end
34
+
35
+ def self.connect_and_cd dir
36
+ wait_to_find_xpath = lambda do |selector, timeout: 2, &block|
37
+ Timeout.timeout(timeout) do
38
+ sleep 0.1 until found = (block ? block.call : br).at_xpath(selector)
39
+ found
40
+ end
41
+ end
42
+ @@browser.go_to "chrome-extension://iodihamcpbpeioajjeobimgagajmlibd/html/nassh.html##{ENV.fetch "USER"}@localhost"
43
+ wait_to_find_xpath.call("//*[*[contains(text(),'fingerprint')]]//input"){ @@browser.frames.last }.type("yes\n")
44
+ @@browser.execute "window.removeEventListener('beforeunload', nassh_.onBeforeUnload_)"
45
+ wait_to_find_xpath.call("//*[*[contains(text(),'Password')]]//input"){ @@browser.frames.last }.type("#{ENV.fetch "SHELENIUM_PASSWORD"}\n")
46
+ @@browser.keyboard.type "cd #{Shellwords.escape File.expand_path dir}\n"
47
+ end
48
+
49
+ def self.get_current_lines
50
+ @@browser.evaluate("term_.getRowsText(0, term_.getRowCount())").split("\n")
51
+ end
52
+
53
+ def self.wait_for_still_frame wait_time = 2, freeze_time = 1
54
+ Timeout.timeout wait_time do
55
+ frames = []
56
+ until frames.last(freeze_time * 10).size == freeze_time * 10 && frames.last(freeze_time * 10).uniq.size == 1
57
+ sleep 0.1
58
+ frames.push get_current_lines
59
+ end
60
+ frames.last
61
+ end
62
+ end
63
+
64
+ end
data/shelenium.gemspec ADDED
@@ -0,0 +1,15 @@
1
+ Gem::Specification.new do |spec|
2
+ spec.name = "shelenium"
3
+ spec.version = "0.0.0"
4
+ spec.summary = "Access and test terminal session like a table of chars."
5
+
6
+ spec.author = "Victor Maslov aka Nakilon"
7
+ spec.email = "nakilon@gmail.com"
8
+ spec.license = "MIT"
9
+ spec.metadata = {"source_code_uri" => "https://github.com/nakilon/shelenium"}
10
+
11
+ spec.add_dependency "ferrum"
12
+ spec.add_dependency "rubyzip"
13
+
14
+ spec.files = %w{ LICENSE shelenium.gemspec lib/shelenium.rb }
15
+ end
metadata ADDED
@@ -0,0 +1,75 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: shelenium
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Victor Maslov aka Nakilon
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-10-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: ferrum
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rubyzip
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description:
42
+ email: nakilon@gmail.com
43
+ executables: []
44
+ extensions: []
45
+ extra_rdoc_files: []
46
+ files:
47
+ - LICENSE
48
+ - lib/shelenium.rb
49
+ - shelenium.gemspec
50
+ homepage:
51
+ licenses:
52
+ - MIT
53
+ metadata:
54
+ source_code_uri: https://github.com/nakilon/shelenium
55
+ post_install_message:
56
+ rdoc_options: []
57
+ require_paths:
58
+ - lib
59
+ required_ruby_version: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
64
+ required_rubygems_version: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ requirements: []
70
+ rubyforge_project:
71
+ rubygems_version: 2.5.2.3
72
+ signing_key:
73
+ specification_version: 4
74
+ summary: Access and test terminal session like a table of chars.
75
+ test_files: []