ruby_smb 3.0.4 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (113) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/.github/workflows/verify.yml +1 -1
  4. data/.simplecov +1 -1
  5. data/CONTRIBUTING.md +28 -3
  6. data/README.md +8 -0
  7. data/examples/pwsh_service.rb +112 -0
  8. data/lib/ruby_smb/client/encryption.rb +16 -4
  9. data/lib/ruby_smb/client/negotiation.rb +4 -2
  10. data/lib/ruby_smb/client.rb +18 -2
  11. data/lib/ruby_smb/dcerpc/request.rb +2 -0
  12. data/lib/ruby_smb/dcerpc/svcctl/create_service_w_request.rb +35 -0
  13. data/lib/ruby_smb/dcerpc/svcctl/create_service_w_response.rb +24 -0
  14. data/lib/ruby_smb/dcerpc/svcctl/delete_service_request.rb +21 -0
  15. data/lib/ruby_smb/dcerpc/svcctl/delete_service_response.rb +21 -0
  16. data/lib/ruby_smb/dcerpc/svcctl.rb +66 -5
  17. data/lib/ruby_smb/dcerpc/winreg/open_root_key_request.rb +1 -1
  18. data/lib/ruby_smb/dcerpc/winreg/regsam.rb +1 -1
  19. data/lib/ruby_smb/dcerpc/winreg.rb +1 -1
  20. data/lib/ruby_smb/fscc/file_information.rb +4 -0
  21. data/lib/ruby_smb/server/server_client/encryption.rb +66 -0
  22. data/lib/ruby_smb/server/server_client/negotiation.rb +14 -3
  23. data/lib/ruby_smb/server/server_client/session_setup.rb +18 -3
  24. data/lib/ruby_smb/server/server_client/share_io.rb +17 -0
  25. data/lib/ruby_smb/server/server_client/tree_connect.rb +40 -3
  26. data/lib/ruby_smb/server/server_client.rb +147 -37
  27. data/lib/ruby_smb/server/session.rb +6 -0
  28. data/lib/ruby_smb/server/share/provider/disk/file_system.rb +28 -0
  29. data/lib/ruby_smb/server/share/provider/disk/processor/close.rb +42 -0
  30. data/lib/ruby_smb/server/share/provider/disk/processor/create.rb +143 -0
  31. data/lib/ruby_smb/server/share/provider/disk/processor/query.rb +359 -0
  32. data/lib/ruby_smb/server/share/provider/disk/processor/read.rb +69 -0
  33. data/lib/ruby_smb/server/share/provider/disk/processor.rb +159 -0
  34. data/lib/ruby_smb/server/share/provider/disk.rb +4 -416
  35. data/lib/ruby_smb/server/share/provider/pipe.rb +2 -2
  36. data/lib/ruby_smb/server/share/provider/processor.rb +16 -0
  37. data/lib/ruby_smb/signing.rb +18 -4
  38. data/lib/ruby_smb/smb1/bit_field/directory_access_mask.rb +1 -1
  39. data/lib/ruby_smb/smb1/bit_field/file_access_mask.rb +1 -1
  40. data/lib/ruby_smb/smb1/commands.rb +1 -0
  41. data/lib/ruby_smb/smb1/packet/nt_create_andx_request.rb +11 -1
  42. data/lib/ruby_smb/smb1/packet/nt_trans/create_request.rb +1 -1
  43. data/lib/ruby_smb/smb1/packet/read_andx_response.rb +5 -4
  44. data/lib/ruby_smb/smb1/packet/session_setup_request.rb +12 -4
  45. data/lib/ruby_smb/smb1/packet/trans2/data_block.rb +9 -1
  46. data/lib/ruby_smb/smb1/packet/trans2/find_first2_request.rb +52 -51
  47. data/lib/ruby_smb/smb1/packet/trans2/find_first2_response.rb +37 -37
  48. data/lib/ruby_smb/smb1/packet/trans2/find_information_level/find_file_both_directory_info.rb +48 -0
  49. data/lib/ruby_smb/smb1/packet/trans2/find_information_level.rb +28 -15
  50. data/lib/ruby_smb/smb1/packet/trans2/find_next2_request.rb +51 -51
  51. data/lib/ruby_smb/smb1/packet/trans2/find_next2_response.rb +36 -36
  52. data/lib/ruby_smb/smb1/packet/trans2/open2_request.rb +40 -39
  53. data/lib/ruby_smb/smb1/packet/trans2/open2_response.rb +40 -40
  54. data/lib/ruby_smb/smb1/packet/trans2/query_file_information_request.rb +60 -0
  55. data/lib/ruby_smb/smb1/packet/trans2/query_file_information_response.rb +59 -0
  56. data/lib/ruby_smb/smb1/packet/trans2/query_fs_information_level/query_fs_attribute_info.rb +31 -0
  57. data/lib/ruby_smb/smb1/packet/trans2/query_fs_information_level.rb +40 -0
  58. data/lib/ruby_smb/smb1/packet/trans2/query_fs_information_request.rb +46 -0
  59. data/lib/ruby_smb/smb1/packet/trans2/query_fs_information_response.rb +59 -0
  60. data/lib/ruby_smb/smb1/packet/trans2/query_information_level/query_file_basic_info.rb +23 -0
  61. data/lib/ruby_smb/smb1/packet/trans2/query_information_level/query_file_standard_info.rb +22 -0
  62. data/lib/ruby_smb/smb1/packet/trans2/query_information_level.rb +62 -0
  63. data/lib/ruby_smb/smb1/packet/trans2/query_path_information_request.rb +65 -0
  64. data/lib/ruby_smb/smb1/packet/trans2/query_path_information_response.rb +59 -0
  65. data/lib/ruby_smb/smb1/packet/trans2/request.rb +24 -8
  66. data/lib/ruby_smb/smb1/packet/trans2/request_secondary.rb +4 -4
  67. data/lib/ruby_smb/smb1/packet/trans2/response.rb +29 -20
  68. data/lib/ruby_smb/smb1/packet/trans2/set_file_information_request.rb +42 -42
  69. data/lib/ruby_smb/smb1/packet/trans2/set_file_information_response.rb +23 -23
  70. data/lib/ruby_smb/smb1/packet/trans2/subcommands.rb +23 -5
  71. data/lib/ruby_smb/smb1/packet/trans2.rb +4 -0
  72. data/lib/ruby_smb/smb1/packet/tree_connect_request.rb +4 -1
  73. data/lib/ruby_smb/smb2/bit_field/directory_access_mask.rb +1 -1
  74. data/lib/ruby_smb/smb2/bit_field/file_access_mask.rb +1 -1
  75. data/lib/ruby_smb/smb2/negotiate_context.rb +10 -1
  76. data/lib/ruby_smb/smb2/packet/session_setup_request.rb +11 -0
  77. data/lib/ruby_smb/smb2/packet/transform_header.rb +7 -7
  78. data/lib/ruby_smb/smb2.rb +1 -0
  79. data/lib/ruby_smb/version.rb +1 -1
  80. data/ruby_smb.gemspec +1 -1
  81. data/spec/lib/ruby_smb/client_spec.rb +20 -6
  82. data/spec/lib/ruby_smb/dcerpc/svcctl/create_service_w_request_spec.rb +143 -0
  83. data/spec/lib/ruby_smb/dcerpc/svcctl/create_service_w_response_spec.rb +45 -0
  84. data/spec/lib/ruby_smb/dcerpc/svcctl/delete_service_request_spec.rb +29 -0
  85. data/spec/lib/ruby_smb/dcerpc/svcctl/delete_service_response_spec.rb +29 -0
  86. data/spec/lib/ruby_smb/dcerpc/winreg/open_root_key_request_spec.rb +8 -8
  87. data/spec/lib/ruby_smb/dcerpc/winreg/regsam_spec.rb +1 -1
  88. data/spec/lib/ruby_smb/dcerpc/winreg_spec.rb +1 -1
  89. data/spec/lib/ruby_smb/smb1/bit_field/directory_access_mask_spec.rb +4 -4
  90. data/spec/lib/ruby_smb/smb1/bit_field/file_access_mask_spec.rb +4 -4
  91. data/spec/lib/ruby_smb/smb1/packet/trans2/find_first2_request_spec.rb +2 -2
  92. data/spec/lib/ruby_smb/smb1/packet/trans2/find_first2_response_spec.rb +36 -2
  93. data/spec/lib/ruby_smb/smb1/packet/trans2/find_next2_request_spec.rb +2 -2
  94. data/spec/lib/ruby_smb/smb1/packet/trans2/find_next2_response_spec.rb +35 -1
  95. data/spec/lib/ruby_smb/smb1/packet/trans2/query_file_information_request_spec.rb +74 -0
  96. data/spec/lib/ruby_smb/smb1/packet/trans2/query_file_information_response_spec.rb +96 -0
  97. data/spec/lib/ruby_smb/smb1/packet/trans2/query_fs_information_request_spec.rb +62 -0
  98. data/spec/lib/ruby_smb/smb1/packet/trans2/query_fs_information_response_spec.rb +88 -0
  99. data/spec/lib/ruby_smb/smb1/packet/trans2/query_path_information_request_spec.rb +79 -0
  100. data/spec/lib/ruby_smb/smb1/packet/trans2/query_path_information_response_spec.rb +96 -0
  101. data/spec/lib/ruby_smb/smb1/packet/trans2/request_spec.rb +2 -2
  102. data/spec/lib/ruby_smb/smb1/packet/trans2/response_spec.rb +3 -3
  103. data/spec/lib/ruby_smb/smb1/packet/trans2/set_file_information_request_spec.rb +3 -2
  104. data/spec/lib/ruby_smb/smb1/packet/trans2/set_file_information_response_spec.rb +7 -2
  105. data/spec/lib/ruby_smb/smb1/tree_spec.rb +8 -3
  106. data/spec/lib/ruby_smb/smb2/bit_field/directory_access_mask_spec.rb +4 -4
  107. data/spec/lib/ruby_smb/smb2/bit_field/file_access_mask_spec.rb +4 -4
  108. data/spec/lib/ruby_smb/smb2/packet/transform_header_spec.rb +2 -2
  109. data/spec/lib/ruby_smb/smb2/tree_spec.rb +6 -1
  110. data/spec/spec_helper.rb +2 -3
  111. data.tar.gz.sig +0 -0
  112. metadata +48 -4
  113. metadata.gz.sig +0 -0
