Saturday, April 28, 2012

Lua scripting language in nmap overview.


Nmap, wireshark, and other programs use Lua as a scripting language to enable users to extend the functionality of the program. Seems that Lua is very popular in security programs.  As popular as Tcl in the hospital environment.

This is the nmap scripting chapter from the nmap book;
http://nmap.org/book/nse.html

From the link:

 The Nmap Scripting Engine (NSE) is one of Nmap's most powerful and flexible features. It allows users to write (and share) simple scripts to automate a wide variety of networking tasks. Those scripts are then executed in parallel with the speed and efficiency you expect from Nmap. Users can rely on the growing and diverse set of scripts distributed with Nmap, or write their own to meet custom needs.

In the end, Lua excelled in all of our criteria. It is small, distributed under the liberal MIT open source license, has coroutines for efficient parallel script execution, was designed with embeddability in mind, has excellent documentation, and is actively developed by a large and committed community. Lua is now even embedded in other popular open source security tools including the Wireshark sniffer and Snort IDS. 

Here is a link to a pdf that discusses extending both nmap and wireshark:
http://nmap.org/presentations/Sharkfest10/sharkfest10-slides-fyodor.pdf

This is a video presentation of the lua interface in nmap by David Fifield:
The Nmap scripting engine

David had been the maintainer of the scripting engine for two years when that video was made.

And "Mastering The Nmap Scripting Engine (Blackhat 2010)" Video:
http://www.securitytube.net/video/1223


Learning the Lua Language

This is a general tutorial for the language:
http://lua-users.org/wiki/LuaTutorial

From the link:
This tutorial is aimed at all newcomers to the language Lua. We start off with where to find relevant introductory material and then progress to using the language with tutorials in the TutorialDirectory. The style is directed at newcomers to scripting languages, as well as newcomers to Lua. Common uses of Lua are:

  • A configuration language for applications.
  • A standalone scripting language.
  • An embedded language in applications to modify runtime behavior.

There is a link from the above overview to a list of very good, detailed tutorials here:
http://lua-users.org/wiki/TutorialDirectory

You can also do functional programming in Lua using lisp like structures
http://en.wikibooks.org/wiki/Lua_Functional_Programming/Functions

And is one of the few languages to support the power of closures:
http://www.lua.org/pil/6.1.html

The complete language reference is available from here:
http://www.lua.org/pil/index.html

And that Lua language book is available from the languages main web site:
http://www.lua.org/


No comments:

Post a Comment