예제 #1
0
파일: bug1163046.c 프로젝트: dreamsxin/re2c
int main(int,void**)
{
	int res, result = 0;
	do_scan("(This file must be converted with BinHex 4.0)", 1);
	do_scan("x(This file must be converted with BinHex 4.0)", 0);
	do_scan("(This file must be converted with BinHex 4.0)x", 1);
	do_scan("x(This file must be converted with BinHex 4.0)x", 0);
	
	return result;
}
예제 #2
0
static void
ns_interfacemgr_scan0(ns_interfacemgr_t *mgr, ns_listenlist_t *ext_listen,
		      isc_boolean_t verbose)
{
	isc_boolean_t purge = ISC_TRUE;

	REQUIRE(NS_INTERFACEMGR_VALID(mgr));

	mgr->generation++;	/* Increment the generation count. */

	if (do_scan(mgr, ext_listen, verbose) != ISC_R_SUCCESS)
		purge = ISC_FALSE;

	/*
	 * Now go through the interface list and delete anything that
	 * does not have the current generation number.  This is
	 * how we catch interfaces that go away or change their
	 * addresses.
	 */
	if (purge)
		purge_old_interfaces(mgr);

	/*
	 * Warn if we are not listening on any interface, unless
	 * we're in lwresd-only mode, in which case that is to
	 * be expected.
	 */
	if (ext_listen == NULL &&
	    ISC_LIST_EMPTY(mgr->interfaces) && ! ns_g_lwresdonly) {
		isc_log_write(IFMGR_COMMON_LOGARGS, ISC_LOG_WARNING,
			      "not listening on any interfaces");
	}
}
예제 #3
0
/*
 * This routine implements the 'verify' command.  It writes the disk
 * by writing unique data for each block; after the write pass, it
 * reads the data and verifies for correctness. Note that the entire
 * disk (or the range of disk) is fully written first and then read.
 * This should eliminate any caching effect on the drives.
 * It is not ok to run this command on any data you want to keep.
 */
int
a_verify()
{
	/*
	 * The current disk must be formatted before disk analysis.
	 */
	if (!(cur_flags & DISK_FORMATTED)) {
		err_print("Current Disk is unformatted.\n");
		return (-1);
	}
	if (scan_random) {
		fmt_print("The verify command does not write random data\n");
		scan_random = 0;
	}
	if (scan_passes < 2 && !scan_loop) {
		scan_passes = 2;
		fmt_print("The verify command runs minimum of 2 passes, one"
		    " for writing and \nanother for reading and verfying."
		    " Resetting the number of passes to 2.\n");
	}

	if (check("Ready to verify (will corrupt data). This takes a long time,"
	    "\nbut is interruptable with CTRL-C. Continue")) {
		return (-1);
	}

	return (do_scan(SCAN_WRITE | SCAN_VERIFY, F_NORMAL));
}
예제 #4
0
void spell_farsight( int sn, int level, Character *ch, void *vo,int target)
{
    if (IS_AFFECTED(ch,AFF_BLIND))
    {
        send_to_char("Maybe it would help if you could see?\n\r",ch);
        return;
    }
 
    do_scan(ch,target_name);
}
예제 #5
0
파일: bug1390174.c 프로젝트: pjump/re2c
main()
{
	do_scan(1, "a\n");
	do_scan(1, "aa\n");
	do_scan(1, "aaa\n");
	do_scan(1, "aaaa\n");
	do_scan(1, "\n");

	do_scan(0, "q");
	do_scan(0, "a");
}
예제 #6
0
//线程函数,扫描指定ip的指定端口区间
void *scanner(void *arg){
	port_info pi;
	struct sockaddr_in des_addr;
	unsigned short int i;

	memcpy(&pi,arg,sizeof(pi));
	des_addr.sin_family = AF_INET;
	des_addr.sin_addr.s_addr = pi.dest_ip.s_addr;
	for(i=pi.begin_port;i<=pi.end_port;++i){
		//printf("%d\n",i);	
		des_addr.sin_port = htons(i);
		do_scan(&des_addr);
	}
	return NULL;
}
예제 #7
0
/*
 * This routine implements the 'test' command.  It performs surface
 * analysis by reading the disk, writing then reading a pattern on the disk,
 * then writing the original data back to the disk.
 * It is ok to run this command on file systems, but not while they are
 * mounted.
 */
