IOActive / laf

This project intends to provide a series of tools to craft, parse, send, analyze and crack a set of LoRaWAN packets in order to audit or pentest the security of a LoraWAN infrastructure.
BSD 3-Clause "New" or "Revised" License
171 stars 34 forks source link

Safely close socket #15

Closed eversinc33 closed 2 years ago

eversinc33 commented 3 years ago

Hey,

In the UdpSender, when a response is received, the socket is closed before the response is logged. The logging calls send_socket.getsockname() which is causing an exception due to being called on a closed socket.

Traceback (most recent call last):
  File "/home/pi/laf/tools/UdpSender.py", line 139, in udp_sender
    sender(data, fuzz_out_mode, key, dev_address, timeout, new_counter, local_port, remote_ip, remote_port)
  File "/home/pi/laf/tools/UdpSender.py", line 116, in sender
    receiver(send_socket, timeout)
  File "/home/pi/laf/tools/UdpSender.py", line 133, in receiver
    logger.debug('Received UDP. Source {0}. Local port {1}:\n{2!r}{3}'.format(source_address, send_socket.getsockname()[1], data, formatData(data)))
OSError: [Errno 9] Bad file descriptor

Closing the socket after logging fixes this.

Best wishes