我正在使用scapy的tacacs contrib,无法获取scapy Fields类中定义的一些常量值
例如,TacacsAuthorizationRequest类包含一个字段“authen_service”,该字段引用一个映射,该映射包含启用和定义的幻数是2之间的关联。我想根据pcap文件中的密钥获取名为enable的字段值
执行脚本后,我得到了字段描述中不存在的随机值
enter code here
TACACSAUTHENSERVICE={0:'None', 1:'登录', 2:'启用', 3:‘购买力平价’, 4.‘阿拉普’, 5:‘PT’, 6:‘RCMD’, 7:'X25', 8.‘纳西’, 9:'FwProxy'}
类TacacsAuthenticationStart(数据包):
'''
Tacacs authentication start body from section 4.1
https://tools.ietf.org/html/draft-ietf-opsawg-tacacs-06#section-4.1
'''
name = 'Tacacs Authentication Start Body'
fields_desc = [ByteEnumField('action', 1, TACACSAUTHENACTION),
ByteEnumField('priv_lvl', 1, TACACSPRIVLEVEL),
ByteEnumField('authen_type', 1, TACACSAUTHENTYPE),
ByteEnumField('authen_service', 1, TACACSAUTHENSERVICE),
FieldLenField('user_len', None, fmt='!B', length_of='user'),
FieldLenField('port_len', None, fmt='!B', length_of='port'),
FieldLenField('rem_addr_len', None, fmt='!B', length_of='rem_addr'), # noqa: E501
FieldLenField('data_len', None, fmt='!B', length_of='data'),
ConditionalField(StrLenField('user', '', length_from=lambda x: x.user_len), # noqa: E501
lambda x: x != ''),
StrLenField('port', '', length_from=lambda x: x.port_len),
下面是我为从pcap文件获取authen_服务字段密钥而编写的代码
def parse(frame):
if frame.haslayer(TacacsAuthorizationRequest):
fulldata=frame[TacacsAuthorizationRequest].fields
print(frame.getlayer(TacacsAuthorizationRequest).get_field('authen_service').i2repr(frame[TacacsAuthorizationRequest,frame[TacacsAuthorizationRequest].authen_service))
输出: 208
但208不是正确的值。我必须从字段_desc(即2)中的键值中获取值
有人能帮我找到传递给代码的pcap文件的正确密钥和对应值吗
目前没有回答
相关问题 更多 >
编程相关推荐