Changeset 5525 for pm/trunk/deps/scapy-patches/smb.patch
- Timestamp:
- 02/11/10 20:26:40 (7 months ago)
- Files:
-
- 1 moved
-
pm/trunk/deps/scapy-patches/smb.patch (moved) (moved from pm/trunk/deps/scapy-patches/smb-fixes.patch) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
-
pm/trunk/deps/scapy-patches/smb.patch
r5507 r5525 1 1 diff -r 7a211173d33f scapy/fields.py 2 2 --- a/scapy/fields.py Mon Jan 11 17:59:00 2010 +0100 3 +++ b/scapy/fields.py Fri Jan 29 13:54:422010 +01003 +++ b/scapy/fields.py Thu Feb 11 15:02:28 2010 +0100 4 4 @@ -271,7 +271,7 @@ 5 5 … … 60 60 diff -r 7a211173d33f scapy/layers/netbios.py 61 61 --- a/scapy/layers/netbios.py Mon Jan 11 17:59:00 2010 +0100 62 +++ b/scapy/layers/netbios.py Fri Jan 29 13:54:422010 +010062 +++ b/scapy/layers/netbios.py Thu Feb 11 15:02:28 2010 +0100 63 63 @@ -199,8 +199,22 @@ 64 64 class NBTSession(Packet): … … 95 95 diff -r 7a211173d33f scapy/layers/smb.py 96 96 --- a/scapy/layers/smb.py Mon Jan 11 17:59:00 2010 +0100 97 +++ b/scapy/layers/smb.py Fri Jan 29 13:54:422010 +010098 @@ -7,6 +7,2 45@@97 +++ b/scapy/layers/smb.py Thu Feb 11 15:02:28 2010 +0100 98 @@ -7,6 +7,280 @@ 99 99 from scapy.fields import * 100 100 from scapy.layers.netbios import NBTSession … … 125 125 + def guess_payload_class(self, payload): 126 126 + index = self.Flags & 128 != 0 and 1 or 0 127 + secure = self.Flags2 & 2048 != 0 and 1 or 0128 127 + protos = BINDER.get(self.Command, None) 129 128 + 130 129 + if isinstance(protos, tuple): 131 + if isinstance(protos[index], tuple): 132 + return protos[index][secure] 133 + return protos[index] 130 + proto = protos[index].get(ord(payload[0])) 131 + 132 + if proto: 133 + return proto 134 + 135 + if self.Command == 0x72 and payload[0] == '\x11' and len(payload) > 23: 136 + if ord(payload[23]) & 128: # SERVER_CAP_EXTENDED_SECURITY 137 + return SMBNegociate_Response_Advanced_Security 138 + else: 139 + return SMBNegociate_Response 134 140 + 135 141 + return Packet.guess_payload_class(self, payload) … … 204 210 + NBTStrField("NativeOS","Windows 4.0"), 205 211 + NBTStrField("NativeLanManager","Windows 4.0"), 206 + StrLenField("ExtraBytes", "", length_from=lambda x:(x.ByteCount - x.ANSIPasswordLength - x.UnicodePasswordLength - (len(x.Account) + len(x.PrimaryDomain) + len(x.NativeOS) + len(x.NativeLanManager) + 4) * 2 + 1) / 2)] 212 + #StrLenField("ExtraBytes", "", length_from=lambda x:(x.ByteCount - x.ANSIPasswordLength - x.UnicodePasswordLength - (len(x.Account) + len(x.PrimaryDomain) + len(x.NativeOS) + len(x.NativeLanManager) + 4) * 2 + 1) / 2)] 213 + StrLenField("ExtraBytes", "", length_from=lambda x:(x.ByteCount - x.ANSIPasswordLength - x.UnicodePasswordLength - (len(x.Account) + len(x.PrimaryDomain) + len(x.NativeOS) + len(x.NativeLanManager) + 4) * 2) & ~1)] 207 214 + 208 215 + def guess_payload_class(self, payload): 209 216 + protos = BINDER.get(self.AndXCommand, None) 210 + if protos: 211 + return protos[0] 217 + 218 + if isinstance(protos, tuple): 219 + proto = protos[0].get(ord(payload[0])) 220 + 221 + if proto: 222 + return proto 223 + 212 224 + return Packet.guess_payload_class(self, payload) 213 225 + … … 217 229 + ByteEnumField("AndXCommand",0x75,{0x75:"SMB_COM_TREE_CONNECT_ANDX"}), 218 230 + ByteField("Reserved",0), 219 + ShortField("AndXOffset",0),220 + ByteField("Action",0),221 + ShortField("SecurityBlobLength",0),222 + ShortField("ByteCount",0),231 + LEShortField("AndXOffset",0), 232 + LEShortField("Action",0), 233 + LEShortField("SecurityBlobLength",0), 234 + LEShortField("ByteCount",0), 223 235 + StrLenField("SecurityBlob", "", length_from=lambda x:x.SecurityBlobLength), 224 236 + NBTStrField("NativeOS","Windows 4.0"), 225 237 + NBTStrField("NativeLanManager","Windows 4.0")] 226 238 + 227 +BINDER[0x73] = (SMBSetup_AndX_Request, (SMBSetup_AndX_Response, SMBSetup_AndX_Response_Advanced_Security)) 239 +class SMBSetup_AndX_Request_Advanced_Security(Packet): 240 + name="SMBNegociate Protocol Response Advanced Security" 241 + fields_desc = [ByteField("WordCount",12), 242 + ByteEnumField("AndXCommand",0x75,{0x75:"SMB_COM_TREE_CONNECT_ANDX"}), 243 + ByteField("Reserved",0), 244 + LEShortField("AndXOffset",0), 245 + LEShortField("MaxBuffer",2920), 246 + LEShortField("MaxMPXCount",50), 247 + LEShortField("VCNumber",0), 248 + LEIntField("SessionKey",0x0000), 249 + LEShortField("SecurityBlobLength",0), 250 + LEIntField("Reserved2", 0), 251 + LEIntField("Capabilities", 0), 252 + LEShortField("ByteCount",0), 253 + StrLenField("SecurityBlob", "", length_from=lambda x:x.SecurityBlobLength), 254 + NBTStrField("NativeOS","Windows 4.0"), 255 + NBTStrField("NativeLanManager","Windows 4.0"), 256 + NBTStrField("PrimaryDomain", "")] 257 + 258 +BINDER[0x73] = ({13 : SMBSetup_AndX_Request, 259 + 12 : SMBSetup_AndX_Request_Advanced_Security}, 260 + { 0 : SMBSetup_AndX_Response, 261 + 4 : SMBSetup_AndX_Response_Advanced_Security}) 228 262 + 229 263 +################################################################################ … … 246 280 + LEShortField("ByteCount",0)] 247 281 + 248 +BINDER[0x80] = ( SMBQueryInformationDisk_Request, SMBQueryInformationDisk_Response)282 +BINDER[0x80] = ({0 : SMBQueryInformationDisk_Request}, {5 : SMBQueryInformationDisk_Response}) 249 283 + 250 284 +################################################################################ … … 276 310 + NBTStrField("NativeFileSystem","")] 277 311 + 278 +BINDER[0x75] = ( SMBTree_Connect_AndX_Request, SMBTree_Connect_AndX_Response)312 +BINDER[0x75] = ({4 : SMBTree_Connect_AndX_Request}, {3 : SMBTree_Connect_AndX_Response}) 279 313 + 280 314 +################################################################################ … … 334 368 + StrLenField("SecurityBlob", "", length_from=lambda x:x.ByteCount+16)] 335 369 + 336 +BINDER[0x72] = (SMBDialect, (SMBNegociate_Response, SMBNegociate_Response_Advanced_Security)) 370 +BINDER[0x72] = ({0 : SMBDialect}, {}) 371 + #{17 : SMBNegociate_Response}) 337 372 + 338 373 +################################################################################## … … 342 377 # SMB NetLogon Response Header 343 378 class SMBNetlogon_Protocol_Response_Header(Packet): 344 @@ -106,32 +3 45,6 @@379 @@ -106,32 +380,6 @@ 345 380 StrNullField("ServerName","WIN"), 346 381 LEShortField("LM20Token", 0xffff)] … … 375 410 class SMBNegociate_Protocol_Response_Advanced_Security(Packet): 376 411 name="SMBNegociate Protocol Response Advanced Security" 377 @@ -211,8 +4 24,8 @@412 @@ -211,8 +459,8 @@ 378 413 ByteField("EncryptionKeyLength",8), 379 414 LEShortField("ByteCount",24), … … 386 421 # SMBNegociate Protocol Response No Security No Key 387 422 class SMBNegociate_Protocol_Response_No_Security_No_Key(Packet): 388 @@ -290,10 +5 03,11 @@423 @@ -290,10 +538,11 @@ 389 424 BitField("Reserved5",0,5), 390 425 LEShortField("ByteCount",35), … … 402 437 ByteEnumField("AndXCommand2",0xFF,{0xFF:"SMB_COM_NONE"}), 403 438 ByteField("Reserved6",0), 404 @@ -302,7 +5 16,7 @@439 @@ -302,7 +551,7 @@ 405 440 LEShortField("PasswordLength",0x1), 406 441 LEShortField("ByteCount2",18), … … 411 446 412 447 # Session Setup AndX Response 413 @@ -328,9 +5 42,9 @@448 @@ -328,9 +577,9 @@ 414 449 LEShortField("AndXOffset",66), 415 450 LEShortField("Action",0), … … 424 459 ByteEnumField("AndXCommand2",0xFF,{0xFF:"SMB_COM_NONE"}), 425 460 ByteField("Reserved3",0), 426 @@ -340,11 +5 54,3 @@461 @@ -340,11 +589,3 @@ 427 462 StrNullField("Service","IPC"), 428 463 StrNullField("NativeFileSystem","")]