@@ -2,52 +2,52 @@ module RubySMB
2
2
  module SMB1
3
3
  module Packet
4
4
  module Trans2
5
- # This class represents an SMB1 Trans2 FIND_NEXT2 Response Packet as defined in
6
- # [2.2.6.3.2 Response](https://msdn.microsoft.com/en-us/library/ee441871.aspx)
7
- class FindNext2Response < RubySMB::GenericPacket
8
- COMMAND = RubySMB::SMB1::Commands::SMB_COM_TRANSACTION2
5
+ # The Trans2 Parameter Block for this particular Subcommand
6
+ class FindNext2ResponseTrans2Parameters < BinData::Record
7
+ endian :little
9
8
 
10
- class ParameterBlock < RubySMB::SMB1::Packet::Trans2::Response::ParameterBlock
11
- end
9
+ uint16 :search_count, label: 'Search Count'
10
+ uint16 :eos, label: 'End of Search'
11
+ uint16 :ea_error_offset, label: 'Offset to EA Error'
12
+ uint16 :last_name_offset, label: 'Last Name Offset'
12
13
 
13
- # The Trans2 Parameter Block for this particular Subcommand
14
- class Trans2Parameters < BinData::Record
15
- endian :little
14
+ # Returns the length of the Trans2Parameters struct
15
+ # in number of bytes
16
+ def length
17
+ do_num_bytes
18
+ end
19
+ end
16
20
 
