ruby-vnc 1.2.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9b9252091b18c38896b7f1e8ee618dc77c1848c471c6f4eec36c9a2831b70640
4
- data.tar.gz: d8599868187fa9f97649b68ded844306534609a9a9606bf022a629ab2174df1d
3
+ metadata.gz: 35b783e130f4558de029290d6987e7de00d69698852e9f042d35a9399356dcee
4
+ data.tar.gz: 65c200c7306c747e47a68b7ff122d26d3343b92da667f03686f0788e6e771de2
5
5
  SHA512:
6
- metadata.gz: e671beb2f0319145b5c1f930c02245026adef5ef81accaf2530b42c25e5cca5bc996c4c67445d3c308a8b012c579bd49f4899633f0e42093921d4396aa594c54
7
- data.tar.gz: eae517b3eb5295687fad89289ca0c3ca9067d12e3264c91057a9430ebc782d1a6f1b72ae8fdf94adac5e94e2f4abc786c14a4ce3483d2f2e08cb84e0207a95b8
6
+ metadata.gz: a19834bbdb4a03be6f4ab370b887b9d964a50b228e68b9c227a9819f83b7bceba54c241b18888bbe1e3a05a76275200f8d9e0dcffb31cb3862b688181ceb3280
7
+ data.tar.gz: 59f26fef289eacd35cd4c0c3dfdd67499910f3726b251f06e7ddda32178f8e2e28b58648b04f279c1e26b6e8229e42c5e1e1bcec04f70d12cadb05108bcff41b
data/Changelog.rdoc CHANGED
@@ -1,5 +1,14 @@
1
1
  == Unreleased:
2
2
 
3
+ N/A
4
+
5
+ == 1.3.0 / 2023-10-30
6
+
7
+ - Got rid of DES, it's no longer properly supported without nasty hacks. If
8
+ you need security, wrap your connection over SSH or SSL.
9
+ - Updated ChunkyPNG.
10
+ - Require Ruby 3.0.0 or newer.
11
+
3
12
  == 1.2.0 / 2021-09-21
4
13
 
5
14
  - Replaced DES-algorithm with Ruby's built-in OpenSSL wrapper instead
@@ -1,5 +1,5 @@
1
1
  module Net
2
2
  class VNC
3
- VERSION = '1.2.0'.freeze
3
+ VERSION = '1.3.0'.freeze
4
4
  end
5
5
  end
data/lib/net/vnc.rb CHANGED
@@ -1,6 +1,5 @@
1
1
  require 'socket'
2
2
  require 'yaml'
3
- require 'cipher/vncdes'
4
3
  require 'net/vnc/version'
5
4
 
6
5
  module Net
@@ -13,7 +12,7 @@ module Net
13
12
  # # launch xclock on localhost. note that there is an xterm in the top-left
14
13
  #
15
14
  # require 'net/vnc'
16
- # Net::VNC.open 'localhost:0', :shared => true, :password => 'mypass' do |vnc|
15
+ # Net::VNC.open 'localhost:0', :shared => true do |vnc|
17
16
  # vnc.pointer_move 10, 10
18
17
  # vnc.type 'xclock'
19
18
  # vnc.key_press :return
@@ -124,12 +123,7 @@ module Net
124
123
  when 1
125
124
  # ok...
126
125
  when 2
127
- password = @options[:password] or raise 'Need to authenticate but no password given'
128
- challenge = socket.read CHALLENGE_SIZE
129
- response = Cipher::VNCDES.new(password).encrypt(challenge)
130
- socket.write response
131
- ok = socket.read(4).to_s.unpack1('N')
132
- raise 'Unable to authenticate - %p' % ok unless ok == 0
126
+ raise 'Unable to authenticate - DES no longer supported'
133
127
  else
134
128
  raise 'Unknown authentication scheme - %d' % auth
135
129
  end
@@ -2,7 +2,6 @@ require 'spec_helper'
2
2
  require 'net/vnc'
3
3
 
4
4
  NO_AUTH_SERVER_DISPLAY = ':1'.freeze
5
- WITH_AUTH_SERVER_DISPLAY = ':2'.freeze
6
5
 
7
6
  RSpec.describe Net::VNC do
8
7
  context 'no auth' do
@@ -26,29 +25,6 @@ RSpec.describe Net::VNC do
26
25
  end
27
26
  end
28
27
 
29
- context 'with auth' do
30
- it 'should connect with a password' do
31
- Net::VNC.open(WITH_AUTH_SERVER_DISPLAY, password: 'matzisnicesowearenice') do |vnc|
32
- vnc.pointer_move(10, 15)
33
- expect(vnc.pointer.x).to eq 10
34
- expect(vnc.pointer.y).to eq 15
35
- end
36
- end
37
-
38
- it 'should give error with a wrong password' do
39
- expect do
40
- Net::VNC.open(WITH_AUTH_SERVER_DISPLAY,
41
- password: 'wrongPasssword')
42
- end.to raise_error(RuntimeError, 'Unable to authenticate - 1')
43
- end
44
-
45
- it 'should give error with no password' do
46
- expect do
47
- Net::VNC.open(WITH_AUTH_SERVER_DISPLAY)
48
- end.to raise_error(RuntimeError, 'Need to authenticate but no password given')
49
- end
50
- end
51
-
52
28
  context 'screenshotting' do
