scapy icon indicating copy to clipboard operation
scapy copied to clipboard

PNIOServiceReqPDU Layer doesn't compute length parameters

Open CodingTrainee2 opened this issue 3 years ago • 1 comments

Brief description

The args_max, args_length, max_count and actual_count parameters of layer PNIOServiceReqPDU are not automatically computed when I try to sent a implicite Read Request.

Scapy version

2.5.0

Python version

3.11

Operating system

Windows Version 10.0.19045 Build 19045

Additional environment information

No response

How to reproduce

ReadPacket = scapy.all.Ether() / scapy.all.IP(dst=192.168.1.3) / scapy.all.UDP(dport=49152, sport=59832) / scapy.all.DceRpc4(
            rpc_vers=4, ptype=0, flags1=0x28, flags2=0x00, object=0xdea000006c9711d182710001fff1011e, endian=0, if_id=0xdea000016c9711d1827100a02442df7d, act_id=0x9bf6098164c5452fa410d885d4e300d1, opnum=5,  seqnum=rpc_seqnum
        )/scapy.contrib.pnio_rpc.PNIOServiceReqPDU()/scapy.contrib.pnio_rpc.IODReadReq(
            block_length=60, seqNum=1, slotNumber=0, subslotNumber=1, index=0xAFF1, recordDataLength=4096)
        ReadPacket.show() #ReadPacket.show2() doesn't show anything different
        scapy.all.sendp(ReadPacket, iface=interface)
#replace interface with your interface

Actual result

###[ PNIOServiceReqPDU ]###
              args_max  = None
              args_length= None
              max_count = None
              offset    = 0
              actual_count= None
              \blocks    \

Expected result

###[ PNIOServiceReqPDU ]###
              args_max  = 1392
              args_length= 64
              max_count = 1392
              offset    = 0
              actual_count= 64
              \blocks    \

Related resources

PNIO Bug Report.zip

CodingTrainee2 avatar Jan 09 '23 13:01 CodingTrainee2

def post_build(self, p, pay):   
        #Missing Array handling
        if self.args_max == None:
            self.args_max = len(pay)
            
        if  self.max_count == None:    
            self.max_count = len(pay)   
            
        
        self.args_length = len(pay)                      
        self.actual_count = len(pay)         
        return p+pay

Adding this code to scapy.contrib.pnio_rpc.PNIOServiceReqPDU(scapy.all.Packet) fixes the issue but only works as long as messages are not bigger than 1392 Bytes and therefore don't need to be Segmented.

When this turns out to be an confirmed missing implementation I might add it later, as I need it to work for a project.

CodingTrainee2 avatar Jan 09 '23 13:01 CodingTrainee2