Sending UDP payloads using NSE sockets
NSE offers a robust library for handling networking I/O operations by providing an interface to Nsock. Nsock is Nmap's optimized parallel sockets library, and its flexibility allows developers to handle raw packets and decide whether to use blocking or non-blocking network I/O operations.
This recipe will go through the process of writing an NSE script that reads a payload from a file and sends a UDP packet to exploit a vulnerability in Huawei HG5xx routers.
How to do it...
Huawei HG5xx routers reveal sensitive information when they receive a special packet to the UDP port 43690
. This vulnerability caught my attention because this is a very popular device, worked remotely, and it can retrieve interesting information such as PPPoE credentials, the MAC address, and exact software/firmware versions.
Let's write a simple script to exploit these devices:
- To start, create the
huawei-hg5xx-udpinfo.nse
file and define the...