Penetration Tester's Open Source Toolkit

NASL Script Syntax

This section provides a descriptive overview of NASL script syntax, written to help the reader write his or her own NASL scripts. For a complete discussion of the NASL syntax, including a formal description of NASL grammar, please refer to The NASL2 Reference Manual, by Michel Arboi.

Comments

Text following a # character is ignored by the parser. Multiline comments (e.g., C's / * */) and inline comments are not supported.

Example of a Valid Comment:

x = 1      # set x equal to 1

Examples of Invalid Comments:

# Author: Eric HeitzmanFilename:  example.nasl #   port = get_kb_item # read port number from KB # ("Services/http")

The comment character causes everything following it to be ignored, but only until the end of the line. The error with the preceding examples is that they are being used as delimiters for comment blocks.

Variables

The variables in NASL are very easy to use. They do not need to be declared before being used, and variable-type conversion and memory allocation and deallocation are handled automatically. As in C, NASL variables are case-sensitive.

NASL supports the following data types: integers, strings, arrays, and NULL. Booleans are implemented, but not as a standalone data type. NASL does not support floating-point numbers.

Integers

There are three types of integer: decimal (base 10), octal (base 8), and hexadecimal (base 16). Octal numbers are denoted by a leading 0 (zero) and hexadecimal...

UNLIMITED FREE
ACCESS
TO THE WORLD'S BEST IDEAS

SUBMIT
Already a GlobalSpec user? Log in.

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.

Customize Your GlobalSpec Experience

Category: Math Calculation Software
Finish!
Privacy Policy

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.