void nmpVLANConfig(struct nipperConfig *nipper) { // Variables... struct vlanConfig *vlanNMPPointer = 0; output_table(nipper, true, settings_vlan_table, &settings_vlan_heading); vlanNMPPointer = nipper->nmp->vlan; while(vlanNMPPointer != 0) { fprintf(nipper->reportFile, "%s%d%s", nipper->tablerow_start, vlanNMPPointer->vlan, nipper->tablerow_mid); fprintf(nipper->reportFile, "%s%s", vlanNMPPointer->name, nipper->tablerow_mid); if (vlanNMPPointer->active == true) fprintf(nipper->reportFile, "Yes%s", nipper->tablerow_mid); else fprintf(nipper->reportFile, "No%s", nipper->tablerow_mid); fprintf(nipper->reportFile, "%s%s", vlanNMPPointer->type, nipper->tablerow_mid); if (vlanNMPPointer->firewall == -1) fprintf(nipper->reportFile, "None%s", nipper->tablerow_mid); else fprintf(nipper->reportFile, "%d%s", vlanNMPPointer->firewall, nipper->tablerow_mid); fprintf(nipper->reportFile, "%d%s", vlanNMPPointer->said, nipper->tablerow_mid); fprintf(nipper->reportFile, "%d%s", vlanNMPPointer->mtu, nipper->tablerow_mid); fprintf(nipper->reportFile, "%d%s", vlanNMPPointer->spanTreeMaxHops, nipper->tablerow_mid); fprintf(nipper->reportFile, "%d%s", vlanNMPPointer->allRoutesMaxHops, nipper->tablerow_end); vlanNMPPointer = vlanNMPPointer->next; } output_table(nipper, false, settings_vlan_table, &settings_vlan_heading); addAbbreviation("SAID", false); addAbbreviation("VLAN", false); addAbbreviation("MTU", false); }
// Service Groups void fw1ServiceGroupConfig(struct nipperConfig *nipper) { // Variables... struct objectConfig *objectPointer = 0; struct objectListConfig *objectListPointer = 0; struct objectMember *memberPointer = 0; char tempString[nipper->maxSize]; char tempString2[nipper->maxSize]; objectListPointer = getObjectListPointer(nipper, "FW1-Services"); objectPointer = objectListPointer->object; while (objectPointer != 0) { if (objectPointer->type == object_type_group) { sprintf(tempString, "%s %s", objectPointer->name, settings_fw1servicegroup_table); outputFriendly(tempString, tempString2, nipper->maxSize, nipper->outputFormat); output_table(nipper, true, tempString, &settings_fw1servicegroup_heading); memberPointer = objectPointer->members; while (memberPointer != 0) { outputFriendly(memberPointer->name, tempString, nipper->maxSize, nipper->outputFormat); fprintf(nipper->reportFile, "%s%s%s", nipper->tablerow_start, tempString, nipper->tablerow_end); memberPointer = memberPointer->next; } output_table(nipper, false, tempString2, &settings_fw1servicegroup_heading); } objectPointer = objectPointer->next; } }
// Machine Range Definitions void fw1MachRangeConfig(struct nipperConfig *nipper) { // Variables... struct objectConfig *objectPointer = 0; struct objectListConfig *objectListPointer = 0; char tempString[nipper->maxSize]; output_table(nipper, true, settings_objects_machrange_table, &settings_object_machrange_heading); objectListPointer = getObjectListPointer(nipper, "FW1-Objects"); objectPointer = objectListPointer->object; while (objectPointer != 0) { if (objectPointer->type == object_type_machinesrange) { outputFriendly(objectPointer->name, tempString, nipper->maxSize, nipper->outputFormat); if (nipper->outputFormat == output_html) fprintf(nipper->reportFile, "%s<a name=\"object-%s\">%s</a>%s", nipper->tablerow_start, tempString, tempString, nipper->tablerow_mid); else fprintf(nipper->reportFile, "%s%s%s", nipper->tablerow_start, tempString, nipper->tablerow_mid); fprintf(nipper->reportFile, "%s%s", objectPointer->address, nipper->tablerow_mid); fprintf(nipper->reportFile, "%s%s", objectPointer->netMask, nipper->tablerow_end); } objectPointer = objectPointer->next; } output_table(nipper, false, settings_objects_machrange_table, &settings_object_machrange_heading); }
// Object Definitions (Gateway Cluster Members...) void fw1GatewayClusterMemberConfig(struct nipperConfig *nipper) { // Variables... struct objectConfig *objectPointer = 0; struct objectListConfig *objectListPointer = 0; struct hostInterfaces *fw1InterfacePointer = 0; char tempString[nipper->maxSize]; char tempString2[nipper->maxSize]; objectListPointer = getObjectListPointer(nipper, "FW1-Objects"); objectPointer = objectListPointer->object; while (objectPointer != 0) { if (objectPointer->type == object_type_cluster_member) { // Gateway Configuration Settings... if (nipper->outputFormat == output_html) fprintf(nipper->reportFile, "<a name=\"object-%s\">", objectPointer->name); sprintf(tempString, "%s %s", objectPointer->name, settings_objects_gatewayclustermem_table); outputFriendly(tempString, tempString2, nipper->maxSize, nipper->outputFormat); output_table(nipper, true, tempString2, &settings_general_heading); outputFriendly(objectPointer->name, tempString, nipper->maxSize, nipper->outputFormat); fprintf(nipper->reportFile, "%sGateway Cluster Member Name%s%s%s", nipper->tablerow_start, nipper->tablerow_mid, tempString, nipper->tablerow_end); fprintf(nipper->reportFile, "%sIP Address%s%s%s", nipper->tablerow_start, nipper->tablerow_mid, objectPointer->address, nipper->tablerow_end); output_table(nipper, false, tempString2, &settings_general_heading); if (nipper->outputFormat == output_html) fprintf(nipper->reportFile, "</a>"); // Gateway Interfaces... fw1InterfacePointer = objectPointer->interfaces; if (fw1InterfacePointer != 0) { sprintf(tempString, "%s %s", objectPointer->name, settings_objects_gatewayclustermem_int_table); outputFriendly(tempString, tempString2, nipper->maxSize, nipper->outputFormat); output_table(nipper, true, tempString2, &settings_object_gateinter_heading); while (fw1InterfacePointer != 0) { fprintf(nipper->reportFile, "%s%d%s", nipper->tablerow_start, fw1InterfacePointer->interface, nipper->tablerow_mid); outputFriendly(fw1InterfacePointer->name, tempString, nipper->maxSize, nipper->outputFormat); fprintf(nipper->reportFile, "%s%s", tempString, nipper->tablerow_mid); if (fw1InterfacePointer->dynamicIP == true) fprintf(nipper->reportFile, "Enabled%sN/A%sN/A%s", nipper->tablerow_mid, nipper->tablerow_mid, nipper->tablerow_end); else fprintf(nipper->reportFile, "Disabled%s%s%s%s%s", nipper->tablerow_mid, fw1InterfacePointer->address, nipper->tablerow_mid, fw1InterfacePointer->netMask, nipper->tablerow_end); fw1InterfacePointer = fw1InterfacePointer->next; } output_table(nipper, false, tempString2, &settings_object_gateinter_heading); } } objectPointer = objectPointer->next; } }
void munge_file(void) { FILE *munge_fp = 0; FILE *table_fp = 0; FILE *header_fp = 0; static char line_buf[LINEBUFFER_SIZE + 1]; if ((munge_fp = fopen(munge_filename, "r")) == NULL) { fprintf(stderr, "couldn't open '%s' for reading\n", munge_filename); exit(-1); } if (header_munging) if ((header_fp = fopen(header_filename, "w")) == NULL) { fprintf(stderr, "couldn't open '%s' for writing\n", header_filename); exit(-1); } if (table_munging) if ((table_fp = fopen(table_filename, "w")) == NULL) { fprintf(stderr, "couldn't open '%s' for writing\n", table_filename); exit(-1); } while (fgets(line_buf, LINEBUFFER_SIZE, munge_fp)) { if (line_buf[0] == '#') /* comment lines. */ { continue; } else /* non comment lines */ { char command[100], string[100]; command[0] = string[0] = 0; sscanf(line_buf, " %s %s ", command, string); if (!command[0] || !string[0]) continue; add_command(command, string); } } fclose(munge_fp); sort_commands(); if (header_munging) output_header(header_fp); if (table_munging) output_table(table_fp); }
static void output_actions(void) { nvectors = 2 * nstates + nvars; froms = NEW2(nvectors, Value_t *); tos = NEW2(nvectors, Value_t *); tally = NEW2(nvectors, Value_t); width = NEW2(nvectors, Value_t); token_actions(); FREE(lookaheads); FREE(LA); FREE(LAruleno); FREE(accessing_symbol); goto_actions(); FREE(goto_map + ntokens); FREE(from_state); FREE(to_state); sort_actions(); pack_table(); output_base(); output_table(); output_check(); }
void output_actions() { nvectors = 3*nstates + nvars; froms = NEW2(nvectors, Yshort *); tos = NEW2(nvectors, Yshort *); tally = NEW2(nvectors, Yshort); width = NEW2(nvectors, Yshort); if (SRtotal+RRtotal) conflicts = NEW2(4*(SRtotal+RRtotal), Yshort); else conflicts = 0; nconflicts = 0; token_actions(); FREE(lookaheads); FREE(LA); FREE(LAruleno); goto_actions(); FREE(goto_map + ntokens); FREE(from_state); FREE(to_state); sort_actions(); pack_table(); output_base(); output_table(); output_check(); output_ctable(); output_astable(); FREE(accessing_symbol); }
output_actions() { nvectors = nstates + nvars; froms = NEW2(nvectors, short *); tos = NEW2(nvectors, short *); tally = NEW2(nvectors, short); width = NEW2(nvectors, short); token_actions(); free_shifts(); free_reductions(); FREE(lookaheads); FREE(LA); FREE(LAruleno); FREE(accessing_symbol); goto_actions(); FREE(goto_map + ntokens); FREE(from_state); FREE(to_state); sort_actions(); pack_table(); output_base(); output_table(); output_check(); }
void run_all_except_insertion(int random_arr[], int sorted_arr[], int length) { //copy of the input arrays to keep them intact int random_arr_copy[length]; int sorted_arr_copy[length]; //double arrays with running times double sorted_times[4]; double random_times[4]; //clock_t struct returned by the clock function for start and end times clock_t start, end; int ndx = 0; copy_array(random_arr, random_arr_copy, length); copy_array(sorted_arr, sorted_arr_copy, length); //run quicksort getting elapsed time for each start = clock(); quick_sort(random_arr_copy, 0, length - 1); end = clock(); copy_array(random_arr, random_arr_copy, length); random_times[ndx] = ((double)(end - start)) / CLOCKS_PER_SEC; start = clock(); quick_sort(sorted_arr_copy, 0, length - 1); end = clock(); copy_array(sorted_arr, sorted_arr_copy, length); sorted_times[ndx++] = ((double)(end - start)) / CLOCKS_PER_SEC; //run heapsort start = clock(); heap_sort(random_arr_copy, length, length); end = clock(); copy_array(random_arr, random_arr_copy, length); random_times[ndx] = ((double)(end - start)) / CLOCKS_PER_SEC; start = clock(); heap_sort(sorted_arr_copy, length, length); end = clock(); copy_array(sorted_arr, sorted_arr_copy, length); sorted_times[ndx++] = ((double)(end - start)) / CLOCKS_PER_SEC; //run merge sort start = clock(); merge_sort(random_arr_copy, 0, length - 1); end = clock(); copy_array(random_arr, random_arr_copy, length); random_times[ndx] = ((double)(end - start)) / CLOCKS_PER_SEC; start = clock(); merge_sort(sorted_arr_copy, 0, length - 1); end = clock(); copy_array(sorted_arr, sorted_arr_copy, length); sorted_times[ndx++] = ((double)(end - start)) / CLOCKS_PER_SEC; output_table(random_times, sorted_times); }
void iosTACACSConfig(struct nipperConfig *nipper) { // Variables... struct host *hostPointer = 0; char tempString[nipper->maxSize]; output_table(nipper, true, settings_tacacs_table, &settings_general_heading); if (nipper->passwords == true) { outputFriendly(nipper->ios->tacacs->key, tempString, nipper->maxSize, nipper->outputFormat); fprintf(nipper->reportFile, "%sTACACS Key%s%s %s", nipper->tablerow_start, nipper->tablerow_mid, tempString, nipper->tablerow_end); } switch(nipper->ios->tacacs->encryption) { case encrypt_type7: fprintf(nipper->reportFile, "%sKey Encryption Type%sType-7%s", nipper->tablerow_start, nipper->tablerow_mid, nipper->tablerow_end); break; case encrypt_md5: fprintf(nipper->reportFile, "%sKey Encryption Type%sMD5%s", nipper->tablerow_start, nipper->tablerow_mid, nipper->tablerow_end); addAbbreviation("MD5", false); break; case encrypt_none: fprintf(nipper->reportFile, "%sKey Encryption Type%sNone%s", nipper->tablerow_start, nipper->tablerow_mid, nipper->tablerow_end); break; case encrypt_unknown: fprintf(nipper->reportFile, "%sKey Encryption Type%sUnknown%s", nipper->tablerow_start, nipper->tablerow_mid, nipper->tablerow_end); break; } output_table(nipper, false, settings_tacacs_table, &settings_general_heading); addAbbreviation("TACACS", false); if (nipper->ios->tacacs->host != 0) { output_table(nipper, true, settings_tacacsserv_table, &settings_tacacsserv_heading); hostPointer = nipper->ios->tacacs->host; while (hostPointer != 0) { outputFriendly(hostPointer->server, tempString, nipper->maxSize, nipper->outputFormat); fprintf(nipper->reportFile, "%s%s%s", nipper->tablerow_start, tempString, nipper->tablerow_end); hostPointer = hostPointer->next; } output_table(nipper, false, settings_tacacsserv_table, &settings_tacacsserv_heading); } }
void pixURPFIssue(struct nipperConfig *nipper) { // Variables... struct interfacePIXConfig *interfacePIXConfigPointer = 0; char tempString[nipper->maxSize]; output_parseText(report_urpf_pix_obs, nipper, section_obs, rate_none, nipper->uRPFIssues, nipper->tableNum); if (nipper->uRPFIssues > 1) { interfacePIXConfigPointer = nipper->pix->interface; output_table(nipper, true, report_urpf_table, &report_interfacepix_heading); while (interfacePIXConfigPointer != 0) { if ((interfacePIXConfigPointer->uRPF == false) && (interfacePIXConfigPointer->shutdown == false) && (strcmp(interfacePIXConfigPointer->ipAddress, "") != 0)) { fprintf(nipper->reportFile, "%s%s%s", nipper->tablerow_start, interfacePIXConfigPointer->interface, nipper->tablerow_mid); fprintf(nipper->reportFile, "%s%s", interfacePIXConfigPointer->name, nipper->tablerow_end); } interfacePIXConfigPointer = interfacePIXConfigPointer->next; } output_table(nipper, false, report_urpf_table, &report_interfacepix_heading); } else if (nipper->uRPFIssues > 0) { interfacePIXConfigPointer = nipper->pix->interface; while (interfacePIXConfigPointer != 0) { if ((interfacePIXConfigPointer->uRPF == false) && (interfacePIXConfigPointer->shutdown == false) && (strcmp(interfacePIXConfigPointer->ipAddress, "") != 0)) { outputFriendly(interfacePIXConfigPointer->interface, tempString, nipper->maxSize, nipper->outputFormat); fprintf(nipper->reportFile, "%s.", tempString); } interfacePIXConfigPointer = interfacePIXConfigPointer->next; } output_newPara(nipper); } output_endsection(nipper, section_obs); output_parseText(report_urpf_impact, nipper, section_imp, rate_med, nipper->uRPFIssues, nipper->tableNum); output_endsection(nipper, section_imp); output_parseText(report_urpf_ease, nipper, section_ease, rate_noease, nipper->uRPFIssues, nipper->tableNum); output_endsection(nipper, section_ease); output_parseText(report_urpf_pix_rec, nipper, section_rec, rate_none, nipper->uRPFIssues, nipper->tableNum); output_endsection(nipper, section_rec); }
void pixServicesConfig(struct nipperConfig *nipper) { output_table(nipper, true, settings_services_table, &report_services_heading); if (nipper->pix->snmp == 0) fprintf(nipper->reportFile, "%sSNMP Server%sEnabled%s", nipper->tablerow_start, nipper->tablerow_mid, nipper->tablerow_end); else if (nipper->pix->snmp->enabled == true) fprintf(nipper->reportFile, "%sSNMP Server%sEnabled%s", nipper->tablerow_start, nipper->tablerow_mid, nipper->tablerow_end); else fprintf(nipper->reportFile, "%sSNMP Server%sDisabled%s", nipper->tablerow_start, nipper->tablerow_mid, nipper->tablerow_end); if (nipper->pix->http == 0) fprintf(nipper->reportFile, "%sHTTPS Server%sDisabled%s", nipper->tablerow_start, nipper->tablerow_mid, nipper->tablerow_end); else if (nipper->pix->http->httpServer == false) fprintf(nipper->reportFile, "%sHTTPS Server%sDisabled%s", nipper->tablerow_start, nipper->tablerow_mid, nipper->tablerow_end); else fprintf(nipper->reportFile, "%sHTTPS Server%sEnabled%s", nipper->tablerow_start, nipper->tablerow_mid, nipper->tablerow_end); output_table(nipper, false, settings_services_table, &report_services_heading); addAbbreviation("SNMP", false); addAbbreviation("HTTPS", false); }
int main(int argc, char **argv) { employ_t *company; int workers_n; if(display_help(argc,argv)) return 0; company = (employ_t *) calloc(MAX_STUDENTS_NUMBER, sizeof(employ_t)); workers_n = (input(company)); company = (employ_t *) realloc(company, workers_n * sizeof(employ_t)); sort_up(company, workers_n); output_table(company, workers_n); free(company); return (0); /* I like it */ }
void pixGeneralConfig(struct nipperConfig *nipper) { // Variables... char tempString[nipper->maxSize]; output_table(nipper, true, settings_general_table, &settings_general_heading); fprintf(nipper->reportFile, "%sHostname%s%s %s", nipper->tablerow_start, nipper->tablerow_mid, nipper->friendlyHostname, nipper->tablerow_end); if (nipper->domainName[0] != 0) { outputFriendly(nipper->domainName, tempString, nipper->maxSize, nipper->outputFormat); fprintf(nipper->reportFile, "%sDomain Name%s%s%s", nipper->tablerow_start, nipper->tablerow_mid, tempString, nipper->tablerow_end); } if ((nipper->version[0] != 0) && (nipper->deviceType == type_pix_firewall)) { addAbbreviation("PIX", false); fprintf(nipper->reportFile, "%sPIX Version%s%s %s", nipper->tablerow_start, nipper->tablerow_mid, nipper->version, nipper->tablerow_end); } else if ((nipper->version[0] != 0) && (nipper->deviceType == type_asa_firewall)) { addAbbreviation("ASA", false); fprintf(nipper->reportFile, "%sASA Version%s%s %s", nipper->tablerow_start, nipper->tablerow_mid, nipper->version, nipper->tablerow_end); } else if ((nipper->version[0] != 0) && (nipper->deviceType == type_fwsm_firewall)) { addAbbreviation("FWSM", false); fprintf(nipper->reportFile, "%sFWSM Version%s%s %s", nipper->tablerow_start, nipper->tablerow_mid, nipper->version, nipper->tablerow_end); } if (nipper->pix->transparent == true) fprintf(nipper->reportFile, "%sTransparent Firewall%sYes%s", nipper->tablerow_start, nipper->tablerow_mid, nipper->tablerow_end); else fprintf(nipper->reportFile, "%sTransparent Firewall%sNo%s", nipper->tablerow_start, nipper->tablerow_mid, nipper->tablerow_end); if (nipper->pix->floodguard == true) fprintf(nipper->reportFile, "%sFlood Guard%sEnabled%s", nipper->tablerow_start, nipper->tablerow_mid, nipper->tablerow_end); else fprintf(nipper->reportFile, "%sFlood Guard%sDisabled%s", nipper->tablerow_start, nipper->tablerow_mid, nipper->tablerow_end); output_table(nipper, false, settings_general_table, &settings_general_heading); }
void sort_input_is_random_not_insertion(int random_arr[], int length) { int random_arr_copy[length]; //double arrays with running times double random_times[4]; //we won't need this array, but output_table expects it. double sorted_times[4] = {0,0,0,0}; //clock_t struct returned by the clock function for start and end times clock_t start, end; int ndx = 0; copy_array(random_arr, random_arr_copy, length); //run quicksort getting elapsed time for each start = clock(); quick_sort(random_arr_copy, 0, length - 1); end = clock(); copy_array(random_arr, random_arr_copy, length); random_times[ndx++] = ((double)(end - start)) / CLOCKS_PER_SEC; //run heapsort start = clock(); heap_sort(random_arr_copy, length, length); end = clock(); copy_array(random_arr, random_arr_copy, length); random_times[ndx++] = ((double)(end - start)) / CLOCKS_PER_SEC; //run merge sort start = clock(); merge_sort(random_arr_copy, 0, length - 1); end = clock(); copy_array(random_arr, random_arr_copy, length); random_times[ndx++] = ((double)(end - start)) / CLOCKS_PER_SEC; output_table(random_times, sorted_times); }
void pgsql2sqlite(Connection conn, std::string const& query, std::string const& output_table_name, std::string const& output_filename) { namespace sqlite = mapnik::sqlite; sqlite::database db(output_filename); boost::shared_ptr<ResultSet> rs = conn->executeQuery("select * from (" + query + ") as query limit 0;"); int count = rs->getNumFields(); std::ostringstream select_sql; select_sql << "select "; for (int i=0; i<count; ++i) { if (i!=0) select_sql << ","; select_sql << "\"" << rs->getFieldName(i) << "\""; } select_sql << " from (" << query << ") as query"; std::string table_name = mapnik::sql_utils::table_from_sql(query); std::string schema_name=""; std::string::size_type idx=table_name.find_last_of('.'); if (idx!=std::string::npos) { schema_name=table_name.substr(0,idx); table_name=table_name.substr(idx+1); } else { table_name=table_name.substr(0); } std::ostringstream geom_col_sql; geom_col_sql << "select f_geometry_column,srid,type from geometry_columns "; geom_col_sql << "where f_table_name='" << table_name << "'"; if (schema_name.length() > 0) { geom_col_sql <<" and f_table_schema='"<< schema_name <<"'"; } rs = conn->executeQuery(geom_col_sql.str()); int srid = -1; std::string geom_col = "UNKNOWN"; std::string geom_type = "UNKNOWN"; if ( rs->next()) { try { srid = boost::lexical_cast<int>(rs->getValue("srid")); } catch (boost::bad_lexical_cast &ex) { std::clog << ex.what() << std::endl; } geom_col = rs->getValue("f_geometry_column"); geom_type = rs->getValue("type"); } // add AsBinary(<geometry_column>) modifier std::string select_sql_str = select_sql.str(); boost::algorithm::replace_all(select_sql_str, "\"" + geom_col + "\"","AsBinary(" + geom_col+") as " + geom_col); #ifdef MAPNIK_DEBUG std::cout << select_sql_str << "\n"; #endif std::ostringstream cursor_sql; std::string cursor_name("my_cursor"); cursor_sql << "DECLARE " << cursor_name << " BINARY INSENSITIVE NO SCROLL CURSOR WITH HOLD FOR " << select_sql_str << " FOR READ ONLY"; conn->execute(cursor_sql.str()); boost::shared_ptr<CursorResultSet> cursor(new CursorResultSet(conn,cursor_name,10000)); unsigned num_fields = cursor->getNumFields(); if (num_fields == 0) return; std::string feature_id = "fid"; std::ostringstream create_sql; create_sql << "create table if not exists " << output_table_name << " (" << feature_id << " INTEGER PRIMARY KEY AUTOINCREMENT,"; int geometry_oid = -1; std::string output_table_insert_sql = "insert into " + output_table_name + " values (?"; context_ptr ctx = boost::make_shared<context_type>(); for ( unsigned pos = 0; pos < num_fields ; ++pos) { const char* field_name = cursor->getFieldName(pos); ctx->push(field_name); if (pos > 0) { create_sql << ","; } output_table_insert_sql +=",?"; int oid = cursor->getTypeOID(pos); if (geom_col == cursor->getFieldName(pos)) { geometry_oid = oid; create_sql << "'" << cursor->getFieldName(pos) << "' BLOB"; } else { create_sql << "'" << cursor->getFieldName(pos); switch (oid) { case 20: case 21: case 23: create_sql << "' INTEGER"; break; case 700: case 701: create_sql << "' REAL"; break; default: create_sql << "' TEXT"; break; } } } create_sql << ");"; output_table_insert_sql +=")"; std::cout << "client_encoding=" << conn->client_encoding() << "\n"; std::cout << "geometry_column=" << geom_col << "(" << geom_type << ") srid=" << srid << " oid=" << geometry_oid << "\n"; db.execute("begin;"); // output table sql db.execute(create_sql.str()); // spatial index sql std::string spatial_index_sql = "create virtual table idx_" + output_table_name + "_" + geom_col + " using rtree(pkid, xmin, xmax, ymin, ymax)"; db.execute(spatial_index_sql); //blob_to_hex hex; int pkid = 0; std::string spatial_index_insert_sql = "insert into idx_" + output_table_name + "_" + geom_col + " values (?,?,?,?,?)" ; sqlite::prepared_statement spatial_index(db,spatial_index_insert_sql); #ifdef MAPNIK_DEBUG std::cout << output_table_insert_sql << "\n"; #endif sqlite::prepared_statement output_table(db,output_table_insert_sql); while (cursor->next()) { ++pkid; sqlite::record_type output_rec; output_rec.push_back(sqlite::value_type(pkid)); bool empty_geom = true; const char * buf = 0; for (unsigned pos=0 ; pos < num_fields; ++pos) { if (! cursor->isNull(pos)) { int size=cursor->getFieldLength(pos); int oid = cursor->getTypeOID(pos); buf=cursor->getValue(pos); switch (oid) { case 25: case 1042: case 1043: { std::string text(buf); boost::algorithm::replace_all(text,"'","''"); output_rec.push_back(sqlite::value_type(text)); break; } case 23: output_rec.push_back(sqlite::value_type(int4net(buf))); break; case 21: output_rec.push_back(sqlite::value_type(int2net(buf))); break; case 700: { float val; float4net(val,buf); output_rec.push_back(sqlite::value_type(val)); break; } case 701: { double val; float8net(val,buf); output_rec.push_back(sqlite::value_type(val)); break; } case 1700: { std::string str = mapnik::sql_utils::numeric2string(buf); try { double val = boost::lexical_cast<double>(str); output_rec.push_back(sqlite::value_type(val)); } catch (boost::bad_lexical_cast & ex) { std::clog << ex.what() << "\n"; } break; } default: { if (oid == geometry_oid) { mapnik::Feature feat(ctx,pkid); geometry_utils::from_wkb(feat.paths(),buf,size,wkbGeneric); if (feat.num_geometries() > 0) { geometry_type const& geom=feat.get_geometry(0); box2d<double> bbox = geom.envelope(); if (bbox.valid()) { sqlite::record_type rec; rec.push_back(sqlite::value_type(pkid)); rec.push_back(sqlite::value_type(bbox.minx())); rec.push_back(sqlite::value_type(bbox.maxx())); rec.push_back(sqlite::value_type(bbox.miny())); rec.push_back(sqlite::value_type(bbox.maxy())); spatial_index.insert_record(rec); empty_geom = false; } } output_rec.push_back(sqlite::blob(buf,size)); } else { output_rec.push_back(sqlite::null_type()); } break; } } } else { output_rec.push_back(sqlite::null_type()); } } if (!empty_geom) output_table.insert_record(output_rec); if (pkid % 1000 == 0) { std::cout << "\r processing " << pkid << " features"; std::cout.flush(); } if (pkid % 100000 == 0) { db.execute("commit;begin;"); } } // commit db.execute("commit;"); std::cout << "\r processed " << pkid << " features"; db.execute("VACUUM;"); std::cout << "\r vacumming"; std::cout << "\n Done!" << std::endl; }
void pixVulnerabilityIssue(struct nipperConfig *nipper) { // Variables... struct vulnerability *vulnPointer = 0; char tempString[nipper->maxSize]; output_parseText(report_osver_obs1, nipper, section_obs, rate_none, nipper->vulnIssues, nipper->tableNum); if (nipper->vulnIssues > 1) { output_table(nipper, true, report_osver_table, &report_osver_heading); if (nipper->deviceType == type_fwsm_firewall) vulnPointer = &report_vuln_fwsm; else vulnPointer = &report_vuln_pix; while (vulnPointer->next != 0) { if (vulnPointer->include == true) { outputFriendly(vulnPointer->description, tempString, nipper->maxSize, nipper->outputFormat); fprintf(nipper->reportFile, "%s%s%s", nipper->tablerow_start, tempString, nipper->tablerow_mid); fprintf(nipper->reportFile, "%s%s%s%s", vulnPointer->cve, nipper->tablerow_mid, vulnPointer->bid, nipper->tablerow_end); } vulnPointer = vulnPointer->next; } output_table(nipper, false, report_osver_table, &report_osver_heading); output_parseText(report_osver_obs2, nipper, section_none, rate_none, nipper->vulnIssues, nipper->tableNum -1); } else if (nipper->vulnIssues > 0) { output_parseText(report_osver_obs3, nipper, section_none, rate_none, nipper->vulnIssues, nipper->tableNum -1); if (nipper->deviceType == type_fwsm_firewall) vulnPointer = &report_vuln_fwsm; else vulnPointer = &report_vuln_pix; while (vulnPointer->next != 0) { if (vulnPointer->include == true) { outputFriendly(vulnPointer->description, tempString, nipper->maxSize, nipper->outputFormat); fprintf(nipper->reportFile, "\"%s\" (", tempString); if (vulnPointer->cve[0] != 0) fprintf(nipper->reportFile, "CVE reference %s", vulnPointer->cve); if ((vulnPointer->cve[0] != 0) && (vulnPointer->bid[0] != 0)) fprintf(nipper->reportFile, " and "); if (vulnPointer->bid[0] != 0) fprintf(nipper->reportFile, " Bugtraq ID %s", vulnPointer->bid); fprintf(nipper->reportFile, ")."); } vulnPointer = vulnPointer->next; } if (nipper->outputFormat == output_xml) fprintf(nipper->reportFile, "</text>\n"); output_parseText(report_osver_obs2, nipper, section_none, rate_none, nipper->vulnIssues, nipper->tableNum -1); } output_endsection(nipper, section_obs); if (nipper->vulnIssues > 0) { output_parseText(report_osver_impact1, nipper, section_imp, rate_high, nipper->vulnIssues, nipper->tableNum -1); if ((nipper->vulnIssueDos == true) && (nipper->vulnIssueRemote == true)) output_parseText(report_osver_impact2, nipper, section_none, rate_none, nipper->vulnIssues, nipper->tableNum -1); else if (nipper->vulnIssueDos == true) output_parseText(report_osver_impact3, nipper, section_none, rate_none, nipper->vulnIssues, nipper->tableNum -1); else if (nipper->vulnIssueRemote == true) output_parseText(report_osver_impact4, nipper, section_none, rate_none, nipper->vulnIssues, nipper->tableNum -1); addAbbreviation("CVE", false); addAbbreviation("BID", false); } else output_parseText(report_osver_impact5, nipper, section_imp, rate_high, nipper->vulnIssues, nipper->tableNum -1); output_endsection(nipper, section_imp); output_parseText(report_osver_ease, nipper, section_ease, rate_trivial, nipper->vulnIssues, nipper->tableNum -1); output_endsection(nipper, section_ease); output_parseText(report_osver_rec, nipper, section_rec, rate_none, nipper->vulnIssues, nipper->tableNum -1); output_endsection(nipper, section_rec); }
// Object Definitions (Groups...) void fw1GroupObjectsConfig(struct nipperConfig *nipper) { // Variables... struct objectConfig *objectPointer = 0; struct objectConfig *objectPointer2 = 0; struct objectMember *memberPointer = 0; struct objectListConfig *objectListPointer = 0; char tempString[nipper->maxSize]; char tempString2[nipper->maxSize]; objectListPointer = getObjectListPointer(nipper, "FW1-Objects"); objectPointer = objectListPointer->object; while (objectPointer != 0) { if (objectPointer->type == object_type_group) { sprintf(tempString, "%s %s", objectPointer->name, settings_objects_group_table); outputFriendly(tempString, tempString2, nipper->maxSize, nipper->outputFormat); if (nipper->outputFormat == output_html) fprintf(nipper->reportFile, "<a name=\"object-%s\">", objectPointer->name); output_table(nipper, true, tempString2, &settings_object_group_heading); memberPointer = objectPointer->members; while (memberPointer != 0) { objectPointer2 = nipper->objectList->object; while ((objectPointer2->next != 0) && (strcasecmp(objectPointer2->name, memberPointer->name) != 0)) objectPointer2 = objectPointer2->next; outputFriendly(memberPointer->name, tempString, nipper->maxSize, nipper->outputFormat); if ((nipper->outputFormat == output_html) && (objectPointer2->type == object_type_group)) fprintf(nipper->reportFile, "%s<a href=\"#object-%s\">%s</a>%s", nipper->tablerow_start, tempString, tempString, nipper->tablerow_mid); else fprintf(nipper->reportFile, "%s%s%s", nipper->tablerow_start, tempString, nipper->tablerow_mid); if (strcasecmp(objectPointer2->name, memberPointer->name) == 0) { switch (objectPointer2->type) { case object_type_network: fprintf(nipper->reportFile, "Network%s", nipper->tablerow_mid); fprintf(nipper->reportFile, "%s%s", objectPointer2->address, nipper->tablerow_mid); fprintf(nipper->reportFile, "%s %s", objectPointer2->netMask, nipper->tablerow_mid); if (objectPointer2->internal == true) fprintf(nipper->reportFile, "Yes%s", nipper->tablerow_end); else fprintf(nipper->reportFile, "No%s", nipper->tablerow_end); break; case object_type_group: fprintf(nipper->reportFile, "Group%s", nipper->tablerow_mid); fprintf(nipper->reportFile, "-%s-%s-%s", nipper->tablerow_mid, nipper->tablerow_mid, nipper->tablerow_end); break; case object_type_host: fprintf(nipper->reportFile, "Host%s", nipper->tablerow_mid); fprintf(nipper->reportFile, "%s%s", objectPointer2->address, nipper->tablerow_mid); fprintf(nipper->reportFile, "-%s", nipper->tablerow_mid); if (objectPointer2->internal == true) fprintf(nipper->reportFile, "Yes%s", nipper->tablerow_end); else fprintf(nipper->reportFile, "No%s", nipper->tablerow_end); break; case object_type_machinesrange: fprintf(nipper->reportFile, "Range%s", nipper->tablerow_mid); fprintf(nipper->reportFile, "%s%s", objectPointer2->address, nipper->tablerow_mid); fprintf(nipper->reportFile, "%s %s", objectPointer2->netMask, nipper->tablerow_mid); if (objectPointer2->internal == true) fprintf(nipper->reportFile, "Yes%s", nipper->tablerow_end); else fprintf(nipper->reportFile, "No%s", nipper->tablerow_end); break; case object_type_dynamicnet: fprintf(nipper->reportFile, "Dynamic Net%s", nipper->tablerow_mid); fprintf(nipper->reportFile, "-%s-%s-%s", nipper->tablerow_mid, nipper->tablerow_mid, nipper->tablerow_end); break; case object_type_gateway: fprintf(nipper->reportFile, "Gateway%s", nipper->tablerow_mid); fprintf(nipper->reportFile, "%s%s", objectPointer2->address, nipper->tablerow_mid); fprintf(nipper->reportFile, "-%s", nipper->tablerow_mid); if (objectPointer2->internal == true) fprintf(nipper->reportFile, "Yes%s", nipper->tablerow_end); else fprintf(nipper->reportFile, "No%s", nipper->tablerow_end); break; case object_type_cluster_member: fprintf(nipper->reportFile, "Cluster Member%s", nipper->tablerow_mid); fprintf(nipper->reportFile, "%s%s", objectPointer2->address, nipper->tablerow_mid); fprintf(nipper->reportFile, "-%s", nipper->tablerow_mid); if (objectPointer2->internal == true) fprintf(nipper->reportFile, "Yes%s", nipper->tablerow_end); else fprintf(nipper->reportFile, "No%s", nipper->tablerow_end); break; case object_type_gateway_cluster: fprintf(nipper->reportFile, "Gateway Cluster%s", nipper->tablerow_mid); fprintf(nipper->reportFile, "%s%s", objectPointer2->address, nipper->tablerow_mid); fprintf(nipper->reportFile, "%s %s", objectPointer2->netMask, nipper->tablerow_mid); if (objectPointer2->internal == true) fprintf(nipper->reportFile, "Yes%s", nipper->tablerow_end); else fprintf(nipper->reportFile, "No%s", nipper->tablerow_end); break; default: fprintf(nipper->reportFile, "Unknown%s", nipper->tablerow_mid); fprintf(nipper->reportFile, "-%s-%s-%s", nipper->tablerow_mid, nipper->tablerow_mid, nipper->tablerow_end); break; } } else fprintf(nipper->reportFile, "Unknown%s-%s-%s-%s", nipper->tablerow_mid, nipper->tablerow_mid, nipper->tablerow_mid, nipper->tablerow_end); memberPointer = memberPointer->next; } output_table(nipper, false, tempString2, &settings_object_group_heading); if (nipper->outputFormat == output_html) fprintf(nipper->reportFile, "</a>"); } objectPointer = objectPointer->next; } }
void pixUsersConfig(struct nipperConfig *nipper) { // Variables... struct enablePIXPassword *enablePIXPointer = 0; struct usernamePIX *usernamePIXPointer = 0; // Login Password if (nipper->pix->password[0] != 0) { if (nipper->outputFormat == output_xml) fprintf(nipper->reportFile, " <text>"); fprintf(nipper->reportFile, "%s %s.", settings_logon_password, nipper->pix->password); if (nipper->outputFormat == output_xml) fprintf(nipper->reportFile, "</text>\n"); output_newPara(nipper); } // Enable Password if (nipper->pix->enable != 0) { output_table(nipper, true, settings_enable_table, &report_enablepix_heading); enablePIXPointer = nipper->pix->enable; while (enablePIXPointer != 0) { fprintf(nipper->reportFile, "%s%d", nipper->tablerow_start, enablePIXPointer->level); fprintf(nipper->reportFile, "%s%s", nipper->tablerow_mid, enablePIXPointer->passwordEncrypted); fprintf(nipper->reportFile, "%s", nipper->tablerow_end); enablePIXPointer = enablePIXPointer->next; } output_table(nipper, false, settings_enable_table, &report_enablepix_heading); } // Usernames if (nipper->pix->username != 0) { output_table(nipper, true, settings_users_table, &report_userspix_heading); usernamePIXPointer = nipper->pix->username; while (usernamePIXPointer != 0) { fprintf(nipper->reportFile, "%s%s%s", nipper->tablerow_start, usernamePIXPointer->username, nipper->tablerow_mid); fprintf(nipper->reportFile, "%d%s", usernamePIXPointer->level, nipper->tablerow_mid); switch (usernamePIXPointer->encryption) { case encrypt_none: fprintf(nipper->reportFile, "N/A"); break; case encrypt_pix: fprintf(nipper->reportFile, "Standard"); break; case encrypt_mschap: fprintf(nipper->reportFile, "MS-CHAP"); addAbbreviation("MS-CHAP", false); break; case encrypt_ntenc: fprintf(nipper->reportFile, "NT Encrypted"); addAbbreviation("NT", false); break; } if (nipper->passwords == true) { if (usernamePIXPointer->passwordEncrypted[0] == 0) fprintf(nipper->reportFile, "%sNone%s", nipper->tablerow_mid, nipper->tablerow_end); else fprintf(nipper->reportFile, "%s%s%s", nipper->tablerow_mid, usernamePIXPointer->passwordEncrypted, nipper->tablerow_end); } else fprintf(nipper->reportFile, "%s", nipper->tablerow_end); usernamePIXPointer = usernamePIXPointer->next; } output_table(nipper, false, settings_users_table, &report_userspix_heading); } }
void sosStrengthIssue(struct nipperConfig *nipper) { // Variables... int tempInt = 0; output_parseText(report_strength_obs, nipper, section_obs, rate_none, nipper->passwordStrengths, nipper->tableNum); if (nipper->passwordStrengths > 1) { output_table(nipper, true, report_strength_table, &report_dict_heading); output_SOSTablePasswords(nipper, false); output_table(nipper, false, report_strength_table, &report_dict_heading); } else output_SOSLinePasswords(nipper, false); output_endsection(nipper, section_obs); output_parseText(report_strength_impact, nipper, section_imp, rate_high, nipper->passwordStrengths, nipper->tableNum); output_endsection(nipper, section_imp); output_parseText(report_strength_ease, nipper, section_ease, rate_trivial, nipper->passwordStrengths, nipper->tableNum); output_endsection(nipper, section_ease); output_parseText(report_strength_rec, nipper, section_rec, rate_trivial, nipper->passwordStrengths, nipper->tableNum); numToWord(nipper->reportFile, nipper->passwordLength); fprintf(nipper->reportFile, " characters in length and contain"); if (nipper->passwordUppers == true) tempInt = 1; else tempInt = 0; if (nipper->passwordLowers == true) tempInt++; if (nipper->passwordEither == true) tempInt++; if (nipper->passwordNumbers == true) tempInt++; if (nipper->passwordSpecials == true) tempInt++; if (nipper->passwordUppers == true) { fprintf(nipper->reportFile, " uppercase"); if (tempInt > 2) fprintf(nipper->reportFile, ","); else if (tempInt == 2) fprintf(nipper->reportFile, " and"); tempInt--; } if (nipper->passwordLowers == true) { fprintf(nipper->reportFile, " lowercase"); if (tempInt > 2) fprintf(nipper->reportFile, ","); else if (tempInt == 2) fprintf(nipper->reportFile, " and"); tempInt--; } if (nipper->passwordEither == true) { fprintf(nipper->reportFile, " either uppercase or lowercase characters"); if (tempInt > 2) fprintf(nipper->reportFile, ","); else if (tempInt == 2) fprintf(nipper->reportFile, " and"); tempInt--; } if (nipper->passwordNumbers == true) { fprintf(nipper->reportFile, " numbers"); if (tempInt > 2) fprintf(nipper->reportFile, ","); else if (tempInt == 2) fprintf(nipper->reportFile, " and"); tempInt--; } if (nipper->passwordSpecials == true) { fprintf(nipper->reportFile, " special"); if (tempInt > 2) fprintf(nipper->reportFile, ","); else if (tempInt == 2) fprintf(nipper->reportFile, " and"); tempInt--; } if (((nipper->passwordNumbers == true) && (nipper->passwordSpecials == false)) || ((nipper->passwordEither == false) && (nipper->passwordNumbers == false) && (nipper->passwordSpecials == false))) fprintf(nipper->reportFile, "."); else fprintf(nipper->reportFile, " characters."); if (nipper->outputFormat == output_xml) fprintf(nipper->reportFile, "</text>\n"); output_newPara(nipper); output_endsection(nipper, section_rec); }
void pixNATPATConfig(struct nipperConfig *nipper) { // Variables... struct staticPIX *staticPIXPointer = 0; char tempString[nipper->maxSize]; output_parseText(settings_natpat_desc, nipper, section_none, rate_none, 1, 0); if (nipper->pix->staticNAT !=0) { output_table(nipper, true, settings_nat_static_table, &settings_nat_static_heading); staticPIXPointer = nipper->pix->staticNAT; while (staticPIXPointer != 0) { outputFriendly(staticPIXPointer->interfaceReal, tempString, nipper->maxSize, nipper->outputFormat); fprintf(nipper->reportFile, "%s%s%s", nipper->tablerow_start, tempString, nipper->tablerow_mid); if (staticPIXPointer->interface == true) fprintf(nipper->reportFile, "Interface"); else if (staticPIXPointer->accessList[0] != 0) { outputFriendly(staticPIXPointer->accessList, tempString, nipper->maxSize, nipper->outputFormat); fprintf(nipper->reportFile, "ACL: %s", tempString); addAbbreviation("ACL", false); } else if (staticPIXPointer->ipNetMaskReal[0] != 0) fprintf(nipper->reportFile, "%s %s", staticPIXPointer->ipReal, staticPIXPointer->ipNetMaskReal); else fprintf(nipper->reportFile, "%s", staticPIXPointer->ipReal); outputFriendly(staticPIXPointer->interfaceMapped, tempString, nipper->maxSize, nipper->outputFormat); fprintf(nipper->reportFile, "%s%s%s", nipper->tablerow_mid, tempString, nipper->tablerow_mid); outputFriendly(staticPIXPointer->ipMapped, tempString, nipper->maxSize, nipper->outputFormat); fprintf(nipper->reportFile, "%s%s", tempString, nipper->tablerow_mid); if (staticPIXPointer->dns == true) fprintf(nipper->reportFile, "Yes%s", nipper->tablerow_mid); else fprintf(nipper->reportFile, "No%s", nipper->tablerow_mid); if (staticPIXPointer->randomseq == true) fprintf(nipper->reportFile, "Yes%s", nipper->tablerow_mid); else fprintf(nipper->reportFile, "No%s", nipper->tablerow_mid); if (staticPIXPointer->nailed == true) fprintf(nipper->reportFile, "Yes%s", nipper->tablerow_mid); else fprintf(nipper->reportFile, "No%s", nipper->tablerow_mid); if (staticPIXPointer->tcpMaxConnections == 0) fprintf(nipper->reportFile, "Unlimited%s", nipper->tablerow_mid); else fprintf(nipper->reportFile, "%d%s", staticPIXPointer->tcpMaxConnections, nipper->tablerow_mid); if (staticPIXPointer->embrionicConnections == 0) fprintf(nipper->reportFile, "Unlimited%s", nipper->tablerow_mid); else fprintf(nipper->reportFile, "%d%s", staticPIXPointer->embrionicConnections, nipper->tablerow_mid); if (staticPIXPointer->udpMaxConnections == 0) fprintf(nipper->reportFile, "Unlimited%s", nipper->tablerow_end); else fprintf(nipper->reportFile, "%d%s", staticPIXPointer->udpMaxConnections, nipper->tablerow_end); staticPIXPointer = staticPIXPointer->next; } output_table(nipper, false, settings_nat_static_table, &settings_nat_static_heading); } if (nipper->pix->staticPAT !=0) { output_table(nipper, true, settings_pat_static_table, &settings_pat_static_heading); staticPIXPointer = nipper->pix->staticPAT; while (staticPIXPointer != 0) { outputFriendly(staticPIXPointer->interfaceReal, tempString, nipper->maxSize, nipper->outputFormat); if (staticPIXPointer->protocolTcp == true) fprintf(nipper->reportFile, "%sTCP%s", nipper->tablerow_start, nipper->tablerow_mid); else fprintf(nipper->reportFile, "%sUDP%s", nipper->tablerow_start, nipper->tablerow_mid); fprintf(nipper->reportFile, "%s%s", tempString, nipper->tablerow_mid); if (staticPIXPointer->interface == true) fprintf(nipper->reportFile, "Interface"); else if (staticPIXPointer->accessList[0] != 0) { outputFriendly(staticPIXPointer->accessList, tempString, nipper->maxSize, nipper->outputFormat); fprintf(nipper->reportFile, "ACL: %s", tempString); addAbbreviation("ACL", false); } else if (staticPIXPointer->ipNetMaskReal[0] != 0) fprintf(nipper->reportFile, "%s %s", staticPIXPointer->ipReal, staticPIXPointer->ipNetMaskReal); else fprintf(nipper->reportFile, "%s", staticPIXPointer->ipReal); fprintf(nipper->reportFile, " (%s)", staticPIXPointer->portReal); outputFriendly(staticPIXPointer->interfaceMapped, tempString, nipper->maxSize, nipper->outputFormat); fprintf(nipper->reportFile, "%s%s%s", nipper->tablerow_mid, tempString, nipper->tablerow_mid); outputFriendly(staticPIXPointer->ipMapped, tempString, nipper->maxSize, nipper->outputFormat); fprintf(nipper->reportFile, "%s (%s)%s", tempString, staticPIXPointer->portMapped, nipper->tablerow_mid); if (staticPIXPointer->dns == true) fprintf(nipper->reportFile, "Yes%s", nipper->tablerow_mid); else fprintf(nipper->reportFile, "No%s", nipper->tablerow_mid); if (staticPIXPointer->randomseq == true) fprintf(nipper->reportFile, "Yes%s", nipper->tablerow_mid); else fprintf(nipper->reportFile, "No%s", nipper->tablerow_mid); if (staticPIXPointer->nailed == true) fprintf(nipper->reportFile, "Yes%s", nipper->tablerow_mid); else fprintf(nipper->reportFile, "No%s", nipper->tablerow_mid); if (staticPIXPointer->tcpMaxConnections == 0) fprintf(nipper->reportFile, "Unlimited%s", nipper->tablerow_mid); else fprintf(nipper->reportFile, "%d%s", staticPIXPointer->tcpMaxConnections, nipper->tablerow_mid); if (staticPIXPointer->embrionicConnections == 0) fprintf(nipper->reportFile, "Unlimited%s", nipper->tablerow_mid); else fprintf(nipper->reportFile, "%d%s", staticPIXPointer->embrionicConnections, nipper->tablerow_mid); if (staticPIXPointer->udpMaxConnections == 0) fprintf(nipper->reportFile, "Unlimited%s", nipper->tablerow_end); else fprintf(nipper->reportFile, "%d%s", staticPIXPointer->udpMaxConnections, nipper->tablerow_end); staticPIXPointer = staticPIXPointer->next; } output_table(nipper, false, settings_pat_static_table, &settings_pat_static_heading); } }
void pixTimeoutIssue(struct nipperConfig *nipper) { // Variables... char tempString[nipper->maxSize]; output_parseText(report_timeout_obs1, nipper, section_obs, rate_none, nipper->insecureTimeouts, nipper->tableNum); if ((nipper->connectionTimeout % 60) == 0) { numToWord(nipper->reportFile, (nipper->connectionTimeout / 60)); fprintf(nipper->reportFile, " minutes"); } else { numToWord(nipper->reportFile, nipper->connectionTimeout / 60); fprintf(nipper->reportFile, " minutes and "); numToWord(nipper->reportFile, nipper->connectionTimeout % 60); fprintf(nipper->reportFile, " seconds"); } output_parseText(report_timeout_obs2, nipper, section_none, rate_none, nipper->insecureTimeouts, nipper->tableNum); if (nipper->insecureTimeouts > 1) { output_table(nipper, true, report_timeout_table, &report_timeout_heading); if (nipper->pix->ssh != 0) { if ((nipper->pix->ssh->timeout * 60) > nipper->connectionTimeout) { fprintf(nipper->reportFile, "%sSSH Session Timeout%s", nipper->tablerow_start, nipper->tablerow_mid); numToWord(nipper->reportFile, nipper->pix->ssh->timeout); fprintf(nipper->reportFile, " minutes%s", nipper->tablerow_end); } } output_table(nipper, false, report_timeout_table, &report_timeout_heading); } else { if (nipper->pix->ssh != 0) { if ((nipper->pix->ssh->timeout * 60) > nipper->connectionTimeout) { sprintf(tempString, "*NOTEXTSTART*The SSH session timeout was *NUMBER* minutes."); output_parseText(tempString, nipper, section_none, rate_none, nipper->pix->ssh->timeout, 0); } } } output_endsection(nipper, section_obs); output_parseText(report_timeout_impact, nipper, section_imp, rate_high, 0, 0); output_endsection(nipper, section_imp); output_parseText(report_timeout_ease, nipper, section_ease, rate_difficult, 0, 0); output_endsection(nipper, section_ease); output_parseText(report_timeout_rec1, nipper, section_rec, rate_none, 0, 0); if ((nipper->connectionTimeout % 60) == 0) { numToWord(nipper->reportFile, (nipper->connectionTimeout / 60)); fprintf(nipper->reportFile, " minutes"); } else { numToWord(nipper->reportFile, nipper->connectionTimeout / 60); fprintf(nipper->reportFile, " minutes and "); numToWord(nipper->reportFile, (nipper->connectionTimeout % 60)); fprintf(nipper->reportFile, " seconds"); } output_parseText(report_timeout_rec2, nipper, section_none, rate_none, 0, 0); output_endsection(nipper, section_rec); }
void iosUsersConfig(struct nipperConfig *nipper) { // Variables... struct enablePassword *enablePointer = 0; struct usernameList *usernamePointer = 0; struct privilageLevels *privilagePointer = 0; struct bannerConfig *bannerPointer = 0; char tempString[nipper->maxSize]; // Enable Password if (nipper->ios->enable != 0) { output_table(nipper, true, settings_enable_table, &report_enable_heading); enablePointer = nipper->ios->enable; while (enablePointer != 0) { fprintf(nipper->reportFile, "%s%d%s", nipper->tablerow_start, enablePointer->level, nipper->tablerow_mid); if (nipper->passwords == true) { outputFriendly(enablePointer->password, tempString, nipper->maxSize, nipper->outputFormat); fprintf(nipper->reportFile, "%s %s", tempString, nipper->tablerow_mid); } switch (enablePointer->encryption) { case encrypt_type7: fprintf(nipper->reportFile, "Type-7%s", nipper->tablerow_end); break; case encrypt_md5: fprintf(nipper->reportFile, "MD5%s", nipper->tablerow_end); addAbbreviation("MD5", false); break; case encrypt_none: fprintf(nipper->reportFile, "None%s", nipper->tablerow_end); break; case encrypt_unknown: fprintf(nipper->reportFile, "Unknown%s", nipper->tablerow_end); break; } enablePointer = enablePointer->next; } output_table(nipper, false, settings_enable_table, &report_enable_heading); } // Usernames if (nipper->ios->username != 0) { output_table(nipper, true, settings_users_table, &report_users_heading); usernamePointer = nipper->ios->username; while (usernamePointer != 0) { outputFriendly(usernamePointer->username, tempString, nipper->maxSize, nipper->outputFormat); fprintf(nipper->reportFile, "%s%s%s%d%s", nipper->tablerow_start, tempString, nipper->tablerow_mid, usernamePointer->privilage, nipper->tablerow_mid); if (nipper->passwords == true) { outputFriendly(usernamePointer->password, tempString, nipper->maxSize, nipper->outputFormat); fprintf(nipper->reportFile, "%s %s", tempString, nipper->tablerow_mid); } switch (usernamePointer->encryption) { case encrypt_type7: fprintf(nipper->reportFile, "Type-7%s", nipper->tablerow_end); break; case encrypt_md5: fprintf(nipper->reportFile, "MD5%s", nipper->tablerow_end); addAbbreviation("MD5", false); break; case encrypt_none: fprintf(nipper->reportFile, "None%s", nipper->tablerow_end); break; case encrypt_unknown: fprintf(nipper->reportFile, "Unknown%s", nipper->tablerow_end); break; } usernamePointer = usernamePointer->next; } output_table(nipper, false, settings_users_table, &report_users_heading); } // Privilage if (nipper->ios->privilage != 0) { output_parseText(settings_privs_desc, nipper, section_none, rate_none, 0, 0); output_table(nipper, true, settings_privs_table, &report_privs_heading); privilagePointer = nipper->ios->privilage; while (privilagePointer != 0) { printf("%s%d%s%s%s", nipper->tablerow_start, privilagePointer->level, nipper->tablerow_mid, privilagePointer->command, nipper->tablerow_end); privilagePointer = privilagePointer->next; } output_table(nipper, false, settings_privs_table, &report_privs_heading); } // Banner if (nipper->ios->banner != 0) { output_parseText(settings_banner_desc, nipper, section_none, rate_none, 0, 0); bannerPointer = nipper->ios->banner; switch (nipper->outputFormat) { case output_html: fprintf(nipper->reportFile, "<quote>\n"); break; case output_xml: fprintf(nipper->reportFile, " <code>"); break; } while (bannerPointer != 0) { fprintf(nipper->reportFile, "%s", bannerPointer->line); switch (nipper->outputFormat) { case output_html: fprintf(nipper->reportFile, "<br>\n"); break; default: fprintf(nipper->reportFile, "\n"); break; } bannerPointer = bannerPointer->next; } switch (nipper->outputFormat) { case output_html: fprintf(nipper->reportFile, "</quote>"); break; case output_xml: fprintf(nipper->reportFile, "</code>\n"); break; } output_newPara(nipper); } }
// Services void fw1ServiceConfig(struct nipperConfig *nipper) { // Variables... struct objectConfig *objectPointer = 0; struct objectListConfig *objectListPointer = 0; char tempString[nipper->maxSize]; output_table(nipper, true, settings_fw1services_title, &settings_fw1services_heading); objectListPointer = getObjectListPointer(nipper, "FW1-Services"); objectPointer = objectListPointer->object; while (objectPointer != 0) { if (objectPointer->type != object_type_group) { outputFriendly(objectPointer->name, tempString, nipper->maxSize, nipper->outputFormat); addAbbreviation(objectPointer->name, false); fprintf(nipper->reportFile, "%s%s%s", nipper->tablerow_start, tempString, nipper->tablerow_mid); switch (objectPointer->serviceType) { case service_protocol_tcp: addAbbreviation("TCP", false); fprintf(nipper->reportFile, "TCP"); break; case service_protocol_udp: addAbbreviation("UDP", false); fprintf(nipper->reportFile, "UDP"); break; case service_protocol_other: fprintf(nipper->reportFile, "Other"); break; case service_protocol_dcerpc: fprintf(nipper->reportFile, "DCE/RPC"); addAbbreviation("DCERPC", false); addAbbreviation("RPC", false); addAbbreviation("DCE", false); break; case service_protocol_rpc: fprintf(nipper->reportFile, "RPC"); addAbbreviation("RPC", false); break; case service_protocol_icmp: fprintf(nipper->reportFile, "ICMP"); addAbbreviation("ICMP", false); break; case service_protocol_tcpsub: fprintf(nipper->reportFile, "TCP Sub"); addAbbreviation("TCP", false); break; case service_protocol_gtp0: fprintf(nipper->reportFile, "GTP v0"); addAbbreviation("GTP", false); break; case service_protocol_gtp1: fprintf(nipper->reportFile, "GTP v1"); addAbbreviation("GTP", false); break; default: fprintf(nipper->reportFile, "Unknown"); break; } fprintf(nipper->reportFile, "%s%s%s", nipper->tablerow_mid, objectPointer->address, nipper->tablerow_mid); outputFriendly(objectPointer->comment, tempString, nipper->maxSize, nipper->outputFormat); fprintf(nipper->reportFile, "%s%s", tempString, nipper->tablerow_end); } objectPointer = objectPointer->next; } output_table(nipper, false, settings_fw1services_title, &settings_fw1services_heading); }
void nmpSNMPConfig(struct nipperConfig *nipper) { // Variables... struct snmpNMPCommunity *communityNMPPointer = 0; struct snmpNMPHost *snmpNMPHostPointer = 0; struct snmpTrap *snmpTrapPointer = 0; if (nipper->nmp->snmp->community != 0) { output_table(nipper, true, settings_snmpstring_table, &settings_snmpcomm_heading); communityNMPPointer = nipper->nmp->snmp->community; while (communityNMPPointer != 0) { if (communityNMPPointer->type == snmp_nmp_standard) fprintf(nipper->reportFile, "%sStandard%s", nipper->tablerow_start, nipper->tablerow_mid); else fprintf(nipper->reportFile, "%sExtended%s", nipper->tablerow_start, nipper->tablerow_mid); if (nipper->passwords == true) fprintf(nipper->reportFile, "%s %s", communityNMPPointer->community, nipper->tablerow_mid); switch (communityNMPPointer->access) { case snmp_nmp_readonly: fprintf(nipper->reportFile, "Read-Only%s", nipper->tablerow_end); break; case snmp_nmp_readwrite: fprintf(nipper->reportFile, "Read-Write%s", nipper->tablerow_end); break; case snmp_nmp_readwrite_all: fprintf(nipper->reportFile, "Read-Write-All%s", nipper->tablerow_end); break; } communityNMPPointer = communityNMPPointer->next; } output_table(nipper, false, settings_snmpstring_table, &settings_snmpcomm_heading); } if (nipper->nmp->snmp->trap != 0) { output_table(nipper, true, settings_snmptrap_table, &settings_snmptraps_heading); snmpTrapPointer = nipper->nmp->snmp->trap; while (snmpTrapPointer != 0) { if (snmpTrapPointer->enabled == true) fprintf(nipper->reportFile, "%sEnabled", nipper->tablerow_start); else fprintf(nipper->reportFile, "%sDisabled", nipper->tablerow_start); fprintf(nipper->reportFile, "%s%s%s", nipper->tablerow_mid, snmpTrapPointer->trap, nipper->tablerow_end); addAbbreviation(snmpTrapPointer->trap, false); snmpTrapPointer = snmpTrapPointer->next; } output_table(nipper, false, settings_snmptrap_table, &settings_snmptraps_heading); } if (nipper->nmp->snmp->host != 0) { output_table(nipper, true, settings_snmphost_table, &settings_snmphosts_heading); snmpNMPHostPointer = nipper->nmp->snmp->host; while (snmpNMPHostPointer != 0) { fprintf(nipper->reportFile, "%s%s%s", nipper->tablerow_start, snmpNMPHostPointer->host, nipper->tablerow_mid); if (nipper->passwords == true) fprintf(nipper->reportFile, "%s%s", snmpNMPHostPointer->community, nipper->tablerow_mid); fprintf(nipper->reportFile, "%d%s", snmpNMPHostPointer->version, nipper->tablerow_mid); fprintf(nipper->reportFile, "%d%s", snmpNMPHostPointer->port, nipper->tablerow_mid); fprintf(nipper->reportFile, "%s%s", snmpNMPHostPointer->owner, nipper->tablerow_mid); fprintf(nipper->reportFile, "%d%s", snmpNMPHostPointer->index, nipper->tablerow_end); snmpNMPHostPointer = snmpNMPHostPointer->next; } output_table(nipper, false, settings_snmphost_table, &settings_snmphosts_heading); } addAbbreviation("SNMP", false); }
void nmpPermitConfig(struct nipperConfig *nipper) { // Variables... struct hostNMP *hostNMPPointer = 0; char tempString[nipper->maxSize]; output_table(nipper, true, settings_permit_table, &settings_permit_heading); if (nipper->nmp->permit->telnet == true) fprintf(nipper->reportFile, "%sTelnet%sEnabled%s", nipper->tablerow_start, nipper->tablerow_mid, nipper->tablerow_end); else if (nipper->nmp->permit->telnet == false) fprintf(nipper->reportFile, "%sTelnet%sDisabled%s", nipper->tablerow_start, nipper->tablerow_mid, nipper->tablerow_end); else fprintf(nipper->reportFile, "%sTelnet%sDefault%s", nipper->tablerow_start, nipper->tablerow_mid, nipper->tablerow_end); if (nipper->nmp->permit->ssh == true) fprintf(nipper->reportFile, "%sSSH%sEnabled%s", nipper->tablerow_start, nipper->tablerow_mid, nipper->tablerow_end); else if (nipper->nmp->permit->ssh == false) fprintf(nipper->reportFile, "%sSSH%sDisabled%s", nipper->tablerow_start, nipper->tablerow_mid, nipper->tablerow_end); else fprintf(nipper->reportFile, "%sSSH%sDefault%s", nipper->tablerow_start, nipper->tablerow_mid, nipper->tablerow_end); if (nipper->nmp->permit->snmp == true) fprintf(nipper->reportFile, "%sSNMP%sEnabled%s", nipper->tablerow_start, nipper->tablerow_mid, nipper->tablerow_end); else if (nipper->nmp->permit->snmp == false) fprintf(nipper->reportFile, "%sSNMP%sDisabled%s", nipper->tablerow_start, nipper->tablerow_mid, nipper->tablerow_end); else fprintf(nipper->reportFile, "%sSNMP%sDefault%s", nipper->tablerow_start, nipper->tablerow_mid, nipper->tablerow_end); output_table(nipper, false, settings_permit_table, &settings_permit_heading); addAbbreviation("SNMP", false); addAbbreviation("SSH", false); // Telnet Permission List if (nipper->nmp->permit->telnet == true) { output_table(nipper, true, "Telnet permit list", &settings_permitlist_heading); hostNMPPointer = nipper->nmp->permit->telnetHost; while (hostNMPPointer != 0) { outputFriendly(hostNMPPointer->host, tempString, nipper->maxSize, nipper->outputFormat); fprintf(nipper->reportFile, "%s%s%s%s%s", nipper->tablerow_start, tempString, nipper->tablerow_mid, hostNMPPointer->netMask, nipper->tablerow_end); hostNMPPointer = hostNMPPointer->next; } output_table(nipper, false, "Telnet permit list", &settings_permitlist_heading); } // SSH Permission List if (nipper->nmp->permit->ssh == true) { output_table(nipper, true, "SSH permit list", &settings_permitlist_heading); hostNMPPointer = nipper->nmp->permit->sshHost; while (hostNMPPointer != 0) { outputFriendly(hostNMPPointer->host, tempString, nipper->maxSize, nipper->outputFormat); fprintf(nipper->reportFile, "%s%s%s%s%s", nipper->tablerow_start, tempString, nipper->tablerow_mid, hostNMPPointer->netMask, nipper->tablerow_end); hostNMPPointer = hostNMPPointer->next; } output_table(nipper, false, "SSH permit list", &settings_permitlist_heading); } // SNMP Permission List if (nipper->nmp->permit->snmp == true) { output_table(nipper, true, "SNMP permit list", &settings_permitlist_heading); hostNMPPointer = nipper->nmp->permit->snmpHost; while (hostNMPPointer != 0) { outputFriendly(hostNMPPointer->host, tempString, nipper->maxSize, nipper->outputFormat); fprintf(nipper->reportFile, "%s%s%s%s%s", nipper->tablerow_start, tempString, nipper->tablerow_mid, hostNMPPointer->netMask, nipper->tablerow_end); hostNMPPointer = hostNMPPointer->next; } output_table(nipper, false, "SNMP permit list", &settings_permitlist_heading); } }
void sort_and_display(int random_arr[], int sorted_arr[], int length) { std::cout << "Random array unsorted: " << std::endl; print_array(random_arr, length); std::cout << "Sorted array before sort: " << std::endl; print_array(sorted_arr, length); //copy of the input arrays to keep them intact int random_arr_copy[length]; int sorted_arr_copy[length]; //double arrays with running times double sorted_times[4]; double random_times[4]; //clock_t struct returned by the clock function for start and end times clock_t start, end; int ndx = 0; copy_array(random_arr, random_arr_copy, length); copy_array(sorted_arr, sorted_arr_copy, length); //run a sort getting elapsed time for each //print the arrays before and after and then copy the original array //back std::cout << "Unsorted" << std::endl; print_array(random_arr_copy, length); start = clock(); quick_sort(random_arr_copy, 0, length - 1); end = clock(); std::cout << "Sorted" << std::endl; print_array(random_arr_copy, length); random_times[ndx] = ((double)(end - start)) / CLOCKS_PER_SEC; std::cout << "Unsorted" << std::endl; print_array(sorted_arr_copy, length); start = clock(); quick_sort(sorted_arr_copy, 0, length - 1); end = clock(); std::cout << "Sorted" << std::endl; print_array(sorted_arr_copy, length); sorted_times[ndx++] = ((double)(end - start)) / CLOCKS_PER_SEC; copy_array(random_arr, random_arr_copy, length); copy_array(sorted_arr, sorted_arr_copy, length); //run a sort getting elapsed time for each //print the arrays before and after and then copy the original array //back std::cout << "Unsorted" << std::endl; print_array(random_arr_copy, length); start = clock(); heap_sort(random_arr_copy, length, length); end = clock(); std::cout << "Sorted" << std::endl; print_array(random_arr_copy, length); random_times[ndx] = ((double)(end - start)) / CLOCKS_PER_SEC; std::cout << "Unsorted" << std::endl; print_array(sorted_arr_copy, length); start = clock(); heap_sort(sorted_arr_copy, length, length); end = clock(); std::cout << "Sorted" << std::endl; print_array(sorted_arr_copy, length); sorted_times[ndx++] = ((double)(end - start)) / CLOCKS_PER_SEC; copy_array(random_arr, random_arr_copy, length); copy_array(sorted_arr, sorted_arr_copy, length); //run a sort getting elapsed time for each //print the arrays before and after and then copy the original array //back std::cout << "Unsorted" << std::endl; print_array(random_arr_copy, length); start = clock(); merge_sort(random_arr_copy, 0, length - 1); end = clock(); std::cout << "Sorted" << std::endl; print_array(random_arr_copy, length); random_times[ndx] = ((double)(end - start)) / CLOCKS_PER_SEC; std::cout << "Unsorted" << std::endl; print_array(sorted_arr_copy, length); start = clock(); merge_sort(sorted_arr_copy, 0, length - 1); end = clock(); std::cout << "Sorted" << std::endl; print_array(sorted_arr_copy, length); sorted_times[ndx++] = ((double)(end - start)) / CLOCKS_PER_SEC; copy_array(random_arr, random_arr_copy, length); copy_array(sorted_arr, sorted_arr_copy, length); //run insertion sort getting elapsed time for each std::cout << "Unsorted" << std::endl; print_array(random_arr_copy, length); start = clock(); insertion_sort(random_arr_copy, length); end = clock(); std::cout << "Sorted" << std::endl; print_array(random_arr_copy, length); random_times[ndx] = ((double)(end - start)) / CLOCKS_PER_SEC; std::cout << "Unsorted" << std::endl; print_array(sorted_arr_copy, length); start = clock(); insertion_sort(sorted_arr_copy, length); end = clock(); std::cout << "Sorted" << std::endl; print_array(sorted_arr_copy, length); sorted_times[ndx++] = ((double)(end - start)) / CLOCKS_PER_SEC; copy_array(random_arr, random_arr_copy, length); copy_array(sorted_arr, sorted_arr_copy, length); output_table(random_times, sorted_times); }