pom-ng:lua
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| pom-ng:lua [2012/10/22 08:19] – 2001:7e8:2221:600:901a:feff:fe05:41fe | pom-ng:lua [2020/05/26 21:59] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 3: | Line 3: | ||
| Currently, the lua API allows the creation of scripted pom-ng output. | Currently, the lua API allows the creation of scripted pom-ng output. | ||
| + | Quick link : [[pom-ng: | ||
| ===== Tutorial ===== | ===== Tutorial ===== | ||
| Line 8: | Line 9: | ||
| ==== Register an output ==== | ==== Register an output ==== | ||
| - | To create a new output, you simply call **output.new(name, | + | To create a new output, you simply call **output.new(name, |
| - | + | ||
| - | After creating your output | + | |
| When the output is started, the function **open()** will be called. Similarily, the function **close()** will be called when the output is stopped. | When the output is started, the function **open()** will be called. Similarily, the function **close()** will be called when the output is stopped. | ||
| Line 29: | Line 28: | ||
| local param2_value = self: | local param2_value = self: | ||
| print(" | print(" | ||
| - | end | ||
| - | |||
| - | function my_output_register() | ||
| - | pom.output.register(my_output) | ||
| end | end | ||
| Line 54: | Line 49: | ||
| function my_output: | function my_output: | ||
| - | self: | + | self: |
| end | end | ||
| Line 79: | Line 74: | ||
| print(" | print(" | ||
| priv.tot_len = 0 | priv.tot_len = 0 | ||
| + | return true | ||
| end | end | ||
| function my_output: | function my_output: | ||
| priv.tot_len += pdata.len | priv.tot_len += pdata.len | ||
| + | return true | ||
| end | end | ||
| Line 90: | Line 87: | ||
| function my_output: | function my_output: | ||
| - | self: | + | self: |
| end | end | ||
| Line 111: | Line 108: | ||
| <code lua> | <code lua> | ||
| - | function my_output:pload_process(pload_priv, | + | function my_output:pload_open(pload_priv, |
| -- Log the event associated with the payload | -- Log the event associated with the payload | ||
| | | ||
| Line 118: | Line 115: | ||
| local fname = "/ | local fname = "/ | ||
| | | ||
| + | |||
| + | -- Send the payload to the plugin, it will take care of it from now on | ||
| | | ||
| + | |||
| + | -- Return false because there is nothing more to do | ||
| + | | ||
| end | end | ||
| Line 134: | Line 136: | ||
| self.file_count = 0 | self.file_count = 0 | ||
| | | ||
| - | -- Listen to the http_request event | + | -- Listen to the http_request event in order have the payload generated out of it |
| - | self: | + | self: |
| + | |||
| + | -- Listen to payloads -- | ||
| + | | ||
| end | end | ||
| function my_output: | function my_output: | ||
| + | self: | ||
| self: | self: | ||
| self.file: | self.file: | ||
| Line 164: | Line 170: | ||
| local key, value | local key, value | ||
| key, value = data_iter() | key, value = data_iter() | ||
| - | | + | |
| | | ||
| - | local value_type = type(v) | + | local value_type = type(value) |
| if value_type == " | if value_type == " | ||
| print(" | print(" | ||
| Line 182: | Line 188: | ||
| == Parameters: == | == Parameters: == | ||
| * // | * // | ||
| + | |||
| + | === pom.dns.forward_lookup(name) === | ||
| + | Perform a forward lookup for a hostname using the offline DNS database. | ||
| + | |||
| + | == Parameters: == | ||
| + | * //name//: A name to lookup | ||
| + | |||
| + | === pom.dns.reverse_lookup(name) === | ||
| + | Perform a reverse lookup for a hostname or IP using the offline DNS database. It will try to find out what was the original query that points to the provided name. | ||
| + | |||
| + | == Parameters: == | ||
| + | * //name//: A name or IP to lookup | ||
| === pom.log(level, | === pom.log(level, | ||
| Line 199: | Line 217: | ||
| == Returns: == | == Returns: == | ||
| An output class. | An output class. | ||
| - | |||
| - | === pom.output.register(output_class) === | ||
| - | Registers a new output. | ||
| - | |||
| - | == Parameters: == | ||
| - | * // | ||
| === pom.plugin.new(plugin_name) === | === pom.plugin.new(plugin_name) === | ||
| Line 238: | Line 250: | ||
| Returns a data object containing all the information related to this event. | Returns a data object containing all the information related to this event. | ||
| + | === event.timestsamp === | ||
| + | == Returns: == | ||
| + | Returns the timestamp when the event started in micro seconds since epoch. | ||
| ==== output ==== | ==== output ==== | ||
| Line 245: | Line 260: | ||
| Called when an instance of the output is stopped. This function must be implemented by addon. | Called when an instance of the output is stopped. This function must be implemented by addon. | ||
| - | === output: | + | === output: |
| Call this function to start listening to a particular event. You must call output: | Call this function to start listening to a particular event. You must call output: | ||
| == Parameters: == | == Parameters: == | ||
| * // | * // | ||
| - | * // | + | * // |
| - | * // | + | * // |
| + | * //filter//: String containing an event filter, optional. | ||
| === output: | === output: | ||
| Line 262: | Line 278: | ||
| Called when an instance of the output is started. This function must be implemented by addon. | Called when an instance of the output is started. This function must be implemented by addon. | ||
| - | === output: | + | === output: |
| Start listening to payloads. Every payload will be processed. It's up to the output to filter them. If you don't need a specific function, you can specify nil instead. | Start listening to payloads. Every payload will be processed. It's up to the output to filter them. If you don't need a specific function, you can specify nil instead. | ||
| == Parameters: == | == Parameters: == | ||
| - | * // | + | * // |
| - | * // | + | * // |
| * // | * // | ||
| + | * //filter//: Pload filter to use, optional. | ||
| == Parameters of the above functions: == | == Parameters of the above functions: == | ||
| Line 285: | Line 302: | ||
| ==== pload ==== | ==== pload ==== | ||
| + | |||
| + | === pload.data === | ||
| + | |||
| + | == Returns: == | ||
| + | Returns the data related to this payload. It contains the data that the analyzer identified. For example, images will contain ' | ||
| === pload.event === | === pload.event === | ||
| Line 291: | Line 313: | ||
| Returns the event related to this payload. | Returns the event related to this payload. | ||
| - | === pload.data === | + | === pload.filename |
| == Returns: == | == Returns: == | ||
| - | Returns the data related to this payload. It contains | + | Returns the pload filename if it has been set, nil otherwise. |
| + | |||
| + | === pload.parent === | ||
| + | |||
| + | == Returns: == | ||
| + | Returns | ||
| === pload.type === | === pload.type === | ||
| Line 322: | Line 349: | ||
| Plugins are a piece of C code, usually from existing outputs, that perform useful functions. There are two types of plugins : event plugins and payload plugins. As you can guess, event plugins will process events and payload plugins will process payloads. | Plugins are a piece of C code, usually from existing outputs, that perform useful functions. There are two types of plugins : event plugins and payload plugins. As you can guess, event plugins will process events and payload plugins will process payloads. | ||
| - | [[pom-ng: | + | Here is a [[pom-ng: |
| Line 328: | Line 355: | ||
| Close the plugin and releases all the associated data. | Close the plugin and releases all the associated data. | ||
| - | === plugin: | + | === plugin: |
| Have the plugin listens to a specific event and process it. | Have the plugin listens to a specific event and process it. | ||
| == Parameters: == | == Parameters: == | ||
| * // | * // | ||
| + | * //filter//: String containing an event filter, optional. | ||
| === plugin: | === plugin: | ||
| Line 366: | Line 394: | ||
| === plugin: | === plugin: | ||
| - | Process a specific payload. | + | Process a specific payload. |
| == Parameters: == | == Parameters: == | ||
pom-ng/lua.1350893980.txt.gz · Last modified: (external edit)
