Changeset 1628
- Timestamp:
- 06/19/08 16:45:51 (2 months ago)
- Files:
-
- libemu/trunk/testsuite/sctest.c (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
libemu/trunk/testsuite/sctest.c
r1627 r1628 120 120 int port; 121 121 }bind; 122 123 struct 124 { 125 struct emu_hashtable *commands; 126 }commands; 127 122 128 }override; 123 129 } opts; 130 131 124 132 125 133 … … 1596 1604 } 1597 1605 1606 bool string_cmp(void *a, void *b) 1607 { 1608 if ( strcmp(a, b) ) 1609 return true; 1610 1611 return false; 1612 } 1613 1614 uint32_t string_hash(void *key) 1615 { 1616 uint32_t hash = 0; 1617 char *c = (char *)key; 1618 uint8_t num = 0x13; 1619 1620 while (*c != 0) 1621 { 1622 hash = hash << (32-num) | hash >> (num); 1623 // hash = hash >> (32-num) | hash << (num); 1624 hash += *c; 1625 c++; 1626 } 1627 1628 return hash; 1629 } 1598 1630 1599 1631 … … 1677 1709 dup2(psiStartInfo->hStdError, fileno(stderr)); 1678 1710 1679 system("/bin/sh -c \"cd ~/.wine/drive_c/; wine 'c:\\windows\\system32\\cmd_orig.exe' \""); 1711 struct emu_hashtable_item *ehi = emu_hashtable_search(opts.override.commands.commands, "cmd"); 1712 if (ehi != NULL) 1713 system((char *)ehi->value); 1714 else 1715 system("/bin/sh -c \"cd ~/.wine/drive_c/; wine 'c:\\windows\\system32\\cmd_orig.exe' \""); 1716 1680 1717 exit(EXIT_SUCCESS); 1681 1718 } … … 2472 2509 { 2473 2510 {"a", "argos-csi" , "PATH" , "use this argos csi files as input"}, 2474 {"b", "bind" , "IP:PORT" , "bind this ip:port"}, 2475 {"c", "connect" , "IP:PORT" , "redirect connects to this ip:port"}, 2511 {"b", "bind" , "IP:PORT" , "bind this ip:port"}, 2512 {"c", "connect" , "IP:PORT" , "redirect connects to this ip:port"}, 2513 {"C", "cmd" , "CMD" , "command to execute for \"cmd\" in shellcode (default: cmd=\"/bin/sh -c \\\"cd ~/.wine/drive_c/; wine 'c:\\windows\\system32\\cmd_orig.exe' \\\"\")"}, 2476 2514 {"d", "dump" , "INTEGER" , "dump the shellcode (binary) to stdout"}, 2477 2515 {"g", "getpc" , NULL , "run getpc mode, try to detect a shellcode"}, … … 2481 2519 {"l", "listtests" , NULL , "list all tests"}, 2482 2520 {"o", "offset" , "[INT|HEX]", "manual offset for shellcode, accepts int and hexvalues"}, 2483 {"p", "profile" , "PATH", "write shellcode profile to this file"},2521 {"p", "profile" , "PATH" , "write shellcode profile to this file"}, 2484 2522 {"S", "stdin" , NULL , "read shellcode/buffer from stdin, works with -g"}, 2485 2523 {"s", "steps" , "INTEGER" , "max number of steps to run"}, … … 2753 2791 opts.offset = 0; 2754 2792 2793 opts.override.commands.commands = emu_hashtable_new(16, string_hash, string_cmp); 2794 2755 2795 while ( 1 ) 2756 2796 { … … 2759 2799 static struct option long_options[] = { 2760 2800 {"argos-csi" , 1, 0, 'a'}, 2761 {"bind" , 1, 0, 'b'}, 2762 {"connect" , 1, 0, 'c'}, 2801 {"bind" , 1, 0, 'b'}, 2802 {"connect" , 1, 0, 'c'}, 2803 {"cmd" , 1, 0, 'C'}, 2763 2804 {"dump" , 1, 0, 'd'}, 2764 2805 {"getpc" , 0, 0, 'g'}, 2765 2806 {"graph" , 1, 0, 'G'}, 2766 2807 {"help" , 0, 0, 'h'}, 2767 {"interactive" , 1, 0, 'i'},2808 {"interactive" , 0, 0, 'i'}, 2768 2809 {"listtests" , 0, 0, 'l'}, 2769 2810 {"offset" , 1, 0, 'o'}, 2770 2811 {"profile" , 1, 0, 'p'}, 2812 {"steps" , 1, 0, 's'}, 2771 2813 {"stdin" , 0, 0, 'S'}, 2772 {"steps" , 1, 0, 's'},2773 2814 {"testnumber" , 1, 0, 't'}, 2774 2815 {"verbose" , 0, 0, 'v'}, … … 2776 2817 }; 2777 2818 2778 c = getopt_long (argc, argv, "a:b:c: d:gG:hilo:p:s:St:v", long_options, &option_index);2819 c = getopt_long (argc, argv, "a:b:c:C:d:gG:hilo:p:s:St:v", long_options, &option_index); 2779 2820 if ( c == -1 ) 2780 2821 break; … … 2818 2859 break; 2819 2860 2861 case 'C': 2862 { 2863 char *cmd = strdup(optarg); 2864 2865 char *value = strstr(cmd, "="); 2866 *value = '\0'; 2867 value++; 2868 printf("command for %s is %s\n", cmd, value ); 2869 emu_hashtable_insert(opts.override.commands.commands, cmd, value); 2870 } 2871 break; 2872 2820 2873 case 'd': 2821 2874 dump(atoi(optarg));
