Exemple #1
0
//Autor: Kevin
// Shows a menu where the user has an option to view the special print menu, view statistics, view hash table efficiency, or return
void miscMenu()
{
    bool isGood = false;
    while (!isGood)
    {
        clearScreen();
        cout << "******************** Misc *******************" << endl << endl;
        cout << "1. Special print cars" << endl;
        cout << "2. View statistics" << endl;
        cout << "3. Test hash table efficiency" << endl;
        cout << "0. Back" << endl << endl;
        cout << "What is your option? ";

        int choice = getUserInputAsInt(0, 3);

        switch (choice)
        {
            case 0:
                isGood = true;
                break;
            case 1:
                specialPrintMenu();
                break;
            case 2:
                statsMenu();
                break;
            case 3:
                testHashEfficiency();
                break;
        }
    }
}
Exemple #2
0
//Print Main Menu
char mainMenu()
{
    char selectmenu;
    printf("\n");
    printf("%60s","################## M E N U ####################\n");
    printf("%60s","# ########################################### #\n");
    printf("%60s","# #                                         # #\n");
    printf("%60s","# #  1 -> Capture to TXT                    # #\n");
    printf("%60s","# #  2 -> Capture to CSV - Excel            # #\n");
    printf("%60s","# #  3 -> Visualize TXT file                # #\n");
    printf("%60s","# #  4 -> Statistics (CSV files)            # #\n");
    printf("%60s","# #  5 -> Exit                              # #\n");
    printf("%60s","# #                                         # #\n");
    printf("%60s","# ########################################### #\n");
    printf("%60s","###############################################\n");
    printf("\nOption: ");

    if(optionSave=='m') {
        scanf("%c", &selectmenu);
    }

    switch (selectmenu)
    {
    case '1':
        optionSave = selectmenu;
        system("clear");
        startCapture(selectmenu);
        fclose(logfile);
        break;
    case '2':
        optionSave = selectmenu;
        system("clear");
        startCapture(selectmenu);
        fclose(logfilecsv);
        break;
    case '3':
        optionSave = selectmenu;
        system("clear");
        catFile();
        break;
    case '4':
        optionSave = selectmenu;
        system("clear");
        statsMenu();
        break;
    case '5':
        printf("Thanks for using this amazing sniffer, bye!!!!\n");
        optionSave = selectmenu;
        exit(0);
        break;
    default:
        system("clear");
        printf(" Invalid option - please select options 1-4!!! \n ");
        main();
        break;
    }

}
Exemple #3
0
//aux to call stats functions
void statistics(char stat)
{
    if(stopApp==1)main();
    char tmp[1024]= {0x0};
    int fldcnt=0;
    char arr[MAXFLDS][MAXFLDSIZE]= {0x0};
    int recordcnt=0;

    if(stat=='a') strcpy(filename,"");

    if (!strcmp(filename,""))
    {
        printf("Enter key [d] to assume defaults [logcsv.csv],\n");
        printf("or insert the name of the CSV file [file.csv]: ");
        scanf("%s", filename);
    }
    if (!strcmp(filename,"d"))
        strcpy(filename,"logcsv.csv");

    in = fopen(filename,"r");/* open file on command line */

    if(checkFileIn()==-1)
    {
        optionSaveStats='3';
        printf("Error loading file...[%s]\n\n", filename);
        statistics('a');
    }
    if(checkFileIn()==0)
    {
        if(stat=='a')printf("Loading file...[%s]\n\n", filename);
        fgets(tmp,sizeof(tmp),in); /*jump over header*/
        while(fgets(tmp,sizeof(tmp),in)!=0) /* read a record */
        {
            i=0;
            j=0;
            recordcnt++;
            parse(tmp,",",arr,&fldcnt);    /* whack record into fields */
            for(i; i<fldcnt; i++)
            {
                //copy all records to strs
                strcpy(strs[recordcnt-1][i],arr[i]);
            }

        }
        if(stat=='a')printf("Done!!!\n", filename);
        if(stat=='a')PressEnterToReturn();
    }

    if (stat=='b') {
        system("clear");
        print_all_macip(recordcnt, 2,"Source devices:\n"); //list of all source devices - print mac and ip
        PressEnterToReturn();
        fclose(in);
        optionSaveStats='3';
        system("clear");
        statsMenu();
    }
    if (stat=='c') {
        system("clear");
        print_all(recordcnt, 8, "Source ports:\n"); //list of all source ports
        PressEnterToReturn();
        fclose(in);
        optionSaveStats='3';
        system("clear");
        statsMenu();
    }
    if (stat=='d') {
        system("clear");
        print_all_macip(recordcnt, 3,"\nDestination devices:\n"); //list of all destination devices - print mac and ip
        PressEnterToReturn();
        fclose(in);
        optionSaveStats='3';
        system("clear");
        statsMenu();
    }
    if (stat=='e') {
        system("clear");
        print_all(recordcnt, 9, "Destination ports:\n"); //list of all destination ports
        PressEnterToReturn();
        fclose(in);
        optionSaveStats='3';
        system("clear");
        statsMenu();
    }
    if (stat=='f') {
        system("clear");
        rep_count(recordcnt, 12, "0", "\nNº of Queries: "); //count number of queries, verifying the flag response=o
        PressEnterToReturn();
        fclose(in);
        optionSaveStats='3';
        system("clear");
        statsMenu();
    }
    if (stat=='g') {
        system("clear");
        rep_count(recordcnt, 12, "1", "\nNº of Responses: "); //count number of responses, verifying the flag response=1
        PressEnterToReturn();
        fclose(in);
        optionSaveStats='3';
        system("clear");
        statsMenu();
    }
    if (stat=='h') {
        system("clear");
        rep_count(recordcnt, 13, "3", "\nNº of Rcodes: "); //count number of Rcodes errors
        PressEnterToReturn();
        fclose(in);
        optionSaveStats='3';
        system("clear");
        statsMenu();
    }
    if (stat=='i') {
        system("clear");
        check_times(recordcnt, 10); //verify delay between question and answer
        PressEnterToReturn();
        fclose(in);
        optionSaveStats='3';
        system("clear");
        statsMenu();
    }
    if (stat=='j') {
        system("clear");
        print_all_stats(recordcnt, 2, "\nMAC source:"); //stats MAC Source
        PressEnterToReturn();
        fclose(in);
        optionSaveStats='3';
        system("clear");
        statsMenu();
    }
    if (stat=='k') {
        system("clear");
        print_all_stats(recordcnt, 3, "\nMAC destination:");//stats MAC destination
        PressEnterToReturn();
        fclose(in);
        optionSaveStats='3';
        system("clear");
        statsMenu();
    }
    if (stat=='l') {
        system("clear");
        print_all_stats(recordcnt, 18, "\nNames:");//stats Name
        PressEnterToReturn();
        fclose(in);
        optionSaveStats='3';
        system("clear");
        statsMenu();
    }
    if (stat=='m') {
        system("clear");
        string keyword;
        printf("Insert the keyword to search in all queries: ");
        scanf("%s", keyword);
        count_occurrences(recordcnt, 18, "\nThe selected keyword:", keyword);
        PressEnterToReturn();
        fclose(in);
        optionSaveStats='3';
        system("clear");
        statsMenu();
    }
    if (stat=='n') {
        system("clear");
        check_blacklisted(recordcnt, 21, "\nCheck queries responses:\n");//Check queries responses
        PressEnterToReturn();
        fclose(in);
        optionSaveStats='3';
        system("clear");
        statsMenu();
    }

    statsMenu();
}
Exemple #4
0
//Print Stats Menu
char statsMenu()
{
    system("clear");
    char select;
    printf("\n");
    printf("%60s","######## S T A T I S T I C S  M E N U #########\n");
    printf("%60s","# ################## D N S ################## #\n");
    printf("%60s","# #                                         # #\n");
    printf("%60s","# #  a -> Load file [csv]                   # #\n");
    printf("%60s","# #  b -> Source devices                    # #\n");
    printf("%60s","# #  c -> Source ports                      # #\n");
    printf("%60s","# #  d -> Destination devices               # #\n");
    printf("%60s","# #  e -> Destination ports                 # #\n");
    printf("%60s","# #  f -> Number of queries                 # #\n");
    printf("%60s","# #  g -> Number of responses               # #\n");
    printf("%60s","# #  h -> Number of Rcodes                  # #\n");
    printf("%60s","# #  i -> Delay between questions/answers   # #\n");
    printf("%60s","# #  j -> Frequencies for MAC source        # #\n");
    printf("%60s","# #  k -> Frequencies for MAC destination   # #\n");
    printf("%60s","# #  l -> Frequencies for Names             # #\n");
    printf("%60s","# #  m -> Search keywords occurencies       # #\n");
    printf("%60s","# #  n -> Check answers in blacklist        # #\n");
    printf("%60s","# #                                         # #\n");
    printf("%60s","# #  q -> RETURN TO MAIN MENU               # #\n");
    printf("%60s","# #                                         # #\n");
    printf("%60s","# ########################################### #\n");
    printf("%60s","###############################################\n");
    printf("Option: ");

    scanf("%1s", &select);

    switch (select)
    {
    case 'a':
        system("clear");
        statistics(select);
        optionSaveStats=='3';
        statsMenu();
        break;
    case 'b':
        system("clear");
        statistics(select);
        optionSaveStats=='3';
        statsMenu();
        break;
    case 'c':
        system("clear");
        statistics(select);
        optionSaveStats=='3';
        statsMenu();
        break;
    case 'd':
        system("clear");
        statistics(select);
        optionSaveStats=='3';
        statsMenu();
        break;
    case 'e':
        system("clear");
        statistics(select);
        optionSaveStats=='3';
        statsMenu();
        break;
    case 'f':
        system("clear");
        statistics(select);
        optionSaveStats=='3';
        statsMenu();
        break;
    case 'g':
        system("clear");
        statistics(select);
        optionSaveStats=='3';
        statsMenu();
        break;
    case 'h':
        system("clear");
        statistics(select);
        optionSaveStats=='3';
        statsMenu();
        break;
    case 'i':
        system("clear");
        statistics(select);
        optionSaveStats=='3';
        statsMenu();
        break;
    case 'j':
        system("clear");
        statistics(select);
        optionSaveStats=='3';
        statsMenu();
        break;
    case 'k':
        system("clear");
        statistics(select);
        optionSaveStats=='3';
        statsMenu();
        break;
    case 'l':
        system("clear");
        statistics(select);
        optionSaveStats=='3';
        statsMenu();
        break;
    case 'm':
        system("clear");
        statistics(select);
        optionSaveStats=='3';
        statsMenu();
        break;
    case 'n':
        system("clear");
        statistics(select);
        optionSaveStats=='3';
        statsMenu();
        break;
    case 'q':
        optionSave = 'm';
        optionSaveStats='3';
        system("clear");
        mainMenu();
        break;
    default:
        system("clear");
        printf(" Invalid option - please select options [a-n] or [q] to return!!! \n ");
        sleep(1);
        optionSaveStats='3';
        statsMenu();
        break;
    }
}