Book Image

Mastering the Nmap Scripting Engine

By : Paulino Calderon
Book Image

Mastering the Nmap Scripting Engine

By: Paulino Calderon

Overview of this book

Table of Contents (23 chapters)
Mastering the Nmap Scripting Engine
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Scan Phases
Script Categories
Nmap Options Mind Map
References
Index

Quick notes about Lua


Now we will cover other concepts in Lua. If you are familiar with other scripting languages, you will find this section very useful because it aims to get you familiar with topics such as comments, array indexes, semantics, and data types.

Comments

A comment can be anything between two hyphens and the end of the line:

--This is a comment

Comment blocks are also supported. They are delimited by the --[[ and ]] characters:

--[[
This is a multi-line 
comment block.
]]

Dummy assignments

There are occasions when you don't need all the information returned by a function; in Lua, you can use dummy assignments to discard a return value. The operator is _ (underscore). For example, in the following code line, we discard the first two return values of string.find and store only the third value:

local _, _, item = string.find(<string>, <pattern with capture>) 

Indexes

Indexes start at one, not zero:

z={"a","b","c"}
z[1]="b" --This assignment will change the content of the table...