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

I/O operations


File manipulation in Lua is done on either implicit or explicit file descriptors. We will focus on using explicit file descriptors to perform most of the operations.

Note

If we work with implicit file descriptors by default, Lua will use stdin and stdout respectively. Alternatively, we can set the output and input descriptors with io.output and io.input, respectively.

Modes

File modes supported in Lua are the following:

File mode

Description

r

This is read mode.

w

This is write mode.

a

This is append mode.

r+

This is update mode. It preserves existing data.

w+

This is update mode. It deletes any existing data.

a+

This is append update mode. It preserves existing data and only allows appending at the end of the file.

Opening a file

The io.open function returns a file descriptor if successful:

file = io.open (filename [, mode])

If it fails, it will return nil and the corresponding error message (like most Lua functions).

Reading a file

To read a file using an explicit file...