ruby_smb 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/ruby_smb/client.rb +26 -4
- data/lib/ruby_smb/client/authentication.rb +43 -25
- data/lib/ruby_smb/client/echo.rb +20 -2
- data/lib/ruby_smb/client/negotiation.rb +27 -12
- data/lib/ruby_smb/client/tree_connect.rb +20 -14
- data/lib/ruby_smb/error.rb +40 -1
- data/lib/ruby_smb/generic_packet.rb +33 -4
- data/lib/ruby_smb/smb1/dcerpc.rb +7 -2
- data/lib/ruby_smb/smb1/file.rb +60 -11
- data/lib/ruby_smb/smb1/packet/close_request.rb +2 -5
- data/lib/ruby_smb/smb1/packet/close_response.rb +2 -1
- data/lib/ruby_smb/smb1/packet/echo_request.rb +2 -4
- data/lib/ruby_smb/smb1/packet/echo_response.rb +2 -1
- data/lib/ruby_smb/smb1/packet/empty_packet.rb +7 -0
- data/lib/ruby_smb/smb1/packet/logoff_request.rb +2 -4
- data/lib/ruby_smb/smb1/packet/logoff_response.rb +2 -1
- data/lib/ruby_smb/smb1/packet/negotiate_request.rb +2 -5
- data/lib/ruby_smb/smb1/packet/negotiate_response.rb +3 -7
- data/lib/ruby_smb/smb1/packet/negotiate_response_extended.rb +4 -4
- data/lib/ruby_smb/smb1/packet/nt_create_andx_request.rb +2 -4
- data/lib/ruby_smb/smb1/packet/nt_create_andx_response.rb +2 -1
- data/lib/ruby_smb/smb1/packet/nt_trans/create_request.rb +2 -1
- data/lib/ruby_smb/smb1/packet/nt_trans/create_response.rb +2 -1
- data/lib/ruby_smb/smb1/packet/nt_trans/request.rb +2 -4
- data/lib/ruby_smb/smb1/packet/nt_trans/response.rb +2 -1
- data/lib/ruby_smb/smb1/packet/read_andx_request.rb +2 -5
- data/lib/ruby_smb/smb1/packet/read_andx_response.rb +2 -1
- data/lib/ruby_smb/smb1/packet/session_setup_legacy_request.rb +2 -1
- data/lib/ruby_smb/smb1/packet/session_setup_legacy_response.rb +2 -1
- data/lib/ruby_smb/smb1/packet/session_setup_request.rb +2 -5
- data/lib/ruby_smb/smb1/packet/session_setup_response.rb +2 -1
- data/lib/ruby_smb/smb1/packet/trans/peek_nmpipe_request.rb +0 -1
- data/lib/ruby_smb/smb1/packet/trans/peek_nmpipe_response.rb +3 -2
- data/lib/ruby_smb/smb1/packet/trans/request.rb +2 -5
- data/lib/ruby_smb/smb1/packet/trans/response.rb +2 -1
- data/lib/ruby_smb/smb1/packet/trans/transact_nmpipe_request.rb +1 -1
- data/lib/ruby_smb/smb1/packet/trans/transact_nmpipe_response.rb +1 -1
- data/lib/ruby_smb/smb1/packet/trans2/find_first2_request.rb +2 -1
- data/lib/ruby_smb/smb1/packet/trans2/find_first2_response.rb +8 -2
- data/lib/ruby_smb/smb1/packet/trans2/find_next2_request.rb +2 -1
- data/lib/ruby_smb/smb1/packet/trans2/find_next2_response.rb +8 -2
- data/lib/ruby_smb/smb1/packet/trans2/open2_request.rb +2 -1
- data/lib/ruby_smb/smb1/packet/trans2/open2_response.rb +2 -1
- data/lib/ruby_smb/smb1/packet/trans2/request.rb +2 -4
- data/lib/ruby_smb/smb1/packet/trans2/request_secondary.rb +2 -4
- data/lib/ruby_smb/smb1/packet/trans2/response.rb +2 -1
- data/lib/ruby_smb/smb1/packet/trans2/set_file_information_request.rb +2 -1
- data/lib/ruby_smb/smb1/packet/trans2/set_file_information_response.rb +2 -1
- data/lib/ruby_smb/smb1/packet/tree_connect_request.rb +2 -4
- data/lib/ruby_smb/smb1/packet/tree_connect_response.rb +13 -3
- data/lib/ruby_smb/smb1/packet/tree_disconnect_request.rb +2 -4
- data/lib/ruby_smb/smb1/packet/tree_disconnect_response.rb +2 -1
- data/lib/ruby_smb/smb1/packet/write_andx_request.rb +2 -5
- data/lib/ruby_smb/smb1/packet/write_andx_response.rb +2 -1
- data/lib/ruby_smb/smb1/pipe.rb +8 -3
- data/lib/ruby_smb/smb1/tree.rb +40 -2
- data/lib/ruby_smb/smb2/dcerpc.rb +7 -2
- data/lib/ruby_smb/smb2/file.rb +97 -1
- data/lib/ruby_smb/smb2/packet/close_request.rb +2 -4
- data/lib/ruby_smb/smb2/packet/close_response.rb +2 -1
- data/lib/ruby_smb/smb2/packet/create_request.rb +2 -4
- data/lib/ruby_smb/smb2/packet/create_response.rb +2 -1
- data/lib/ruby_smb/smb2/packet/echo_request.rb +2 -4
- data/lib/ruby_smb/smb2/packet/echo_response.rb +2 -1
- data/lib/ruby_smb/smb2/packet/error_packet.rb +7 -0
- data/lib/ruby_smb/smb2/packet/ioctl_request.rb +2 -5
- data/lib/ruby_smb/smb2/packet/ioctl_response.rb +2 -1
- data/lib/ruby_smb/smb2/packet/logoff_request.rb +2 -4
- data/lib/ruby_smb/smb2/packet/logoff_response.rb +2 -1
- data/lib/ruby_smb/smb2/packet/negotiate_request.rb +2 -5
- data/lib/ruby_smb/smb2/packet/negotiate_response.rb +2 -1
- data/lib/ruby_smb/smb2/packet/query_directory_request.rb +2 -4
- data/lib/ruby_smb/smb2/packet/query_directory_response.rb +8 -2
- data/lib/ruby_smb/smb2/packet/read_request.rb +2 -4
- data/lib/ruby_smb/smb2/packet/read_response.rb +2 -1
- data/lib/ruby_smb/smb2/packet/session_setup_request.rb +2 -5
- data/lib/ruby_smb/smb2/packet/session_setup_response.rb +2 -1
- data/lib/ruby_smb/smb2/packet/set_info_request.rb +2 -4
- data/lib/ruby_smb/smb2/packet/set_info_response.rb +2 -1
- data/lib/ruby_smb/smb2/packet/tree_connect_request.rb +2 -5
- data/lib/ruby_smb/smb2/packet/tree_connect_response.rb +8 -2
- data/lib/ruby_smb/smb2/packet/tree_disconnect_request.rb +2 -4
- data/lib/ruby_smb/smb2/packet/tree_disconnect_response.rb +2 -1
- data/lib/ruby_smb/smb2/packet/write_request.rb +2 -4
- data/lib/ruby_smb/smb2/packet/write_response.rb +2 -1
- data/lib/ruby_smb/smb2/pipe.rb +9 -9
- data/lib/ruby_smb/smb2/tree.rb +44 -6
- data/lib/ruby_smb/version.rb +1 -1
- data/spec/lib/ruby_smb/client_spec.rb +123 -11
- data/spec/lib/ruby_smb/generic_packet_spec.rb +52 -4
- data/spec/lib/ruby_smb/smb1/file_spec.rb +182 -1
- data/spec/lib/ruby_smb/smb1/packet/{error_packet_spec.rb → empty_packet_spec.rb} +21 -0
- data/spec/lib/ruby_smb/smb1/packet/trans2/find_first2_response_spec.rb +11 -2
- data/spec/lib/ruby_smb/smb1/packet/trans2/find_next2_response_spec.rb +11 -2
- data/spec/lib/ruby_smb/smb1/packet/tree_connect_response_spec.rb +40 -0
- data/spec/lib/ruby_smb/smb1/pipe_spec.rb +63 -2
- data/spec/lib/ruby_smb/smb1/tree_spec.rb +44 -7
- data/spec/lib/ruby_smb/smb2/file_spec.rb +295 -2
- data/spec/lib/ruby_smb/smb2/packet/error_packet_spec.rb +51 -0
- data/spec/lib/ruby_smb/smb2/packet/query_directory_response_spec.rb +8 -0
- data/spec/lib/ruby_smb/smb2/packet/tree_connect_response_spec.rb +8 -0
- data/spec/lib/ruby_smb/smb2/pipe_spec.rb +69 -3
- data/spec/lib/ruby_smb/smb2/tree_spec.rb +214 -0
- metadata +6 -4
- metadata.gz.sig +0 -0
@@ -5,6 +5,8 @@ module RubySMB
|
|
5
5
|
# [2.2.4.42.1 Request](https://msdn.microsoft.com/en-us/library/ee441839.aspx)
|
6
6
|
# [2.2.4.2.1 Client Request Extensions](https://msdn.microsoft.com/en-us/library/ff470250.aspx)
|
7
7
|
class ReadAndxRequest < RubySMB::GenericPacket
|
8
|
+
COMMAND = RubySMB::SMB1::Commands::SMB_COM_READ_ANDX
|
9
|
+
|
8
10
|
# A SMB1 Parameter Block as defined by the {ReadAndxRequest}
|
9
11
|
class ParameterBlock < RubySMB::SMB1::ParameterBlock
|
10
12
|
endian :little
|
@@ -54,11 +56,6 @@ module RubySMB
|
|
54
56
|
parameter_block :parameter_block
|
55
57
|
data_block :data_block
|
56
58
|
|
57
|
-
def initialize_instance
|
58
|
-
super
|
59
|
-
smb_header.command = RubySMB::SMB1::Commands::SMB_COM_READ_ANDX
|
60
|
-
end
|
61
|
-
|
62
59
|
# Sets the read_from_named_pipe flag to `read_from_named_pipe` value (true or false).
|
63
60
|
# When reading from a named pipe, this flag needs to be set to true, which forces
|
64
61
|
# the use of Timeout field in Timeout_or_MaxCountHigh. When set to false (default),
|
@@ -5,6 +5,8 @@ module RubySMB
|
|
5
5
|
# [2.2.4.42.2 Response](https://msdn.microsoft.com/en-us/library/ee441872.aspx)
|
6
6
|
# [2.2.4.2.2 Server Response Extensions](https://msdn.microsoft.com/en-us/library/ff470017.aspx)
|
7
7
|
class ReadAndxResponse < RubySMB::GenericPacket
|
8
|
+
COMMAND = RubySMB::SMB1::Commands::SMB_COM_READ_ANDX
|
9
|
+
|
8
10
|
# A SMB1 Parameter Block as defined by the {ReadAndxResponse}
|
9
11
|
class ParameterBlock < RubySMB::SMB1::ParameterBlock
|
10
12
|
endian :little
|
@@ -38,7 +40,6 @@ module RubySMB
|
|
38
40
|
|
39
41
|
def initialize_instance
|
40
42
|
super
|
41
|
-
smb_header.command = RubySMB::SMB1::Commands::SMB_COM_READ_ANDX
|
42
43
|
smb_header.flags.reply = 1
|
43
44
|
end
|
44
45
|
end
|
@@ -4,6 +4,8 @@ module RubySMB
|
|
4
4
|
# A SMB1 SMB_COM_SESSION_SETUP_ANDX Request Packet, without NTLMSSP as defined in
|
5
5
|
# [2.2.4.53.1 Request](https://msdn.microsoft.com/en-us/library/ee441849.aspx)
|
6
6
|
class SessionSetupLegacyRequest < RubySMB::GenericPacket
|
7
|
+
COMMAND = RubySMB::SMB1::Commands::SMB_COM_SESSION_SETUP
|
8
|
+
|
7
9
|
# A SMB1 Parameter Block as defined by the {SessionSetupRequest}
|
8
10
|
class ParameterBlock < RubySMB::SMB1::ParameterBlock
|
9
11
|
and_x_block :andx_block
|
@@ -37,7 +39,6 @@ module RubySMB
|
|
37
39
|
|
38
40
|
def initialize_instance
|
39
41
|
super
|
40
|
-
smb_header.command = RubySMB::SMB1::Commands::SMB_COM_SESSION_SETUP
|
41
42
|
parameter_block.capabilities.extended_security = 0
|
42
43
|
end
|
43
44
|
end
|
@@ -4,6 +4,8 @@ module RubySMB
|
|
4
4
|
# A SMB1 SMB_COM_SESSION_SETUP Legacy Response Packet as defined in
|
5
5
|
# [2.2.4.53.2 Response](https://msdn.microsoft.com/en-us/library/ee442143.aspx)
|
6
6
|
class SessionSetupLegacyResponse < RubySMB::GenericPacket
|
7
|
+
COMMAND = RubySMB::SMB1::Commands::SMB_COM_SESSION_SETUP
|
8
|
+
|
7
9
|
# A SMB1 Parameter Block as defined by the {SessionSetupResponse}
|
8
10
|
class ParameterBlock < RubySMB::SMB1::ParameterBlock
|
9
11
|
and_x_block :andx_block
|
@@ -24,7 +26,6 @@ module RubySMB
|
|
24
26
|
|
25
27
|
def initialize_instance
|
26
28
|
super
|
27
|
-
smb_header.command = RubySMB::SMB1::Commands::SMB_COM_SESSION_SETUP
|
28
29
|
smb_header.flags.reply = 1
|
29
30
|
end
|
30
31
|
end
|
@@ -4,6 +4,8 @@ module RubySMB
|
|
4
4
|
# A SMB1 SMB_COM_SESSION_SETUP_ANDX Request Packet as defined in
|
5
5
|
# [2.2.4.6.1](https://msdn.microsoft.com/en-us/library/cc246328.aspx)
|
6
6
|
class SessionSetupRequest < RubySMB::GenericPacket
|
7
|
+
COMMAND = RubySMB::SMB1::Commands::SMB_COM_SESSION_SETUP
|
8
|
+
|
7
9
|
# A SMB1 Parameter Block as defined by the {SessionSetupRequest}
|
8
10
|
class ParameterBlock < RubySMB::SMB1::ParameterBlock
|
9
11
|
and_x_block :andx_block
|
@@ -30,11 +32,6 @@ module RubySMB
|
|
30
32
|
parameter_block :parameter_block
|
31
33
|
data_block :data_block
|
32
34
|
|
33
|
-
def initialize_instance
|
34
|
-
super
|
35
|
-
smb_header.command = RubySMB::SMB1::Commands::SMB_COM_SESSION_SETUP
|
36
|
-
end
|
37
|
-
|
38
35
|
# Takes an NTLM Type 1 Message and creates the GSS Security Blob
|
39
36
|
# for it and sets it in the {RubySMB::SMB1::Packet::SessionSetupRequest::DataBlock#security_blob}
|
40
37
|
# field. It also automaticaly sets the length in
|
@@ -4,6 +4,8 @@ module RubySMB
|
|
4
4
|
# A SMB1 SMB_COM_SESSION_SETUP Response Packet as defined in
|
5
5
|
# [2.2.4.6.2](https://msdn.microsoft.com/en-us/library/cc246329.aspx)
|
6
6
|
class SessionSetupResponse < RubySMB::GenericPacket
|
7
|
+
COMMAND = RubySMB::SMB1::Commands::SMB_COM_SESSION_SETUP
|
8
|
+
|
7
9
|
# A SMB1 Parameter Block as defined by the {SessionSetupResponse}
|
8
10
|
class ParameterBlock < RubySMB::SMB1::ParameterBlock
|
9
11
|
and_x_block :andx_block
|
@@ -24,7 +26,6 @@ module RubySMB
|
|
24
26
|
|
25
27
|
def initialize_instance
|
26
28
|
super
|
27
|
-
smb_header.command = RubySMB::SMB1::Commands::SMB_COM_SESSION_SETUP
|
28
29
|
smb_header.flags.reply = 1
|
29
30
|
end
|
30
31
|
|
@@ -12,7 +12,6 @@ module RubySMB
|
|
12
12
|
|
13
13
|
def initialize_instance
|
14
14
|
super
|
15
|
-
smb_header.command = RubySMB::SMB1::Commands::SMB_COM_TRANSACTION
|
16
15
|
data_block.name = "\\PIPE\\"
|
17
16
|
parameter_block.setup << RubySMB::SMB1::Packet::Trans::Subcommands::PEEK_NMPIPE
|
18
17
|
parameter_block.setup_count = 2
|
@@ -5,6 +5,8 @@ module RubySMB
|
|
5
5
|
# This class represents an SMB1 Trans PeekNamedPipe Response Packet as defined in
|
6
6
|
# [2.2.5.5.2 Response](https://msdn.microsoft.com/en-us/library/ee441883.aspx)
|
7
7
|
class PeekNmpipeResponse < RubySMB::GenericPacket
|
8
|
+
COMMAND = RubySMB::SMB1::Commands::SMB_COM_TRANSACTION
|
9
|
+
|
8
10
|
class ParameterBlock < RubySMB::SMB1::Packet::Trans::Response::ParameterBlock
|
9
11
|
end
|
10
12
|
|
@@ -22,7 +24,7 @@ module RubySMB
|
|
22
24
|
do_num_bytes
|
23
25
|
end
|
24
26
|
end
|
25
|
-
|
27
|
+
|
26
28
|
class TransData < BinData::Record
|
27
29
|
string :read_data, label: 'Readable data', length: -> { parent.parameter_block.total_data_count }
|
28
30
|
|
@@ -48,7 +50,6 @@ module RubySMB
|
|
48
50
|
|
49
51
|
def initialize_instance
|
50
52
|
super
|
51
|
-
smb_header.command = RubySMB::SMB1::Commands::SMB_COM_TRANSACTION
|
52
53
|
smb_header.flags.reply = 1
|
53
54
|
parameter_block.setup << RubySMB::SMB1::Packet::Trans::Subcommands::PEEK_NMPIPE
|
54
55
|
end
|
@@ -6,6 +6,8 @@ module RubySMB
|
|
6
6
|
# This class represents a generic SMB1 Trans Request Packet as defined in
|
7
7
|
# [2.2.4.33.1 Request](https://msdn.microsoft.com/en-us/library/ee441730.aspx)
|
8
8
|
class Request < RubySMB::GenericPacket
|
9
|
+
COMMAND = RubySMB::SMB1::Commands::SMB_COM_TRANSACTION
|
10
|
+
|
9
11
|
# A SMB1 Parameter Block
|
10
12
|
class ParameterBlock < RubySMB::SMB1::ParameterBlock
|
11
13
|
uint16 :total_parameter_count, label: 'Total Parameter Count(bytes)', initial_value: -> { parameter_count }
|
@@ -48,11 +50,6 @@ module RubySMB
|
|
48
50
|
parameter_block :parameter_block
|
49
51
|
data_block :data_block
|
50
52
|
|
51
|
-
def initialize_instance
|
52
|
-
super
|
53
|
-
smb_header.command = RubySMB::SMB1::Commands::SMB_COM_TRANSACTION
|
54
|
-
end
|
55
|
-
|
56
53
|
end
|
57
54
|
end
|
58
55
|
end
|
@@ -6,6 +6,8 @@ module RubySMB
|
|
6
6
|
# This class represents a generic SMB1 Trans Response Packet as defined in
|
7
7
|
# [2.2.4.33.2 Response](https://msdn.microsoft.com/en-us/library/ee442061.aspx)
|
8
8
|
class Response < RubySMB::GenericPacket
|
9
|
+
COMMAND = RubySMB::SMB1::Commands::SMB_COM_TRANSACTION
|
10
|
+
|
9
11
|
# A SMB1 Parameter Block
|
10
12
|
class ParameterBlock < RubySMB::SMB1::ParameterBlock
|
11
13
|
uint16 :total_parameter_count, label: 'Total Parameter Count(bytes)', initial_value: -> { parameter_count }
|
@@ -35,7 +37,6 @@ module RubySMB
|
|
35
37
|
|
36
38
|
def initialize_instance
|
37
39
|
super
|
38
|
-
smb_header.command = RubySMB::SMB1::Commands::SMB_COM_TRANSACTION
|
39
40
|
smb_header.flags.reply = 1
|
40
41
|
end
|
41
42
|
|
@@ -6,6 +6,7 @@ module RubySMB
|
|
6
6
|
# A Trans TRANSACT_NMPIPE Request Packet as defined in
|
7
7
|
# [2.2.5.6.1 Request](https://msdn.microsoft.com/en-us/library/ee441832.aspx)
|
8
8
|
class TransactNmpipeRequest < RubySMB::GenericPacket
|
9
|
+
COMMAND = RubySMB::SMB1::Commands::SMB_COM_TRANSACTION
|
9
10
|
|
10
11
|
class ParameterBlock < RubySMB::SMB1::Packet::Trans::Request::ParameterBlock
|
11
12
|
end
|
@@ -42,7 +43,6 @@ module RubySMB
|
|
42
43
|
|
43
44
|
def initialize_instance
|
44
45
|
super
|
45
|
-
smb_header.command = RubySMB::SMB1::Commands::SMB_COM_TRANSACTION
|
46
46
|
parameter_block.max_parameter_count = 0x0000
|
47
47
|
parameter_block.max_setup_count = 0x00
|
48
48
|
parameter_block.setup << RubySMB::SMB1::Packet::Trans::Subcommands::TRANSACT_NMPIPE
|
@@ -6,6 +6,7 @@ module RubySMB
|
|
6
6
|
# A Trans TRANSACT_NMPIPE Response Packet as defined in
|
7
7
|
# [2.2.5.6.2 Response](https://msdn.microsoft.com/en-us/library/ee442003.aspx)
|
8
8
|
class TransactNmpipeResponse < RubySMB::GenericPacket
|
9
|
+
COMMAND = RubySMB::SMB1::Commands::SMB_COM_TRANSACTION
|
9
10
|
|
10
11
|
class ParameterBlock < RubySMB::SMB1::Packet::Trans::Response::ParameterBlock
|
11
12
|
end
|
@@ -33,7 +34,6 @@ module RubySMB
|
|
33
34
|
|
34
35
|
def initialize_instance
|
35
36
|
super
|
36
|
-
smb_header.command = RubySMB::SMB1::Commands::SMB_COM_TRANSACTION
|
37
37
|
smb_header.flags.reply = 1
|
38
38
|
end
|
39
39
|
|
@@ -5,6 +5,8 @@ module RubySMB
|
|
5
5
|
# A Trans2 FIND_FIRST2 Request Packet as defined in
|
6
6
|
# [2.2.6.2.1](https://msdn.microsoft.com/en-us/library/ee441987.aspx)
|
7
7
|
class FindFirst2Request < RubySMB::GenericPacket
|
8
|
+
COMMAND = RubySMB::SMB1::Commands::SMB_COM_TRANSACTION2
|
9
|
+
|
8
10
|
class ParameterBlock < RubySMB::SMB1::Packet::Trans2::Request::ParameterBlock
|
9
11
|
end
|
10
12
|
|
@@ -67,7 +69,6 @@ module RubySMB
|
|
67
69
|
|
68
70
|
def initialize_instance
|
69
71
|
super
|
70
|
-
smb_header.command = RubySMB::SMB1::Commands::SMB_COM_TRANSACTION2
|
71
72
|
parameter_block.setup << RubySMB::SMB1::Packet::Trans2::Subcommands::FIND_FIRST2
|
72
73
|
end
|
73
74
|
end
|
@@ -5,6 +5,8 @@ module RubySMB
|
|
5
5
|
# This class represents an SMB1 Trans2 FIND_FIRST2 Response Packet as defined in
|
6
6
|
# [2.2.6.2.2 Response](https://msdn.microsoft.com/en-us/library/ee441704.aspx)
|
7
7
|
class FindFirst2Response < RubySMB::GenericPacket
|
8
|
+
COMMAND = RubySMB::SMB1::Commands::SMB_COM_TRANSACTION2
|
9
|
+
|
8
10
|
class ParameterBlock < RubySMB::SMB1::Packet::Trans2::Response::ParameterBlock
|
9
11
|
end
|
10
12
|
|
@@ -51,7 +53,6 @@ module RubySMB
|
|
51
53
|
|
52
54
|
def initialize_instance
|
53
55
|
super
|
54
|
-
smb_header.command = RubySMB::SMB1::Commands::SMB_COM_TRANSACTION2
|
55
56
|
parameter_block.setup << RubySMB::SMB1::Packet::Trans2::Subcommands::FIND_FIRST2
|
56
57
|
smb_header.flags.reply = 1
|
57
58
|
end
|
@@ -62,6 +63,7 @@ module RubySMB
|
|
62
63
|
#
|
63
64
|
# @param klass [Class] the FileInformationClass class to read the data as
|
64
65
|
# @return [array<BinData::Record>] An array of structs holding the requested information
|
66
|
+
# @raise [RubySMB::Error::InvalidPacket] if the string buffer is not a valid File Information packet
|
65
67
|
def results(klass, unicode:)
|
66
68
|
information_classes = []
|
67
69
|
blob = data_block.trans2_data.buffer.to_binary_s.dup
|
@@ -76,7 +78,11 @@ module RubySMB
|
|
76
78
|
|
77
79
|
file_info = klass.new
|
78
80
|
file_info.unicode = unicode
|
79
|
-
|
81
|
+
begin
|
82
|
+
information_classes << file_info.read(data)
|
83
|
+
rescue IOError
|
84
|
+
raise RubySMB::Error::InvalidPacket, "Invalid #{klass} File Information packet in the string buffer"
|
85
|
+
end
|
80
86
|
end
|
81
87
|
information_classes
|
82
88
|
end
|
@@ -5,6 +5,8 @@ module RubySMB
|
|
5
5
|
# A Trans2 FIND_NEXT2 Request Packet as defined in
|
6
6
|
# [2.2.6.3.1 Request](https://msdn.microsoft.com/en-us/library/ee441844.aspx)
|
7
7
|
class FindNext2Request < RubySMB::GenericPacket
|
8
|
+
COMMAND = RubySMB::SMB1::Commands::SMB_COM_TRANSACTION2
|
9
|
+
|
8
10
|
class ParameterBlock < RubySMB::SMB1::Packet::Trans2::Request::ParameterBlock
|
9
11
|
end
|
10
12
|
|
@@ -67,7 +69,6 @@ module RubySMB
|
|
67
69
|
|
68
70
|
def initialize_instance
|
69
71
|
super
|
70
|
-
smb_header.command = RubySMB::SMB1::Commands::SMB_COM_TRANSACTION2
|
71
72
|
parameter_block.setup << RubySMB::SMB1::Packet::Trans2::Subcommands::FIND_NEXT2
|
72
73
|
end
|
73
74
|
end
|
@@ -5,6 +5,8 @@ module RubySMB
|
|
5
5
|
# This class represents an SMB1 Trans2 FIND_NEXT2 Response Packet as defined in
|
6
6
|
# [2.2.6.3.2 Response](https://msdn.microsoft.com/en-us/library/ee441871.aspx)
|
7
7
|
class FindNext2Response < RubySMB::GenericPacket
|
8
|
+
COMMAND = RubySMB::SMB1::Commands::SMB_COM_TRANSACTION2
|
9
|
+
|
8
10
|
class ParameterBlock < RubySMB::SMB1::Packet::Trans2::Response::ParameterBlock
|
9
11
|
end
|
10
12
|
|
@@ -50,7 +52,6 @@ module RubySMB
|
|
50
52
|
|
51
53
|
def initialize_instance
|
52
54
|
super
|
53
|
-
smb_header.command = RubySMB::SMB1::Commands::SMB_COM_TRANSACTION2
|
54
55
|
parameter_block.setup << RubySMB::SMB1::Packet::Trans2::Subcommands::FIND_NEXT2
|
55
56
|
smb_header.flags.reply = 1
|
56
57
|
end
|
@@ -61,6 +62,7 @@ module RubySMB
|
|
61
62
|
#
|
62
63
|
# @param klass [Class] the FileInformationClass class to read the data as
|
63
64
|
# @return [array<BinData::Record>] An array of structs holding the requested information
|
65
|
+
# @raise [RubySMB::Error::InvalidPacket] if the string buffer is not a valid File Information packet
|
64
66
|
def results(klass, unicode:)
|
65
67
|
information_classes = []
|
66
68
|
blob = data_block.trans2_data.buffer.to_binary_s.dup
|
@@ -75,7 +77,11 @@ module RubySMB
|
|
75
77
|
|
76
78
|
file_info = klass.new
|
77
79
|
file_info.unicode = unicode
|
78
|
-
|
80
|
+
begin
|
81
|
+
information_classes << file_info.read(data)
|
82
|
+
rescue IOError
|
83
|
+
raise RubySMB::Error::InvalidPacket, "Invalid #{klass} File Information packet in the string buffer"
|
84
|
+
end
|
79
85
|
end
|
80
86
|
information_classes
|
81
87
|
end
|
@@ -5,6 +5,8 @@ module RubySMB
|
|
5
5
|
# A Trans2 OPEN2 Request Packet as defined in
|
6
6
|
# [2.2.6.1.1 Request](https://msdn.microsoft.com/en-us/library/ee441733.aspx)
|
7
7
|
class Open2Request < RubySMB::GenericPacket
|
8
|
+
COMMAND = RubySMB::SMB1::Commands::SMB_COM_TRANSACTION2
|
9
|
+
|
8
10
|
class ParameterBlock < RubySMB::SMB1::Packet::Trans2::Request::ParameterBlock
|
9
11
|
end
|
10
12
|
|
@@ -50,7 +52,6 @@ module RubySMB
|
|
50
52
|
|
51
53
|
def initialize_instance
|
52
54
|
super
|
53
|
-
smb_header.command = RubySMB::SMB1::Commands::SMB_COM_TRANSACTION2
|
54
55
|
parameter_block.setup << RubySMB::SMB1::Packet::Trans2::Subcommands::OPEN2
|
55
56
|
end
|
56
57
|
end
|
@@ -5,6 +5,8 @@ module RubySMB
|
|
5
5
|
# This class represents an SMB1 Trans2 Open2 Response Packet as defined in
|
6
6
|
# [2.2.6.1.2 Response](https://msdn.microsoft.com/en-us/library/ee441545.aspx)
|
7
7
|
class Open2Response < RubySMB::GenericPacket
|
8
|
+
COMMAND = RubySMB::SMB1::Commands::SMB_COM_TRANSACTION2
|
9
|
+
|
8
10
|
class ParameterBlock < RubySMB::SMB1::Packet::Trans2::Response::ParameterBlock
|
9
11
|
end
|
10
12
|
|
@@ -52,7 +54,6 @@ module RubySMB
|
|
52
54
|
|
53
55
|
def initialize_instance
|
54
56
|
super
|
55
|
-
smb_header.command = RubySMB::SMB1::Commands::SMB_COM_TRANSACTION2
|
56
57
|
parameter_block.setup << RubySMB::SMB1::Packet::Trans2::Subcommands::OPEN2
|
57
58
|
smb_header.flags.reply = 1
|
58
59
|
end
|
@@ -5,6 +5,8 @@ module RubySMB
|
|
5
5
|
# This class represents a generic SMB1 Trans2 Request Packet as defined in
|
6
6
|
# [2.2.4.46.1 Request](https://msdn.microsoft.com/en-us/library/ee442192.aspx)
|
7
7
|
class Request < RubySMB::GenericPacket
|
8
|
+
COMMAND = RubySMB::SMB1::Commands::SMB_COM_TRANSACTION2
|
9
|
+
|
8
10
|
# The {RubySMB::SMB1::ParameterBlock} specific to this packet type.
|
9
11
|
class ParameterBlock < RubySMB::SMB1::ParameterBlock
|
10
12
|
uint16 :total_parameter_count, label: 'Total Parameter Count(bytes)'
|
@@ -39,10 +41,6 @@ module RubySMB
|
|
39
41
|
parameter_block :parameter_block
|
40
42
|
data_block :data_block
|
41
43
|
|
42
|
-
def initialize_instance
|
43
|
-
super
|
44
|
-
smb_header.command = RubySMB::SMB1::Commands::SMB_COM_TRANSACTION2
|
45
|
-
end
|
46
44
|
end
|
47
45
|
end
|
48
46
|
end
|
@@ -5,6 +5,8 @@ module RubySMB
|
|
5
5
|
# This class represents a generic SMB1 Trans2 Secondary Request Packet as defined in
|
6
6
|
# [2.2.4.47.1 Request](https://msdn.microsoft.com/en-us/library/ee442105.aspx)
|
7
7
|
class RequestSecondary < RubySMB::GenericPacket
|
8
|
+
COMMAND = RubySMB::SMB1::Commands::SMB_COM_TRANSACTION2_SECONDARY
|
9
|
+
|
8
10
|
# The {RubySMB::SMB1::ParameterBlock} specific to this packet type.
|
9
11
|
class ParameterBlock < RubySMB::SMB1::ParameterBlock
|
10
12
|
uint16 :total_parameter_count, label: 'Total Parameter Count(bytes)'
|
@@ -26,10 +28,6 @@ module RubySMB
|
|
26
28
|
parameter_block :parameter_block
|
27
29
|
data_block :data_block
|
28
30
|
|
29
|
-
def initialize_instance
|
30
|
-
super
|
31
|
-
smb_header.command = RubySMB::SMB1::Commands::SMB_COM_TRANSACTION2_SECONDARY
|
32
|
-
end
|
33
31
|
end
|
34
32
|
end
|
35
33
|
end
|
@@ -5,6 +5,8 @@ module RubySMB
|
|
5
5
|
# This class represents a generic SMB1 Trans2 Response Packet as defined in
|
6
6
|
# [2.2.4.46.2 Response](https://msdn.microsoft.com/en-us/library/ee441550.aspx)
|
7
7
|
class Response < RubySMB::GenericPacket
|
8
|
+
COMMAND = RubySMB::SMB1::Commands::SMB_COM_TRANSACTION2
|
9
|
+
|
8
10
|
# The {RubySMB::SMB1::ParameterBlock} specific to this packet type.
|
9
11
|
class ParameterBlock < RubySMB::SMB1::ParameterBlock
|
10
12
|
uint16 :total_parameter_count, label: 'Total Parameter Count(bytes)'
|
@@ -36,7 +38,6 @@ module RubySMB
|
|
36
38
|
|
37
39
|
def initialize_instance
|
38
40
|
super
|
39
|
-
smb_header.command = RubySMB::SMB1::Commands::SMB_COM_TRANSACTION2
|
40
41
|
smb_header.flags.reply = 1
|
41
42
|
end
|
42
43
|
end
|
@@ -5,6 +5,8 @@ module RubySMB
|
|
5
5
|
# A Trans2 SET_FILE_INFORMATION Request Packet as defined in
|
6
6
|
# [2.2.6.9.1 Request](https://msdn.microsoft.com/en-us/library/ee441527.aspx)
|
7
7
|
class SetFileInformationRequest < RubySMB::GenericPacket
|
8
|
+
COMMAND = RubySMB::SMB1::Commands::SMB_COM_TRANSACTION2
|
9
|
+
|
8
10
|
class ParameterBlock < RubySMB::SMB1::Packet::Trans2::Request::ParameterBlock
|
9
11
|
end
|
10
12
|
|
@@ -56,7 +58,6 @@ module RubySMB
|
|
56
58
|
|
57
59
|
def initialize_instance
|
58
60
|
super
|
59
|
-
smb_header.command = RubySMB::SMB1::Commands::SMB_COM_TRANSACTION2
|
60
61
|
parameter_block.setup << RubySMB::SMB1::Packet::Trans2::Subcommands::SET_FILE_INFORMATION
|
61
62
|
end
|
62
63
|
end
|
@@ -5,6 +5,8 @@ module RubySMB
|
|
5
5
|
# A Trans2 SET_FILE_INFORMATION Response Packet as defined in
|
6
6
|
# [2.2.6.9.2 Response](https://msdn.microsoft.com/en-us/library/ff469853.aspx)
|
7
7
|
class SetFileInformationResponse < RubySMB::GenericPacket
|
8
|
+
COMMAND = RubySMB::SMB1::Commands::SMB_COM_TRANSACTION2
|
9
|
+
|
8
10
|
class ParameterBlock < RubySMB::SMB1::Packet::Trans2::Response::ParameterBlock
|
9
11
|
end
|
10
12
|
|
@@ -46,7 +48,6 @@ module RubySMB
|
|
46
48
|
|
47
49
|
def initialize_instance
|
48
50
|
super
|
49
|
-
smb_header.command = RubySMB::SMB1::Commands::SMB_COM_TRANSACTION2
|
50
51
|
parameter_block.setup << RubySMB::SMB1::Packet::Trans2::Subcommands::SET_FILE_INFORMATION
|
51
52
|
smb_header.flags.reply = 1
|
52
53
|
end
|