ruby_smb 1.0.4 → 1.0.5
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
- checksums.yaml.gz.sig +0 -0
- data/lib/ruby_smb/smb1/packet/empty_packet.rb +4 -2
- data/lib/ruby_smb/smb2/packet/error_packet.rb +11 -4
- data/lib/ruby_smb/version.rb +1 -1
- data/spec/lib/ruby_smb/smb1/packet/empty_packet_spec.rb +10 -0
- data/spec/lib/ruby_smb/smb2/packet/error_packet_spec.rb +50 -2
- data.tar.gz.sig +0 -0
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 104c5f0cf4f597bf65427cf15ab08461943a38aa
|
4
|
+
data.tar.gz: e2f05f2857a898cd253afd829babecb715011c12
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5070ad2e2008739b1b47407c618e0014bc98e7031d72d2cb94daf61c7d21754a8480ef37f8099f90fe31ef0ac95563943951d00ad4bcea110d465c80c6fcf0f8
|
7
|
+
data.tar.gz: eb91ae8bff05249dc9ec88c3fa9e18df4b8db979d9e7e9ac702c6f7af237b36c39d9d420dd0e95680e4004480dede90493fc6d58f942f45d08d3a812977a4066
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module RubySMB
|
2
2
|
module SMB1
|
3
3
|
module Packet
|
4
|
-
# This packet represent an SMB1 Response Packet when the parameter and
|
4
|
+
# This packet represent an SMB1 Error Response Packet when the parameter and
|
5
5
|
# data blocks will be empty.
|
6
6
|
class EmptyPacket < RubySMB::GenericPacket
|
7
7
|
attr_accessor :original_command
|
@@ -12,7 +12,9 @@ module RubySMB
|
|
12
12
|
|
13
13
|
def valid?
|
14
14
|
return smb_header.protocol == RubySMB::SMB1::SMB_PROTOCOL_ID &&
|
15
|
-
|
15
|
+
smb_header.command == @original_command &&
|
16
|
+
parameter_block.word_count == 0 &&
|
17
|
+
data_block.byte_count == 0
|
16
18
|
end
|
17
19
|
end
|
18
20
|
end
|
@@ -1,18 +1,25 @@
|
|
1
1
|
module RubySMB
|
2
2
|
module SMB2
|
3
3
|
module Packet
|
4
|
-
#
|
4
|
+
# This class represents an SMB2 Error Response Packet as defined in
|
5
|
+
# [2.2.2 SMB2 ERROR Response](https://msdn.microsoft.com/en-us/library/cc246530.aspx)
|
5
6
|
class ErrorPacket < RubySMB::GenericPacket
|
6
7
|
attr_accessor :original_command
|
7
8
|
|
8
9
|
endian :little
|
9
10
|
smb2_header :smb2_header
|
10
|
-
uint16 :structure_size,
|
11
|
-
uint8 :
|
11
|
+
uint16 :structure_size, label: 'Structure Size', initial_value: 9
|
12
|
+
uint8 :error_context_count, label: 'ErrorContextCount'
|
13
|
+
uint8 :reserved
|
14
|
+
uint32 :byte_count, label: 'Byte Count of ErrorData',
|
15
|
+
initial_value: -> { error_data.num_bytes == 1 ? 0 : error_data.num_bytes }
|
16
|
+
string :error_data, label: 'Error Data', initial_value: "\x00",
|
17
|
+
read_length: -> { byte_count == 0 ? 1 : byte_count }
|
12
18
|
|
13
19
|
def valid?
|
14
20
|
return smb2_header.protocol == RubySMB::SMB2::SMB2_PROTOCOL_ID &&
|
15
|
-
|
21
|
+
smb2_header.command == @original_command &&
|
22
|
+
structure_size == 9
|
16
23
|
end
|
17
24
|
end
|
18
25
|
end
|
data/lib/ruby_smb/version.rb
CHANGED
@@ -54,5 +54,15 @@ RSpec.describe RubySMB::SMB1::Packet::EmptyPacket do
|
|
54
54
|
packet.smb_header.command = RubySMB::SMB1::Commands::SMB_COM_NEGOTIATE
|
55
55
|
expect(packet).to_not be_valid
|
56
56
|
end
|
57
|
+
|
58
|
+
it 'returns false if the packet parameter block size is not 0' do
|
59
|
+
packet.parameter_block.word_count = 10
|
60
|
+
expect(packet).to_not be_valid
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'returns false if the packet data block size is not 0' do
|
64
|
+
packet.data_block.byte_count = 10
|
65
|
+
expect(packet).to_not be_valid
|
66
|
+
end
|
57
67
|
end
|
58
68
|
end
|
@@ -19,11 +19,54 @@ RSpec.describe RubySMB::SMB2::Packet::ErrorPacket do
|
|
19
19
|
it 'should be a 16-bit unsigned integer' do
|
20
20
|
expect(packet.structure_size).to be_a BinData::Uint16le
|
21
21
|
end
|
22
|
+
|
23
|
+
it 'should be 9 by default' do
|
24
|
+
expect(packet.structure_size).to eq 9
|
25
|
+
end
|
22
26
|
end
|
23
27
|
|
24
|
-
describe '#
|
28
|
+
describe '#error_context_count' do
|
25
29
|
it 'should be a 8-bit unsigned integer' do
|
26
|
-
expect(packet.
|
30
|
+
expect(packet.error_context_count).to be_a BinData::Uint8
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe '#byte_count' do
|
35
|
+
it 'should be a 32-bit unsigned integer' do
|
36
|
+
expect(packet.byte_count).to be_a BinData::Uint32le
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'should be the number of bytes in #error_data' do
|
40
|
+
str = 'testing'
|
41
|
+
packet.error_data = str
|
42
|
+
expect(packet.byte_count).to eq str.size
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'should be 0 when #error_data is 1-byte long' do
|
46
|
+
packet.error_data = "\x00"
|
47
|
+
expect(packet.byte_count).to eq 0
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe '#error_data' do
|
52
|
+
it 'should be a String' do
|
53
|
+
expect(packet.error_data).to be_a BinData::String
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'should be \x00 by default' do
|
57
|
+
expect(packet.error_data).to eq "\x00"
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'should read 1 byte when #byte_count is 0' do
|
61
|
+
packet.error_data = 'test'
|
62
|
+
packet.byte_count = 0
|
63
|
+
expect(described_class.read(packet.to_binary_s).error_data.size).to eq 1
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'should read #byte_count bytes when #byte_count is not 0' do
|
67
|
+
packet.error_data = 'test'
|
68
|
+
packet.byte_count = 4
|
69
|
+
expect(described_class.read(packet.to_binary_s).error_data.size).to eq 4
|
27
70
|
end
|
28
71
|
end
|
29
72
|
|
@@ -46,6 +89,11 @@ RSpec.describe RubySMB::SMB2::Packet::ErrorPacket do
|
|
46
89
|
packet.smb2_header.command = RubySMB::SMB2::Commands::NEGOTIATE
|
47
90
|
expect(packet).to_not be_valid
|
48
91
|
end
|
92
|
+
|
93
|
+
it 'returns false if the packet #structure_size is wrong' do
|
94
|
+
packet.structure_size = 10
|
95
|
+
expect(packet).to_not be_valid
|
96
|
+
end
|
49
97
|
end
|
50
98
|
end
|
51
99
|
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_smb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Maloney
|
@@ -91,7 +91,7 @@ cert_chain:
|
|
91
91
|
G+Hmcg1v810agasPdoydE0RTVZgEOOMoQ07qu7JFXVWZ9ZQpHT7qJATWL/b2csFG
|
92
92
|
8mVuTXnyJOKRJA==
|
93
93
|
-----END CERTIFICATE-----
|
94
|
-
date: 2018-
|
94
|
+
date: 2018-10-25 00:00:00.000000000 Z
|
95
95
|
dependencies:
|
96
96
|
- !ruby/object:Gem::Dependency
|
97
97
|
name: redcarpet
|
metadata.gz.sig
CHANGED
Binary file
|