53
29
  def verify_screenshot(input)
54
30
  image_size = ImageSize.path(input)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-vnc
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Charles Lowe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-21 00:00:00.000000000 Z
11
+ date: 2023-10-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chunky_png
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.3.0
19
+ version: 1.4.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 1.3.0
26
+ version: 1.4.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: vncrec
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -107,12 +107,9 @@ files:
107
107
  - README.rdoc
108
108
  - Rakefile
109
109
  - data/keys.yaml
110
- - lib/cipher/vncdes.rb
111
110
  - lib/net/rfb/frame_buffer.rb
112
111
  - lib/net/vnc.rb
113
112
  - lib/net/vnc/version.rb
114
- - spec/cipher_vncdes_spec.rb
115
- - spec/net_vnc_spec.rb
116
113
  - spec/real_net_vnc_spec.rb
117
114
  homepage: https://github.com/kaspergrubbe/ruby-vnc
118
115
  licenses:
@@ -132,14 +129,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
132
129
  requirements:
133
130
  - - ">="
134
131
  - !ruby/object:Gem::Version
135
- version: 2.5.0
132
+ version: 3.0.0
136
133
  required_rubygems_version: !ruby/object:Gem::Requirement
137
134
  requirements:
138
135
  - - ">="
139
136
  - !ruby/object:Gem::Version
140
137
  version: '0'
141
138
  requirements: []
142
- rubygems_version: 3.2.3
139
+ rubygems_version: 3.4.10
143
140
  signing_key:
144
141
  specification_version: 4
145
142
  summary: Ruby VNC library.
