eblot / pybootd

A minimalist bootp/dhcp/pxe and tftp server
Other
106 stars 31 forks source link

PXEd[pxed] CRITICAL: Padding overflow #16

Closed Lionel-snoopy63 closed 4 years ago

Lionel-snoopy63 commented 4 years ago

Hello. I need your help because I try to use bootp protocol but each time I get an error message. I've tried to dig inside the code but I don't know how to fix this issue. You will find below the output. Thanks in advance for any help. 17:37:18 PXEd[daemons] INFO: pybootd-1.7.1 <pybootd.util.EasyConfigParser object at 0x000001D904CDE1C8> 17:37:06 PXEd[pxed] INFO: Using ifname:{A5E9C4C2-457E-4842-87E8-CF9297BADB4D}, mask:255.255.255.0, net:192.168.1.0, server:192.168.1.58 17:37:06 PXEd[pxed] INFO: Listening to 0.0.0.0:67 17:37:18 PXEd[pxed] INFO: Sender: ('0.0.0.0', 68) on socket ('0.0.0.0', 67) 17:37:18 PXEd[pxed] INFO: PXE UUID not present in request 17:37:18 PXEd[pxed] INFO: 00:0A:86:A2:2F:3E access is authorized, request will be satisfied 17:37:18 PXEd[pxed] INFO: Client needs its address 17:37:18 PXEd[pxed] INFO: Reply to: 192.168.1.255:68 17:37:18 PXEd[pxed] INFO: Offering lease for MAC 00:0A:86:A2:2F:3E: IP 192.168.1.65 17:37:18 PXEd[pxed] INFO: Sender: ('0.0.0.0', 68) on socket ('0.0.0.0', 67) 17:37:18 PXEd[pxed] CRITICAL: Padding overflow

eblot commented 4 years ago

Hi. Can you enable DEBUG traces?

eblot commented 4 years ago

Which kind of DHCP client is it?

Lionel-snoopy63 commented 4 years ago

Which kind of DHCP client is it?

Client is an EtherNet communication module (this module is installed on a drive to be able to communicate with a PLC). When the module is out the box, bootp protocol is enable.

Lionel-snoopy63 commented 4 years ago

Hi. Can you enable DEBUG traces?

Yes of course. See below the output. C:\Users\Fxxx\AppData\Local\Programs\Python\Python37\Test_pybootd_20200108>pybootd.py -c C:\Users\Fxxx\AppData\Local\Programs\Python\Python37\Test_pybootd_20200108\pybootd\etc\pybootd.ini -p -d 16:01:24 PXEd[daemons] INFO: pybootd-1.7.1 16:01:24 PXEd[pxed] INFO: Using ifname:{A5E9C4C2-457E-4842-87E8-CF9297BADB4D}, mask:255.255.255.0, net:192.168.1.0, server:192.168.1.58 16:01:24 PXEd[pxed] INFO: Listening to 0.0.0.0:67 16:01:30 PXEd[pxed] INFO: Sender: ('0.0.0.0', 68) on socket ('0.0.0.0', 67) 16:01:30 PXEd[pxed] INFO: PXE UUID not present in request 16:01:30 PXEd[pxed] INFO: 00:0A:86:A2:2F:3E access is authorized, request will be satisfied 16:01:30 PXEd[pxed] INFO: Client needs its address 16:01:30 PXEd[pxed] INFO: Reply to: 192.168.1.255:68 16:01:30 PXEd[pxed] INFO: Offering lease for MAC 00:0A:86:A2:2F:3E: IP 192.168.1.25 16:01:30 PXEd[pxed] INFO: Sender: ('0.0.0.0', 68) on socket ('0.0.0.0', 67) 16:01:30 PXEd[pxed] CRITICAL: Padding overflow Traceback (most recent call last): File "C:\Users\Fxxx\AppData\Local\Programs\Python\Python37\Test_pybootd_20200108\pybootd\pxed.py", line 279, in start self.handle(sock, addr, data) File "C:\Users\Fxxx\AppData\Local\Programs\Python\Python37\Test_pybootd_20200108\pybootd\pxed.py", line 358, in handle options = self.parse_options(tail) File "C:\Users\Fxxx\AppData\Local\Programs\Python\Python37\Test_pybootd_20200108\pybootd\pxed.py", line 297, in parse_options raise ValueError('Padding overflow') ValueError: Padding overflow

16:01:35 PXEd[pxed] INFO: Sender: ('0.0.0.0', 68) on socket ('0.0.0.0', 67) 16:01:35 PXEd[pxed] CRITICAL: Padding overflow Traceback (most recent call last): File "C:\Users\Fxxx\AppData\Local\Programs\Python\Python37\Test_pybootd_20200108\pybootd\pxed.py", line 279, in start self.handle(sock, addr, data) File "C:\Users\Fxxx\AppData\Local\Programs\Python\Python37\Test_pybootd_20200108\pybootd\pxed.py", line 358, in handle options = self.parse_options(tail) File "C:\Users\Fxxx\AppData\Local\Programs\Python\Python37\Test_pybootd_20200108\pybootd\pxed.py", line 297, in parse_options raise ValueError('Padding overflow') ValueError: Padding overflow

Aborting...

C:\Users\Fxxx\AppData\Local\Programs\Python\Python37\Test_pybootd_20200108>

eblot commented 4 years ago

The error would be raised when the DHCP data received from the client is malformed - or there is a bug in pybootd :-)

