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

String handling


Lua's string library supports a lot of handy string operations. Strings will obviously be used frequently when writing NSE scripts since they are perfect for representing byte sequences. Let's review the most common functions and operators used in string handling.

Character classes

Character classes are special operators used in patterns. We will need them when matching or subtracting substrings, so keep them in mind when we review patterns and string operations:

Character classes

Represents

.

All characters

%a

Letters

%c

Control characters

%d

Digits

%l

Lowercase letters

%p

Punctuation characters

%s

Space characters

%u

Uppercase letters

%w

Alphanumeric characters

%x

Hexadecimal digits

%z

Null (0x90)

Magic characters

The following characters have special functions within patterns:

Operator

Function

( )

Parentheses encapsulate the pattern to capture

.

Any character

%

Escape character for magic characters and non-alphanumeric characters

+

Repetition...