ruby_smb 3.0.5 → 3.1.1
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 +2 -3
- data/.github/workflows/verify.yml +1 -1
- data/.simplecov +1 -1
- data/CONTRIBUTING.md +28 -3
- data/README.md +8 -0
- data/examples/pwsh_service.rb +112 -0
- data/lib/ruby_smb/client/encryption.rb +16 -4
- data/lib/ruby_smb/client/negotiation.rb +10 -8
- data/lib/ruby_smb/dcerpc/request.rb +2 -0
- data/lib/ruby_smb/dcerpc/svcctl/create_service_w_request.rb +35 -0
- data/lib/ruby_smb/dcerpc/svcctl/create_service_w_response.rb +24 -0
- data/lib/ruby_smb/dcerpc/svcctl/delete_service_request.rb +21 -0
- data/lib/ruby_smb/dcerpc/svcctl/delete_service_response.rb +21 -0
- data/lib/ruby_smb/dcerpc/svcctl.rb +66 -5
- data/lib/ruby_smb/dcerpc/winreg/open_root_key_request.rb +1 -1
- data/lib/ruby_smb/dcerpc/winreg/regsam.rb +1 -1
- data/lib/ruby_smb/dcerpc/winreg.rb +1 -1
- data/lib/ruby_smb/fscc/file_information.rb +4 -0
- data/lib/ruby_smb/gss/provider/ntlm.rb +4 -0
- data/lib/ruby_smb/server/server_client/encryption.rb +66 -0
- data/lib/ruby_smb/server/server_client/negotiation.rb +14 -3
- data/lib/ruby_smb/server/server_client/session_setup.rb +18 -3
- data/lib/ruby_smb/server/server_client/share_io.rb +17 -0
- data/lib/ruby_smb/server/server_client/tree_connect.rb +40 -3
- data/lib/ruby_smb/server/server_client.rb +147 -37
- data/lib/ruby_smb/server/share/provider/disk/file_system.rb +28 -0
- data/lib/ruby_smb/server/share/provider/disk/processor/close.rb +42 -0
- data/lib/ruby_smb/server/share/provider/disk/processor/create.rb +143 -0
- data/lib/ruby_smb/server/share/provider/disk/processor/query.rb +359 -0
- data/lib/ruby_smb/server/share/provider/disk/processor/read.rb +69 -0
- data/lib/ruby_smb/server/share/provider/disk/processor.rb +159 -0
- data/lib/ruby_smb/server/share/provider/disk.rb +4 -416
- data/lib/ruby_smb/server/share/provider/pipe.rb +2 -2
- data/lib/ruby_smb/server/share/provider/processor.rb +16 -0
- data/lib/ruby_smb/signing.rb +18 -4
- data/lib/ruby_smb/smb1/bit_field/directory_access_mask.rb +1 -1
- data/lib/ruby_smb/smb1/bit_field/file_access_mask.rb +1 -1
- data/lib/ruby_smb/smb1/commands.rb +1 -0
- data/lib/ruby_smb/smb1/packet/nt_create_andx_request.rb +11 -1
- data/lib/ruby_smb/smb1/packet/nt_trans/create_request.rb +1 -1
- data/lib/ruby_smb/smb1/packet/read_andx_response.rb +5 -4
- data/lib/ruby_smb/smb1/packet/session_setup_request.rb +12 -4
- data/lib/ruby_smb/smb1/packet/trans2/data_block.rb +9 -1
- data/lib/ruby_smb/smb1/packet/trans2/find_first2_request.rb +52 -51
- data/lib/ruby_smb/smb1/packet/trans2/find_first2_response.rb +37 -37
- data/lib/ruby_smb/smb1/packet/trans2/find_information_level/find_file_both_directory_info.rb +48 -0
- data/lib/ruby_smb/smb1/packet/trans2/find_information_level.rb +28 -15
- data/lib/ruby_smb/smb1/packet/trans2/find_next2_request.rb +51 -51
- data/lib/ruby_smb/smb1/packet/trans2/find_next2_response.rb +36 -36
- data/lib/ruby_smb/smb1/packet/trans2/open2_request.rb +40 -39
- data/lib/ruby_smb/smb1/packet/trans2/open2_response.rb +40 -40
- data/lib/ruby_smb/smb1/packet/trans2/query_file_information_request.rb +60 -0
- data/lib/ruby_smb/smb1/packet/trans2/query_file_information_response.rb +59 -0
- data/lib/ruby_smb/smb1/packet/trans2/query_fs_information_level/query_fs_attribute_info.rb +31 -0
- data/lib/ruby_smb/smb1/packet/trans2/query_fs_information_level.rb +40 -0
- data/lib/ruby_smb/smb1/packet/trans2/query_fs_information_request.rb +46 -0
- data/lib/ruby_smb/smb1/packet/trans2/query_fs_information_response.rb +59 -0
- data/lib/ruby_smb/smb1/packet/trans2/query_information_level/query_file_basic_info.rb +23 -0
- data/lib/ruby_smb/smb1/packet/trans2/query_information_level/query_file_standard_info.rb +22 -0
- data/lib/ruby_smb/smb1/packet/trans2/query_information_level.rb +62 -0
- data/lib/ruby_smb/smb1/packet/trans2/query_path_information_request.rb +65 -0
- data/lib/ruby_smb/smb1/packet/trans2/query_path_information_response.rb +59 -0
- data/lib/ruby_smb/smb1/packet/trans2/request.rb +24 -8
- data/lib/ruby_smb/smb1/packet/trans2/request_secondary.rb +4 -4
- data/lib/ruby_smb/smb1/packet/trans2/response.rb +29 -20
- data/lib/ruby_smb/smb1/packet/trans2/set_file_information_request.rb +42 -42
- data/lib/ruby_smb/smb1/packet/trans2/set_file_information_response.rb +23 -23
- data/lib/ruby_smb/smb1/packet/trans2/subcommands.rb +23 -5
- data/lib/ruby_smb/smb1/packet/trans2.rb +4 -0
- data/lib/ruby_smb/smb1/packet/tree_connect_request.rb +4 -1
- data/lib/ruby_smb/smb2/bit_field/directory_access_mask.rb +1 -1
- data/lib/ruby_smb/smb2/bit_field/file_access_mask.rb +1 -1
- data/lib/ruby_smb/smb2/negotiate_context.rb +10 -1
- data/lib/ruby_smb/smb2/packet/transform_header.rb +7 -7
- data/lib/ruby_smb/smb2.rb +1 -0
- data/lib/ruby_smb/version.rb +1 -1
- data/ruby_smb.gemspec +1 -1
- data/spec/lib/ruby_smb/client_spec.rb +31 -8
- data/spec/lib/ruby_smb/dcerpc/svcctl/create_service_w_request_spec.rb +143 -0
- data/spec/lib/ruby_smb/dcerpc/svcctl/create_service_w_response_spec.rb +45 -0
- data/spec/lib/ruby_smb/dcerpc/svcctl/delete_service_request_spec.rb +29 -0
- data/spec/lib/ruby_smb/dcerpc/svcctl/delete_service_response_spec.rb +29 -0
- data/spec/lib/ruby_smb/dcerpc/winreg/open_root_key_request_spec.rb +8 -8
- data/spec/lib/ruby_smb/dcerpc/winreg/regsam_spec.rb +1 -1
- data/spec/lib/ruby_smb/dcerpc/winreg_spec.rb +1 -1
- data/spec/lib/ruby_smb/smb1/bit_field/directory_access_mask_spec.rb +4 -4
- data/spec/lib/ruby_smb/smb1/bit_field/file_access_mask_spec.rb +4 -4
- data/spec/lib/ruby_smb/smb1/packet/trans2/find_first2_request_spec.rb +2 -2
- data/spec/lib/ruby_smb/smb1/packet/trans2/find_first2_response_spec.rb +36 -2
- data/spec/lib/ruby_smb/smb1/packet/trans2/find_next2_request_spec.rb +2 -2
- data/spec/lib/ruby_smb/smb1/packet/trans2/find_next2_response_spec.rb +35 -1
- data/spec/lib/ruby_smb/smb1/packet/trans2/query_file_information_request_spec.rb +74 -0
- data/spec/lib/ruby_smb/smb1/packet/trans2/query_file_information_response_spec.rb +96 -0
- data/spec/lib/ruby_smb/smb1/packet/trans2/query_fs_information_request_spec.rb +62 -0
- data/spec/lib/ruby_smb/smb1/packet/trans2/query_fs_information_response_spec.rb +88 -0
- data/spec/lib/ruby_smb/smb1/packet/trans2/query_path_information_request_spec.rb +79 -0
- data/spec/lib/ruby_smb/smb1/packet/trans2/query_path_information_response_spec.rb +96 -0
- data/spec/lib/ruby_smb/smb1/packet/trans2/request_spec.rb +2 -2
- data/spec/lib/ruby_smb/smb1/packet/trans2/response_spec.rb +3 -3
- data/spec/lib/ruby_smb/smb1/packet/trans2/set_file_information_request_spec.rb +3 -2
- data/spec/lib/ruby_smb/smb1/packet/trans2/set_file_information_response_spec.rb +7 -2
- data/spec/lib/ruby_smb/smb1/tree_spec.rb +3 -3
- data/spec/lib/ruby_smb/smb2/bit_field/directory_access_mask_spec.rb +4 -4
- data/spec/lib/ruby_smb/smb2/bit_field/file_access_mask_spec.rb +4 -4
- data/spec/lib/ruby_smb/smb2/packet/transform_header_spec.rb +2 -2
- data/spec/spec_helper.rb +2 -3
- data.tar.gz.sig +0 -0
- metadata +48 -4
- metadata.gz.sig +1 -2
@@ -0,0 +1,62 @@
|
|
1
|
+
module RubySMB
|
2
|
+
module SMB1
|
3
|
+
module Packet
|
4
|
+
module Trans2
|
5
|
+
# SMB Query Information Levels as defined in
|
6
|
+
# [2.2.8.3 QUERY Information Levels](https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-cifs/b9dcb99c-e810-4df8-ae29-cdf37e8c5a23)
|
7
|
+
# used in TRANS2_QUERY_PATH_INFORMATION and TRANS2_QUERY_FILE_INFORMATION
|
8
|
+
module QueryInformationLevel
|
9
|
+
# Constants defined in
|
10
|
+
# [2.2.2.3.3 QUERY Information Level Codes](https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-cifs/794afe2e-7c11-4a8c-b909-0a397966f6a9)
|
11
|
+
# [dialect] description
|
12
|
+
|
13
|
+
# [LANMAN2.0] Query creation, access, and last write timestamps, size and file attributes.
|
14
|
+
SMB_INFO_STANDARD = 0x0001 # 1
|
15
|
+
|
16
|
+
# [LANMAN2.0] Query the SMB_INFO_STANDARD data along with the size of the file's extended attributes (EAs).
|
17
|
+
SMB_INFO_QUERY_EA_SIZE = 0x0002 # 2
|
18
|
+
|
19
|
+
# [LANMAN2.0] Query a file's specific EAs by attribute name.
|
20
|
+
SMB_INFO_QUERY_EAS_FROM_LIST = 0x0003 # 3
|
21
|
+
|
22
|
+
# [LANMAN2.0] Query all of a file's EAs.
|
23
|
+
SMB_INFO_QUERY_ALL_EAS = 0x0004 # 4
|
24
|
+
|
25
|
+
# [LANMAN2.0] Validate the syntax of the path provided in the request. Not supported for TRANS2_QUERY_FILE_INFORMATION.
|
26
|
+
SMB_INFO_IS_NAME_VALID = 0x0006 # 6
|
27
|
+
|
28
|
+
# [NT LANMAN] Query 64-bit create, access, write, and change timestamps along with extended file attributes.
|
29
|
+
SMB_QUERY_FILE_BASIC_INFO = 0x0101 # 257
|
30
|
+
|
31
|
+
# [NT LANMAN] Query size, number of links, if a delete is pending, and if the path is a directory.
|
32
|
+
SMB_QUERY_FILE_STANDARD_INFO = 0x0102 # 258
|
33
|
+
|
34
|
+
# [NT LANMAN] Query the size of the file's EAs.
|
35
|
+
SMB_QUERY_FILE_EA_INFO = 0x0103 # 259
|
36
|
+
|
37
|
+
# [NT LANMAN] Query the long file name in Unicode format.
|
38
|
+
SMB_QUERY_FILE_NAME_INFO = 0x0104 # 260
|
39
|
+
|
40
|
+
# [NT LANMAN] Query the SMB_QUERY_FILE_BASIC_INFO, SMB_QUERY_FILE_STANDARD_INFO, SMB_QUERY_FILE_EA_INFO, and SMB_QUERY_FILE_NAME_INFO data as well as access flags, access mode, and alignment information in a single request.
|
41
|
+
SMB_QUERY_FILE_ALL_INFO = 0x0107 # 263
|
42
|
+
|
43
|
+
# [NT LANMAN] Query the 8.3 file name.<22>
|
44
|
+
SMB_QUERY_FILE_ALT_NAME_INFO = 0x0108 # 264
|
45
|
+
|
46
|
+
# [NT LANMAN] Query file stream information.
|
47
|
+
SMB_QUERY_FILE_STREAM_INFO = 0x0109 # 265
|
48
|
+
|
49
|
+
# [NT LANMAN] Query file compression information.
|
50
|
+
SMB_QUERY_FILE_COMPRESSION_INFO = 0x010B # 267
|
51
|
+
|
52
|
+
def self.name(value)
|
53
|
+
constants.select { |c| c.upcase == c }.find { |c| const_get(c) == value }
|
54
|
+
end
|
55
|
+
|
56
|
+
require 'ruby_smb/smb1/packet/trans2/query_information_level/query_file_basic_info'
|
57
|
+
require 'ruby_smb/smb1/packet/trans2/query_information_level/query_file_standard_info'
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
module RubySMB
|
2
|
+
module SMB1
|
3
|
+
module Packet
|
4
|
+
module Trans2
|
5
|
+
# The Trans2 Parameter Block for this particular Subcommand
|
6
|
+
class QueryPathInformationRequestTrans2Parameters < BinData::Record
|
7
|
+
endian :little
|
8
|
+
|
9
|
+
uint16 :information_level, label: 'Information Level'
|
10
|
+
uint32 :reserved, label: 'Reserved'
|
11
|
+
choice :filename, copy_on_change: true, selection: -> { parent.parent.smb_header.flags2.unicode } do
|
12
|
+
stringz16 1, label: 'FileName'
|
13
|
+
stringz 0, label: 'FileName'
|
14
|
+
end
|
15
|
+
|
16
|
+
|
17
|
+
# Returns the length of the Trans2Parameters struct
|
18
|
+
# in number of bytes
|
19
|
+
def length
|
20
|
+
do_num_bytes
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# The Trans2 Data Block for this particular Subcommand
|
25
|
+
class QueryPathInformationRequestTrans2Data < BinData::Record
|
26
|
+
smb_gea_list :extended_attribute_list, label: 'Get Extended Attribute List',
|
27
|
+
onlyif: -> { parent.trans2_parameters.information_level == FindInformationLevel::SMB_INFO_QUERY_EAS_FROM_LIST}
|
28
|
+
|
29
|
+
# Returns the length of the Trans2Data struct
|
30
|
+
# in number of bytes
|
31
|
+
def length
|
32
|
+
do_num_bytes
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# The {RubySMB::SMB1::DataBlock} specific to this packet type.
|
37
|
+
class QueryPathInformationRequestDataBlock < RubySMB::SMB1::Packet::Trans2::DataBlock
|
38
|
+
uint8 :name, label: 'Name', initial_value: 0x00
|
39
|
+
string :pad1, length: -> { pad1_length }
|
40
|
+
query_path_information_request_trans2_parameters :trans2_parameters, label: 'Trans2 Parameters'
|
41
|
+
string :pad2, length: -> { pad2_length }
|
42
|
+
query_path_information_request_trans2_data :trans2_data, label: 'Trans2 Data'
|
43
|
+
end
|
44
|
+
|
45
|
+
# A Trans2 QUERY_PATH_INFORMATION Request Packet as defined in
|
46
|
+
# [2.2.6.6.1](https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-cifs/9b171bbf-c6d8-4c88-ac85-23c795cbb5d3)
|
47
|
+
class QueryPathInformationRequest < RubySMB::GenericPacket
|
48
|
+
COMMAND = RubySMB::SMB1::Commands::SMB_COM_TRANSACTION2
|
49
|
+
|
50
|
+
class ParameterBlock < RubySMB::SMB1::Packet::Trans2::Request::ParameterBlock
|
51
|
+
end
|
52
|
+
|
53
|
+
smb_header :smb_header
|
54
|
+
parameter_block :parameter_block
|
55
|
+
query_path_information_request_data_block :data_block
|
56
|
+
|
57
|
+
def initialize_instance
|
58
|
+
super
|
59
|
+
parameter_block.setup << RubySMB::SMB1::Packet::Trans2::Subcommands::QUERY_PATH_INFORMATION
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
module RubySMB
|
2
|
+
module SMB1
|
3
|
+
module Packet
|
4
|
+
module Trans2
|
5
|
+
# The Trans2 Parameter Block for this particular Subcommand
|
6
|
+
class QueryPathInformationResponseTrans2Parameters < BinData::Record
|
7
|
+
endian :little
|
8
|
+
|
9
|
+
uint16 :ea_error_offset, label: 'EA Error Offset'
|
10
|
+
|
11
|
+
# Returns the length of the Trans2Parameters struct
|
12
|
+
# in number of bytes
|
13
|
+
def length
|
14
|
+
do_num_bytes
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
# The Trans2 Data Block for this particular Subcommand
|
19
|
+
class QueryPathInformationResponseTrans2Data < BinData::Record
|
20
|
+
string :buffer, label: 'Results Buffer', read_length: :buffer_read_length
|
21
|
+
|
22
|
+
# Returns the length of the Trans2Data struct
|
23
|
+
# in number of bytes
|
24
|
+
def length
|
25
|
+
do_num_bytes
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
# The {RubySMB::SMB1::DataBlock} specific to this packet type.
|
30
|
+
class QueryPathInformationResponseDataBlock < RubySMB::SMB1::Packet::Trans2::DataBlock
|
31
|
+
uint8 :name, label: 'Name', initial_value: 0x00
|
32
|
+
string :pad1, length: -> { pad1_length }
|
33
|
+
query_path_information_response_trans2_parameters :trans2_parameters, label: 'Trans2 Parameters'
|
34
|
+
string :pad2, length: -> { pad2_length }
|
35
|
+
query_path_information_response_trans2_data :trans2_data, label: 'Trans2 Data'
|
36
|
+
end
|
37
|
+
|
38
|
+
# A Trans2 QUERY_PATH_INFORMATION Response Packet as defined in
|
39
|
+
# [2.2.6.6.2](https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-cifs/abd94ec3-6c35-4da5-9cef-7abbbf233a80)
|
40
|
+
class QueryPathInformationResponse < RubySMB::GenericPacket
|
41
|
+
COMMAND = RubySMB::SMB1::Commands::SMB_COM_TRANSACTION2
|
42
|
+
|
43
|
+
class ParameterBlock < RubySMB::SMB1::Packet::Trans2::Response::ParameterBlock
|
44
|
+
end
|
45
|
+
|
46
|
+
smb_header :smb_header
|
47
|
+
parameter_block :parameter_block
|
48
|
+
query_path_information_response_data_block :data_block
|
49
|
+
|
50
|
+
def initialize_instance
|
51
|
+
super
|
52
|
+
parameter_block.setup << RubySMB::SMB1::Packet::Trans2::Subcommands::QUERY_PATH_INFORMATION
|
53
|
+
smb_header.flags.reply = 1
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -25,22 +25,38 @@ module RubySMB
|
|
25
25
|
uint8 :setup_count, label: 'Setup Count', initial_value: -> { setup.length }
|
26
26
|
uint8 :reserved3, label: 'Reserved Space', initial_value: 0x00
|
27
27
|
|
28
|
-
array :setup, type: :uint16, initial_length:
|
28
|
+
array :setup, type: :uint16, initial_length: :setup_count
|
29
29
|
end
|
30
30
|
|
31
31
|
# The {RubySMB::SMB1::DataBlock} specific to this packet type.
|
32
32
|
class DataBlock < RubySMB::SMB1::Packet::Trans2::DataBlock
|
33
|
-
uint8 :name,
|
34
|
-
string :pad1,
|
35
|
-
string :trans2_parameters,
|
36
|
-
string :pad2,
|
37
|
-
string :trans2_data,
|
33
|
+
uint8 :name, label: 'Name', initial_value: 0x00
|
34
|
+
string :pad1, length: -> { pad1_length }
|
35
|
+
string :trans2_parameters, label: 'Trans2 Parameters'
|
36
|
+
string :pad2, length: -> { pad2_length }
|
37
|
+
string :trans2_data, label: 'Trans2 Data'
|
38
38
|
end
|
39
39
|
|
40
|
+
require 'ruby_smb/smb1/packet/trans2/find_first2_request'
|
41
|
+
require 'ruby_smb/smb1/packet/trans2/find_next2_request'
|
42
|
+
require 'ruby_smb/smb1/packet/trans2/open2_request'
|
43
|
+
require 'ruby_smb/smb1/packet/trans2/query_file_information_request'
|
44
|
+
require 'ruby_smb/smb1/packet/trans2/query_path_information_request'
|
45
|
+
require 'ruby_smb/smb1/packet/trans2/set_file_information_request'
|
46
|
+
require 'ruby_smb/smb1/packet/trans2/query_fs_information_request'
|
47
|
+
|
40
48
|
smb_header :smb_header
|
41
49
|
parameter_block :parameter_block
|
42
|
-
data_block
|
43
|
-
|
50
|
+
choice :data_block, selection: -> { parameter_block.setup.first || :default } do
|
51
|
+
open2_request_data_block Subcommands::OPEN2
|
52
|
+
find_first2_request_data_block Subcommands::FIND_FIRST2
|
53
|
+
find_next2_request_data_block Subcommands::FIND_NEXT2
|
54
|
+
query_file_information_request_data_block Subcommands::QUERY_FILE_INFORMATION
|
55
|
+
query_path_information_request_data_block Subcommands::QUERY_PATH_INFORMATION
|
56
|
+
set_file_information_request_data_block Subcommands::SET_FILE_INFORMATION
|
57
|
+
query_fs_information_request_data_block Subcommands::QUERY_FS_INFORMATION
|
58
|
+
data_block :default
|
59
|
+
end
|
44
60
|
end
|
45
61
|
end
|
46
62
|
end
|
@@ -9,7 +9,7 @@ module RubySMB
|
|
9
9
|
|
10
10
|
# The {RubySMB::SMB1::ParameterBlock} specific to this packet type.
|
11
11
|
class ParameterBlock < RubySMB::SMB1::ParameterBlock
|
12
|
-
uint16
|
12
|
+
uint16 :total_parameter_count, label: 'Total Parameter Count(bytes)'
|
13
13
|
uint16 :total_data_count, label: 'Total Data Count(bytes)'
|
14
14
|
uint16 :parameter_count, label: 'Parameter Count(bytes)', initial_value: -> { parent.data_block.trans2_parameters.length }
|
15
15
|
uint16 :parameter_offset, label: 'Parameter Offset', initial_value: -> { parent.data_block.trans2_parameters.abs_offset }
|
@@ -24,9 +24,9 @@ module RubySMB
|
|
24
24
|
class DataBlock < RubySMB::SMB1::Packet::Trans2::Request::DataBlock
|
25
25
|
end
|
26
26
|
|
27
|
-
smb_header
|
28
|
-
parameter_block
|
29
|
-
data_block
|
27
|
+
smb_header :smb_header
|
28
|
+
parameter_block :parameter_block
|
29
|
+
data_block :data_block
|
30
30
|
|
31
31
|
end
|
32
32
|
end
|
@@ -9,32 +9,41 @@ module RubySMB
|
|
9
9
|
|
10
10
|
# The {RubySMB::SMB1::ParameterBlock} specific to this packet type.
|
11
11
|
class ParameterBlock < RubySMB::SMB1::ParameterBlock
|
12
|
-
uint16
|
13
|
-
uint16
|
14
|
-
uint16
|
15
|
-
uint16
|
16
|
-
uint16
|
17
|
-
uint16
|
18
|
-
uint16
|
19
|
-
uint16
|
20
|
-
uint16
|
21
|
-
uint8
|
22
|
-
uint8
|
12
|
+
uint16 :total_parameter_count, label: 'Total Parameter Count(bytes)'
|
13
|
+
uint16 :total_data_count, label: 'Total Data Count(bytes)'
|
14
|
+
uint16 :reserved, label: 'Reserved Space', initial_value: 0x00
|
15
|
+
uint16 :parameter_count, label: 'Parameter Count(bytes)', initial_value: -> { parent.data_block.trans2_parameters.length }
|
16
|
+
uint16 :parameter_offset, label: 'Parameter Offset', initial_value: -> { parent.data_block.trans2_parameters.abs_offset }
|
17
|
+
uint16 :parameter_displacement, label: 'Parameter Displacement'
|
18
|
+
uint16 :data_count, label: 'Data Count(bytes)', initial_value: -> { parent.data_block.trans2_data.length }
|
19
|
+
uint16 :data_offset, label: 'Data Offset', initial_value: -> { parent.data_block.trans2_data.abs_offset }
|
20
|
+
uint16 :data_displacement, label: 'Data Displacement'
|
21
|
+
uint8 :setup_count, label: 'Setup Count', initial_value: -> { setup.length }
|
22
|
+
uint8 :reserved2, label: 'Reserved Space', initial_value: 0x00
|
23
23
|
|
24
|
-
array :setup, type: :uint16, initial_length:
|
24
|
+
array :setup, type: :uint16, initial_length: :setup_count
|
25
25
|
end
|
26
26
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
27
|
+
require 'ruby_smb/smb1/packet/trans2/find_first2_response'
|
28
|
+
require 'ruby_smb/smb1/packet/trans2/find_next2_response'
|
29
|
+
require 'ruby_smb/smb1/packet/trans2/open2_response'
|
30
|
+
require 'ruby_smb/smb1/packet/trans2/query_file_information_response'
|
31
|
+
require 'ruby_smb/smb1/packet/trans2/query_path_information_response'
|
32
|
+
require 'ruby_smb/smb1/packet/trans2/set_file_information_response'
|
33
|
+
require 'ruby_smb/smb1/packet/trans2/query_fs_information_response'
|
34
34
|
|
35
35
|
smb_header :smb_header
|
36
36
|
parameter_block :parameter_block
|
37
|
-
data_block
|
37
|
+
choice :data_block, selection: -> { parameter_block.setup.first || :default } do
|
38
|
+
open2_response_data_block Subcommands::OPEN2
|
39
|
+
find_first2_response_data_block Subcommands::FIND_FIRST2
|
40
|
+
find_next2_response_data_block Subcommands::FIND_NEXT2
|
41
|
+
query_file_information_response_data_block Subcommands::QUERY_FILE_INFORMATION
|
42
|
+
query_path_information_response_data_block Subcommands::QUERY_PATH_INFORMATION
|
43
|
+
set_file_information_response_data_block Subcommands::SET_FILE_INFORMATION
|
44
|
+
query_fs_information_response_data_block Subcommands::QUERY_FS_INFORMATION
|
45
|
+
data_block :default
|
46
|
+
end
|
38
47
|
|
39
48
|
def initialize_instance
|
40
49
|
super
|
@@ -2,59 +2,59 @@ module RubySMB
|
|
2
2
|
module SMB1
|
3
3
|
module Packet
|
4
4
|
module Trans2
|
5
|
-
#
|
6
|
-
|
7
|
-
|
8
|
-
COMMAND = RubySMB::SMB1::Commands::SMB_COM_TRANSACTION2
|
5
|
+
# The Trans2 Parameter Block for this particular Subcommand
|
6
|
+
class SetFileInformationRequestTrans2Parameters < BinData::Record
|
7
|
+
endian :little
|
9
8
|
|
10
|
-
|
11
|
-
|
9
|
+
uint16 :fid, label: 'FID'
|
10
|
+
uint16 :information_level, label: 'Information Level'
|
11
|
+
uint16 :reserved, label: 'Reserved Space'
|
12
12
|
|
13
|
-
#
|
14
|
-
|
15
|
-
|
13
|
+
# Returns the length of the Trans2Parameters struct
|
14
|
+
# in number of bytes
|
15
|
+
def length
|
16
|
+
do_num_bytes
|
17
|
+
end
|
18
|
+
end
|
16
19
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
+
# The Trans2 Data Block for this particular Subcommand
|
21
|
+
class SetFileInformationRequestTrans2Data < BinData::Record
|
22
|
+
include RubySMB::Fscc::FileInformation
|
20
23
|
|
21
|
-
|
22
|
-
#
|
23
|
-
|
24
|
-
|
25
|
-
|
24
|
+
choice :info_level_struct, selection: -> { parent.trans2_parameters.information_level } do
|
25
|
+
# It supports new pass-through Information Level capabilities, as specified in
|
26
|
+
# [2.2.2.3.5 Pass-through Information Level Codes](https://msdn.microsoft.com/en-us/library/ff470158.aspx)
|
27
|
+
file_disposition_information (FILE_DISPOSITION_INFORMATION + SMB_INFO_PASSTHROUGH), label: 'File Disposition Information'
|
28
|
+
file_rename_information (FILE_RENAME_INFORMATION + SMB_INFO_PASSTHROUGH), label: 'File Rename Information'
|
26
29
|
end
|
27
30
|
|
28
|
-
#
|
29
|
-
|
30
|
-
|
31
|
+
# Returns the length of the Trans2Data struct
|
32
|
+
# in number of bytes
|
33
|
+
def length
|
34
|
+
do_num_bytes
|
35
|
+
end
|
36
|
+
end
|
31
37
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
+
# The {RubySMB::SMB1::DataBlock} specific to this packet type.
|
39
|
+
class SetFileInformationRequestDataBlock < RubySMB::SMB1::Packet::Trans2::DataBlock
|
40
|
+
uint8 :name, label: 'Name', initial_value: 0x00
|
41
|
+
string :pad1, length: -> { pad1_length }
|
42
|
+
set_file_information_request_trans2_parameters :trans2_parameters, label: 'Trans2 Parameters'
|
43
|
+
string :pad2, length: -> { pad2_length }
|
44
|
+
set_file_information_request_trans2_data :trans2_data, label: 'Trans2 Data'
|
45
|
+
end
|
38
46
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
end
|
44
|
-
end
|
47
|
+
# A Trans2 SET_FILE_INFORMATION Request Packet as defined in
|
48
|
+
# [2.2.6.9.1 Request](https://msdn.microsoft.com/en-us/library/ee441527.aspx)
|
49
|
+
class SetFileInformationRequest < RubySMB::GenericPacket
|
50
|
+
COMMAND = RubySMB::SMB1::Commands::SMB_COM_TRANSACTION2
|
45
51
|
|
46
|
-
|
47
|
-
class DataBlock < RubySMB::SMB1::Packet::Trans2::DataBlock
|
48
|
-
uint8 :name, label: 'Name', initial_value: 0x00
|
49
|
-
string :pad1, length: -> { pad1_length }
|
50
|
-
trans2_parameters :trans2_parameters, label: 'Trans2 Parameters'
|
51
|
-
string :pad2, length: -> { pad2_length }
|
52
|
-
trans2_data :trans2_data, label: 'Trans2 Data'
|
52
|
+
class ParameterBlock < RubySMB::SMB1::Packet::Trans2::Request::ParameterBlock
|
53
53
|
end
|
54
54
|
|
55
|
-
smb_header
|
56
|
-
parameter_block
|
57
|
-
|
55
|
+
smb_header :smb_header
|
56
|
+
parameter_block :parameter_block
|
57
|
+
set_file_information_request_data_block :data_block
|
58
58
|
|
59
59
|
def initialize_instance
|
60
60
|
super
|
@@ -2,6 +2,26 @@ module RubySMB
|
|
2
2
|
module SMB1
|
3
3
|
module Packet
|
4
4
|
module Trans2
|
5
|
+
# The Trans2 Parameter Block for this particular Subcommand
|
6
|
+
class SetFileInformationResponseTrans2Parameters < BinData::Record
|
7
|
+
endian :little
|
8
|
+
|
9
|
+
uint16 :ea_error_offset, label: 'Extended Attribute Error Offset'
|
10
|
+
|
11
|
+
# Returns the length of the Trans2Parameters struct
|
12
|
+
# in number of bytes
|
13
|
+
def length
|
14
|
+
do_num_bytes
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
# The {RubySMB::SMB1::DataBlock} specific to this packet type.
|
19
|
+
class SetFileInformationResponseDataBlock < RubySMB::SMB1::Packet::Trans2::DataBlock
|
20
|
+
string :pad1, length: -> { pad1_length }
|
21
|
+
set_file_information_response_trans2_parameters :trans2_parameters, label: 'Trans2 Parameters'
|
22
|
+
# trans2_data: No data is sent by this message.
|
23
|
+
end
|
24
|
+
|
5
25
|
# A Trans2 SET_FILE_INFORMATION Response Packet as defined in
|
6
26
|
# [2.2.6.9.2 Response](https://msdn.microsoft.com/en-us/library/ff469853.aspx)
|
7
27
|
class SetFileInformationResponse < RubySMB::GenericPacket
|
@@ -10,29 +30,9 @@ module RubySMB
|
|
10
30
|
class ParameterBlock < RubySMB::SMB1::Packet::Trans2::Response::ParameterBlock
|
11
31
|
end
|
12
32
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
uint16 :ea_error_offset, label: 'Extended Attribute Error Offset'
|
18
|
-
|
19
|
-
# Returns the length of the Trans2Parameters struct
|
20
|
-
# in number of bytes
|
21
|
-
def length
|
22
|
-
do_num_bytes
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
# The {RubySMB::SMB1::DataBlock} specific to this packet type.
|
27
|
-
class DataBlock < RubySMB::SMB1::Packet::Trans2::DataBlock
|
28
|
-
string :pad1, length: -> { pad1_length }
|
29
|
-
trans2_parameters :trans2_parameters, label: 'Trans2 Parameters'
|
30
|
-
# trans2_data: No data is sent by this message.
|
31
|
-
end
|
32
|
-
|
33
|
-
smb_header :smb_header
|
34
|
-
parameter_block :parameter_block
|
35
|
-
data_block :data_block
|
33
|
+
smb_header :smb_header
|
34
|
+
parameter_block :parameter_block
|
35
|
+
set_file_information_response_data_block :data_block
|
36
36
|
|
37
37
|
def initialize_instance
|
38
38
|
super
|
@@ -2,12 +2,30 @@ module RubySMB
|
|
2
2
|
module SMB1
|
3
3
|
module Packet
|
4
4
|
module Trans2
|
5
|
+
# Transaction2 subcommand constants as defined in
|
6
|
+
# [2.2.6 Transaction2 Subcommands](https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-cifs/1cc40e02-aaea-4f33-b7b7-3a6b63906516)
|
5
7
|
module Subcommands
|
6
|
-
OPEN2
|
7
|
-
FIND_FIRST2
|
8
|
-
FIND_NEXT2
|
9
|
-
|
10
|
-
|
8
|
+
OPEN2 = 0x0000
|
9
|
+
FIND_FIRST2 = 0x0001
|
10
|
+
FIND_NEXT2 = 0x0002
|
11
|
+
QUERY_FS_INFORMATION = 0x0003
|
12
|
+
SET_FS_INFORMATION = 0x0004
|
13
|
+
QUERY_PATH_INFORMATION = 0x0005
|
14
|
+
SET_PATH_INFORMATION = 0x0006
|
15
|
+
QUERY_FILE_INFORMATION = 0x0007
|
16
|
+
SET_FILE_INFORMATION = 0x0008
|
17
|
+
FSCTL = 0x0009
|
18
|
+
IOCTL2 = 0x000A
|
19
|
+
FIND_NOTIFY_FIRST = 0x000B
|
20
|
+
FIND_NOTIFY_NEXT = 0x000C
|
21
|
+
CREATE_DIRECTORY = 0x000D
|
22
|
+
SESSION_SETUP = 0x000E
|
23
|
+
GET_DFS_REFERRAL = 0x0010
|
24
|
+
REPORT_DFS_INCONSISTENCY = 0x0011
|
25
|
+
|
26
|
+
def self.name(value)
|
27
|
+
constants.select { |c| c.upcase == c }.find { |c| const_get(c) == value }
|
28
|
+
end
|
11
29
|
end
|
12
30
|
end
|
13
31
|
end
|
@@ -5,6 +5,8 @@ module RubySMB
|
|
5
5
|
# [2.2.4.46 SMB_COM_TRANSACTION2 (0x32)](https://msdn.microsoft.com/en-us/library/ee441652.aspx)
|
6
6
|
module Trans2
|
7
7
|
require 'ruby_smb/smb1/packet/trans2/find_information_level'
|
8
|
+
require 'ruby_smb/smb1/packet/trans2/query_information_level'
|
9
|
+
require 'ruby_smb/smb1/packet/trans2/query_fs_information_level'
|
8
10
|
require 'ruby_smb/smb1/packet/trans2/data_block'
|
9
11
|
require 'ruby_smb/smb1/packet/trans2/subcommands'
|
10
12
|
require 'ruby_smb/smb1/packet/trans2/request'
|
@@ -18,6 +20,8 @@ module RubySMB
|
|
18
20
|
require 'ruby_smb/smb1/packet/trans2/find_next2_response'
|
19
21
|
require 'ruby_smb/smb1/packet/trans2/set_file_information_request'
|
20
22
|
require 'ruby_smb/smb1/packet/trans2/set_file_information_response'
|
23
|
+
require 'ruby_smb/smb1/packet/trans2/query_path_information_request'
|
24
|
+
require 'ruby_smb/smb1/packet/trans2/query_path_information_response'
|
21
25
|
end
|
22
26
|
end
|
23
27
|
end
|
@@ -16,7 +16,10 @@ module RubySMB
|
|
16
16
|
# The {RubySMB::SMB1::DataBlock} specific to this packet type.
|
17
17
|
class DataBlock < RubySMB::SMB1::DataBlock
|
18
18
|
stringz :password, label: 'Password Field', initial_value: '', length: -> { parent.parameter_block.password_length }
|
19
|
-
|
19
|
+
choice :path, selection: -> { parent.smb_header.flags2.unicode } do
|
20
|
+
stringz 0
|
21
|
+
stringz16 1
|
22
|
+
end
|
20
23
|
stringz :service, label: 'Resource Type', initial_value: '?????'
|
21
24
|
end
|
22
25
|
|
@@ -30,7 +30,7 @@ module RubySMB
|
|
30
30
|
bit1 :generic_execute, label: 'Generic Execute'
|
31
31
|
bit1 :generic_all, label: 'Generic All'
|
32
32
|
bit2 :reserved3
|
33
|
-
bit1 :
|
33
|
+
bit1 :maximum_allowed, label: 'Maximum Allowed'
|
34
34
|
bit1 :system_security, label: 'System Security'
|
35
35
|
end
|
36
36
|
end
|
@@ -30,7 +30,7 @@ module RubySMB
|
|
30
30
|
bit1 :generic_execute, label: 'Generic Execute'
|
31
31
|
bit1 :generic_all, label: 'Generic All'
|
32
32
|
bit2 :reserved3
|
33
|
-
bit1 :
|
33
|
+
bit1 :maximum_allowed, label: 'Maximum Allowed'
|
34
34
|
bit1 :system_security, label: 'System Security'
|
35
35
|
end
|
36
36
|
end
|
@@ -22,9 +22,13 @@ module RubySMB
|
|
22
22
|
class EncryptionCapabilities < BinData::Record
|
23
23
|
AES_128_CCM = 0x0001
|
24
24
|
AES_128_GCM = 0x0002
|
25
|
+
AES_256_CCM = 0x0003
|
26
|
+
AES_256_GCM = 0x0004
|
25
27
|
ENCRYPTION_ALGORITHM_MAP = {
|
26
28
|
AES_128_CCM => 'AES-128-CCM',
|
27
|
-
AES_128_GCM => 'AES-128-GCM'
|
29
|
+
AES_128_GCM => 'AES-128-GCM',
|
30
|
+
AES_256_CCM => 'AES-256-CCM',
|
31
|
+
AES_256_GCM => 'AES-256-GCM'
|
28
32
|
}
|
29
33
|
|
30
34
|
endian :little
|
@@ -99,6 +103,10 @@ module RubySMB
|
|
99
103
|
SMB2_NETNAME_NEGOTIATE_CONTEXT_ID = 0x0005
|
100
104
|
# The NegotiateContext Data field contains the transport capabilities, as specified in section 2.2.3.1.5.
|
101
105
|
SMB2_TRANSPORT_CAPABILITIES = 0x0006
|
106
|
+
# The NegotiateContext Data field contains the RDMA transform capabilities, as specified in section 2.2.3.1.6.
|
107
|
+
SMB2_RDMA_TRANSFORM_CAPABILITIES = 0x0007
|
108
|
+
# The NegotiateContext Data field contains the signing capabilities, as specified in section 2.2.3.1.7.
|
109
|
+
SMB2_SIGNING_CAPABILITIES = 0x0008
|
102
110
|
|
103
111
|
endian :little
|
104
112
|
|
@@ -112,6 +120,7 @@ module RubySMB
|
|
112
120
|
compression_capabilities SMB2_COMPRESSION_CAPABILITIES, label: 'Compression Capabilities'
|
113
121
|
netname_negotiate_context_id SMB2_NETNAME_NEGOTIATE_CONTEXT_ID, label: 'Netname Negotiate Context ID', data_length: :data_length
|
114
122
|
transport_capabilities SMB2_TRANSPORT_CAPABILITIES, label: 'Transport Capabilities'
|
123
|
+
string :default, label: 'Unsupported Negotiating Context', read_length: :data_length
|
115
124
|
end
|
116
125
|
|
117
126
|
def pad_length
|