An Nmap script is comprised of several unique sections, each of which define different areas for the script to execute, or for Nmap to interpret expected output. There are several primary areas that we must always include in any script we create, in order to ensure that the script will run effectively (and that Nmap will be able to understand how to interpret the data).
Although Nmap scripts are written in Lua, an interpreted programming language, it's important to remember that these scripts are not stand-alone executables that can be run on their own. Rather than running a script with Nmap as a requirement, it's better to think of Nmap scripts as simply sets of instructions for a unique Nmap programming language.
An Nmap script is comprised of three unique sections: