Ejemplo n.º 1
0
Archivo: htpy.c Proyecto: 0rbytal/htpy
static int htpy_config_init(htpy_config *self, PyObject *args, PyObject *kwds) {
	self->cfg = htp_config_create();
	if (!self->cfg)
		return -1;

	htp_config_set_tx_auto_destroy(self->cfg, 1);

	return 0;
}
Ejemplo n.º 2
0
VALUE rbhtp_config_initialize( VALUE self )
{
	char* const* v = &rbhtp_config_pvars[0];
	while ( *v[0] != '\0' ) {
		rb_iv_set( self, *v, Qnil );
		++v;
	}
	
	htp_cfg_t* cfg = htp_config_create();

	rb_iv_set( self, "@cfg",
		Data_Wrap_Struct( rb_cObject, 0, rbhtp_config_free, cfg )
	);
	
	return Qnil;
}
Ejemplo n.º 3
0
/**
 * Main entry point for this program.
 *
 * @param argc
 * @param argv
 */
int main(int argc, char *argv[]) {
    // Check parameters
    if ((argc < 2)||(argc > 4)) {
        print_usage();
        return 1;
    }

    // Configure libnids
    if (argc > 2) {
        if (strcmp(argv[1], "-r") != 0) {
            print_usage();
            return 1;
        }

        nids_params.filename = argv[2];

        if (argc == 4) {
            nids_params.pcap_filter = argv[3];
        }
    } else {
        nids_params.pcap_filter = argv[1];
    }

    // Initialize libnids
    if (!nids_init()) {
        fprintf(stderr, "libnids initialization failed: %s\n", nids_errbuf);
        return 1;
    }

    // Create LibHTP configuration
    cfg = htp_config_create();
    htp_config_set_server_personality(cfg, HTP_SERVER_APACHE_2_2);

    htp_config_register_response(cfg, callback_response);
    htp_config_register_log(cfg, callback_log);

    // Run libnids
    nids_register_tcp(tcp_callback);
    nids_run();

    // Destroy LibHTP configuration
    htp_config_destroy(cfg);

    return 0;
}
Ejemplo n.º 4
0
    virtual void SetUp() {
        home = getenv("srcdir");
        if (home == NULL) {
            fprintf(stderr, "This program needs environment variable 'srcdir' set.");
            exit(EXIT_FAILURE);
        }

        cfg = htp_config_create();
        htp_config_set_server_personality(cfg, HTP_SERVER_APACHE_2);

        connp = htp_connp_create(cfg);
        tx = htp_connp_tx_create(connp);
        htp_tx_set_user_data(tx, &output);

        decompressor = htp_gzip_decompressor_create(connp, HTP_COMPRESSION_GZIP);
        decompressor->callback = GUnzip_decompressor_callback;

        o_boxing_wizards = bstr_dup_c("The five boxing wizards jump quickly.");
        output = NULL;
    }