How it works...

The script http-tplink-dir-traversal.nse performs the following tasks to exploit the discussed path traversal vulnerability:

  1. First, it sends a path traversal request to determine if an installation is vulnerable.
  2. If the installation is vulnerable, extract the requested file out of the response sent by the web server.
  3. Report the vulnerability to the user and provide the proof of concept.

In this case, the library http was required to send the HTTP request containing the path traversal payload. To determine if the device is vulnerable, we request the file /etc/shadow because we know this file exists in all of the devices, and a root account must exist in it:

 local response = http.get(host, port, "/help/../../../etc/shadow") ...

Get Nmap: Network Exploration and Security Auditing Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.