Exemplo n.º 1
0
int main(){
	printf("\n*********************************************************\n\n");
	printf("                      Card Test 2\n\n");
	printf("*********************************************************\n");
	
//	Test Initialization
	int i, temp1, temp2, temp3, temp4;
	srand (time(NULL));
	struct gameState game;
	int cards[10] = {estate, duchy, adventurer, embargo, sea_hag, feast, gardens, mine, tribute, outpost}; 
	int playerNum = 4;
	
// Random settings
	int ramdomSeed = rand() % 99999 + 1;	
	int bonus = rand() % 10;
	int handNum = rand() % MAX_HAND;

	check_functions(initializeGame(playerNum, cards, ramdomSeed, &game));
	int theplayer = whoseTurn(&game);

	temp1 = game.handCount[theplayer];
	temp3 = game.deckCount[theplayer];

	check_functions(cardEffect(adventurer, 0, 0, 0, &game, 0, 0));
	temp2 = game.handCount[theplayer];
	temp4 = game.deckCount[theplayer];

	check_equal(temp1, temp2);
	check_equal(temp3, temp4);

	printf("Card 'adventurer': TEST SUCCESSFULLY COMPLETED\n\n");
	return 0;
}
Exemplo n.º 2
0
int main(void) {
  vars = hashtbl_init(free, NULL, 0);
  /*fprintf(stderr, "%.15Lg\n", evaluate(argv[1]));*/
  check_operators();
  check_functions();
  check_precedence();
  check_longer();
  hashtbl_destroy(vars);
  return 0;
}
Exemplo n.º 3
0
int
main (void)
{
  memcpy (&initial_cpuvec, &__gmpn_cpuvec, sizeof (__gmpn_cpuvec));

  tests_start ();

  check_functions ();
  check_thresholds ();

  tests_end ();
  exit (0);
}
Exemplo n.º 4
0
	pResult analyze(const mana::PE& pe) override
	{
		pResult res = create_result();
		check_functions(pe, dynamic_import, NO_OPINION, "[!] The program may be hiding some of its imports", AT_LEAST_TWO, res);
		check_functions(pe, anti_debug, SUSPICIOUS, "Functions which can be used for anti-debugging purposes", AT_LEAST_ONE, res);
		check_functions(pe, vanilla_injection, MALICIOUS, "Code injection capabilities", AT_LEAST_THREE, res);
		check_functions(pe, "", NO_OPINION, "Can access the registry", AT_LEAST_ONE, res);
		check_functions(pe, process_creation_api, NO_OPINION, "Possibly launches other programs", AT_LEAST_ONE, res);
		check_functions(pe, "(Nt|Zw)(.*)", SUSPICIOUS, "Uses Windows' Native API", AT_LEAST_TWO, res);
		check_functions(pe, "Crypt(.*)", NO_OPINION, "Uses Microsoft's cryptographic API", AT_LEAST_ONE, res);
		check_functions(pe, temporary_files, NO_OPINION, "Can create temporary files", AT_LEAST_TWO, res);
		check_functions(pe, "Wlx(.*)", MALICIOUS, "Possibly attempts GINA replacement", AT_LEAST_THREE, res);
		check_functions(pe, keylogger_api, MALICIOUS, "Uses functions commonly found in keyloggers", AT_LEAST_TWO, res);
		check_functions(pe, packer_api, SUSPICIOUS, "Memory manipulation functions often used by packers", AT_LEAST_TWO, res);
		check_functions(pe, raw_socket_api, SUSPICIOUS, "Leverages the raw socket API to access the Internet", AT_LEAST_ONE, res);
		check_functions(pe, wininet_api, NO_OPINION, "Has Internet access capabilities", AT_LEAST_ONE, res);
		check_functions(pe, privilege_api, MALICIOUS, "Functions related to the privilege level", AT_LEAST_ONE, res);
		check_functions(pe, service_manipulation_api, SUSPICIOUS, "Interacts with services", AT_LEAST_ONE, res);
		check_functions(pe, hdd_enumeration, NO_OPINION, "Enumerates local disk drives", AT_LEAST_ONE, res);
		check_functions(pe, driver_enumeration, SUSPICIOUS, "Enumerates drivers present on the system", AT_LEAST_ONE, res);
		check_functions(pe, process_manipulation_api, SUSPICIOUS, "Manipulates other processes", AT_LEAST_ONE, res);
		check_functions(pe, eventlog_deletion, MALICIOUS, "Deletes entries from the event log", AT_LEAST_ONE, res);
		check_functions(pe, dacl_api, SUSPICIOUS, "Changes object ACLs", AT_LEAST_ONE, res);
		check_functions(pe, screenshot_api, SUSPICIOUS, "Can take screenshots", AT_LEAST_TWO, res);
		check_functions(pe, audio_api, SUSPICIOUS, "Can use the microphone to record audio.", AT_LEAST_ONE, res);
		check_functions(pe, networking_api, SUSPICIOUS, "Modifies the network configuration", AT_LEAST_ONE, res);
		check_functions(pe, "GetClipboardData", NO_OPINION, "Reads the contents of the clipboard", AT_LEAST_ONE, res);
		check_functions(pe, "IsUserAnAdmin", NO_OPINION, "Checks if it has admin rights", AT_LEAST_ONE, res);
		check_functions(pe, "Cert(Add|Open|Register|Remove|Save|Srv|Store)(.*)", SUSPICIOUS, "Interacts with the certificate store", AT_LEAST_ONE, res);
		check_functions(pe, shutdown_functions, NO_OPINION, "Can shut the system down or lock the screen", AT_LEAST_ONE, res);

		switch (res->get_level())
		{
			case NO_OPINION:
				if (res->get_information() && res->get_information()->size() > 0) {
					res->set_summary("The PE contains common functions which appear in legitimate applications.");
				}
				break;
			case SUSPICIOUS:
				res->set_summary("The PE contains functions most legitimate programs don't use.");
				break;
			case MALICIOUS:
				res->set_summary("The PE contains functions mostly used by malwares.");
				break;
			default:
				break;
		}

		return res;
	}
