HTP
0.5
|
Creates a copy of the supplied configuration structure. The idea is to create one or more configuration objects at configuration-time, but to use this function to create per-connection copies. That way it will be possible to adjust per-connection configuration as necessary, without affecting the global configuration. Make sure no other thread changes the configuration object while this function is operating.
[in] | cfg |
htp_cfg_t* htp_config_create | ( | void | ) |
Creates a new configuration structure. Configuration structures created at configuration time must not be changed afterwards in order to support lock-less copying.
void htp_config_destroy | ( | htp_cfg_t * | cfg | ) |
Destroy a configuration structure.
[in] | cfg |
void* htp_config_get_user_data | ( | htp_cfg_t * | cfg | ) |
Retrieves user data associated with this configuration.
[in] | cfg |
Registers a callback that is invoked every time there is a log message with severity equal and higher than the configured log level.
[in] | cfg | |
[in] | callback_fn |
void htp_config_register_multipart_parser | ( | htp_cfg_t * | cfg | ) |
Adds the built-in Multipart parser to the configuration. This parser will extract information stored in request bodies, when they are in multipart/form-data format.
[in] | cfg |
void htp_config_register_request_body_data | ( | htp_cfg_t * | cfg, |
int(*)(htp_tx_data_t *) | callback_fn | ||
) |
Registers a REQUEST_BODY_DATA callback.
[in] | cfg | |
[in] | callback_fn |
Registers a REQUEST_COMPLETE callback.
[in] | cfg | |
[in] | callback_fn |
void htp_config_register_request_file_data | ( | htp_cfg_t * | cfg, |
int(*)(htp_file_data_t *) | callback_fn | ||
) |
Registers a REQUEST_FILE_DATA callback.
[in] | cfg | |
[in] | callback_fn |
void htp_config_register_request_header_data | ( | htp_cfg_t * | cfg, |
int(*)(htp_tx_data_t *) | callback_fn | ||
) |
Registers a REQUEST_HEADER_DATA callback.
[in] | cfg | |
[in] | callback_fn |
Registers a REQUEST_HEADERS callback.
[in] | cfg | |
[in] | callback_fn |
Registers a REQUEST_LINE callback.
[in] | cfg | |
[in] | callback_fn |
Registers a REQUEST_START callback, which is invoked every time a new request begins and before any parsing is done.
[in] | cfg | |
[in] | callback_fn |
Registers a HTP_REQUEST_TRAILER callback.
[in] | cfg | |
[in] | callback_fn |
void htp_config_register_request_trailer_data | ( | htp_cfg_t * | cfg, |
int(*)(htp_tx_data_t *d) | callback_fn | ||
) |
Registers a REQUEST_TRAILER_DATA callback.
[in] | cfg | |
[in] | callback_fn |
Registers a REQUEST_URI_NORMALIZE callback.
[in] | cfg | |
[in] | callback_fn |
void htp_config_register_response_body_data | ( | htp_cfg_t * | cfg, |
int(*)(htp_tx_data_t *) | callback_fn | ||
) |
Registers a RESPONSE_BODY_DATA callback.
[in] | cfg | |
[in] | callback_fn |
Registers a RESPONSE_COMPLETE callback.
[in] | cfg | |
[in] | callback_fn |
void htp_config_register_response_header_data | ( | htp_cfg_t * | cfg, |
int(*)(htp_tx_data_t *) | callback_fn | ||
) |
Registers a RESPONSE_HEADER_DATA callback.
[in] | cfg | |
[in] | callback_fn |
Registers a RESPONSE_HEADERS callback.
[in] | cfg | |
[in] | callback_fn |
Registers a RESPONSE_LINE callback.
[in] | cfg | |
[in] | callback_fn |
Registers a RESPONSE_START callback.
[in] | cfg | |
[in] | callback_fn |
Registers a RESPONSE_TRAILER callback.
[in] | cfg | |
[in] | callback_fn |
void htp_config_register_response_trailer_data | ( | htp_cfg_t * | cfg, |
int(*)(htp_tx_data_t *d) | callback_fn | ||
) |
Registers a RESPONSE_TRAILER_DATA callback.
[in] | cfg | |
[in] | callback_fn |
Registers a TRANSACTION_COMPLETE callback.
[in] | cfg | |
[in] | callback_fn |
void htp_config_register_urlencoded_parser | ( | htp_cfg_t * | cfg | ) |
Adds the built-in Urlencoded parser to the configuration. The parser will parse query strings and request bodies with the appropriate MIME type.
[in] | cfg |
void htp_config_set_backslash_convert_slashes | ( | htp_cfg_t * | cfg, |
enum htp_decoder_ctx_t | ctx, | ||
int | enabled | ||
) |
Configures whether backslash characters are treated as path segment separators. They are not on Unix systems, but are on Windows systems. If this setting is enabled, a path such as "/one\two/three" will be converted to "/one/two/three". Implemented only for HTP_DECODER_URL_PATH.
[in] | cfg | |
[in] | ctx | |
[in] | enabled |
void htp_config_set_bestfit_map | ( | htp_cfg_t * | cfg, |
enum htp_decoder_ctx_t | ctx, | ||
void * | map | ||
) |
Configures a best-fit map, which is used whenever characters longer than one byte need to be converted to a single-byte. By default a Windows 1252 best-fit map is used. The map is an list of triplets, the first 2 bytes being an UCS-2 character to map from, and the third byte being the single byte to map to. Make sure that your map contains the mappings to cover the full-width and half-width form characters (U+FF00-FFEF). The last triplet in the map must be all zeros (3 NUL bytes).
[in] | cfg | |
[in] | ctx | |
[in] | map |
void htp_config_set_bestfit_replacement_byte | ( | htp_cfg_t * | cfg, |
enum htp_decoder_ctx_t | ctx, | ||
int | replacement_byte | ||
) |
Sets the replacement character that will be used to in the lossy best-fit mapping from multi-byte to single-byte streams. The question mark character is used as the default replacement byte.
[in] | cfg | |
[in] | ctx | |
[in] | replacement_byte |
void htp_config_set_control_chars_unwanted | ( | htp_cfg_t * | cfg, |
enum htp_decoder_ctx_t | ctx, | ||
enum htp_unwanted_t | unwanted | ||
) |
Controls reaction to raw control characters in the data.
[in] | cfg | |
[in] | ctx | |
[in] | unwanted |
void htp_config_set_convert_lowercase | ( | htp_cfg_t * | cfg, |
enum htp_decoder_ctx_t | ctx, | ||
int | enabled | ||
) |
Configures whether input data will be converted to lowercase. Useful when set on the HTP_DECODER_URL_PATH context, in order to handle servers with case-insensitive filesystems. Implemented only for HTP_DECODER_URL_PATH.
[in] | cfg | |
[in] | ctx | |
[in] | enabled |
htp_status_t htp_config_set_extract_request_files | ( | htp_cfg_t * | cfg, |
int | extract_files, | ||
int | limit | ||
) |
Enables or disables Multipart file extraction. This function can be invoked only after a previous htp_config_set_tmpdir() invocation. Otherwise, the configuration change will fail, and extraction will not be enabled. Disabled by default. Please note that the built-in file extraction implementation uses synchronous I/O, which means that it is not suitable for use in an event-driven container. There's an upper limit to how many files can be created on the filesystem during a single request. The limit exists in order to mitigate against a DoS attack with a Multipart payload that contains hundreds and thousands of files (it's cheap for the attacker to do this, but costly for the server to support it). The default limit may be pretty conservative.
[in] | cfg | |
[in] | extract_files | 1 if you wish extraction to be enabled, 0 otherwise |
[in] | limit | the maximum number of files allowed; use -1 to use the parser default. |
void htp_config_set_field_limits | ( | htp_cfg_t * | cfg, |
size_t | soft_limit, | ||
size_t | hard_limit | ||
) |
Configures the maximum size of the buffer LibHTP will use when all data is not available in the current buffer (e.g., a very long header line that might span several packets). This limit is controlled by the hard_limit parameter. The soft_limit parameter is not implemented.
[in] | cfg | |
[in] | soft_limit | NOT IMPLEMENTED. |
[in] | hard_limit |
void htp_config_set_log_level | ( | htp_cfg_t * | cfg, |
enum htp_log_level_t | log_level | ||
) |
Configures the desired log level.
[in] | cfg | |
[in] | log_level |
void htp_config_set_nul_encoded_terminates | ( | htp_cfg_t * | cfg, |
enum htp_decoder_ctx_t | ctx, | ||
int | enabled | ||
) |
Configures how the server reacts to encoded NUL bytes. Some servers will stop at at NUL, while some will respond with 400 or 404. When the termination option is not used, the NUL byte will remain in the path.
[in] | cfg | |
[in] | ctx | |
[in] | enabled |
void htp_config_set_nul_encoded_unwanted | ( | htp_cfg_t * | cfg, |
enum htp_decoder_ctx_t | ctx, | ||
enum htp_unwanted_t | unwanted | ||
) |
Configures reaction to encoded NUL bytes in input data.
[in] | cfg | |
[in] | ctx | |
[in] | unwanted |
void htp_config_set_nul_raw_terminates | ( | htp_cfg_t * | cfg, |
enum htp_decoder_ctx_t | ctx, | ||
int | enabled | ||
) |
Configures the handling of raw NUL bytes. If enabled, raw NUL terminates strings.
[in] | cfg | |
[in] | ctx | |
[in] | enabled |
void htp_config_set_nul_raw_unwanted | ( | htp_cfg_t * | cfg, |
enum htp_decoder_ctx_t | ctx, | ||
enum htp_unwanted_t | unwanted | ||
) |
Configures how the server reacts to raw NUL bytes. Some servers will terminate path at NUL, while some will respond with 400 or 404. When the termination option is not used, the NUL byte will remain in the data.
[in] | cfg | |
[in] | ctx | |
[in] | unwanted |
void htp_config_set_parse_request_auth | ( | htp_cfg_t * | cfg, |
int | parse_request_auth | ||
) |
Enable or disable request HTTP Authentication parsing. Enabled by default.
[in] | cfg | |
[in] | parse_request_auth |
void htp_config_set_parse_request_cookies | ( | htp_cfg_t * | cfg, |
int | parse_request_cookies | ||
) |
Enable or disable request cookie parsing. Enabled by default.
[in] | cfg | |
[in] | parse_request_cookies |
void htp_config_set_path_separators_compress | ( | htp_cfg_t * | cfg, |
enum htp_decoder_ctx_t | ctx, | ||
int | enabled | ||
) |
Configures whether consecutive path segment separators will be compressed. When enabled, a path such as "/one//two" will be normalized to "/one/two". Backslash conversion and path segment separator decoding are carried out before compression. For example, the path "/one\\/two\/%5cthree/%2f//four" will be converted to "/one/two/three/four" (assuming all 3 options are enabled). Implemented only for HTP_DECODER_URL_PATH.
[in] | cfg | |
[in] | ctx | |
[in] | enabled |
void htp_config_set_path_separators_decode | ( | htp_cfg_t * | cfg, |
enum htp_decoder_ctx_t | ctx, | ||
int | enabled | ||
) |
Configures whether encoded path segment separators will be decoded. Apache does not do this by default, but IIS does. If enabled, a path such as "/one%2ftwo" will be normalized to "/one/two". If the backslash_separators option is also enabled, encoded backslash characters will be converted too (and subsequently normalized to forward slashes). Implemented only for HTP_DECODER_URL_PATH.
[in] | cfg | |
[in] | ctx | |
[in] | enabled |
void htp_config_set_path_separators_encoded_unwanted | ( | htp_cfg_t * | cfg, |
enum htp_decoder_ctx_t | ctx, | ||
enum htp_unwanted_t | unwanted | ||
) |
Configures reaction to encoded path separator characters (e.g., %2f). Implemented only for HTP_DECODER_URL_PATH.
[in] | cfg | |
[in] | ctx | |
[in] | unwanted |
void htp_config_set_plusspace_decode | ( | htp_cfg_t * | cfg, |
enum htp_decoder_ctx_t | ctx, | ||
int | enabled | ||
) |
Configures whether plus characters are converted to spaces when decoding URL-encoded strings. This is appropriate to do for parameters, but not for URLs. Only applies to contexts where decoding is taking place.
[in] | cfg | |
[in] | ctx | |
[in] | enabled |
void htp_config_set_requestline_leading_whitespace_unwanted | ( | htp_cfg_t * | cfg, |
enum htp_decoder_ctx_t | ctx, | ||
enum htp_unwanted_t | unwanted | ||
) |
Configures how the server reacts to leading whitespace on the request line.
[in] | cfg | |
[in] | ctx | |
[in] | unwanted |
void htp_config_set_response_decompression | ( | htp_cfg_t * | cfg, |
int | enabled | ||
) |
Controls whether compressed response bodies will be automatically decompressed.
[in] | cfg | |
[in] | enabled | set to 1 to enable decompression, 0 otherwise |
void htp_config_set_response_decompression_layer_limit | ( | htp_cfg_t * | cfg, |
int | limit | ||
) |
Configures many layers of compression we try to decompress.
[in] | cfg | |
[in] | limit | 0 disables limit |
int htp_config_set_server_personality | ( | htp_cfg_t * | cfg, |
enum htp_server_personality_t | personality | ||
) |
Configure desired server personality.
[in] | cfg | |
[in] | personality |
void htp_config_set_tmpdir | ( | htp_cfg_t * | cfg, |
char * | tmpdir | ||
) |
Configures the path where temporary files should be stored. Must be set in order to use the Multipart file extraction functionality.
[in] | cfg | |
[in] | tmpdir |
void htp_config_set_tx_auto_destroy | ( | htp_cfg_t * | cfg, |
int | tx_auto_destroy | ||
) |
Configures whether transactions will be automatically destroyed once they are processed and all callbacks invoked. This option is appropriate for programs that process transactions as they are processed.
[in] | cfg | |
[in] | tx_auto_destroy |
void htp_config_set_u_encoding_decode | ( | htp_cfg_t * | cfg, |
enum htp_decoder_ctx_t | ctx, | ||
int | enabled | ||
) |
Configures whether u-encoded sequences are decoded. Such sequences will be treated as invalid URL encoding if decoding is not desirable.
[in] | cfg | |
[in] | ctx | |
[in] | enabled |
void htp_config_set_u_encoding_unwanted | ( | htp_cfg_t * | cfg, |
enum htp_decoder_ctx_t | ctx, | ||
enum htp_unwanted_t | unwanted | ||
) |
Configures reaction to u-encoded sequences in input data.
[in] | cfg | |
[in] | ctx | |
[in] | unwanted |
void htp_config_set_url_encoding_invalid_handling | ( | htp_cfg_t * | cfg, |
enum htp_decoder_ctx_t | ctx, | ||
enum htp_url_encoding_handling_t | handling | ||
) |
Configures how the server handles to invalid URL encoding.
[in] | cfg | |
[in] | ctx | |
[in] | handling |
void htp_config_set_url_encoding_invalid_unwanted | ( | htp_cfg_t * | cfg, |
enum htp_decoder_ctx_t | ctx, | ||
enum htp_unwanted_t | unwanted | ||
) |
Configures how the server reacts to invalid URL encoding.
[in] | cfg | |
[in] | ctx | |
[in] | unwanted |
void htp_config_set_user_data | ( | htp_cfg_t * | cfg, |
void * | user_data | ||
) |
Associates provided opaque user data with the configuration.
[in] | cfg | |
[in] | user_data |
void htp_config_set_utf8_convert_bestfit | ( | htp_cfg_t * | cfg, |
enum htp_decoder_ctx_t | ctx, | ||
int | enabled | ||
) |
Controls whether the data should be treated as UTF-8 and converted to a single-byte stream using best-fit mapping. Implemented only for HTP_DECODER_URL_PATH.
[in] | cfg | |
[in] | ctx | |
[in] | enabled |
void htp_config_set_utf8_invalid_unwanted | ( | htp_cfg_t * | cfg, |
enum htp_decoder_ctx_t | ctx, | ||
enum htp_unwanted_t | unwanted | ||
) |
Configures how the server reacts to invalid UTF-8 characters. This setting does not affect path normalization; it only controls what response status will be expect for a request that contains invalid UTF-8 characters. Implemented only for HTP_DECODER_URL_PATH.
[in] | cfg | |
[in] | ctx | |
[in] | unwanted |