2015-02-24 252 views
0

我试图访问这个数据包的RAW数据。我不知道如何提取并将其存储在变量中。我尝试过使用getlayer方法,但它不返回原始有效负载。Scapy:如何访问自定义数据包的RAW

>>> b.show2() 
###[ LSP Object ]### 
    \common_object_header\ 
    |###[ PCEP Common Object Header ]### 
    | oclass= LSP 
    | oType= 1L 
    | resflags= 
    | pflag= 
    | iflag= 
    | obLength= 20 
    plspid= 0x1L 
    flag= 0L 
    Cflag= 
    oflag= DOWN 
    Aflag= 
    Rflag= 
    Sflag= 
    Dflag= D 
    \symbolic_path_name\ 
    |###[ symbolic_path_name_tlv ]### 
    | tlvType= SYMBOLIC-PATHNAME-TLV 
    | tlvLength= 5 
    | tlvValue= 'lsp12' 
    |###[ Raw ]### 
    |  load= '000' <---- How to access this field??? 
>>> 

>>> b.symbolic_path_name.getlayer(Raw) <--- This does'nt return anything 
>>> 
>>> 
>>> b.symbolic_path_name.getlayer(Raw).load 
Traceback (most recent call last): 
    File "<console>", line 1, in <module> 
AttributeError: 'NoneType' object has no attribute 'load' 
>>>                                              

回答

0

所以我认为Raw对象是最后一层,它代表有效载荷。 所以你可以直接访问它

last = b.getlayer(Raw) 
# Because Raw is last this works as well, e.g. No Padding 
last2 = b.lastlayer() 
print last.load 
print last2.load