Exemplo n.º 5
0
int main(int argc, char **argv)
{
    unsigned long i = 0;
    unsigned long seq_count = 0;
    unsigned long limit = 0;
    char **sequences = NULL;
    unsigned long *sizes = NULL;
    char *endptr = NULL;
    char *filename = NULL;
    int c = 0;
    int test_scores = 1;
    int test_stats = 0;
    char *matrixname = NULL;
    const parasail_matrix_t *matrix = NULL;
    gap_score_t gap = {INT_MIN,INT_MIN};
    int do_sse2 = 1;
    int do_sse41 = 1;
    int do_avx2 = 1;
    int do_disp = 1;
    int do_nw = 1;
    int do_sg = 1;
    int do_sw = 1;

    while ((c = getopt(argc, argv, "f:m:n:o:e:vsSi:")) != -1) {
        switch (c) {
            case 'f':
                filename = optarg;
                break;
            case 'm':
                matrixname = optarg;
                break;
            case 'n':
                errno = 0;
                seq_count = strtol(optarg, &endptr, 10);
                if (errno) {
                    perror("strtol");
                    exit(1);
                }
                break;
            case 'o':
                errno = 0;
                gap.open = strtol(optarg, &endptr, 10);
                if (errno) {
                    perror("strtol gap.open");
                    exit(1);
                }
                break;
            case 'e':
                errno = 0;
                gap.extend = strtol(optarg, &endptr, 10);
                if (errno) {
                    perror("strtol gap.extend");
                    exit(1);
                }
                break;
            case 'v':
                verbose = 1;
                break;
            case 's':
                test_stats = 1;
                break;
            case 'S':
                test_scores = 0;
                break;
            case 'i':
                do_sse2 = (NULL == strstr(optarg, "sse2"));
                do_sse41 = (NULL == strstr(optarg, "sse41"));
                do_avx2 = (NULL == strstr(optarg, "avx2"));
                do_disp = (NULL == strstr(optarg, "disp"));
                do_nw = (NULL == strstr(optarg, "nw"));
                do_sg = (NULL == strstr(optarg, "sg"));
                do_sw = (NULL == strstr(optarg, "sw"));
                break;
            case '?':
                if (optopt == 'f' || optopt == 'n') {
                    fprintf(stderr,
                            "Option -%c requires an argument.\n",
                            optopt);
                }
                else if (isprint(optopt)) {
                    fprintf(stderr, "Unknown option `-%c'.\n",
                            optopt);
                }
                else {
                    fprintf(stderr,
                            "Unknown option character `\\x%x'.\n",
                            optopt);
                }
                exit(1);
            default:
                fprintf(stderr, "default case in getopt\n");
                exit(1);
        }
    }

    if (filename) {
        parse_sequences(filename, &sequences, &sizes, &seq_count);
    }
    else {
        fprintf(stderr, "no filename specified\n");
        exit(1);
    }

    /* select the matrix */
    if (matrixname) {
        matrix = parasail_matrix_lookup(matrixname);
        if (NULL == matrix) {
            fprintf(stderr, "Specified substitution matrix not found.\n");
            exit(1);
        }
    }

    limit = binomial_coefficient(seq_count, 2);
    printf("%lu choose 2 is %lu\n", seq_count, limit);


#if HAVE_SSE2
    if (do_sse2 && parasail_can_use_sse2()) {
        if (test_scores) {
            if (do_nw) check_functions(parasail_nw_sse2, sequences, sizes, limit, matrix, gap);
            if (do_sg) check_functions(parasail_sg_sse2, sequences, sizes, limit, matrix, gap);
            if (do_sw) check_functions(parasail_sw_sse2, sequences, sizes, limit, matrix, gap);
        }
        if (test_stats) {
            if (do_nw) check_functions(parasail_nw_stats_sse2, sequences, sizes, limit, matrix, gap);
            if (do_sg) check_functions(parasail_sg_stats_sse2, sequences, sizes, limit, matrix, gap);
            if (do_sw) check_functions(parasail_sw_stats_sse2, sequences, sizes, limit, matrix, gap);
        }
    }
#endif

#if HAVE_SSE41
    if (do_sse41 && parasail_can_use_sse41()) {
        if (test_scores) {
            if (do_nw) check_functions(parasail_nw_sse41, sequences, sizes, limit, matrix, gap);
            if (do_sg) check_functions(parasail_sg_sse41, sequences, sizes, limit, matrix, gap);
            if (do_sw) check_functions(parasail_sw_sse41, sequences, sizes, limit, matrix, gap);
        }
        if (test_stats) {
            if (do_nw) check_functions(parasail_nw_stats_sse41, sequences, sizes, limit, matrix, gap);
            if (do_sg) check_functions(parasail_sg_stats_sse41, sequences, sizes, limit, matrix, gap);
            if (do_sw) check_functions(parasail_sw_stats_sse41, sequences, sizes, limit, matrix, gap);
        }
    }
#endif

#if HAVE_AVX2
    if (do_avx2 && parasail_can_use_avx2()) {
        if (test_scores) {
            if (do_nw) check_functions(parasail_nw_avx2, sequences, sizes, limit, matrix, gap);
            if (do_sg) check_functions(parasail_sg_avx2, sequences, sizes, limit, matrix, gap);
            if (do_sw) check_functions(parasail_sw_avx2, sequences, sizes, limit, matrix, gap);
        }
        if (test_stats) {
            if (do_nw) check_functions(parasail_nw_stats_avx2, sequences, sizes, limit, matrix, gap);
            if (do_sg) check_functions(parasail_sg_stats_avx2, sequences, sizes, limit, matrix, gap);
            if (do_sw) check_functions(parasail_sw_stats_avx2, sequences, sizes, limit, matrix, gap);
        }
    }
#endif

#if HAVE_KNC
    {
        if (test_scores) {
            if (do_nw) check_functions(parasail_nw_knc, sequences, sizes, limit, matrix, gap);
            if (do_sg) check_functions(parasail_sg_knc, sequences, sizes, limit, matrix, gap);
            if (do_sw) check_functions(parasail_sw_knc, sequences, sizes, limit, matrix, gap);
        }
        if (test_stats) {
            if (do_nw) check_functions(parasail_nw_stats_knc, sequences, sizes, limit, matrix, gap);
            if (do_sg) check_functions(parasail_sg_stats_knc, sequences, sizes, limit, matrix, gap);
            if (do_sw) check_functions(parasail_sw_stats_knc, sequences, sizes, limit, matrix, gap);
        }
    }
#endif

    if (do_disp) {
        if (test_scores) {
            if (do_nw) check_functions(parasail_nw_disp, sequences, sizes, limit, matrix, gap);
            if (do_sg) check_functions(parasail_sg_disp, sequences, sizes, limit, matrix, gap);
            if (do_sw) check_functions(parasail_sw_disp, sequences, sizes, limit, matrix, gap);
        }
        if (test_stats) {
            if (do_nw) check_functions(parasail_nw_stats_disp, sequences, sizes, limit, matrix, gap);
            if (do_sg) check_functions(parasail_sg_stats_disp, sequences, sizes, limit, matrix, gap);
            if (do_sw) check_functions(parasail_sw_stats_disp, sequences, sizes, limit, matrix, gap);
        }
    }

    for (i=0; i<seq_count; ++i) {
        free(sequences[i]);
    }
    free(sequences);
    free(sizes);

    return 0;
}