ruby_smb 3.0.6 → 3.1.2
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/examples/file_server.rb +8 -1
- data/examples/virtual_file_server.rb +143 -0
- data/lib/ruby_smb/client/encryption.rb +16 -4
- data/lib/ruby_smb/client/negotiation.rb +10 -8
- data/lib/ruby_smb/fscc/file_information/file_access_information.rb +15 -0
- data/lib/ruby_smb/fscc/file_information/file_alignment_information.rb +45 -0
- data/lib/ruby_smb/fscc/file_information/file_all_information.rb +23 -0
- data/lib/ruby_smb/fscc/file_information/file_basic_information.rb +20 -0
- data/lib/ruby_smb/fscc/file_information/file_both_directory_information.rb +3 -3
- data/lib/ruby_smb/fscc/file_information/file_directory_information.rb +3 -3
- data/lib/ruby_smb/fscc/file_information/file_ea_information.rb +1 -0
- data/lib/ruby_smb/fscc/file_information/file_full_directory_information.rb +3 -3
- data/lib/ruby_smb/fscc/file_information/file_id_both_directory_information.rb +3 -3
- data/lib/ruby_smb/fscc/file_information/file_id_full_directory_information.rb +3 -3
- data/lib/ruby_smb/fscc/file_information/file_internal_information.rb +15 -0
- data/lib/ruby_smb/fscc/file_information/file_mode_information.rb +29 -0
- data/lib/ruby_smb/fscc/file_information/file_name_information.rb +16 -0
- data/lib/ruby_smb/fscc/file_information/file_names_information.rb +1 -1
- data/lib/ruby_smb/fscc/file_information/file_normalized_name_information.rb +16 -0
- data/lib/ruby_smb/fscc/file_information/file_position_information.rb +15 -0
- data/lib/ruby_smb/fscc/file_information/file_rename_information.rb +1 -1
- data/lib/ruby_smb/fscc/file_information/file_standard_information.rb +20 -0
- data/lib/ruby_smb/fscc/file_information/file_stream_information.rb +3 -0
- data/lib/ruby_smb/fscc/file_information.rb +43 -6
- data/lib/ruby_smb/fscc/file_system_information/file_fs_attribute_information.rb +1 -0
- data/lib/ruby_smb/fscc/file_system_information/file_fs_volume_information.rb +1 -0
- data/lib/ruby_smb/fscc/file_system_information.rb +4 -0
- data/lib/ruby_smb/gss/provider/ntlm.rb +20 -3
- data/lib/ruby_smb/gss/provider.rb +10 -1
- 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 +21 -4
- 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 +156 -38
- data/lib/ruby_smb/server/session.rb +5 -1
- data/lib/ruby_smb/server/share/provider/disk/file_system.rb +28 -0
- data/lib/ruby_smb/server/share/provider/disk/processor/close.rb +46 -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 +70 -0
- data/lib/ruby_smb/server/share/provider/disk/processor.rb +223 -0
- data/lib/ruby_smb/server/share/provider/disk.rb +12 -418
- 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/server/share/provider/virtual_disk/virtual_file.rb +85 -0
- data/lib/ruby_smb/server/share/provider/virtual_disk/virtual_pathname.rb +196 -0
- data/lib/ruby_smb/server/share/provider/virtual_disk/virtual_stat.rb +175 -0
- data/lib/ruby_smb/server/share/provider/virtual_disk.rb +116 -0
- data/lib/ruby_smb/server/share/provider.rb +1 -0
- data/lib/ruby_smb/server.rb +13 -3
- data/lib/ruby_smb/signing.rb +18 -4
- 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/negotiate_context.rb +10 -1
- data/lib/ruby_smb/smb2/packet/transform_header.rb +7 -7
- data/lib/ruby_smb/smb2/tree.rb +1 -0
- data/lib/ruby_smb/smb2.rb +1 -0
- data/lib/ruby_smb/version.rb +1 -1
- data/spec/lib/ruby_smb/client_spec.rb +31 -8
- data/spec/lib/ruby_smb/fscc/file_information/file_access_information_spec.rb +21 -0
- data/spec/lib/ruby_smb/fscc/file_information/file_alignment_information_spec.rb +21 -0
- data/spec/lib/ruby_smb/fscc/file_information/file_all_information_spec.rb +61 -0
- data/spec/lib/ruby_smb/fscc/file_information/file_basic_information_spec.rb +41 -0
- data/spec/lib/ruby_smb/fscc/file_information/file_both_directory_information_spec.rb +59 -10
- data/spec/lib/ruby_smb/fscc/file_information/file_directory_information_spec.rb +30 -12
- data/spec/lib/ruby_smb/fscc/file_information/file_ea_information_spec.rb +21 -0
- data/spec/lib/ruby_smb/fscc/file_information/file_full_directory_information_spec.rb +30 -12
- data/spec/lib/ruby_smb/fscc/file_information/file_id_both_directory_information_spec.rb +63 -10
- data/spec/lib/ruby_smb/fscc/file_information/file_id_full_directory_information_spec.rb +30 -12
- data/spec/lib/ruby_smb/fscc/file_information/file_internal_information_spec.rb +21 -0
- data/spec/lib/ruby_smb/fscc/file_information/file_mode_information_spec.rb +21 -0
- data/spec/lib/ruby_smb/fscc/file_information/file_name_information_spec.rb +44 -0
- data/spec/lib/ruby_smb/fscc/file_information/file_names_information_spec.rb +30 -12
- data/spec/lib/ruby_smb/fscc/file_information/file_network_open_information_spec.rb +51 -0
- data/spec/lib/ruby_smb/fscc/file_information/file_normalized_name_information_spec.rb +44 -0
- data/spec/lib/ruby_smb/fscc/file_information/file_position_information_spec.rb +21 -0
- data/spec/lib/ruby_smb/fscc/file_information/file_rename_information_spec.rb +1 -1
- data/spec/lib/ruby_smb/fscc/file_information/file_standard_information_spec.rb +41 -0
- data/spec/lib/ruby_smb/fscc/file_information/file_stream_information_spec.rb +51 -0
- data/spec/lib/ruby_smb/fscc/file_information_spec.rb +14 -0
- data/spec/lib/ruby_smb/fscc/file_system_information/file_fs_attribute_information_spec.rb +46 -0
- data/spec/lib/ruby_smb/fscc/file_system_information/file_fs_volume_information_spec.rb +51 -0
- data/spec/lib/ruby_smb/fscc/file_system_information_spec.rb +14 -0
- data/spec/lib/ruby_smb/server/server_client_spec.rb +15 -0
- data/spec/lib/ruby_smb/server/share/provider/virtual_disk/virtual_pathname_spec.rb +581 -0
- data/spec/lib/ruby_smb/server/share/provider/virtual_disk/virtual_stat_spec.rb +207 -0
- data/spec/lib/ruby_smb/server/share/provider/virtual_disk_spec.rb +122 -0
- 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/packet/transform_header_spec.rb +2 -2
- data.tar.gz.sig +0 -0
- metadata +88 -2
- metadata.gz.sig +0 -0
@@ -2,6 +2,43 @@ 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 Open2ResponseTrans2Parameters < BinData::Record
|
7
|
+
endian :little
|
8
|
+
uint8 :fid, label: 'File ID'
|
9
|
+
smb_file_attributes :file_attributes, label: 'File Attributes'
|
10
|
+
utime :creation_time, label: 'Creation Time'
|
11
|
+
open2_access_mode :access_mode, label: 'AccessMode'
|
12
|
+
uint16 :resource_type, label: 'Resource Type'
|
13
|
+
smb_nmpipe_status :nmpipe_status, label: 'Named Pipe Status'
|
14
|
+
|
15
|
+
struct :action_taken do
|
16
|
+
endian :little
|
17
|
+
bit6 :reserved, label: 'Reserved Space'
|
18
|
+
bit2 :open_result, label: 'Open Result'
|
19
|
+
# byte boundary
|
20
|
+
bit1 :lock_status, label: 'Lock Status'
|
21
|
+
resume_byte_alignment
|
22
|
+
end
|
23
|
+
|
24
|
+
uint32 :reserved, label: 'Reserved Space'
|
25
|
+
uint16 :extended_attribute_offset, label: 'Extended Attribute Offset'
|
26
|
+
uint32 :extended_attribute_length, label: 'Extended Attribute Length'
|
27
|
+
|
28
|
+
# Returns the length of the Trans2Parameters struct
|
29
|
+
# in number of bytes
|
30
|
+
def length
|
31
|
+
do_num_bytes
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# The {RubySMB::SMB1::DataBlock} specific to this packet type.
|
36
|
+
class Open2ResponseDataBlock < RubySMB::SMB1::Packet::Trans2::DataBlock
|
37
|
+
string :pad1, length: -> { pad1_length }
|
38
|
+
open2_response_trans2_parameters :trans2_parameters, label: 'Trans2 Parameters'
|
39
|
+
# trans2_data: No data is sent by this message.
|
40
|
+
end
|
41
|
+
|
5
42
|
# This class represents an SMB1 Trans2 Open2 Response Packet as defined in
|
6
43
|
# [2.2.6.1.2 Response](https://msdn.microsoft.com/en-us/library/ee441545.aspx)
|
7
44
|
class Open2Response < RubySMB::GenericPacket
|
@@ -10,46 +47,9 @@ module RubySMB
|
|
10
47
|
class ParameterBlock < RubySMB::SMB1::Packet::Trans2::Response::ParameterBlock
|
11
48
|
end
|
12
49
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
uint8 :fid, label: 'File ID'
|
17
|
-
smb_file_attributes :file_attributes, label: 'File Attributes'
|
18
|
-
utime :creation_time, label: 'Creation Time'
|
19
|
-
open2_access_mode :access_mode, label: 'AccessMode'
|
20
|
-
uint16 :resource_type, label: 'Resource Type'
|
21
|
-
smb_nmpipe_status :nmpipe_status, label: 'Named Pipe Status'
|
22
|
-
|
23
|
-
struct :action_taken do
|
24
|
-
endian :little
|
25
|
-
bit6 :reserved, label: 'Reserved Space'
|
26
|
-
bit2 :open_result, label: 'Open Result'
|
27
|
-
# byte boundary
|
28
|
-
bit1 :lock_status, label: 'Lock Status'
|
29
|
-
resume_byte_alignment
|
30
|
-
end
|
31
|
-
|
32
|
-
uint32 :reserved, label: 'Reserved Space'
|
33
|
-
uint16 :extended_attribute_offset, label: 'Extended Attribute Offset'
|
34
|
-
uint32 :extended_attribute_length, label: 'Extended Attribute Length'
|
35
|
-
|
36
|
-
# Returns the length of the Trans2Parameters struct
|
37
|
-
# in number of bytes
|
38
|
-
def length
|
39
|
-
do_num_bytes
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
# The {RubySMB::SMB1::DataBlock} specific to this packet type.
|
44
|
-
class DataBlock < RubySMB::SMB1::Packet::Trans2::DataBlock
|
45
|
-
string :pad1, length: -> { pad1_length }
|
46
|
-
trans2_parameters :trans2_parameters, label: 'Trans2 Parameters'
|
47
|
-
# trans2_data: No data is sent by this message.
|
48
|
-
end
|
49
|
-
|
50
|
-
smb_header :smb_header
|
51
|
-
parameter_block :parameter_block
|
52
|
-
data_block :data_block
|
50
|
+
smb_header :smb_header
|
51
|
+
parameter_block :parameter_block
|
52
|
+
open2_response_data_block :data_block
|
53
53
|
|
54
54
|
def initialize_instance
|
55
55
|
super
|
@@ -0,0 +1,60 @@
|
|
1
|
+
module RubySMB
|
2
|
+
module SMB1
|
3
|
+
module Packet
|
4
|
+
module Trans2
|
5
|
+
# The Trans2 Parameter Block for this particular Subcommand
|
6
|
+
class QueryFileInformationRequestTrans2Parameters < BinData::Record
|
7
|
+
endian :little
|
8
|
+
|
9
|
+
uint16 :fid, label: 'FID'
|
10
|
+
uint16 :information_level, label: 'Information Level'
|
11
|
+
|
12
|
+
# Returns the length of the Trans2Parameters struct
|
13
|
+
# in number of bytes
|
14
|
+
def length
|
15
|
+
do_num_bytes
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
# The Trans2 Data Block for this particular Subcommand
|
20
|
+
class QueryFileInformationRequestTrans2Data < BinData::Record
|
21
|
+
smb_gea_list :extended_attribute_list, label: 'Get Extended Attribute List',
|
22
|
+
onlyif: -> { parent.trans2_parameters.information_level == FindInformationLevel::SMB_INFO_QUERY_EAS_FROM_LIST}
|
23
|
+
|
24
|
+
# Returns the length of the Trans2Data struct
|
25
|
+
# in number of bytes
|
26
|
+
def length
|
27
|
+
do_num_bytes
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
# The {RubySMB::SMB1::DataBlock} specific to this packet type.
|
32
|
+
class QueryFileInformationRequestDataBlock < RubySMB::SMB1::Packet::Trans2::DataBlock
|
33
|
+
uint8 :name, label: 'Name', initial_value: 0x00
|
34
|
+
string :pad1, length: -> { pad1_length }
|
35
|
+
query_file_information_request_trans2_parameters :trans2_parameters, label: 'Trans2 Parameters'
|
36
|
+
string :pad2, length: -> { pad2_length }
|
37
|
+
query_file_information_request_trans2_data :trans2_data, label: 'Trans2 Data'
|
38
|
+
end
|
39
|
+
|
40
|
+
# A Trans2 QUERY_FILE_INFORMATION Request Packet as defined in
|
41
|
+
# [2.2.6.8.1](https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-cifs/357bf60d-f30a-457e-9787-9f78322b92d3)
|
42
|
+
class QueryFileInformationRequest < RubySMB::GenericPacket
|
43
|
+
COMMAND = RubySMB::SMB1::Commands::SMB_COM_TRANSACTION2
|
44
|
+
|
45
|
+
class ParameterBlock < RubySMB::SMB1::Packet::Trans2::Request::ParameterBlock
|
46
|
+
end
|
47
|
+
|
48
|
+
smb_header :smb_header
|
49
|
+
parameter_block :parameter_block
|
50
|
+
query_file_information_request_data_block :data_block
|
51
|
+
|
52
|
+
def initialize_instance
|
53
|
+
super
|
54
|
+
parameter_block.setup << RubySMB::SMB1::Packet::Trans2::Subcommands::QUERY_FILE_INFORMATION
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
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 QueryFileInformationResponseTrans2Parameters < 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 QueryFileInformationResponseTrans2Data < 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 QueryFileInformationResponseDataBlock < RubySMB::SMB1::Packet::Trans2::DataBlock
|
31
|
+
uint8 :name, label: 'Name', initial_value: 0x00
|
32
|
+
string :pad1, length: -> { pad1_length }
|
33
|
+
query_file_information_response_trans2_parameters :trans2_parameters, label: 'Trans2 Parameters'
|
34
|
+
string :pad2, length: -> { pad2_length }
|
35
|
+
query_file_information_response_trans2_data :trans2_data, label: 'Trans2 Data'
|
36
|
+
end
|
37
|
+
|
38
|
+
# A Trans2 QUERY_FILE_INFORMATION Response Packet as defined in
|
39
|
+
# [2.2.6.8.2](https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-cifs/262fd0c3-41c4-41db-9f0c-61154f694636)
|
40
|
+
class QueryFileInformationResponse < 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_file_information_response_data_block :data_block
|
49
|
+
|
50
|
+
def initialize_instance
|
51
|
+
super
|
52
|
+
parameter_block.setup << RubySMB::SMB1::Packet::Trans2::Subcommands::QUERY_FILE_INFORMATION
|
53
|
+
smb_header.flags.reply = 1
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module RubySMB
|
2
|
+
module SMB1
|
3
|
+
module Packet
|
4
|
+
module Trans2
|
5
|
+
# SMB_QUERY_FS_ATTRIBUTE_INFO Class as defined in
|
6
|
+
# [2.2.8.2.6 SMB_QUERY_FS_ATTRIBUTE_INFO](https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-cifs/1011206a-55c5-4dbf-aff0-119514136940)
|
7
|
+
module QueryFsInformationLevel
|
8
|
+
class QueryFsAttributeInfo < BinData::Record
|
9
|
+
CLASS_LEVEL = SMB_QUERY_FS_ATTRIBUTE_INFO
|
10
|
+
endian :little
|
11
|
+
|
12
|
+
struct :file_system_attributes, label: 'File System Attributes' do
|
13
|
+
bit3 :reserved1
|
14
|
+
bit1 :file_file_compression, label: 'File Compression'
|
15
|
+
bit1 :file_persistent_acls, label: 'Persistent ACLs'
|
16
|
+
bit1 :file_unicode_on_disk, label: 'Unicode on Disk'
|
17
|
+
bit1 :file_case_preserved_names, label: 'Case Preserved Names'
|
18
|
+
bit1 :file_case_sensitive_search, label: 'Case Sensitive Search'
|
19
|
+
# byte boundary
|
20
|
+
bit1 :file_volume_is_compressed, label: 'Volume is Compressed'
|
21
|
+
bit23 :reserved2
|
22
|
+
end
|
23
|
+
uint32 :max_file_name_length_in_bytes, label: 'Max File Name Length In Bytes'
|
24
|
+
uint32 :length_of_file_system_name, label: 'Length of File System Name', initial_value: -> { file_system_name.num_bytes }
|
25
|
+
string16 :file_system_name, label: 'File System name', read_length: -> { length_of_file_system_name }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module RubySMB
|
2
|
+
module SMB1
|
3
|
+
module Packet
|
4
|
+
module Trans2
|
5
|
+
# SMB Query Information Levels as defined in
|
6
|
+
# [2.2.8.2 QUERY_FS Information Levels](https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-cifs/2c7707b4-afcd-4dbf-a0f3-35abebe68fac)
|
7
|
+
# used in TRANS2_QUERY_FS_INFORMATION
|
8
|
+
module QueryFsInformationLevel
|
9
|
+
# Constants defined in
|
10
|
+
# [2.2.2.3.2 QUERY_FS Information Level Codes](https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-cifs/55217a26-87ef-489f-a159-3ed6cc6412e9)
|
11
|
+
# [dialect] description
|
12
|
+
|
13
|
+
# [LANMAN2.0] Query file system allocation unit information.
|
14
|
+
SMB_INFO_ALLOCATION = 0x0001 # 1
|
15
|
+
|
16
|
+
# [LANMAN2.0] Query volume name and serial number.
|
17
|
+
SMB_INFO_VOLUME = 0x0002 # 2
|
18
|
+
|
19
|
+
# [NT LANMAN] Query the creation timestamp, serial number, and Unicode-encoded volume label.
|
20
|
+
SMB_QUERY_FS_VOLUME_INFO = 0x0102 # 258
|
21
|
+
|
22
|
+
# [NT LANMAN] Query 64-bit file system allocation unit information.
|
23
|
+
SMB_QUERY_FS_SIZE_INFO = 0x0103 # 259
|
24
|
+
|
25
|
+
# [NT LANMAN] Query a file system's underlying device type and characteristics.
|
26
|
+
SMB_QUERY_FS_DEVICE_INFO = 0x0104 # 260
|
27
|
+
|
28
|
+
# [NT LANMAN] Query file system attributes.
|
29
|
+
SMB_QUERY_FS_ATTRIBUTE_INFO = 0x0105 # 261
|
30
|
+
|
31
|
+
def self.name(value)
|
32
|
+
constants.select { |c| c.upcase == c }.find { |c| const_get(c) == value }
|
33
|
+
end
|
34
|
+
|
35
|
+
require 'ruby_smb/smb1/packet/trans2/query_fs_information_level/query_fs_attribute_info'
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module RubySMB
|
2
|
+
module SMB1
|
3
|
+
module Packet
|
4
|
+
module Trans2
|
5
|
+
# The Trans2 Parameter Block for this particular Subcommand
|
6
|
+
class QueryFsInformationRequestTrans2Parameters < BinData::Record
|
7
|
+
endian :little
|
8
|
+
|
9
|
+
uint16 :information_level, label: 'Information Level'
|
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 QueryFsInformationRequestDataBlock < RubySMB::SMB1::Packet::Trans2::DataBlock
|
20
|
+
uint8 :name, label: 'Name', initial_value: 0x00
|
21
|
+
string :pad1, length: -> { pad1_length }
|
22
|
+
query_fs_information_request_trans2_parameters :trans2_parameters, label: 'Trans2 Parameters'
|
23
|
+
# trans2_data: No data is sent by this message.
|
24
|
+
end
|
25
|
+
|
26
|
+
# A Trans2 QUERY_FS_INFORMATION Request Packet as defined in
|
27
|
+
# [2.2.6.4.1](https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-cifs/cfa23a11-0e80-43bd-bbd4-e9cfb99b5dce)
|
28
|
+
class QueryFsInformationRequest < RubySMB::GenericPacket
|
29
|
+
COMMAND = RubySMB::SMB1::Commands::SMB_COM_TRANSACTION2
|
30
|
+
|
31
|
+
class ParameterBlock < RubySMB::SMB1::Packet::Trans2::Request::ParameterBlock
|
32
|
+
end
|
33
|
+
|
34
|
+
smb_header :smb_header
|
35
|
+
parameter_block :parameter_block
|
36
|
+
query_fs_information_request_data_block :data_block
|
37
|
+
|
38
|
+
def initialize_instance
|
39
|
+
super
|
40
|
+
parameter_block.setup << RubySMB::SMB1::Packet::Trans2::Subcommands::QUERY_FS_INFORMATION
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
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 QueryFsInformationResponseTrans2Parameters < BinData::Record
|
7
|
+
endian :little
|
8
|
+
|
9
|
+
# this field is intentionally empty
|
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 QueryFsInformationResponseTrans2Data < 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 QueryFsInformationResponseDataBlock < RubySMB::SMB1::Packet::Trans2::DataBlock
|
31
|
+
uint8 :name, label: 'Name', initial_value: 0x00
|
32
|
+
string :pad1, length: -> { pad1_length }
|
33
|
+
query_fs_information_response_trans2_parameters :trans2_parameters, label: 'Trans2 Parameters'
|
34
|
+
string :pad2, length: -> { pad2_length }
|
35
|
+
query_fs_information_response_trans2_data :trans2_data, label: 'Trans2 Data'
|
36
|
+
end
|
37
|
+
|
38
|
+
# A Trans2 QUERY_FS_INFORMATION Response Packet as defined in
|
39
|
+
# [2.2.6.4.1](https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-cifs/cfa23a11-0e80-43bd-bbd4-e9cfb99b5dce)
|
40
|
+
class QueryFsInformationResponse < 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_fs_information_response_data_block :data_block
|
49
|
+
|
50
|
+
def initialize_instance
|
51
|
+
super
|
52
|
+
parameter_block.setup << RubySMB::SMB1::Packet::Trans2::Subcommands::QUERY_FS_INFORMATION
|
53
|
+
smb_header.flags.reply = 1
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module RubySMB
|
2
|
+
module SMB1
|
3
|
+
module Packet
|
4
|
+
module Trans2
|
5
|
+
# SMB_QUERY_FILE_BASIC_INFO Class as defined in
|
6
|
+
# [2.2.8.3.6 SMB_QUERY_FILE_BASIC_INFO](https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-cifs/3da7df75-43ba-4498-a6b3-a68ba57ec922)
|
7
|
+
module QueryInformationLevel
|
8
|
+
class QueryFileBasicInfo < BinData::Record
|
9
|
+
CLASS_LEVEL = SMB_QUERY_FILE_BASIC_INFO
|
10
|
+
endian :little
|
11
|
+
|
12
|
+
file_time :create_time, label: 'Create Time'
|
13
|
+
file_time :last_access, label: 'Last Accessed Time'
|
14
|
+
file_time :last_write, label: 'Last Write Time'
|
15
|
+
file_time :last_change, label: 'Last Modified Time'
|
16
|
+
smb_ext_file_attributes :ext_file_attributes, label: 'Extended File Attributes'
|
17
|
+
uint32 :reserved, label: 'Reserved'
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module RubySMB
|
2
|
+
module SMB1
|
3
|
+
module Packet
|
4
|
+
module Trans2
|
5
|
+
# SMB_QUERY_FILE_STANDARD_INFO Class as defined in
|
6
|
+
# [2.2.8.3.7 SMB_QUERY_FILE_STANDARD_INFO](https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-cifs/3bdd080c-f8a4-4a09-acf1-0f8bd00152e4)
|
7
|
+
module QueryInformationLevel
|
8
|
+
class QueryFileStandardInfo < BinData::Record
|
9
|
+
CLASS_LEVEL = SMB_QUERY_FILE_STANDARD_INFO
|
10
|
+
endian :little
|
11
|
+
|
12
|
+
uint64 :allocation_size, label: 'Allocated Size'
|
13
|
+
uint64 :end_of_file, label: 'End of File'
|
14
|
+
uint32 :number_of_links, label: 'Number of Hard Links'
|
15
|
+
uint8 :delete_pending, label: 'Delete Pending?'
|
16
|
+
uint8 :directory, label: 'Directory?'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -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
|