17
- uint16 :search_count, label: 'Search Count'
18
- uint16 :eos, label: 'End of Search'
19
- uint16 :ea_error_offset, label: 'Offset to EA Error'
20
- uint16 :last_name_offset, label: 'Last Name Offset'
21
+ # The Trans2 Data Block for this particular Subcommand
22
+ class FindNext2ResponseTrans2Data < BinData::Record
23
+ string :buffer, label: 'Results Buffer', read_length: :buffer_read_length
21
24
 
22
- # Returns the length of the Trans2Parameters struct
23
- # in number of bytes
24
- def length
25
- do_num_bytes
26
- end
25
+ # Returns the length of the Trans2Data struct
26
+ # in number of bytes
27
+ def length
28
+ do_num_bytes
27
29
  end
30
+ end
28
31
 
29
- # The Trans2 Data Block for this particular Subcommand
30
- class Trans2Data < BinData::Record
31
- rest :buffer, label: 'Results Buffer'
32
+ # The {RubySMB::SMB1::DataBlock} specific to this packet type.
33
+ class FindNext2ResponseDataBlock < RubySMB::SMB1::Packet::Trans2::DataBlock
34
+ string :pad1, length: -> { pad1_length }
35
+ find_next2_response_trans2_parameters :trans2_parameters, label: 'Trans2 Parameters'
36
+ string :pad2, length: -> { pad2_length }
37
+ find_next2_response_trans2_data :trans2_data, label: 'Trans2 Data', length: 0
38
+ end
32
39
 
