@cetapod/react-native-smb 1.0.0

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.
Files changed (137) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +72 -0
  3. package/ReactNativeSmb.podspec +59 -0
  4. package/cpp/ios/OnLoad.mm +24 -0
  5. package/cpp/shared/HybridSMB.cpp +324 -0
  6. package/cpp/shared/HybridSMB.hpp +102 -0
  7. package/cpp/shared/ReactNativeSmb.hpp +428 -0
  8. package/cpp/shared/connection/ContextRequest.hpp +27 -0
  9. package/cpp/shared/connection/ContextRequestQueue.cpp +85 -0
  10. package/cpp/shared/connection/ContextRequestQueue.hpp +28 -0
  11. package/cpp/shared/connection/MetadataContextLease.hpp +33 -0
  12. package/cpp/shared/connection/PoolContextHandle.cpp +35 -0
  13. package/cpp/shared/connection/PoolContextHandle.hpp +44 -0
  14. package/cpp/shared/connection/PoolSlot.cpp +73 -0
  15. package/cpp/shared/connection/PoolSlot.hpp +46 -0
  16. package/cpp/shared/connection/PoolTypes.hpp +41 -0
  17. package/cpp/shared/connection/SmbConnection.cpp +385 -0
  18. package/cpp/shared/connection/SmbConnection.hpp +93 -0
  19. package/cpp/shared/connection/SmbConnectionPool.cpp +316 -0
  20. package/cpp/shared/connection/SmbConnectionPool.hpp +84 -0
  21. package/cpp/shared/core/CancellationToken.hpp +22 -0
  22. package/cpp/shared/core/OperatorContext.hpp +24 -0
  23. package/cpp/shared/core/SmbEnums.hpp +126 -0
  24. package/cpp/shared/core/SmbTask.cpp +131 -0
  25. package/cpp/shared/core/SmbTask.hpp +52 -0
  26. package/cpp/shared/core/SmbTaskCore.cpp +222 -0
  27. package/cpp/shared/core/SmbTaskCore.hpp +107 -0
  28. package/cpp/shared/core/SmbTypes.hpp +35 -0
  29. package/cpp/shared/core/TaskObserverHub.cpp +166 -0
  30. package/cpp/shared/core/TaskObserverHub.hpp +66 -0
  31. package/cpp/shared/core/TaskSnapshotCodec.cpp +32 -0
  32. package/cpp/shared/core/TaskSnapshotCodec.hpp +41 -0
  33. package/cpp/shared/io/SmbCopyTree.hpp +114 -0
  34. package/cpp/shared/io/SmbDirScan.hpp +80 -0
  35. package/cpp/shared/io/SmbFileIO.cpp +1355 -0
  36. package/cpp/shared/io/SmbFileIO.hpp +45 -0
  37. package/cpp/shared/io/SmbPathUtil.hpp +75 -0
  38. package/cpp/shared/io/SmbSecurity.cpp +308 -0
  39. package/cpp/shared/io/SmbSecurity.hpp +32 -0
  40. package/cpp/shared/io/SmbTreeOps.hpp +112 -0
  41. package/cpp/shared/operators/Operator.hpp +35 -0
  42. package/cpp/shared/operators/OperatorBase.cpp +57 -0
  43. package/cpp/shared/operators/OperatorBase.hpp +57 -0
  44. package/cpp/shared/operators/connection/ConnectOperator.cpp +19 -0
  45. package/cpp/shared/operators/connection/ConnectOperator.hpp +22 -0
  46. package/cpp/shared/operators/connection/ConnectShareOperator.cpp +19 -0
  47. package/cpp/shared/operators/connection/ConnectShareOperator.hpp +21 -0
  48. package/cpp/shared/operators/connection/DisconnectOperator.cpp +12 -0
  49. package/cpp/shared/operators/connection/DisconnectOperator.hpp +15 -0
  50. package/cpp/shared/operators/connection/InitializeOperator.cpp +12 -0
  51. package/cpp/shared/operators/connection/InitializeOperator.hpp +22 -0
  52. package/cpp/shared/operators/connection/ListSharesOperator.cpp +13 -0
  53. package/cpp/shared/operators/connection/ListSharesOperator.hpp +18 -0
  54. package/cpp/shared/operators/listing/GetPathInfoOperator.cpp +43 -0
  55. package/cpp/shared/operators/listing/GetPathInfoOperator.hpp +21 -0
  56. package/cpp/shared/operators/listing/GetSecurityDescriptorOperator.cpp +202 -0
  57. package/cpp/shared/operators/listing/GetSecurityDescriptorOperator.hpp +22 -0
  58. package/cpp/shared/operators/listing/ListDirectoryOperator.cpp +20 -0
  59. package/cpp/shared/operators/listing/ListDirectoryOperator.hpp +24 -0
  60. package/cpp/shared/operators/mutate/CopyItemOperator.cpp +19 -0
  61. package/cpp/shared/operators/mutate/CopyItemOperator.hpp +25 -0
  62. package/cpp/shared/operators/mutate/CreateDirectoryOperator.cpp +28 -0
  63. package/cpp/shared/operators/mutate/CreateDirectoryOperator.hpp +20 -0
  64. package/cpp/shared/operators/mutate/DeleteItemOperator.cpp +96 -0
  65. package/cpp/shared/operators/mutate/DeleteItemOperator.hpp +23 -0
  66. package/cpp/shared/operators/mutate/DuplicateItemOperator.cpp +48 -0
  67. package/cpp/shared/operators/mutate/DuplicateItemOperator.hpp +23 -0
  68. package/cpp/shared/operators/mutate/MoveItemOperator.cpp +32 -0
  69. package/cpp/shared/operators/mutate/MoveItemOperator.hpp +21 -0
  70. package/cpp/shared/operators/mutate/RenameItemOperator.cpp +37 -0
  71. package/cpp/shared/operators/mutate/RenameItemOperator.hpp +21 -0
  72. package/cpp/shared/operators/transfer/DownloadFileOperator.cpp +31 -0
  73. package/cpp/shared/operators/transfer/DownloadFileOperator.hpp +21 -0
  74. package/cpp/shared/operators/transfer/UploadFileOperator.cpp +27 -0
  75. package/cpp/shared/operators/transfer/UploadFileOperator.hpp +21 -0
  76. package/cpp/shared/util/SmbErrorMapper.hpp +229 -0
  77. package/cpp/shared/util/SmbLog.hpp +20 -0
  78. package/docs/API.md +105 -0
  79. package/docs/ARCHITECTURE.md +70 -0
  80. package/docs/TASK_MODEL.md +149 -0
  81. package/ios/include/smb2/libsmb2-dcerpc-lsa.h +172 -0
  82. package/ios/include/smb2/libsmb2-dcerpc-srvsvc.h +180 -0
  83. package/ios/include/smb2/libsmb2-dcerpc.h +155 -0
  84. package/ios/include/smb2/libsmb2-raw.h +497 -0
  85. package/ios/include/smb2/libsmb2.h +1384 -0
  86. package/ios/include/smb2/smb2-errors.h +549 -0
  87. package/ios/include/smb2/smb2.h +1251 -0
  88. package/ios/libs/device/libsmb2-device.a +0 -0
  89. package/ios/libs/libsmb2.xcframework/Info.plist +48 -0
  90. package/ios/libs/libsmb2.xcframework/ios-arm64/Headers/smb2/libsmb2-dcerpc-lsa.h +172 -0
  91. package/ios/libs/libsmb2.xcframework/ios-arm64/Headers/smb2/libsmb2-dcerpc-srvsvc.h +180 -0
  92. package/ios/libs/libsmb2.xcframework/ios-arm64/Headers/smb2/libsmb2-dcerpc.h +155 -0
  93. package/ios/libs/libsmb2.xcframework/ios-arm64/Headers/smb2/libsmb2-raw.h +497 -0
  94. package/ios/libs/libsmb2.xcframework/ios-arm64/Headers/smb2/libsmb2.h +1384 -0
  95. package/ios/libs/libsmb2.xcframework/ios-arm64/Headers/smb2/smb2-errors.h +549 -0
  96. package/ios/libs/libsmb2.xcframework/ios-arm64/Headers/smb2/smb2.h +1251 -0
  97. package/ios/libs/libsmb2.xcframework/ios-arm64/libsmb2.a +0 -0
  98. package/ios/libs/libsmb2.xcframework/ios-arm64_x86_64-simulator/Headers/smb2/libsmb2-dcerpc-lsa.h +172 -0
  99. package/ios/libs/libsmb2.xcframework/ios-arm64_x86_64-simulator/Headers/smb2/libsmb2-dcerpc-srvsvc.h +180 -0
  100. package/ios/libs/libsmb2.xcframework/ios-arm64_x86_64-simulator/Headers/smb2/libsmb2-dcerpc.h +155 -0
  101. package/ios/libs/libsmb2.xcframework/ios-arm64_x86_64-simulator/Headers/smb2/libsmb2-raw.h +497 -0
  102. package/ios/libs/libsmb2.xcframework/ios-arm64_x86_64-simulator/Headers/smb2/libsmb2.h +1384 -0
  103. package/ios/libs/libsmb2.xcframework/ios-arm64_x86_64-simulator/Headers/smb2/smb2-errors.h +549 -0
  104. package/ios/libs/libsmb2.xcframework/ios-arm64_x86_64-simulator/Headers/smb2/smb2.h +1251 -0
  105. package/ios/libs/libsmb2.xcframework/ios-arm64_x86_64-simulator/libsmb2.a +0 -0
  106. package/ios/libs/simulator/libsmb2-simulator.a +0 -0
  107. package/lib/ReactNativeSmb.d.ts +200 -0
  108. package/lib/ReactNativeSmb.js +1 -0
  109. package/lib/bridge/decode.d.ts +4 -0
  110. package/lib/bridge/decode.js +92 -0
  111. package/lib/core/SMB.d.ts +3 -0
  112. package/lib/core/SMB.js +4 -0
  113. package/lib/core/SmbClient.d.ts +35 -0
  114. package/lib/core/SmbClient.js +99 -0
  115. package/lib/core/SmbTask.d.ts +41 -0
  116. package/lib/core/SmbTask.js +74 -0
  117. package/lib/core/TransferStore.d.ts +22 -0
  118. package/lib/core/TransferStore.js +88 -0
  119. package/lib/core/ids.d.ts +1 -0
  120. package/lib/core/ids.js +3 -0
  121. package/lib/core/taskResult.d.ts +3 -0
  122. package/lib/core/taskResult.js +52 -0
  123. package/lib/hooks/useSubscribe.d.ts +20 -0
  124. package/lib/hooks/useSubscribe.js +36 -0
  125. package/lib/hooks/useTransfers.d.ts +7 -0
  126. package/lib/hooks/useTransfers.js +29 -0
  127. package/lib/index.d.ts +7 -0
  128. package/lib/index.js +7 -0
  129. package/lib/labels.d.ts +6 -0
  130. package/lib/labels.js +71 -0
  131. package/lib/types.d.ts +141 -0
  132. package/lib/types.js +59 -0
  133. package/lib/utils.d.ts +79 -0
  134. package/lib/utils.js +153 -0
  135. package/package.json +63 -0
  136. package/scripts/build-libsmb2.sh +143 -0
  137. package/scripts/create-xcframework.sh +84 -0