int
a_test()
{
	/*
	 * The current disk must be formatted before disk analysis.
	 */
	if (!(cur_flags & DISK_FORMATTED)) {
		err_print("Current Disk is unformatted.\n");
		return (-1);
	}

	if (check(
"Ready to analyze (won't harm data). This takes a long time, \n"
"but is interruptable with CTRL-C. Continue"))
		return (-1);
	return (do_scan(SCAN_VALID | SCAN_PATTERN | SCAN_WRITE, F_NORMAL));
}
예제 #8
0
///-------------------------------------------------------------------------------------------------
///  Begin a recursive scan of all paths previously provided to ms_add_path(). If async mode
///   is enabled, this call will return immediately. You must obtain the file descriptor using
///   ms_async_fd and this must be checked using an event loop or select(). When the fd becomes
///   readable you must call ms_async_process to trigger any necessary callbacks.
///
/// @author Andy Grundman
/// @date 03/15/2011
///
/// @param [in,out] s If non-null, the.
///
/// ### remarks .
///-------------------------------------------------------------------------------------------------
void ms_scan(MediaScan *s) {

  if (s->on_result == NULL) {
    LOG_ERROR("Result callback not set, aborting scan\n");
    goto out;
  }

  if (s->npaths == 0) {
    LOG_ERROR("No paths set, aborting scan\n");
    goto out;
  }

  if (s->async) {
    thread_data_type *thread_data;

    thread_data = (thread_data_type *)calloc(sizeof(thread_data_type), 1);
    LOG_MEM("new thread_data @ %p\n", thread_data);

    thread_data->lpDir = NULL;
    thread_data->s = s;

    s->thread = thread_create(do_scan, thread_data, s->async_fds);
    if (!s->thread) {
      LOG_ERROR("Unable to start async thread\n");
      goto out;
    }
  }
  else {
    thread_data_type thread_data;
    thread_data.s = s;
    thread_data.lpDir = NULL;
    do_scan(&thread_data);
  }

out:
  return;
}                               /* ms_scan() */
예제 #9
0
/*
 * This routine implements the 'purge' command.  It purges the disk
 * by writing three patterns to the disk then reading the last one back.
 * It is not ok to run this command on any data you want to keep.
 */