33
- # Returns the length of the Trans2Data struct
34
- # in number of bytes
35
- def length
36
- do_num_bytes
37
- end
38
- end
40
+ # This class represents an SMB1 Trans2 FIND_NEXT2 Response Packet as defined in
41
+ # [2.2.6.3.2 Response](https://msdn.microsoft.com/en-us/library/ee441871.aspx)
42
+ class FindNext2Response < RubySMB::GenericPacket
43
+ COMMAND = RubySMB::SMB1::Commands::SMB_COM_TRANSACTION2
39
44
 
40
- # The {RubySMB::SMB1::DataBlock} specific to this packet type.
41
- class DataBlock < RubySMB::SMB1::Packet::Trans2::DataBlock
42
- string :pad1, length: -> { pad1_length }
43
- trans2_parameters :trans2_parameters, label: 'Trans2 Parameters'
44
- string :pad2, length: -> { pad2_length }
45
- trans2_data :trans2_data, label: 'Trans2 Data', length: 0
45
+ class ParameterBlock < RubySMB::SMB1::Packet::Trans2::Response::ParameterBlock
46
46
  end
47
47
 
48
- smb_header :smb_header
49
- parameter_block :parameter_block
50
- data_block :data_block
48
+ smb_header :smb_header
49
+ parameter_block :parameter_block
50
+ find_next2_response_data_block :data_block
51
51
 
52
52
  def initialize_instance
53
53
  super
@@ -2,53 +2,54 @@ module RubySMB
2
2
  module SMB1
3
3
  module Packet
4
4
  module Trans2
5
- # A Trans2 OPEN2 Request Packet as defined in
6
- # [2.2.6.1.1 Request](https://msdn.microsoft.com/en-us/library/ee441733.aspx)
7
- class Open2Request < RubySMB::GenericPacket
8
- COMMAND = RubySMB::SMB1::Commands::SMB_COM_TRANSACTION2
5
+ # The Trans2 Parameter Block for this particular Subcommand
6
+ class Open2RequestTrans2Parameters < BinData::Record
7
+ endian :little
9
8
 