Binary file
@@ -0,0 +1,48 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>AvailableLibraries</key>
6
+ <array>
7
+ <dict>
8
+ <key>BinaryPath</key>
9
+ <string>libsmb2.a</string>
10
+ <key>HeadersPath</key>
11
+ <string>Headers</string>
12
+ <key>LibraryIdentifier</key>
13
+ <string>ios-arm64_x86_64-simulator</string>
14
+ <key>LibraryPath</key>
15
+ <string>libsmb2.a</string>
16
+ <key>SupportedArchitectures</key>
17
+ <array>
18
+ <string>arm64</string>
19
+ <string>x86_64</string>
20
+ </array>
21
+ <key>SupportedPlatform</key>
22
+ <string>ios</string>
23
+ <key>SupportedPlatformVariant</key>
24
+ <string>simulator</string>
25
+ </dict>
26
+ <dict>
27
+ <key>BinaryPath</key>
28
+ <string>libsmb2.a</string>
29
+ <key>HeadersPath</key>
30
+ <string>Headers</string>
31
+ <key>LibraryIdentifier</key>
32
+ <string>ios-arm64</string>
33
+ <key>LibraryPath</key>
34
+ <string>libsmb2.a</string>
35
+ <key>SupportedArchitectures</key>
36
+ <array>
37
+ <string>arm64</string>
38
+ </array>
39
+ <key>SupportedPlatform</key>
40
+ <string>ios</string>
41
+ </dict>
42
+ </array>
43
+ <key>CFBundlePackageType</key>
44
+ <string>XFWK</string>
45
+ <key>XCFrameworkFormatVersion</key>
46
+ <string>1.0</string>
47
+ </dict>
48
+ </plist>
@@ -0,0 +1,172 @@
1
+ /* -*- mode:c; tab-width:8; c-basic-offset:8; indent-tabs-mode:nil; -*- */
2
+ /*
3
+ Copyright (C) 2020 by Ronnie Sahlberg <ronniesahlberg@gmail.com>
4
+
5
+ This program is free software; you can redistribute it and/or modify
6
+ it under the terms of the GNU Lesser General Public License as published by
7
+ the Free Software Foundation; either version 2.1 of the License, or
8
+ (at your option) any later version.
9
+
10
+ This program is distributed in the hope that it will be useful,
11
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ GNU Lesser General Public License for more details.
14
+
15
+ You should have received a copy of the GNU Lesser General Public License
16
+ along with this program; if not, see <http://www.gnu.org/licenses/>.
17
+ */
18
+
19
+ #ifndef _LIBSMB2_DCERPC_LSA_H_
20
+ #define _LIBSMB2_DCERPC_LSA_H_
21
+
22
+ #ifdef __cplusplus
23
+ extern "C" {
24
+ #endif
25
+
26
+ #define LSA_CLOSE 0x00
27
+ #define LSA_OPENPOLICY2 0x2c
28
+ #define LSA_LOOKUPSIDS2 0x39
29
+
30
+ /* Access Mask. LSA specific flags. */
31
+ #define POLICY_VIEW_LOCAL_INFORMATION 0x00000001
32
+ #define POLICY_VIEW_AUDIT_INFORMATION 0x00000002
33
+ #define POLICY_GET_PRIVATE_INFORMATION 0x00000004
34
+ #define POLICY_TRUST_ADMIN 0x00000008
35
+ #define POLICY_CREATE_ACCOUNT 0x00000010
36
+ #define POLICY_CREATE_SECRET 0x00000020
37
+ #define POLICY_CREATE_PRIVILEGE 0x00000040
38
+ #define POLICY_SET_DEFAULT_QUOTA_LIMITS 0x00000080
39
+ #define POLICY_SET_AUDIT_REQUIREMENTS 0x00000100
40
+ #define POLICY_AUDIT_LOG_ADMIN 0x00000200
41
+ #define POLICY_SERVER_ADMIN 0x00000400
42
+ #define POLICY_LOOKUP_NAMES 0x00000800
43
+ #define POLICY_NOTIFICATION 0x00001000
44
+
45
+ extern unsigned char NT_SID_AUTHORITY[6];
46
+
47
+ typedef struct RPC_SID {
48
+ uint8_t Revision;
49
+ uint8_t SubAuthorityCount;
50
+ uint8_t IdentifierAuthority[6];
51
+ uint32_t *SubAuthority;
52
+ } RPC_SID, *PRPC_SID;
53
+
54
+ typedef struct _LSAPR_TRANSLATED_NAME_EX {
55
+ uint32_t Use;
56
+ char *Name;
57
+ uint32_t DomainIndex;
58
+ uint32_t Flags;
59
+ } LSAPR_TRANSLATED_NAME_EX, *PLSAPR_TRANSLATED_NAME_EX;
60
+
61
+ typedef struct _LSAPR_TRANSLATED_NAMES_EX {
62
+ uint32_t Entries;
63
+ LSAPR_TRANSLATED_NAME_EX *Names;
64
+ } LSAPR_TRANSLATED_NAMES_EX, *PLSAPR_TRANSLATED_NAMES_EX;
65
+
66
+ typedef struct _SID_ENUM_BUFFER {
67
+ uint32_t Entries;
68
+ PRPC_SID *SidInfo;
69
+ } LSAPR_SID_ENUM_BUFFER, *PLSAPR_SID_ENUM_BUFFER;
70
+
71
+ typedef enum _LSAP_LOOKUP_LEVEL {
72
+ LsapLookupWksta = 1,
73
+ LsapLookupPDC,
74
+ LsapLookupTDL,
75
+ LsapLookupGC,
76
+ LsapLookupXForestReferral,
77
+ LsapLookupXForestResolve,
78
+ LsapLookupRODCReferralToFullDC
79
+ } LSAP_LOOKUP_LEVEL, *PLSAP_LOOKUP_LEVEL;
80
+
81
+ typedef struct _LSAPR_TRUST_INFORMATION {
82
+ char *Name;
83
+ RPC_SID Sid;
84
+ } LSAPR_TRUST_INFORMATION, *PLSAPR_TRUST_INFORMATION;
85
+
86
+ typedef struct _LSAPR_REFERENCED_DOMAIN_LIST {
87
+ uint32_t Entries;
88
+ LSAPR_TRUST_INFORMATION *Domains;
89
+ uint32_t MaxEntries; /* must be ignored */
90
+ } LSAPR_REFERENCED_DOMAIN_LIST, *PLSAPR_REFERENCED_DOMAIN_LIST;
91
+
92
+ /* For OPENPOLICY2: RootDirectory MUST be zero. Everything else is ignored. */
93
+ typedef struct _LSAPR_OBJECT_ATTRIBUTES {
94
+ uint32_t Length;
95
+ unsigned char *RootDirectory;
96
+ void *ObjectName;
97
+ uint32_t Attributes;
98
+ void *SecurityDescriptor;
99
+ void *SecurityQualityOfService;
100
+ } LSAPR_OBJECT_ATTRIBUTES, *PLSAPR_OBJECT_ATTRIBUTES;
101
+
102
+ struct lsa_close_req {
103
+ struct ndr_context_handle PolicyHandle;
104
+ };
105
+
106
+ struct lsa_close_rep {
107
+ uint32_t status;
108
+
109
+ struct ndr_context_handle PolicyHandle;
110
+ };
111
+
112
+ struct lsa_openpolicy2_req {
113
+ char *SystemName;
114
+ LSAPR_OBJECT_ATTRIBUTES ObjectAttributes;
115
+ uint32_t DesiredAccess;
116
+ };
117
+
118
+ struct lsa_openpolicy2_rep {
119
+ uint32_t status;
120
+
121
+ struct ndr_context_handle PolicyHandle;
122
+ };
123
+
124
+ struct lsa_lookupsids2_req {
125
+ struct ndr_context_handle PolicyHandle;
126
+ LSAPR_SID_ENUM_BUFFER SidEnumBuffer;
127
+ LSAPR_TRANSLATED_NAMES_EX TranslatedNames;
128
+ LSAP_LOOKUP_LEVEL LookupLevel;
129
+ };
130
+
131
+ struct lsa_lookupsids2_rep {
132
+ uint32_t status;
133
+
134
+ LSAPR_REFERENCED_DOMAIN_LIST ReferencedDomains;
135
+ LSAPR_TRANSLATED_NAMES_EX TranslatedNames;
136
+ uint32_t MappedCount;
137
+ };
138
+
139
+ int lsa_Close_rep_coder(struct dcerpc_context *dce,
140
+ struct dcerpc_pdu *pdu,
141
+ struct smb2_iovec *iov, int *offset,
142
+ void *ptr);
143
+ int lsa_Close_req_coder(struct dcerpc_context *dce,
144
+ struct dcerpc_pdu *pdu,
145
+ struct smb2_iovec *iov, int *offset,
146
+ void *ptr);
147
+ int lsa_LookupSids2_rep_coder(struct dcerpc_context *dce,
148
+ struct dcerpc_pdu *pdu,
149
+ struct smb2_iovec *iov, int *offset,
150
+ void *ptr);
151
+ int lsa_LookupSids2_req_coder(struct dcerpc_context *dce,
152
+ struct dcerpc_pdu *pdu,
153
+ struct smb2_iovec *iov, int *offset,
154
+ void *ptr);
155
+ int lsa_OpenPolicy2_rep_coder(struct dcerpc_context *dce,
156
+ struct dcerpc_pdu *pdu,
157
+ struct smb2_iovec *iov, int *offset,
158
+ void *ptr);
159
+ int lsa_OpenPolicy2_req_coder(struct dcerpc_context *dce,
160
+ struct dcerpc_pdu *pdu,
161
+ struct smb2_iovec *iov, int *offset,
162
+ void *ptr);
163
+ int lsa_RPC_SID_coder(struct dcerpc_context *dce,
164
+ struct dcerpc_pdu *pdu,
165
+ struct smb2_iovec *iov, int *offset,
166
+ void *ptr);
167
+
168
+ #ifdef __cplusplus
169
+ }
170
+ #endif
171
+
172
+ #endif /* !_LIBSMB2_DCERPC_LSA_H_ */
@@ -0,0 +1,180 @@
1
+ /* -*- mode:c; tab-width:8; c-basic-offset:8; indent-tabs-mode:nil; -*- */
2
+ /*
3
+ Copyright (C) 2018 by Ronnie Sahlberg <ronniesahlberg@gmail.com>
4
+
5
+ This program is free software; you can redistribute it and/or modify
6
+ it under the terms of the GNU Lesser General Public License as published by
7
+ the Free Software Foundation; either version 2.1 of the License, or
8
+ (at your option) any later version.
9
+
10
+ This program is distributed in the hope that it will be useful,
11
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ GNU Lesser General Public License for more details.
14
+
15
+ You should have received a copy of the GNU Lesser General Public License
16
+ along with this program; if not, see <http://www.gnu.org/licenses/>.
17
+ */
18
+
19
+ #ifndef _LIBSMB2_DCERPC_SRVSVC_H_
20
+ #define _LIBSMB2_DCERPC_SRVSVC_H_
21
+
22
+ #ifdef __cplusplus
23
+ extern "C" {
24
+ #endif
25
+
26
+ #include <smb2/libsmb2-dcerpc.h>
27
+
28
+ #define SRVSVC_NETRSHAREENUM 0x0f
29
+ #define SRVSVC_NETRSHAREGETINFO 0x10
30
+
31
+ struct dcerpc_context;
32
+ struct dcerpc_pdu;
33
+
34
+
35
+ /* Low 2 bits desctibe the type */
36
+ #define SHARE_TYPE_DISKTREE 0
37
+ #define SHARE_TYPE_PRINTQ 1
38
+ #define SHARE_TYPE_DEVICE 2
39
+ #define SHARE_TYPE_IPC 3
40
+
41
+ #define SHARE_TYPE_TEMPORARY 0x40000000
42
+ #define SHARE_TYPE_HIDDEN 0x80000000
43
+
44
+ enum SHARE_INFO_enum {
45
+ SHARE_INFO_0 = 0,
46
+ SHARE_INFO_1 = 1,
47
+ };
48
+
49
+ struct srvsvc_SHARE_INFO_0 {
50
+ struct dcerpc_utf16 netname;
51
+ };
52
+ int srvsvc_SHARE_INFO_0_coder(struct dcerpc_context *ctx,
53
+ struct dcerpc_pdu *pdu,
54
+ struct smb2_iovec *iov, int *offset,
55
+ void *ptr);
56
+
57
+ struct srvsvc_SHARE_INFO_0_carray {
58
+ uint32_t max_count;
59
+ struct srvsvc_SHARE_INFO_0 *share_info_0;
60
+ };
61
+
62
+ struct srvsvc_SHARE_INFO_0_CONTAINER {
63
+ uint32_t EntriesRead;
64
+ struct srvsvc_SHARE_INFO_0_carray *Buffer;
65
+ };
66
+
67
+ struct srvsvc_SHARE_INFO_1 {
68
+ struct dcerpc_utf16 netname;
69
+ uint32_t type;
70
+ struct dcerpc_utf16 remark;
71
+ };
72
+ int srvsvc_SHARE_INFO_1_coder(struct dcerpc_context *ctx,
73
+ struct dcerpc_pdu *pdu,
74
+ struct smb2_iovec *iov, int *offset,
75
+ void *ptr);
76
+
77
+ struct srvsvc_SHARE_INFO_1_carray {
78
+ uint32_t max_count;
79
+ struct srvsvc_SHARE_INFO_1 *share_info_1;
80
+ };
81
+
82
+ struct srvsvc_SHARE_INFO_1_CONTAINER {
83
+ uint32_t EntriesRead;
84
+ struct srvsvc_SHARE_INFO_1_carray *Buffer;
85
+ };
86
+
87
+ int srvsvc_SHARE_INFO_1_CONTAINER_coder(struct dcerpc_context *dce,
88
+ struct dcerpc_pdu *pdu,
89
+ struct smb2_iovec *iov, int *offset,
90
+ void *ptr);
91
+
92
+ struct srvsvc_SHARE_ENUM_UNION {
93
+ uint32_t Level;
94
+ union {
95
+ struct srvsvc_SHARE_INFO_0_CONTAINER Level0;
96
+ struct srvsvc_SHARE_INFO_1_CONTAINER Level1;
97
+ };
98
+ };
99
+
100
+ struct srvsvc_SHARE_ENUM_STRUCT {
101
+ uint32_t Level;
102
+ struct srvsvc_SHARE_ENUM_UNION ShareInfo;
103
+ };
104
+
105
+ struct srvsvc_NetrShareEnum_req {
106
+ struct dcerpc_utf16 ServerName;
107
+ struct srvsvc_SHARE_ENUM_STRUCT ses;
108
+ uint32_t PreferedMaximumLength;
109
+ uint32_t ResumeHandle;
110
+ };
111
+
112
+ struct srvsvc_NetrShareEnum_rep {
113
+ uint32_t status;
114
+
115
+ struct srvsvc_SHARE_ENUM_STRUCT ses;
116
+ uint32_t total_entries;
117
+ uint32_t resume_handle;
118
+ };
119
+
120
+ struct srvsvc_SHARE_INFO {
121
+ uint32_t level;
122
+ union {
123
+ struct srvsvc_SHARE_INFO_1 ShareInfo1;
124
+ };
125
+ };
126
+
127
+ struct srvsvc_NetrShareGetInfo_req {
128
+ struct dcerpc_utf16 ServerName;
129
+ struct dcerpc_utf16 NetName;
130
+ uint32_t Level;
131
+ };
132
+
133
+ struct srvsvc_NetrShareGetInfo_rep {
134
+ uint32_t status;
135
+
136
+ struct srvsvc_SHARE_INFO InfoStruct;
137
+ };
138
+
139
+ struct srvsvc_rep {
140
+ uint32_t status;
141
+ };
142
+
143
+ /*
144
+ * Async share_enum()
145
+ * This function only works when connected to the IPC$ share.
146
+ *
147
+ * Returns
148
+ * 0 : The operation was initiated. Result of the operation will be
149
+ * reported through the callback function.
150
+ * -errno : There was an error. The callback function will not be invoked.
151
+ *
152
+ * When the callback is invoked, status indicates the result:
153
+ * 0 : Success. Command_data is struct srvsvc_NetrShareEnum_rep *
154
+ * This pointer must be freed using smb2_free_data().
155
+ * -errno : An error occurred.
156
+ */
157
+ int smb2_share_enum_async(struct smb2_context *smb2, enum SHARE_INFO_enum level,
158
+ smb2_command_cb cb, void *cb_data);
159
+
160
+ int srvsvc_NetrShareEnum_rep_coder(struct dcerpc_context *dce,
161
+ struct dcerpc_pdu *pdu,
162
+ struct smb2_iovec *iov, int *offset,
163
+ void *ptr);
164
+ int srvsvc_NetrShareEnum_req_coder(struct dcerpc_context *ctx,
165
+ struct dcerpc_pdu *pdu,
166
+ struct smb2_iovec *iov, int *offset,
167
+ void *ptr);
168
+ int srvsvc_NetrShareGetInfo_rep_coder(struct dcerpc_context *dce,
169
+ struct dcerpc_pdu *pdu,
170
+ struct smb2_iovec *iov, int *offset,
171
+ void *ptr);
172
+ int srvsvc_NetrShareGetInfo_req_coder(struct dcerpc_context *ctx,
173
+ struct dcerpc_pdu *pdu,
174
+ struct smb2_iovec *iov, int *offset,
175
+ void *ptr);
176
+ #ifdef __cplusplus
177
+ }
178
+ #endif
179
+
180
+ #endif /* !_LIBSMB2_DCERPC_SRVSVC_H_ */
@@ -0,0 +1,155 @@
1
+ /* -*- mode:c; tab-width:8; c-basic-offset:8; indent-tabs-mode:nil; -*- */
2
+ /*
3
+ Copyright (C) 2018 by Ronnie Sahlberg <ronniesahlberg@gmail.com>
4
+
5
+ This program is free software; you can redistribute it and/or modify
6
+ it under the terms of the GNU Lesser General Public License as published by
7
+ the Free Software Foundation; either version 2.1 of the License, or
8
+ (at your option) any later version.
9
+
10
+ This program is distributed in the hope that it will be useful,
11
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ GNU Lesser General Public License for more details.
14
+
15
+ You should have received a copy of the GNU Lesser General Public License
16
+ along with this program; if not, see <http://www.gnu.org/licenses/>.
17
+ */
18
+
19
+ #ifndef _LIBSMB2_DCERPC_H_
20
+ #define _LIBSMB2_DCERPC_H_
21
+
22
+ #ifdef __cplusplus
23
+ extern "C" {
24
+ #endif
25
+
26
+ /* Data representation */
27
+ /* Integer */
28
+ #define DCERPC_DR_BIG_ENDIAN 0x00
29
+ #define DCERPC_DR_LITTLE_ENDIAN 0x10
30
+ /* Character */
31
+ #define DCERPC_DR_ASCII 0x00
32
+ #define DCERPC_DR_EBCDIC 0x01
33
+
34
+ struct dcerpc_context;
35
+ struct dcerpc_pdu;
36
+
37
+ /* Encoder/Decoder for a DCERPC object */
38
+ typedef int (*dcerpc_coder)(struct dcerpc_context *dce, struct dcerpc_pdu *pdu,
39
+ struct smb2_iovec *iov, int *offset,
40
+ void *ptr);
41
+
42
+ enum ptr_type {
43
+ PTR_REF = 0,
44
+ PTR_UNIQUE = 1,
45
+ PTR_FULL = 2
46
+ };
47
+
48
+ typedef struct dcerpc_uuid {
49
+ uint32_t v1;
50
+ uint16_t v2;
51
+ uint16_t v3;
52
+ uint8_t v4[8];
53
+ } dcerpc_uuid_t;
54
+
55
+ typedef struct p_syntax_id {
56
+ dcerpc_uuid_t uuid;
57
+ uint16_t vers;
58
+ uint16_t vers_minor;
59
+ } p_syntax_id_t;
60
+
61
+ struct ndr_transfer_syntax {
62
+ dcerpc_uuid_t uuid;
63
+ uint16_t vers;
64
+ };
65
+
66
+ struct ndr_context_handle {
67
+ uint32_t context_handle_attributes;
68
+ dcerpc_uuid_t context_handle_uuid;
69
+ };
70
+
71
+ struct dcerpc_utf16 {
72
+ uint32_t max_count; /* internal use only */
73
+ uint32_t offset; /* internal use only */
74
+ uint32_t actual_count; /* internal use only */
75
+
76
+ struct smb2_utf16 *utf16; /* internal use only */
77
+
78
+ const char *utf8;
79
+ };
80
+
81
+ struct dcerpc_carray {
82
+ uint32_t max_count;
83
+ uint8_t *data;
84
+ };
85
+
86
+ extern p_syntax_id_t lsa_interface;
87
+ extern p_syntax_id_t srvsvc_interface;
88
+
89
+ typedef void (*dcerpc_cb)(struct dcerpc_context *dce, int status,
90
+ void *command_data, void *cb_data);
91
+
92
+ struct dcerpc_context *dcerpc_create_context(struct smb2_context *smb2);
93
+ void dcerpc_free_data(struct dcerpc_context *dce, void *data);
94
+ const char *dcerpc_get_error(struct dcerpc_context *dce);
95
+ int dcerpc_connect_context_async(struct dcerpc_context *dce,
96
+ const char *path, p_syntax_id_t *syntax,
97
+ dcerpc_cb cb, void *cb_data);
98
+ void dcerpc_destroy_context(struct dcerpc_context *dce);
99
+
100
+ struct smb2_context *dcerpc_get_smb2_context(struct dcerpc_context *dce);
101
+ void *dcerpc_get_pdu_payload(struct dcerpc_pdu *pdu);
102
+
103
+ int dcerpc_open_async(struct dcerpc_context *dce, dcerpc_cb cb, void *cb_data);
104
+ int dcerpc_call_async(struct dcerpc_context *dce,
105
+ int opnum,
106
+ dcerpc_coder req_coder, void *req,
107
+ dcerpc_coder rep_coder, int decode_size,
108
+ dcerpc_cb cb, void *cb_data);
109
+
110
+ int dcerpc_do_coder(struct dcerpc_context *ctx, struct dcerpc_pdu *pdu,
111
+ struct smb2_iovec *iov,
112
+ int *offset, void *ptr,
113
+ dcerpc_coder coder);
114
+ int dcerpc_ptr_coder(struct dcerpc_context *dce, struct dcerpc_pdu *pdu,
115
+ struct smb2_iovec *iov, int *offset, void *ptr,
116
+ enum ptr_type type, dcerpc_coder coder);
117
+ int dcerpc_carray_coder(struct dcerpc_context *ctx,
118
+ struct dcerpc_pdu *pdu,
119
+ struct smb2_iovec *iov, int *offset,
120
+ void *ptr, int elem_size, dcerpc_coder coder);
121
+ int dcerpc_uint8_coder(struct dcerpc_context *ctx, struct dcerpc_pdu *pdu,
122
+ struct smb2_iovec *iov, int *offset, void *ptr);
123
+ int dcerpc_uint16_coder(struct dcerpc_context *ctx, struct dcerpc_pdu *pdu,
124
+ struct smb2_iovec *iov, int *offset, void *ptr);
125
+ int dcerpc_uint32_coder(struct dcerpc_context *ctx, struct dcerpc_pdu *pdu,
126
+ struct smb2_iovec *iov, int *offset, void *ptr);
127
+ int dcerpc_uint3264_coder(struct dcerpc_context *ctx, struct dcerpc_pdu *pdu,
128
+ struct smb2_iovec *iov, int *offset, void *ptr);
129
+ int dcerpc_conformance_coder(struct dcerpc_context *ctx, struct dcerpc_pdu *pdu,
130
+ struct smb2_iovec *iov, int *offset, void *ptr);
131
+ int dcerpc_utf16_coder(struct dcerpc_context *ctx, struct dcerpc_pdu *pdu,
132
+ struct smb2_iovec *iov, int *offset, void *ptr);
133
+ int dcerpc_utf16z_coder(struct dcerpc_context *ctx, struct dcerpc_pdu *pdu,
134
+ struct smb2_iovec *iov, int *offset, void *ptr);
135
+ int dcerpc_context_handle_coder(struct dcerpc_context *dce,
136
+ struct dcerpc_pdu *pdu,
137
+ struct smb2_iovec *iov, int *offset,
138
+ void *ptr);
139
+ int dcerpc_uuid_coder(struct dcerpc_context *dce,
140
+ struct dcerpc_pdu *pdu,
141
+ struct smb2_iovec *iov, int *offset,
142
+ dcerpc_uuid_t *uuid);
143
+ int dcerpc_uint8_coder(struct dcerpc_context *ctx, struct dcerpc_pdu *pdu,
144
+ struct smb2_iovec *iov, int *offset, void *ptr);
145
+ #define DCERPC_DECODE 0
146
+ #define DCERPC_ENCODE 1
147
+ struct dcerpc_pdu *dcerpc_allocate_pdu(struct dcerpc_context *dce,
148
+ int direction, int payload_size);
149
+ void dcerpc_free_pdu(struct dcerpc_context *dce, struct dcerpc_pdu *pdu);
150
+
151
+ #ifdef __cplusplus
152
+ }
153
+ #endif
154
+
155
+ #endif /* !_LIBSMB2_DCERPC_H_ */