int
a_purge()
{
	int status = 0;

	/*
	 * The current disk must be formatted before disk analysis.
	 */
	if (!(cur_flags & DISK_FORMATTED)) {
		err_print("Current Disk is unformatted.\n");
		return (-1);
	}
	if (scan_random) {
		fmt_print("The purge command does not write random data\n");
		scan_random = 0;
	}

	if (!scan_loop && (scan_passes <= NPPATTERNS)) {
		if (scan_passes < NPPATTERNS) {
			fmt_print("The purge command runs for a minimum of ");
			fmt_print("%d passes plus a last pass if the\n",
						NPPATTERNS);
			fmt_print("first %d passes were successful.\n",
					NPPATTERNS);
		}
		scan_passes = NPPATTERNS + 1;
	}

	if (check(
"Ready to purge (will corrupt data). This takes a long time, \n"
"but is interruptable with CTRL-C. Continue"))
		return (-1);

	status = do_scan(SCAN_PATTERN | SCAN_PURGE, F_NORMAL);

	return (status);
}
예제 #10
0
void sdif_fileinfo_scan(t_sdif_fileinfo *x, t_symbol *s)  {	
	SDIFresult r;
	FILE *f;
	char *filename = s->s_name;
	
	
	x->x_ns = 0; // zero streams until a file is read
	x->x_filenameSymbol = s;
		
	f = OpenSDIFFile(filename);
	if (f == NULL) {
		object_error((t_object *)x, NAME ": Couldn't read SDIF file %s", filename);
		return;
	} 
		
	do_scan(x, f, filename);
	
	if ((r = SDIF_CloseRead(f))) {
		object_post((t_object *)x, NAME ": error closing SDIF file %s:", filename);
		object_post((t_object *)x, "%s", SDIF_GetErrorString(r));
	}
	
	SDIFfileinfo_output(x);
}
예제 #11
0
void parse_opts(int argc, char** argv){
  int longIndex;
  int mode=MODE_ATTACK;
  int i;
  unsigned int f;
  int t=0;
  int recent=0;
  int code=0;
  int query_all=0;
  char *post_key=NULL;
  char *url=NULL;
  char *mime=NULL;
  char *trigger=NULL;
  char *feature=NULL;
  char *description="";
  char *upload_file=NULL;
  unsigned int flags=0;
  struct option long_options[] = {        /* long options array. Items are all caSe SensiTivE! */
    { "add-url", no_argument, &mode, MODE_ADD_URL   }, 
    { "add-trigger", no_argument, &mode, MODE_ADD_TRIGGER},
    { "brute-backup", required_argument, NULL, MODE_BRUTE_BACKUP},
    { "brute-backup-days", required_argument, NULL, BRUTE_BACKUP_DAYS},
    { "brute-backup-pattern", required_argument, NULL, BRUTE_BACKUP_PATTERN},
    { "brute-backup-no-stop", no_argument, &backup_bruteforce_stop, 0},
    { "brute-backup-no-slash", no_argument, &backup_bruteforce_slash, 0},
    { "store-successes", no_argument, NULL, 'S'},
    { "query", no_argument, &mode, MODE_QUERY}, 
    { "all", no_argument, &query_all, 1}, 
    { "code", required_argument, NULL, CODE}, 
    { "post-key", required_argument, NULL, POST_KEY}, 
    { "mime-type", required_argument, NULL, MIME}, 
    { "recent", required_argument, NULL, RECENT}, 
    { "no-async-resolve", no_argument, &async_dns, 0}, 
    { "trigger", required_argument,NULL, TRIGGER},
    { "max-hosts", required_argument,NULL, 'n'},
    { "idle-timeout", required_argument,NULL, RESP_TIMEOUT},
    { "rw-timeout", required_argument,NULL, RW_TIMEOUT},
    { "conn-timeout", required_argument,NULL, CONN_TIMEOUT},
    { "max-connections", required_argument,NULL, 'c'},
    { "max-requests", required_argument,NULL, 'r'},
    { "max-time", required_argument,NULL, MAX_TIME},
    { "progress", required_argument, NULL, 'P' },
    { "file", required_argument, NULL, 'f' },
    { "statistics", no_argument, NULL, STATISTICS },
    { "browser", required_argument, NULL, 'B' },
    { "train",  optional_argument, NULL, 'T' },
    { "feature", required_argument,NULL, FEATURE},
    { "url", required_argument, NULL, URL },
    { "flags", required_argument, NULL, FLAGS },
    { "help", required_argument, NULL, 'h' },
    { "skip-sig", no_argument, &skip_sig, 1},
    { "skip-other-probes", no_argument, &skip_other_probes, 1},
    { "skip-blacklist-success", no_argument, &blacklist_success, 0},
    { "force-save", no_argument, &force_save, 1},
    { "analyze", no_argument, &mode, MODE_ANALYZE},
    { "find-uploaded-file", required_argument, NULL, MODE_FIND_UPLOAD },
    { 0,    0,    0,    0   }       /* terminating -0 item */
  };
  int opt;
  struct t_list *target;
  while((opt=getopt_long( argc, argv, "-n:Sf:P:c:B:h:r:T::", long_options, &longIndex ))!=-1){
    switch(opt){
      case 1:
        target=calloc(sizeof(struct t_list),1);
        target->host=(unsigned char *) optarg;
        unqueued_hosts++;
        LL_APPEND(target_list,target);
        t++;
        break;
      case MODE_BRUTE_BACKUP:
        backup_bruteforce_url=optarg;
        mode=MODE_BRUTE_BACKUP;
        break;
      case BRUTE_BACKUP_DAYS:
        backup_bruteforce_days_back=atoi(optarg);
        break;
      case RESP_TIMEOUT:
        resp_tmout=atoi(optarg);
        break;
      case RW_TIMEOUT:
        rw_tmout=atoi(optarg);
        break;
      case MAX_TIME:
        max_time=atoi(optarg);
        break;
      case CONN_TIMEOUT:
        idle_tmout=atoi(optarg);
        break;
      case BRUTE_BACKUP_PATTERN:
        backup_bruteforce_pattern=optarg;
        break;
      case 'B':
        if (!strcasecmp("metal",optarg)) browser_type=BROWSER_METAL;
        else if (!strcasecmp("minimal",optarg)) browser_type=BROWSER_FAST;
        else if (!strcasecmp("firefox",optarg)) browser_type=BROWSER_FFOX;
        else if (!strcasecmp("explorer",optarg)) browser_type=BROWSER_MSIE;
        else if (!strcasecmp("iphone",optarg)) browser_type=BROWSER_PHONE;
        else {
          printf("ERROR: Browser type '%s' is not supported.\n",optarg);
          exit(1);
        }
        break;
      case 'h':
        usage();
        exit(0);
      case 'S':
        store_successes=1;
        break;
      case URL:
        url=optarg;
        break;
      case 'c':
        max_conn_host=atoi(optarg);
        break;
      case 'f':
        if(!strcmp("-",optarg)) file=stdin;
        else{
          if(!(file=fopen(optarg,"r"))){
            printf("Can't open '%s' for reading!",optarg);
            exit(1);
          }
        }
        int fd = fileno(file);
        int fflags = fcntl(fd, F_GETFL, 0);
        fflags |= O_NONBLOCK;
        fcntl(fd, F_SETFL, fflags);
        t++;
      case 'r':
        max_requests=atoi(optarg);
        break;
      case 'P':
        progress=atoi(optarg);
        break;
      case STATISTICS:
        load_tests();
        load_features();
        show_feature_predictive_values();
        exit(0);
        break;
      case 'T':
        train=1;
        if(optarg) max_train_count=atoi(optarg);
        break;
      case 'n':
        max_hosts=atoi(optarg);
        break;
      case FEATURE:
        feature=optarg;
        break;
      case POST_KEY:
        post_key=optarg;
        break;
      case MIME:
        mime=optarg;
        break;
      case CODE:
        code=atoi(optarg);
        break;
      case RECENT:
        recent=atoi(optarg);
        break;
      case TRIGGER:
        trigger=optarg;
        break;
      case FLAGS:
        for(i=0; i<strlen(optarg); i++){
          f=tolower(optarg[i]);
          switch(f){
            case 'c':
              flags|=F_CRITICAL;
              break;
            case 'i':
              flags|=F_INFO;
              break;
            case 'd':
              flags|=F_DIRECTORY;
              break;
            case 'g':
              flags|=F_CGI;
              break;
            default:
              fprintf (stderr, "Unknown flag: '%c'",f ); 
              exit(1);
          }
        }
        break;
      case MODE_FIND_UPLOAD:
        mode=MODE_FIND_UPLOAD;
        upload_file=optarg;
        break;
    }
  
  }

  if(train){

    /* force aggressive 404 pruning */

    max_requests=0;
    blacklist_success=1;
    skip_other_probes=0;
  }

  switch(mode){
    case MODE_FIND_UPLOAD:
      do {
        struct target *tar;
        if(!t){
          fprintf(stderr, "You must specify a host\n");
          exit(1);
        }
        skip_other_probes=1;
        tar=add_target(target_list->host) ; /* first target only */
        no_add_from_queue=1;
        if(!tar){
          fprintf(stderr,"Couldn't create target '%s'\n",target_list->host);
          exit(1);
        }

        tar->upload_file=upload_file;
        tar->after_probes=start_find_uploaded_file;
        do_scan();
      } while(0);
      break;
    case MODE_ADD_URL:
      add_or_update_url(url, description, flags);
      exit(0);
      break;
    case MODE_ATTACK:
      if(!t){
        usage();
        exit(0);
      }
      max_connections=max_hosts * max_conn_host;
      scan_flags=flags;
      do_scan();
      exit(0);
      break;
    case MODE_ADD_TRIGGER:
      add_aho_corasick_trigger(trigger, feature);
      exit(0);
      break;
    case MODE_QUERY:
      do {
        if(!url && !code && !mime && !flags && !recent && !post_key && !query_all){
          fprintf(stderr,"You must specify at least one attribute to search on (or --all)\n");
          exit(1);
        }
        struct query *q=ck_alloc(sizeof(struct query));
        q->url=url;
        q->code=code;
        q->mime=mime;
        q->flags=flags;
        q->recent=recent;
        q->post_key=post_key;
        store_successes=0;
        do_query(q);
        exit(0);
      break;
      } while(0);
    case MODE_ANALYZE:
      load_tests();
      load_features();
      info("performing feature selection...");
      do_feature_selection();
      exit(0);
    case MODE_BRUTE_BACKUP:
      do {
      struct target *tar;
      skip_other_probes=1;
      tar=add_target(backup_bruteforce_url);
      if(!tar) exit(1);
      tar->after_probes=start_bruteforce_backup;
      do_scan();
      } while(0);
      break;
  }

}
예제 #12
0
int main(int argc, char** argv) {
	u_int32_t flags; int ret;
	num_recovered = num_pend_pub = num_pend_pub_comp = num_pend_priv = num_dups = 0;
	if(argc < 2 || argc > 3) {
		fprintf(stderr, "bitcoin-wallet-recover v0.3\n");
		fprintf(stderr, "(C) 2011-2012 Aidan Thornton. All rights reserved.\n");
		fprintf(stderr, "See LICENSE.txt for full copyright and licensing information\n");
		fprintf(stderr, "\n");
		fprintf(stderr, "Usage: %s <device> [<new wallet>]\n", argv[0]);
		exit(1);
	}

	bufpos = 0; buffill = 0;
	f = open(argv[1], O_RDONLY);
	if(f < 0) {
		perror("Opening input");
		exit(1);
	}
	ftotallen = lseek(f, 0, SEEK_END);
	fpos = fnextcp = 0;
	lseek(f, 0, SEEK_SET);
	//printf("DEBUG: f = %i\n", f);

	if(argc >= 3) {
		ret = db_create(&dbp, NULL, 0);
		if (ret != 0) {
			fprintf(stderr, "Error: couldn't create DB to open output wallet\n");
			exit(1);
		}
		flags = DB_CREATE;
		ret = dbp->open(dbp,
				NULL, // transaction pointer
				argv[2],
				"main", // logical database name
				DB_BTREE,
				flags,
				0);
		if (ret != 0) {
			fprintf(stderr, "Error: couldn't open output wallet\n");
			exit(1);
		}
	} else {
		dbp = NULL;
	}

	do_scan();
	if(dbp && num_recovered > 0)
		invalidate_best_block();
	if(dbp)
		dbp->close(dbp, 0);
	fprintf(stderr, "Done - %i keys recovered, %i %i %i fail %i dups!     \n", num_recovered, num_pend_pub, num_pend_pub_comp, num_pend_priv, num_dups);
	if(num_recovered <= 0) {
		fprintf(stderr, "Sorry, nothing found :-(\n");
	} else {
		if(dbp) {
			fprintf(stderr, "Note: recovered addresses won't be listed under 'Receive coins' in the client\n\n");
		}
		fprintf(stderr, "If this helped, feel free to make a donation to the author at:\n");
		fprintf(stderr, "    *** 1CxDtwy7SAYHu7RJr5MFFUwtn8VEotTj8P ***\n");
		fprintf(stderr, "Please backup your wallet regularly and securely!\n\n");
		if(dbp) {
			fprintf(stderr, "After running the client and confirming your coins are all there, please either:\n");
			fprintf(stderr, " * Send all your coins to a new wallet that's securely backed up in one big transaction, or\n");
			fprintf(stderr, " * Stop the client and take a backup of your wallet before making any transactions\n");
			fprintf(stderr, "I'd also recommend using the -upgradewallet option, though it's not required\n\n");
		}
	}
	return 0;
}
예제 #13
0
파일: bug1187785.c 프로젝트: Wicker25/re2c
main()
{
	do_scan("0");
}
main()
{
	do_scan(1, "a\n");
	do_scan(2, "aa\n");
	do_scan(2, "aaa\n");
	do_scan(4, "aaaa\n");
	do_scan(0, "q");
	do_scan(0, "a");
	do_scan(1, "A\n");
	do_scan(2, "AA\n");
	do_scan(2, "aAa\n");
	do_scan(4, "AaaA\n");
	do_scan(5, "Q");
	do_scan(4, "AaaAa\n");
	do_scan(3, "AaaAaA\n");
	do_scan(5, "A");
	do_scan(0, "\n");
	do_scan(5, "0");
	do_scan(0, "a");
	do_scan(0, "q");
	do_scan(5, "x");
}
예제 #15
0
파일: bug1454253.c 프로젝트: skvadrik/re2c
main()
{
	do_scan("?1??",         2, "20");
	do_scan("#",            1, "0");
	do_scan("##",           2, "0");
	do_scan("##?",          2, "0");
	do_scan("##|",          3, "0");
	do_scan("?!|",          3, "10");
	do_scan("?!?1|",        5, "120");
	do_scan("?!?a+",        5, "120");
	do_scan("?2!1?2??",     4, "20");
	do_scan("?1?2!1?2??",   6, "220");
	do_scan("?1?2?!1?2??",  9, "22120");
	do_scan("?1?2?!1?2?!", 12, "221213");
	do_scan("?1?123?45??",  9, "2220");
	do_scan("?1?123?45?!", 12, "22213");
}
예제 #16
0
파일: test.cpp 프로젝트: Bvangoor/Be-Tree
int test(betree<uint64_t, std::string> &b,
	 uint64_t nops,
	 uint64_t number_of_distinct_keys,
	 FILE *script_input,
	 FILE *script_output)
{
  std::map<uint64_t, std::string> reference;

  for (unsigned int i = 0; i < nops; i++) {
    int op;
    uint64_t t;
    if (script_input) {
      int r = next_command(script_input, &op, &t);
      if (r == EOF)
	exit(0);
      else if (r < 0)
	exit(4);
    } else {
      op = rand() % 7;
      t = rand() % number_of_distinct_keys;
    }
    
    switch (op) {
    case 0: // insert
      if (script_output)
	fprintf(script_output, "Inserting %lu\n", t);
      b.insert(t, std::to_string(t) + ":");
      reference[t] = std::to_string(t) + ":";
      break;
    case 1: // update
      if (script_output)
	fprintf(script_output, "Updating %lu\n", t);
      b.update(t, std::to_string(t) + ":");
      if (reference.count(t) > 0)
      	reference[t] += std::to_string(t) + ":";
      else
      	reference[t] = std::to_string(t) + ":";
      break;
    case 2: // delete
      if (script_output)
	fprintf(script_output, "Deleting %lu\n", t);
      b.erase(t);
      reference.erase(t);
      break;
    case 3: // query
      try {
	std::string bval = b.query(t);
	assert(reference.count(t) > 0);
	std::string rval = reference[t];
	assert(bval == rval);
	if (script_output)
	  fprintf(script_output, "Query %lu -> %s\n", t, bval.c_str());
      } catch (std::out_of_range e) {
	if (script_output)
	  fprintf(script_output, "Query %lu -> DNE\n", t);
	assert(reference.count(t) == 0);
      }
      break;
    case 4: // full scan
      {
	if (script_output)
	  fprintf(script_output, "Full_scan 0\n");
	auto betit = b.begin();
	auto refit = reference.begin();
	do_scan(betit, refit, b, reference);
      }
      break;
    case 5: // lower-bound scan
      {
	if (script_output)
	  fprintf(script_output, "Lower_bound_scan %lu\n", t);
	auto betit = b.lower_bound(t);
	auto refit = reference.lower_bound(t);
	do_scan(betit, refit, b, reference);
      }
      break;
    case 6: // scan
      {
	if (script_output)
	  fprintf(script_output, "Upper_bound_scan %lu\n", t);
	auto betit = b.upper_bound(t);
	auto refit = reference.upper_bound(t);
	do_scan(betit, refit, b, reference);
      }
      break;
    default:
      abort();
    }
  }

  std::cout << "Test PASSED" << std::endl;
  
  return 0;
}