Introduction to Lua scripting

Lua is a lightweight embeddable scripting language, which is built on top of the C programming language, was created in Brazil in 1993 and is still actively developed. It is a powerful and fast programming language mostly used in gaming applications and image processing. The complete source code, manual, plus binaries for some platforms do not go beyond 1.44 MB (which is less than a floppy disk). Some of the security tools that are developed in Lua are Nmap, Wireshark, and Snort 3.0.

One of the reasons why Lua was chosen to be the scripting language in information security is due to its compactness, no buffer overflows and format string vulnerabilities, and because it can be interpreted.

Lua can be installed directly in Kali Linux by issuing the apt-get install lua5.3 command on the Terminal. The following code extract is the sample script to read the file and print the first line:

#!/usr/bin/lua 
local file = io.open("/etc/shadow", "r")
contents = file:read()
file:close()
print (contents)

Lua is similar to any other scripting, such as Bash and Perl scripting. The preceding script should produce the output shown in the following screenshot:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.48.135