3
0

SMB2.py 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import scapy.packet as packet
  2. import scapy.fields as field
  3. import scapy.layers.netbios as netbios
  4. class SMB2_SYNC_Header(packet.Packet):
  5. namez = "SMB2Negociate Protocol Response Header"
  6. fields_desc = [field.StrFixedLenField("Start", "\xfeSMB", 4),
  7. field.LEShortField("StructureSize", 64),
  8. field.LEShortField("CreditCharge", 0),
  9. field.LEIntField("Status", 0),
  10. field.LEShortField("Command", 0),
  11. field.LEShortField("CreditResponse", 0),
  12. field.LEIntField("Flags", 0),
  13. field.LEIntField("NextCommand", 0),
  14. field.LELongField("MessageID", 0),
  15. field.LEIntField("Reserved", 0),
  16. field.LEIntField("TreeID", 0x0),
  17. field.LELongField("SessionID", 0),
  18. field.LELongField("Signature1", 0),
  19. field.LELongField("Signature2", 0)]
  20. # No Support of Security Buffer , Padding or Dialect Revision 0x0311
  21. class SMB2_Negotiate_Protocol_Response(packet.Packet):
  22. namez = "SMB2Negociate Protocol Response"
  23. fields_desc = [field.LEShortField("StructureSize", 65),
  24. field.LEShortField("SecurityMode", 0),
  25. field.LEShortField("DialectRevision", 0x0),
  26. field.LEShortField("NegotiateContentCount/Reserved", 0),
  27. field.StrFixedLenField("ServerGuid", "", 16),
  28. field.LEIntField("Capabilities", 0),
  29. field.LEIntField("MaxTransactSize", 0),
  30. field.LEIntField("MaxReadSize", 0),
  31. field.LEIntField("MaxWriteSize", 0),
  32. field.LELongField("SystemTime", 0),
  33. field.LELongField("ServerStartTime", 0),
  34. field.LEShortField("SecurityBufferOffset", 0),
  35. field.LEShortField("SecurityBufferLength", 0),
  36. field.StrLenField("SecurityBlob", "", length_from=lambda x: x.ByteCount + 16),
  37. field.LEIntField("NegotiateContextOffset/Reserved2", 0)]
  38. packet.bind_layers(netbios.NBTSession, SMB2_SYNC_Header, )
  39. packet.bind_layers(SMB2_SYNC_Header, SMB2_Negotiate_Protocol_Response, )