| 2189 | |
| 2190 | |
| 2191 | class SMB2_Negotiate_Protocol_Request(_SMB2_Payload, _NTLMPayloadPacket): |
| 2192 | name = "SMB2 Negotiate Protocol Request" |
| 2193 | Command = 0x0000 |
| 2194 | _NTLM_PAYLOAD_FIELD_NAME = "Buffer" |
| 2195 | fields_desc = [ |
| 2196 | XLEShortField("StructureSize", 0x24), |
| 2197 | FieldLenField("DialectCount", None, fmt="<H", count_of="Dialects"), |
| 2198 | # SecurityMode |
| 2199 | FlagsField("SecurityMode", 0, -16, SMB2_SECURITY_MODE), |
| 2200 | LEShortField("Reserved", 0), |
| 2201 | # Capabilities |
| 2202 | FlagsField("Capabilities", 0, -32, SMB2_CAPABILITIES), |
| 2203 | UUIDField("ClientGUID", 0x0, uuid_fmt=UUIDField.FORMAT_LE), |
| 2204 | XLEIntField("NegotiateContextsBufferOffset", None), |
| 2205 | LEShortField("NegotiateContextsCount", None), |
| 2206 | ShortField("Reserved2", 0), |
| 2207 | FieldListField( |
| 2208 | "Dialects", |
| 2209 | [0x0202], |
| 2210 | LEShortEnumField("", 0x0, SMB_DIALECTS), |
| 2211 | count_from=lambda pkt: pkt.DialectCount, |
| 2212 | ), |
| 2213 | _NTLMPayloadField( |
| 2214 | "Buffer", |
| 2215 | lambda pkt: 64 + 36 + len(pkt.Dialects) * 2, |
| 2216 | [ |
| 2217 | # Field only exists if Dialects contains 0x0311 |
| 2218 | FieldListField( |
| 2219 | "NegotiateContexts", |
| 2220 | [], |
| 2221 | ReversePadField( |
| 2222 | PacketField("Context", None, SMB2_Negotiate_Context), |
| 2223 | 8, |
| 2224 | ), |
| 2225 | count_from=lambda pkt: pkt.NegotiateContextsCount, |
| 2226 | ), |
| 2227 | ], |
| 2228 | ), |
| 2229 | ] |
| 2230 | |
| 2231 | def post_build(self, pkt, pay): |
| 2232 | # type: (bytes, bytes) -> bytes |
| 2233 | return ( |
| 2234 | _NTLM_post_build( |
| 2235 | self, |
| 2236 | pkt, |
| 2237 | 64 + 36 + len(self.Dialects) * 2, |
| 2238 | { |
| 2239 | "NegotiateContexts": 28, |
| 2240 | }, |
| 2241 | config=[ |
| 2242 | ("BufferOffset", _NTLM_ENUM.OFFSET | _NTLM_ENUM.PAD8), |
| 2243 | ("Count", _NTLM_ENUM.COUNT), |
| 2244 | ], |
| 2245 | ) |
| 2246 | + pay |
| 2247 | ) |
| 2248 |
no test coverage detected
searching dependent graphs…