data/lib/cipher/vncdes.rb DELETED
@@ -1,54 +0,0 @@
1
- require 'openssl'
2
-
3
- # MIT-licensed code by Andrew Dorofeyev
4
- # from https://github.com/d-theus/vncrec-ruby
5
-
6
- # The server sends a random 16-byte challenge:
7
- #
8
- # +--------------+--------------+-------------+
9
- # | No. of bytes | Type [Value] | Description |
10
- # +--------------+--------------+-------------+
11
- # | 16 | U8 | challenge |
12
- # +--------------+--------------+-------------+
13
- #
14
- # The client encrypts the challenge with DES (ECB), using a password supplied
15
- # by the user as the key. To form the key, the password is truncated
16
- # to eight characters, or padded with null bytes on the right.
17
- # Actually, each byte is also reversed. Challenge string is split
18
- # in two chunks of 8 bytes, which are encrypted separately and clashed together
19
- # again. The client then sends the resulting 16-byte response:
20
- #
21
- # +--------------+--------------+-------------+
22
- # | No. of bytes | Type [Value] | Description |
23
- # +--------------+--------------+-------------+
24
- # | 16 | U8 | response |
25
- # +--------------+--------------+-------------+
26
- #
27
- # The protocol continues with the SecurityResult message.
28
-
29
- module Cipher
30
- class VNCDES
31
- attr_reader :key
32
-
33
- def initialize(key)
34
- @key = normalized(key[0..7])
35
- self
36
- end
37
-
38
- def encrypt(challenge)
39
- chunks = [challenge.slice(0, 8), challenge.slice(8, 8)]
40
- cipher = OpenSSL::Cipher::DES.new(:ECB)
41
- cipher.encrypt
42
- cipher.key = key
43
- chunks.reduce('') { |a, e| cipher.reset; a << cipher.update(e) }.force_encoding('UTF-8')
44
- end
45
-
46
- private
47
-
48
- def normalized(key)
49
- rev = ->(n) { (0...8).reduce(0) { |a, e| a + 2**e * n[7 - e] } }
50
- inv = key.each_byte.map { |b| rev[b].chr }.join
51
- inv.ljust(8, "\x00")
52
- end
53
- end
54
- end
@@ -1,22 +0,0 @@
1
- require 'spec_helper'
2
- require 'cipher/vncdes'
3
-
4
- RSpec.describe Cipher::VNCDES do
5
- it 'should pad key with zeroes if key is shorter than 8 characters' do
6
- key = Cipher::VNCDES.new('test').key
7
-
8
- expect(key.size).to eq 8
9
- expect(key[4..7]).to eq(0.chr * 4)
10
- end
11
-
12
- it 'should cut the key if the key is longer than 8 characters' do
13
- expect(Cipher::VNCDES.new('iamdefinitelylongerthan8characters').key.size).to eq 8
14
- end
15
-
16
- it 'should correctly encrypt keys' do
17
- encrypted_string = Cipher::VNCDES.new('matzisnicesowearenice').encrypt("\x9D\xBBU\n\x05b\x96L \b'&\x18\xCE(\xD8")
18
- expect(encrypted_string.encoding.to_s).to eq 'UTF-8'
19
- expect(encrypted_string.size).to eq 16
20
- expect(encrypted_string).to eq "2\x95\xA7\xAE\xD4A\xF3\xDCt\x82d\e\xAE\x8A\xB9c"
21
- end
22
- end
data/spec/net_vnc_spec.rb DELETED
@@ -1,133 +0,0 @@
1
- require 'spec_helper'
2
- require 'net/vnc'
3
-
4
- # class SocketMock
5
- # class MockIOError < IOError
6
- # end
7
- #
8
- # def initialize
9
- # # this can be used to make detailed assertions
10
- # @trace = []
11
- # @read_buf = ''
12
- # @write_buf = ''
13
- # end
14
- #
15
- # def read len
16
- # @trace << [:read, len]
17
- # if @read_buf.length < len
18
- # msg = 'bad socket read sequence - read(%d) but only %d byte(s) available' % [len, @read_buf.length]
19
- # raise MockIOError, msg
20
- # end
21
- # @read_buf.slice! 0, len
22
- # end
23
- #
24
- # def write data
25
- # @trace << [:write, data]
26
- # @write_buf << data
27
- # end
28
- # end
29
- #
30
- # class VNCServerSocketMock < SocketMock
31
- # TICK_TIME = 0.1
32
- #
33
- # def initialize(&block)
34
- # super
35
- #
36
- # @pending_read = nil
37
- # obj = self
38
- # @t = Thread.new { block.call obj; @pending_read = nil }
39
- # 100.times do |i|
40
- # break if @pending_read
41
- # if i == 99
42
- # msg = 'blah'
43
- # raise MockIOError, msg
44
- # end
45
- # sleep TICK_TIME
46
- # end
47
- # end
48
- #
49
- # def run
50
- # yield
51
- # 100.times do |i|
52
- # break unless @pending_read
53
- # if i == 99
54
- # msg = 'missing socket write sequence'
55
- # raise MockIOError, msg
56
- # end
57
- # sleep TICK_TIME
58
- # end
59
- # raise 'wrote to much' if @write_buf.length != 0
60
- # raise 'did not read enough' if @read_buf.length != 0
61
- # end
62
- #
63
- # def read len
64
- # @trace << [:read, len]
65
- # 100.times do |i|
66
- # break if @read_buf.length >= len
67
- # if i == 99
68
- # msg = 'timeout during socket read sequence - read(%d) but only %d byte(s) available' % [len, @read_buf.length]
69
- # raise MockIOError, msg
70
- # end
71
- # sleep TICK_TIME
72
- # end
73
- # @read_buf.slice! 0, len
74
- # end
75
- #
76
- # def write data
77
- # unless @read_buf.empty?
78
- # raise MockIOError, 'tried to write with non empty read buffer - (%p, %p)' % [@read_buf, data]
79
- # end
80
- # super
81
- # if !@pending_read
82
- # raise MockIOError, "wrote to socket but server is not expecting it"
83
- # end
84
- # if @write_buf.length >= @pending_read
85
- # @pending_read = @write_buf.slice!(0, @pending_read)
86
- # sleep TICK_TIME while @pending_read.is_a? String
87
- # end
88
- # end
89
- #
90
- # def provide_data data
91
- # @read_buf << data
92
- # end
93
- #
94
- # def expect_data len
95
- # @pending_read = len
96
- # sleep TICK_TIME while @pending_read.is_a? Fixnum
97
- # @pending_read
98
- # end
99
- # end
100
- #
101
- # describe 'Net::VNC' do
102
- # VNC = Net::VNC
103
- #
104
- # it 'should do something' do
105
- # =begin
106
- # socket_mock.should_receive(:read).once.ordered.with(12).and_return("RFB 003.003\n")
107
- # socket_mock.should_receive(:write).once.ordered.with(/^RFB (\d{3}.\d{3})\n$/)
108
- # socket_mock.should_receive(:read).once.ordered.with(4).and_return([1].pack('N'))
109
- # socket_mock.should_receive(:write).once.ordered.with("\000")
110
- # socket_mock.should_receive(:read).once.ordered.with(20).and_return('')
111
- # socket_mock.should_receive(:read).once.ordered.with(4).and_return([0].pack('N'))
112
- # #m = mock('my mock')
113
- # #m.should_receive(:test1).ordered.once.with('argument').and_return(1)
114
- # #m.should_receive(:test2).ordered.once.with('argument').and_return(2)
115
- # #p m.test1('argument')
116
- # #p m.test2('argument')
117
- # vnc = VNC.open('192.168.0.1:0')
118
- #=end
119
- #
120
- # server = VNCServerSocketMock.new do |s|
121
- # s.provide_data "RFB 003.003\n"
122
- # p :read => s.expect_data(12)
123
- # s.provide_data [1].pack('N')
124
- # p :read => s.expect_data(1)
125
- # s.provide_data ' ' * 20
126
- # s.provide_data [0].pack('N')
127
- # end
128
- # server.run do
129
- # TCPSocket.should_receive(:open).with('192.168.0.1', 5900).and_return(server)
130
- # vnc = VNC.open('192.168.0.1:0')
131
- # end
132
- # end
133
- # end