WAF learning _lua basis

0x00: Introduction

ngx_lua_waf based ngx_lua is a web application firewall.

Address: https://github.com/loveshell/ngx_lua_waf

0x01: Lua

Lua is a compact and lightweight scripting language, written in standard C language and open source code form, which is designed for embedded applications, providing flexible expansion and customization features for the application.

It is designed for embedded applications, thereby providing a flexible expansion and customization of applications.

  • game development
  • Stand-alone application script
  • Web application scripting
  • Extensions and plug-ins such as databases: MySQL Proxy and MySQL WorkBench
  • Security systems such as intrusion detection systems

0x02: foundation

(1) basis
#! /usr/bin/lua
#! Role
Tell the interpreter, use the / usr / bin / lua script interpretation
(2) Notes

- Single-line comments

--[[

Multi-line comments

Multi-line comments

--]]

(3) variable

Full Lua variables are global variables, or even a block of statements in the function, with local unless explicitly declared local.

The scope of local variables is to start from a position where the end of the statement block statement

a = 123

Boolean variables only nil and false

Numbers 0, an empty string is true

If you want to delete a variable, then gave him the assignment to nil

(4) cycle
! # / Usr / bin / Lua 
SUM = 0 
NUM = . 1 
the while NUM <= 100  do 
    SUM = SUM + NUM 
    NUM = NUM + . 1 
    - in Lua = no + ++ 
End 
Print ( " SUM = " , SUM) 

- - for loop 
for I = . 1 , 100  do 
    SUM = SUM + . 1 
End 
Print ( " SUM = " , SUM) 

- [[   
IF Analyzing
~ = is not equal to String splicing operator ".." IO library are read from stdin and stdout, read and write functions - ]] IF == Age 20 and Sex == " Man " the then Print ( " Men equal to 20 " ) ELSEIF Age> 20 is and Sex = ~ " Woman " the then Print ( " Ladies and greater than a non-20 is " ) the else local Age = The call io.read () Print ( " Your Age IS " ..age) End
(5) function

function function_name(argument1,......)

  function_body

  return rusult

end

- [[ function returns the maximum of two values - ]] 
function max (num1, num2) 

   IF (num1> num2) the then 
      Result = num1;
    the else 
      Result = num2;
    End 

   return Result;
 End 
- calling function 
Print ( " two of maximum value comparison " , max ( 10 , . 4 ))
 Print ( " two of maximum value comparison " , max ( . 5 , . 6 ))

 

Guess you like

Origin www.cnblogs.com/liqik/p/12419513.html