in handle(self, sock, addr, data), add a log trace to dump the received data, such as

    def handle(self, sock, addr, data):
        self.log.info('Sender: %s on socket %s' % (addr, sock.getsockname()))
        self.log.info('DHCP data (%d): %s', len(data), hexlify(data).decode())
        # ...

and post the results

Lionel-snoopy63 commented 4 years ago

The error would be raised when the DHCP data received from the client is malformed - or there is a bug in pybootd :-)

in handle(self, sock, addr, data), add a log trace to dump the received data, such as

    def handle(self, sock, addr, data):
        self.log.info('Sender: %s on socket %s' % (addr, sock.getsockname()))
        self.log.info('DHCP data (%d): %s', len(data), hexlify(data).decode())
        # ...

and post the results

Below the results 18:14:07 PXEd[daemons] INFO: pybootd-1.7.1 18:14:07 PXEd[pxed] INFO: Using ifname:{A5E9C4C2-457E-4842-87E8-CF9297BADB4D}, mask:255.255.255.0, net:192.168.1.0, server:192.168.1.58 18:14:07 PXEd[pxed] INFO: Listening to 0.0.0.0:67 18:14:14 PXEd[pxed] INFO: Sender: ('0.0.0.0', 68) on socket ('0.0.0.0', 67) 18:14:14 PXEd[pxed] INFO: DHCP data (300): 010106002233445a0000800000000000000000000000000000000000000a86a22f3e0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000063825363ff0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 18:14:14 PXEd[pxed] INFO: PXE UUID not present in request 18:14:14 PXEd[pxed] INFO: 00:0A:86:A2:2F:3E access is authorized, request will be satisfied 18:14:14 PXEd[pxed] INFO: Client needs its address 18:14:14 PXEd[pxed] INFO: Reply to: 192.168.1.255:68 18:14:14 PXEd[pxed] INFO: Offering lease for MAC 00:0A:86:A2:2F:3E: IP 192.168.1.25 18:14:14 PXEd[pxed] INFO: Sender: ('0.0.0.0', 68) on socket ('0.0.0.0', 67) 18:14:14 PXEd[pxed] INFO: DHCP data (548): 010106002233445a0000800000000000000000000000000000000000000a86a22f3e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003c24496e7465724e6963686520506f727461626c65205443502f49502c2076302e30426574610000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ff638253633501033204c0a801190104ffffff000304c0a8013a33040001518037040103060f3604c0a8013a5106696e69636865000000000000000000340101ff0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 18:14:14 PXEd[pxed] CRITICAL: Padding overflow Traceback (most recent call last): File "C:\Users\Fxxx\AppData\Local\Programs\Python\Python37\Test_pybootd_20200108\pybootd\pxed.py", line 279, in start self.handle(sock, addr, data) File "C:\Users\Fxxx\AppData\Local\Programs\Python\Python37\Test_pybootd_20200108\pybootd\pxed.py", line 359, in handle options = self.parse_options(tail) File "C:\Users\Fxxx\AppData\Local\Programs\Python\Python37\Test_pybootd_20200108\pybootd\pxed.py", line 297, in parse_options raise ValueError('Padding overflow') ValueError: Padding overflow

eblot commented 4 years ago

Wow, never saw that much (useless) padding. I’ll check tomorrow this part of the code, even if the client is dumb, pybootd should be able to cope with it. Thanks for the traces, it helps a lot to understand/reproduce the issue.

eblot commented 4 years ago

Quick update: I've started writing a unit test so I can reproduce this error from the hex data you captured.

Lionel-snoopy63 commented 4 years ago

I've tested your update and that works well. See the result below for your info. Thanks a lot for your help.

18:02:10 PXEd[daemons] INFO: pybootd-1.7.2 18:02:10 PXEd[pxed] INFO: Using ifname:{A5E9C4C2-457E-4842-87E8-CF9297BADB4D}, mask:255.255.255.0, net:192.168.1.0, server:192.168.1.58 18:02:10 PXEd[pxed] INFO: Listening to 0.0.0.0:67 18:02:19 PXEd[pxed] INFO: Sender: ('0.0.0.0', 68) on socket ('0.0.0.0', 67) 18:02:19 PXEd[pxed] INFO: PXE UUID not present in request 18:02:19 PXEd[pxed] INFO: 00:0A:86:A2:2F:3E access is authorized, request will be satisfied 18:02:19 PXEd[pxed] INFO: Client needs its address 18:02:19 PXEd[pxed] INFO: Reply to: 192.168.1.255:68 18:02:19 PXEd[pxed] INFO: Offering lease for MAC 00:0A:86:A2:2F:3E: IP 192.168.1.25 18:02:19 PXEd[pxed] INFO: Sender: ('0.0.0.0', 68) on socket ('0.0.0.0', 67) 18:02:19 PXEd[pxed] INFO: PXE UUID not present in request 18:02:19 PXEd[pxed] INFO: 00:0A:86:A2:2F:3E access is authorized, request will be satisfied 18:02:19 PXEd[pxed] INFO: Client needs its address 18:02:19 PXEd[pxed] INFO: Lease for MAC 00:0A:86:A2:2F:3E already defined as IP 192.168.1.25 18:02:19 PXEd[pxed] INFO: Reply to: 192.168.1.255:68 18:02:19 PXEd[pxed] INFO: New lease for MAC 00:0A:86:A2:2F:3E: IP 192.168.1.25

Aborting...

eblot commented 4 years ago

Ok thanks for letting me know.