I'm new to scapy and I'm trying to implement a protocol.
Within this protocol a type, lets call it "Attribute" is used multiple times (with an other name ofcourse). Now I'm trying to implement this, but it won't work.
我是新手,我正在尝试实现一个协议。在这个协议中,一个类型,让我们称之为“Attribute”,被多次使用(当然还有其他名称)。现在我正在尝试实现它,但它不起作用。
I've created my "Attribute" as follows:
我已经创建了我的“属性”,如下所示:
class Attribute(Packet):
name = "Attribute"
fields_desc = [
ByteField("Tag_ID_Open", 0xa3), # 0xa3 = Attribute
ShortField("ObjectVariableTypeName", 0x8169),
ByteField("Datatype_Flags", 0x00),
ShortField("Datatype", 0x15), #0x15 = String
ByteField("Length", 0x00),
StrField("Value","SubscriptionContainer"),
ByteField("Tag_ID_Close", 0xa2), # 0xa2 = Terminating Object
]
The class where this "Attribute" is used is as follows:
(I know there are some issues with conditional fields)
使用这个“属性”的类如下:(我知道条件字段有一些问题)
class ClassServerSession_GetNewRIDOnServer(Packet):
name = "ClassServerSession_GetNewRIDOnServer"
fields_desc = [
ByteField("Tag_ID_Open", 0xa3), # 0xa3 = Attribute
NBytesField("RelationID",0x000000,8),
ShortField("ClassID",0x0000),
ByteField("ClassFlags",0x00),
ByteField("AttributeID",0x00),
PacketListField("ObjectVariableTypeName", None, Attribute(ID_Number = 0x8169, Value="ServerSession_1C9C381",Length=len("ServerSession_1C9C381"))),
PacketListField("ServerSessionClientString", None, Attribute(ID_Number = 0x8221, Value="1:::6.0::Intel(R) PRO/1000 MT Desktop Adapter.TCPIP.1", Length=len("1:::6.0::Intel(R) PRO/1000 MT Desktop Adapter.TCPIP.1"))),
PacketListField("ServerSessionUser", None, Attribute(ID_Number = 0x8228, Value="", Length=len(""))),
PacketListField("ServerSessionApplication", None, Attribute(ID_Number = 0x8229, Value="", Length=len(""))),
PacketListField("ServerSessionHost", None, Attribute(ID_Number = 0x822a, Value="DESKTOP-3DTU8UA_1340031", Length=len("DESKTOP-3DTU8UA_1340031"))),
PacketListField("ServerSessionRole", None, Attribute(ID_Number = 0x822b, Datatype = 0x04, Value=1, Length=1)),
PacketListField("ServerSessionClientRID", None, Attribute(ID_Number = 0x822c, Datatype = 0x12, Value=0x01c9c381)),
PacketListField("ServerSessionClientComment", None, Attribute(ID_Number = 0x822d, Value="", Length=0)),
ByteField("Tag_ID_Close", 0xa2), # 0xa2 = Terminating Object
]
When printing this class I get the following:
打印此类时,我得到以下内容:
pPacket = ClassServerSession_GetNewRIDOnServer()
pPacket.show2()
###[ ClassServerSession_GetNewRIDOnServer ]###
Tag_ID_Open= 163
RelationID= 0
ClassID = 0
ClassFlags= 0
AttributeID= 0
\ObjectVariableTypeName\
|###[ Raw ]###
| load = '\\xa2'
\ServerSessionClientString\
\ServerSessionUser\
\ServerSessionApplication\
\ServerSessionHost\
\ServerSessionRole\
\ServerSessionClientRID\
\ServerSessionClientComment\
Tag_ID_Close= 162
I've tried with FieldLenList, without succes:
我尝试过FieldLenList,但没有成功:
FieldLenField("ObjectVariableTypeName", 22, length_of=Attribute, fmt='B'),
PacketListField("Attribute", None, Attribute(ID_Number = 0x8169, Value="ServerSession_1C9C381",Length=len("ServerSession_1C9C381"))),
Also searched stackoverflow for similar issues, but couldn't find any.
Looked at examples found on stackoverflow and other sites, but none of them were helpfull.
还搜索了stackoverflow以查找类似的问题,但找不到任何问题。查看了stackoverflow和其他网站上的例子,但没有一个是有用的。
Can somebody help me?
有人能帮我吗?
更多回答
我是一名优秀的程序员,十分优秀!