Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
FlagsField("flags", 0, 8, _peer_flags),
IntField("v6_flag", 0),
IntField("unused1", 0),
IP6Field("addr6", "::")
]
class NTPInfoPeerSummary(Packet):
"""
Sort of the info that ntpdc returns by default.
"""
name = "info_peer_summary"
fields_desc = [
IPField("dstaddr", "0.0.0.0"),
IPField("srcaddr", "0.0.0.0"),
ShortField("srcport", 0),
ByteField("stratum", 0),
ByteField("hpoll", 0),
ByteField("ppoll", 0),
ByteField("reach", 0),
FlagsField("flags", 0, 8, _peer_flags),
ByteField("hmode", _ntp_modes),
FixedPointField("delay", 0, size=32, frac_bits=16),
TimeStampField("offset", 0),
FixedPointField("dispersion", 0, size=32, frac_bits=16),
IntField("v6_flag", 0),
IntField("unused1", 0),
IP6Field("dstaddr6", "::"),
IP6Field("srcaddr6", "::")
]
# DIAG_DGOTYP_FNAME
ConditionalField(StrLenField("name_text", "", length_from=lambda pkt:pkt.atom_length - 13), lambda pkt:pkt.etype == 114),
# DIAG_DGOTYP_PUSHBUTTON_2 */
ConditionalField(ByteField("pushbutton_v_length", 0), lambda pkt:pkt.etype in [115]),
ConditionalField(ByteField("pushbutton_v_height", 0), lambda pkt:pkt.etype in [115]),
ConditionalField(ShortField("pushbutton_function_code_offset", 0), lambda pkt:pkt.etype in [115]),
ConditionalField(ShortField("pushbutton_text_offset", 0), lambda pkt:pkt.etype in [115]),
ConditionalField(StrField("pushbutton_text", ""), lambda pkt:pkt.etype in [115]),
ConditionalField(StrField("pushbutton_function_code", ""), lambda pkt:pkt.etype in [115]),
# DIAG_DGOTYP_TABSTRIP_BUTTON
ConditionalField(ByteField("tabstripbutton_v_length", 0), lambda pkt:pkt.etype in [116]),
ConditionalField(ByteField("tabstripbutton_v_height", 0), lambda pkt:pkt.etype in [116]),
ConditionalField(ByteField("tabstripbutton_page_id", 0), lambda pkt:pkt.etype in [116]),
ConditionalField(ShortField("tabstripbutton_function_code_offset", 0), lambda pkt:pkt.etype in [116]),
ConditionalField(ShortField("tabstripbutton_text_offset", 0), lambda pkt:pkt.etype in [116]),
ConditionalField(ShortField("tabstripbutton_id_offset", 0), lambda pkt:pkt.etype in [116]),
ConditionalField(StrNullField("tabstripbutton_text", ""), lambda pkt:pkt.etype in [116]),
ConditionalField(StrNullField("tabstripbutton_function_code", ""), lambda pkt:pkt.etype in [116]),
ConditionalField(StrNullField("tabstripbutton_id", ""), lambda pkt:pkt.etype in [116]),
# DIAG_DGOTYP_XMLPROP
ConditionalField(StrLenField("xmlprop_text", "", length_from=lambda pkt:pkt.atom_length - 13), lambda pkt:pkt.etype == 120),
# DIAG_DGOTYP_EFIELD_1 or DIAG_DGOTYP_OFIELD_1 or DIAG_DGOTYP_KEYWORD_1
ConditionalField(ByteField("field1_flag1", 0), lambda pkt:pkt.etype in [121, 122, 123]),
ConditionalField(FieldLenField("field1_dlen", None, fmt="B", length_of="field1_text"), lambda pkt:pkt.etype in [121, 122, 123]),
ConditionalField(ByteField("field1_mlen", 0), lambda pkt:pkt.etype in [121, 122, 123]),
ConditionalField(ShortField("field1_maxnrchars", 0), lambda pkt:pkt.etype in [121, 122, 123]),
ConditionalField(StrLenField("field1_text", "", length_from=lambda pkt:pkt.field1_dlen), lambda pkt:pkt.etype in [121, 122, 123]),
# DIAG_DGOTYP_FRAME_1
ConditionalField(ShortField("frame_drows", 0), lambda pkt:pkt.etype in [127]),
ConditionalField(ShortField("frame_dcols", 0), lambda pkt:pkt.etype in [127]),
ConditionalField(StrLenField("frame_text", "", length_from=lambda pkt:pkt.atom_length - 17), lambda pkt:pkt.etype in [127]),
# DIAG_DGOTYP_RADIOBUTTON_3
2: "FRAG_REASM",
3: "FRAG_MASK"}),
ShortField("miss_send_len", 0)]
class OFPTSetConfig(_ofp_header):
name = "OFPT_SET_CONFIG"
fields_desc = [ByteEnumField("version", 0x01, ofp_version),
ByteEnumField("type", 9, ofp_type),
ShortField("len", None),
IntField("xid", 0),
ShortEnumField("flags", 0, {0: "FRAG_NORMAL",
1: "FRAG_DROP",
2: "FRAG_REASM",
3: "FRAG_MASK"}),
ShortField("miss_send_len", 128)]
class OFPTPacketIn(_ofp_header):
name = "OFPT_PACKET_IN"
fields_desc = [ByteEnumField("version", 0x01, ofp_version),
ByteEnumField("type", 10, ofp_type),
ShortField("len", None),
IntField("xid", 0),
IntEnumField("buffer_id", "NO_BUFFER", ofp_buffer),
ShortField("total_len", 0),
ShortEnumField("in_port", 0, ofp_port_no),
ByteEnumField("reason", 0, {0: "OFPR_NO_MATCH",
1: "OFPR_ACTION"}),
XByteField("pad", 0),
PacketField("data", None, Ether)]
fields_desc = [ShortField("count", 0),
IntField("sysUptime", 0),
UTCTimeField("unixSecs", 0),
UTCTimeField("unixNanoSeconds", 0, use_nano=True),
IntField("flowSequence", 0),
ByteField("engineType", 0),
ByteField("engineID", 0),
ShortField("samplingInterval", 0)]
class NetflowRecordV5(Packet):
name = "Netflow Record v5"
fields_desc = [IPField("src", "127.0.0.1"),
IPField("dst", "127.0.0.1"),
IPField("nexthop", "0.0.0.0"),
ShortField("input", 0),
ShortField("output", 0),
IntField("dpkts", 1),
IntField("dOctets", 60),
IntField("first", 0),
IntField("last", 0),
ShortField("srcport", 0),
ShortField("dstport", 0),
ByteField("pad1", 0),
FlagsField("tcpFlags", 0x2, 8, "FSRPAUEC"),
ByteEnumField("prot", IP_PROTOS["tcp"], IP_PROTOS),
ByteField("tos", 0),
ShortField("src_as", 0),
ShortField("dst_as", 0),
ByteField("src_mask", 0),
ByteField("dst_mask", 0),
ShortField("pad2", 0)]
ConditionalField(ShortField("pad2", 0xffff), lambda pkt:pkt.id in [0x02]),
# MS_PROPERTY_IPADR
ConditionalField(IPField("address", "0.0.0.0"), lambda pkt:pkt.id in [0x03]),
ConditionalField(IP6Field("address6", "::"), lambda pkt:pkt.id in [0x03]),
# MS_PROPERTY_PARAM
ConditionalField(FieldLenField("param_len", 0, length_of="param", fmt="I"), lambda pkt:pkt.id in [0x04]),
ConditionalField(StrLenField("param", "", length_from=lambda pkt: pkt.param_len), lambda pkt:pkt.id in [0x04]),
ConditionalField(StrLenField("param_padding", "", length_from=lambda pkt: 100 - pkt.param_len), lambda pkt:pkt.id in [0x04]),
ConditionalField(ShortField("pad3", 0), lambda pkt:pkt.id in [0x04]),
ConditionalField(FieldLenField("value_len", 0x0, length_of="value", fmt="H"), lambda pkt:pkt.id in [0x04]),
ConditionalField(StrLenField("value", "", length_from=lambda pkt:pkt.value_len), lambda pkt:pkt.id in [0x04]),
# MS_PROPERTY_SERVICE
ConditionalField(ShortField("service", 0), lambda pkt:pkt.id in [0x05]),
ConditionalField(ByteField("value", 0), lambda pkt:pkt.id in [0x05]),
# Release Information fields
ConditionalField(StrNullFixedLenField("release", "720", length=10), lambda pkt:pkt.id in [0x07]),
ConditionalField(IntField("patchno", 0), lambda pkt:pkt.id in [0x07]),
ConditionalField(IntField("supplvl", 0), lambda pkt:pkt.id in [0x07]),
ConditionalField(IntField("platform", 0), lambda pkt:pkt.id in [0x07]),
]
class SAPMSJ2EECluster(Packet):
"""SAP Message Server J2EE Cluster packet
This packet is used for the Message Server protocol for J2EE cluster nodes.
"""
name = "SAP Message Server J2EE Cluster"
"""Generate the response block of this request.
Careful: it only sets the fields which can be set from the request
"""
res = ARBlockRes()
for field in ["ARType", "ARUUID", "SessionKey"]:
res.setfieldval(field, self.getfieldval(field))
return res
class ARBlockRes(Block):
"""Application relationship block response"""
fields_desc = [
BlockHeader,
XShortEnumField("ARType", 1, AR_TYPE),
UUIDField("ARUUID", None),
ShortField("SessionKey", 0),
MACField("CMResponderMacAdd", None),
ShortField("CMResponderUDPRTPort", 0x8892),
]
# default block_type value
block_type = 0x8101
# IOCRBlockRe{q,s}
class IOCRAPIObject(Packet):
"""API item descriptor used in API description of IOCR blocks"""
name = "API item"
fields_desc = [
XShortField("SlotNumber", 0),
XShortField("SubslotNumber", 0),
ShortField("FrameOffset", 0),
]
IntField("ip_addr", 0),
ShortField("value", 0)
]
class BGPPAExtCommRedirectAS4Byte(Packet):
"""
Packet handling the (FlowSpec) "redirect AS-4byte" extended community.
(RFC 7674).
References: RFC 7674
"""
name = "FlowSpec redirect AS-4byte extended community"
fields_desc = [
IntField("asn", 0),
ShortField("value", 0)
]
class BGPPAExtCommTrafficMarking(Packet):
"""
Packet handling the (FlowSpec) "traffic-marking" extended community.
References: RFC 5575
"""
name = "FlowSpec traffic-marking extended community"
fields_desc = [
BitEnumField("dscp", 48, 48, _ext_comm_traffic_action_fields)
]
_ext_high_low_dict = {
]
def to_json(self):
return json.dumps(self.fields, separators=(',', ':'))
class AccessControlRow1(Packet):
name = "AccessControlRow1"
fields_desc = [
BitField("set_ctrl", 0, 2),
BitField("row_part_id", 0, 3),
BitField("test", 0, 1),
BitField("row_key", 0, 10),
StrFixedLenField("ipv6_src_addr_start_bytes", None, 12),
ShortField("preview_length", None),
ShortField("preview_repeat_time", None),
ShortField("preview_repeat_count", None),
ShortField("preview_reset_time", None),
ShortField("reserved1", 0)
]
def to_json(self):
return json.dumps(self.fields, separators=(',', ':'))
class AccessControlRow2(Packet):
name = "AccessControlRow2"
fields_desc = [
BitField("set_ctrl", 0, 2),
BitField("row_part_id", 0, 3),
BitField("test", 0, 1),
ByteField("domnamelen", None),
StrFixedLenField("domname", "manbearpig", 32),
ConditionalField(SignedIntField("rev", 0),
lambda pkt:pkt.code == 1 or
pkt.code == 2),
# updater identity
ConditionalField(IPField("uid", "192.168.0.1"),
lambda pkt:pkt.code == 1),
ConditionalField(VTPTimeStampField("timestamp", '930301000000'),
lambda pkt:pkt.code == 1),
ConditionalField(StrFixedLenField("md5", b"\x00" * 16, 16),
lambda pkt:pkt.code == 1),
ConditionalField(
PacketListField("vlaninfo", [], VTPVlanInfo),
lambda pkt: pkt.code == 2),
ConditionalField(ShortField("startvalue", 0),
lambda pkt:pkt.code == 3)
]
def post_build(self, p, pay):
if self.domnamelen is None:
domnamelen = len(self.domname.strip(b"\x00"))
p = p[:3] + chr(domnamelen & 0xff) + p[4:]
p += pay
return p
bind_layers(SNAP, VTP, code=0x2003)
if __name__ == '__main__':
"""SAP Dispatcher Info packet
This packet is encapsulated inside SAPMS packet
and before the MS ADM payload. Kernel 749.
"""
name = "SAP Dispatcher Info v3"
fields_desc = [
IntField("dp_padd1", 185),
ByteEnumKeysField("dp_req_prio", 0x1, dp_prio_values),
ShortField("dp_padd2", 0x0),
ByteField("dp_padd3", 0x0),
ByteField("dp_padd4", 0x0),
IntField("dp_req_len", 0x0),
ShortField("dp_padd5", 0x0),
ByteField("dp_padd6", 0x0),
ByteEnumKeysField("dp_type_from", 0x2, dp_type_values),
StrFixedLenField("dp_fromname", " "*40, 40),
ShortField("dp_padd7", 0x0),
ByteField("dp_padd8", 0x0),
ByteEnumKeysField("dp_agent_type_from", 0x6, dp_agent_type_values),
ShortField("dp_padd9", 0x0),
ByteField("dp_padd10", 0x0),
ByteField("dp_padd12", 0xff),
ShortField("dp_padd13", 0x0),
ByteEnumKeysField("dp_worker_type_from", 0x1, dp_worker_type_values),
ByteField("dp_worker_from_num", 0x0),
ByteField("dp_padd133", 0x0),
ShortField("dp_padd111", 0x0000),