10
- class ParameterBlock < RubySMB::SMB1::Packet::Trans2::Request::ParameterBlock
9
+ open2_flags :flags, label: 'Flags'
10
+ open2_access_mode :access_mode, label: 'AccessMode'
11
+ uint16 :reserved, label: 'Reserved Space'
12
+ smb_file_attributes :file_attributes, label: 'File Attributes'
13
+ utime :creation_time, label: 'Creation Time'
14
+ open2_open_mode :open_mode, label: 'Open Mode'
15
+ uint32 :allocation_size, label: 'Allocation Size'
16
+ array :reserved2, initial_length: 5 do
17
+ uint16 initial_value: 0x0000
11
18
  end
19
+ stringz :filename, label: 'Filename'
12
20
 
13
- # The Trans2 Parameter Block for this particular Subcommand
14
- class Trans2Parameters < BinData::Record
15
- endian :little
16
- open2_flags :flags, label: 'Flags'
17
- open2_access_mode :access_mode, label: 'AccessMode'
18
- uint16 :reserved, label: 'Reserved Space'
19
- smb_file_attributes :file_attributes, label: 'File Attributes'
20
- utime :creation_time, label: 'Creation Time'
21
- open2_open_mode :open_mode, label: 'Open Mode'
22
- uint32 :allocation_size, label: 'Allocation Size'
23
- array :reserved2, initial_length: 5 do
24
- uint16 initial_value: 0x0000
25
- end
26
- stringz :filename, label: 'Filename'
27
-
28
- # Returns the length of the Trans2Parameters struct
29
- # in number of bytes
30
- def length
31
- do_num_bytes
32
- end
21
+ # Returns the length of the Trans2Parameters struct
22
+ # in number of bytes
23
+ def length
24
+ do_num_bytes
33
25
  end
26
+ end
34
27
 
35
- # The Trans2 Data Blcok for this particular Subcommand
36
- class Trans2Data < BinData::Record
37
- smb_fea_list :extended_attribute_list, label: 'Extended Attribute List'
38
- end
28
+ # The Trans2 Data Block for this particular Subcommand
29
+ class Open2RequestTrans2Data < BinData::Record
30
+ smb_fea_list :extended_attribute_list, label: 'Extended Attribute List'
31
+ end
39
32
 
40
- # The {RubySMB::SMB1::DataBlock} specific to this packet type.
41
- class DataBlock < RubySMB::SMB1::Packet::Trans2::DataBlock
42
- uint8 :name, label: 'Name', initial_value: 0x00
43
- string :pad1, length: -> { pad1_length }
44
- trans2_parameters :trans2_parameters, label: 'Trans2 Parameters'
45
- string :pad2, length: -> { pad2_length }
46
- trans2_data :trans2_data, label: 'Trans2 Data'
33
+ # The {RubySMB::SMB1::DataBlock} specific to this packet type.
34
+ class Open2RequestDataBlock < RubySMB::SMB1::Packet::Trans2::DataBlock
35
+ uint8 :name, label: 'Name', initial_value: 0x00
36
+ string :pad1, length: -> { pad1_length }
37
+ open2_request_trans2_parameters :trans2_parameters, label: 'Trans2 Parameters'
38
+ string :pad2, length: -> { pad2_length }
39
+ open2_request_trans2_data :trans2_data, label: 'Trans2 Data'
40
+ end
41
+
42
+ # A Trans2 OPEN2 Request Packet as defined in
43
+ # [2.2.6.1.1 Request](https://msdn.microsoft.com/en-us/library/ee441733.aspx)
44
+ class Open2Request < RubySMB::GenericPacket
45
+ COMMAND = RubySMB::SMB1::Commands::SMB_COM_TRANSACTION2
46
+
47
+ class ParameterBlock < RubySMB::SMB1::Packet::Trans2::Request::ParameterBlock
47
48
  end
48
49
 
49
- smb_header :smb_header
50
- parameter_block :parameter_block
51
- data_block :data_block
50
+ smb_header :smb_header
51
+ parameter_block :parameter_block
52
+ open2_request_data_block :data_block
52
53
 
53
54
  def initialize_instance
54
55
  super
@@ -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
- # The Trans2 Parameter Block for this particular Subcommand
14
- class Trans2Parameters < BinData::Record
15
- endian :little
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