Exemple #1
0
int main(int argc, char **argv)
{
    struct timeval tv;

    // Parse command line options.
    Options *options = parseopts(argc, argv);

    // Start time.
    gettimeofday(&tv, NULL);
    int64_t t0 = (tv.tv_sec*1000) + (tv.tv_usec/1000);

    // Benchmark computation of a DAG.
    // benchmark_dag(options);
    benchmark_count_with_qip(options);

    // End time.
    gettimeofday(&tv, NULL);
    int64_t t1 = (tv.tv_sec*1000) + (tv.tv_usec/1000);

    // Show wall clock time.
    printf("Elapsed Time: %.3f seconds\n", ((float)(t1-t0))/1000);

    // Clean up.
    Options_free(options);
    
    return 0;
}
Exemple #2
0
int
main(int argc, char *argv[]) {
    gchar **uris = NULL;
    xdgHandle xdg;

    /* clean up any zombies */
    sigchld(0);

    gtk_init(&argc, &argv);
    if (!g_thread_supported())
        g_thread_init(NULL);

    /* parse command line opts and get uris to load */
    uris = parseopts(argc, argv);

    /* get XDG basedir data */
    xdgInitHandle(&xdg);

    init_directories(&xdg);
    init_lua(uris, &xdg);

    /* we are finished with this */
    xdgWipeHandle(&xdg);

    gtk_main();
    return EXIT_SUCCESS;
}
Exemple #3
0
void qObjProto::EvalQMail(qCtx *ctx, qStr *out, qArgAry *args)
{
    if (args->Count() >= 1) {
        qMailOpts qmop;

        int argc = args->Count();
        const char **argv = *args;

        try {
            parseopts(&qmop, argc, const_cast<char **&>(argv));
        } catch (CEx ex) {
            ctx->Throw(out, ex.id+600, ex.msg);
        }

        if (qsUnreg) {
            qmop.unreg = true;
        }

        try {
            int errVal = qsmtp(&qmop);
            if (errVal)
                ctx->ThrowF(out, errVal+600, "Mail error #%d.", errVal);
        } catch (CEx ex) {
            ctx->Throw(out, ex.id+600, ex.msg);
        }
    }
    return;
}
Exemple #4
0
int
main(int argc, char *argv[]) {
    gchar **uris = NULL;

    /* clean up any zombies */
    struct sigaction sigact;
    sigact.sa_handler=sigchld;
    sigemptyset (&sigact.sa_mask);
    sigact.sa_flags = SA_NOCLDSTOP;
    if (sigaction(SIGCHLD, &sigact, NULL))
        fatal("Can't install SIGCHLD handler");

    /* parse command line opts and get uris to load */
    uris = parseopts(argc, argv);

    gtk_init(&argc, &argv);
    if (!g_thread_supported())
        g_thread_init(NULL);

    init_directories();
    init_lua(uris);

    /* parse and run configuration file */
    if(!luaH_parserc(globalconf.confpath, TRUE))
        fatal("couldn't find rc file");

    if (!globalconf.windows->len)
        fatal("no windows spawned by rc file, exiting");

    gtk_main();
    return EXIT_SUCCESS;
}
Exemple #5
0
gint
main(gint argc, gchar *argv[]) {
    gboolean *nonblock = NULL;
    gchar **uris = NULL;
    pid_t pid, sid;

    globalconf.starttime = l_time();

    /* clean up any zombies */
    struct sigaction sigact;
    sigact.sa_handler=sigchld;
    sigemptyset (&sigact.sa_mask);
    sigact.sa_flags = SA_NOCLDSTOP;
    if (sigaction(SIGCHLD, &sigact, NULL))
        fatal("Can't install SIGCHLD handler");

    /* set numeric locale to C (required for compatibility with
       LuaJIT and luakit scripts) */
    gtk_set_locale();
    gtk_disable_setlocale();
    setlocale(LC_NUMERIC, "C");

    /* parse command line opts and get uris to load */
    uris = parseopts(&argc, argv, &nonblock);

    /* if non block mode - respawn, detach and continue in child */
    if (nonblock) {
        pid = fork();
        if (pid < 0) {
            fatal("Cannot fork: %d", errno);
        } else if (pid > 0) {
            exit(EXIT_SUCCESS);
        }
        sid = setsid();
        if (sid < 0) {
            fatal("New SID creation failure: %d", errno);
        }
    }

    gtk_init(&argc, &argv);

    init_directories();
    init_lua(uris);

    /* hide command line parameters so process lists don't leak (possibly
       confidential) URLs */
    for (gint i = 1; i < argc; i++)
        memset(argv[i], 0, strlen(argv[i]));

    /* parse and run configuration file */
    if(!luaH_parserc(globalconf.confpath, TRUE))
        fatal("couldn't find rc file");

    if (!globalconf.windows->len)
        fatal("no windows spawned by rc file, exiting");

    gtk_main();
    return EXIT_SUCCESS;
}
Exemple #6
0
int main(int argc, char * const argv[])
{
	parseopts(argc, argv);
	printdesc("Regression testsuite palette handling\n\n");

	testcase1("Draw green box");

	printsummary();

	return 0;
}
Exemple #7
0
int main(int argc, char * const argv[])
{
	parseopts(argc, argv);

	printdesc("Regression testsuite for ggLock(3) & friends.\n\n");

	testcase1("Checks behaviour of locking functions, whether they match documentation.");

	printsummary();

	return 0;
}
Exemple #8
0
int main(int argc, char **argv) {
	
	if (parseopts(argc, argv) != 0) {
		fprintf(stderr, "Try the -h option for usage help.\n");
		return 1;
	}
	
	if (MergeImages() != 0) {
		return 1;
	}
	
	return 0;
}
Exemple #9
0
int main(int argc, char * const argv[])
{
	parseopts(argc, argv);

	printdesc("Regression testsuite for libgg init/exit handling\n\n");

	testcase1("Check that ggInit() behaves as documented.");
	testcase2("Check that ggExit() behaves as documented.");


	printsummary();

	return 0;
}
Exemple #10
0
int main(int argc, char **argv)
{
	char *res;
	char buffer[1024];

	info.base = 0;
	parseopts(argc, argv);

	if (!(res = num2bin(info.num, buffer, sizeof(buffer))))
		_throwerror(1, "%s is a too large number.", argv[1]);

	printf("[dec]\t%llu\t=\t[hex]\t%llx\t[oct]\t%llo\t[bin]\t%s\n", info.num, info.num, info.num, res);

	return 0;
}
Exemple #11
0
int
main(int argc, char *argv[]) {
    gboolean *nonblock = NULL;
    gchar **uris = NULL;
    pid_t pid, sid;

    /* clean up any zombies */
    struct sigaction sigact;
    sigact.sa_handler=sigchld;
    sigemptyset (&sigact.sa_mask);
    sigact.sa_flags = SA_NOCLDSTOP;
    if (sigaction(SIGCHLD, &sigact, NULL))
        fatal("Can't install SIGCHLD handler");

    /* parse command line opts and get uris to load */
    uris = parseopts(argc, argv, &nonblock);

    /* if non block mode - respawn, detach and continue in child */
    if (nonblock) {
        pid = fork();
        if (pid < 0) {
            fatal("Cannot fork: %d", errno);
        } else if (pid > 0) {
            exit(EXIT_SUCCESS);
        }
        sid = setsid();
        if (sid < 0) {
            fatal("New SID creation failure: %d", errno);
        }
    }

    gtk_init(&argc, &argv);
    if (!g_thread_supported())
        g_thread_init(NULL);

    init_directories();
    init_lua(uris);

    /* parse and run configuration file */
    if(!luaH_parserc(globalconf.confpath, TRUE))
        fatal("couldn't find rc file");

    if (!globalconf.windows->len)
        fatal("no windows spawned by rc file, exiting");

    gtk_main();
    return EXIT_SUCCESS;
}
Exemple #12
0
int main(int argc, char * const argv[])
{
	int rc;

	parseopts(argc, argv);
	printdesc("Regression testsuite for display-x(7).\n\n");

	rc = ggiInit();
	if (rc < 0) ggPanic("Couldn't initialize libggi");

	testcase1("See, if mansync actually runs in SYNC mode - sets up the mode the same way as XGGI does");

	printsummary();

	return 0;
}
Exemple #13
0
int main(int argc, char** argv) {
  
  setup_error_handling();
  
  if (argc > 1) {
    int* script_argc = (int*)malloc(sizeof(int));
    char** script_and_args = parseopts(argc, argv, script_argc);
    if (*(script_argc)) {
      return script(*(script_argc), script_and_args);
    }
    return 0;
  } else {
    print_version_info(argv[0]);
    return prompt();
  }
}
Exemple #14
0
int main(int argc, char *argv[])
{
	afskmodulator.next = &fskmodulator;
	afskdemodulator.next = &fskdemodulator;
	fskmodulator.next = &pammodulator;
	fskdemodulator.next = &fskpspdemodulator;
	fskpspdemodulator.next = &pamdemodulator;
	pammodulator.next = &pskmodulator;
	pamdemodulator.next = &pskdemodulator;
	pskmodulator.next = &newqpskmodulator;
	pskdemodulator.next = &newqpskdemodulator;
	newqpskdemodulator.next = &p3ddemodulator;
        ioinit_filein();
        ioinit_soundcard();
        ioinit_sim();
       	parseopts(argc, argv);
	pkttransmitloop(&state);
	exit(0);
}
Exemple #15
0
int main(int argc, char * const argv[])
{
	parseopts(argc, argv);
	printdesc("Regression testsuite mode handling\n\n");

	testcase1("Check that ggiCheckMode() doesn't return GGI_AUTO");
	testcase2("Check that ggiSetMode() can actually set the mode that has been suggested by ggiCheckMode");
	testcase3("Check setting a mode with a given number of frames");
	testcase4("Check setting a mode by its physical size");
	testcase5("Set up the mode in the ggiterm way");
	testcase6("Check that re-setting of a different mode works [async mode]");
	testcase7("Check that re-setting of a different mode works [sync mode]");
	testcase8("Check checking then setting a mode with braindamaged visual size");
	testcase9("Check modelist");

	printsummary();

	return 0;
}
Exemple #16
0
static int
parseboot(char *arg, char **filename, int *howto)
{
	char *opts = NULL;

	*filename = 0;
	*howto = 0;

	/* if there were no arguments */
	if (*arg == NULL)
		return (1);

	/* format is... */
	/* [[xxNx:]filename] [-adqsv] */

	/* check for just args */
	if (arg[0] == '-') {
		opts = arg;
	} else {
		/* there's a file name */
		*filename = arg;

		opts = gettrailer(arg);
		if (*opts == NULL) {
			opts = NULL;
		} else if (*opts != '-') {
			printf("invalid arguments\n");
			bootcmd_help(NULL);
			return (0);
		}
	}

	/* at this point, we have dealt with filenames. */

	/* now, deal with options */
	if (opts) {
		if (parseopts(opts, howto) == 0) {
			return (0);
		}
	}
	return (1);
}
Exemple #17
0
int main(int argc, char *argv[])
{
	parseopts(argc, argv);

	printdesc("Regression testsuite for libgg's internal ggParseTarget() function.\n\n");

	testcase1("Passes a string with whitespaces only. Expected to return \\0.");
	testcase2("Passes a string with an too short target buffer. "
		"This expects to fill up the buffer as much as possible, "
		"but not completely - buffer overflow protection.");
	testcase3("Passes a string with valid arguments.");
	testcase4("Passes a string with syntax error: "
		"A closing bracket doesn\'t match an opening bracket.");
	testcase5("Passes a string with syntax error: "
		"Number of opening and closing brackets matches, but wrong ordered.");

	printsummary();

	return 0;
}
Exemple #18
0
int
main(int argc, char **argv) {
	int rotval = 13;
	const char *msg = NULL;
	const char *rotmsg = NULL;

	parseopts(argc, argv, &rotval);

	msg = argvtostr(argc, argv);

	if (msg == NULL) {
		usage(argc, argv);
	}

	rotmsg = rot(rotval, msg);
	if (rotmsg != NULL) {
		printf("%s\n", rotmsg);
	}

	return EXIT_SUCCESS;
}
Exemple #19
0
int main(int argc, char **argv)
{
	client_t client;
	int cmd, err = 0;
	cmd = parseopts(argc, argv, &client);
	if (cmd < 0)
		return 1;
	/* call function for command */
	switch (cmd) {
	case 1:
		err = do_bind(&client);
		break;
	case 2:
		err = do_unbind(&client);
		break;
	case 3:
		err = do_setcache(&client);
		break;
	}

	client_shutdown(&client);
	return err;
}
Exemple #20
0
int main(int argc, char *argv[]) {
  char shell[strlen(stub) + strlen(shellcode) + 1];
  sprintf(shell, "%s%s", stub, shellcode);

  parseopts(argc, argv);
  int pid = atoi(argv[1]);

  attach(pid);
  struct user_regs_struct *tmp = inject(pid, shell);
  
  struct sigaction hook_ret;
  memset(&hook_ret, 0, sizeof(struct sigaction));
  hook_ret.sa_handler = ret_handler;
  sigaction(0xc, &hook_ret, 0);

  cont(pid);

  while(hit == 0) {}

  set_regs(pid, tmp);

  detach(pid);
  return 0;
}
Exemple #21
0
    int main(int argc, char **argv)
    {
        struct user_opt opt;
        struct crack_data cdata;
        struct capture_data capdata;
        struct wpa_eapol_key *eapkeypacket;
        u8 eapolkey_nomic[99];
        struct timeval start, end;
        int ret;
        char passphrase[MAXPASSLEN + 1];

        printf("%s %s - WPA-PSK dictionary attack. <*****@*****.**>\n",
               PROGNAME, VER);

        memset(&opt, 0, sizeof(struct user_opt));
        memset(&capdata, 0, sizeof(struct capture_data));
        memset(&cdata, 0, sizeof(struct crack_data));
        memset(&eapolkey_nomic, 0, sizeof(eapolkey_nomic));

        /* Collect and test command-line arguments */
        parseopts(&opt, argc, argv);
        testopts(&opt);
        printf("\n");

        /* Populate capdata struct */
        strncpy(capdata.pcapfilename, opt.pcapfile,
            sizeof(capdata.pcapfilename));
        if (openpcap(&capdata) != 0) {
            printf("Unsupported or unrecognized pcap file.\n");
            exit(-1);
        }

        /* populates global *packet */
        while (getpacket(&capdata) > 0) {
            if (opt.verbose > 2) {
                lamont_hdump(packet, h->len);
            }
            /* test packet for data that we are looking for */
            if (memcmp(&packet[capdata.l2type_offset], DOT1X_LLCTYPE, 2) ==
                0 && (h->len >
                capdata.l2type_offset + sizeof(struct wpa_eapol_key))) {
                /* It's a dot1x frame, process it */
                handle_dot1x(&cdata, &capdata, &opt);
                if (cdata.aaset && cdata.spaset && cdata.snonceset &&
                    cdata.anonceset && cdata.keymicset
                    && cdata.eapolframeset) {
                    /* We've collected everything we need. */
                    break;
                }
            }
        }

        if (!(cdata.aaset && cdata.spaset && cdata.snonceset &&
              cdata.anonceset && cdata.keymicset && cdata.eapolframeset)) {

                cdata.aaset = 0;
                cdata.spaset = 0;
                cdata.snonceset = 0;
                cdata.anonceset = 0;
                cdata.keymicset = 0;
                cdata.eapolframeset = 0;

                opt.nonstrict = 1;

                memset(&capdata, 0, sizeof(struct capture_data));
                memset(&cdata, 0, sizeof(struct crack_data));
                memset(&eapolkey_nomic, 0, sizeof(eapolkey_nomic));

                /* Populate capdata struct */
                strncpy(capdata.pcapfilename, opt.pcapfile,
                    sizeof(capdata.pcapfilename));
                if (openpcap(&capdata) != 0) {
                    printf("Unsupported or unrecognized pcap file.\n");
                    exit(-1);
                }

                /* populates global *packet */
                while (getpacket(&capdata) > 0) {
                    if (opt.verbose > 2) {
                        lamont_hdump(packet, h->len);
                    }
                    /* test packet for data that we are looking for */
                    if (memcmp(&packet[capdata.l2type_offset], DOT1X_LLCTYPE, 2) ==
                        0 && (h->len >capdata.l2type_offset + sizeof(struct wpa_eapol_key))) {
                        /* It's a dot1x frame, process it */
                        handle_dot1x(&cdata, &capdata, &opt);

                        if (cdata.aaset && cdata.spaset && cdata.snonceset
			 && cdata.anonceset && cdata.keymicset
                         && cdata.eapolframeset) {

			    if (cdata.replay_counter1 != 0 
                             && cdata.replay_counter2 != 0) {

                              if (memcmp (cdata.replay_counter1,
				          cdata.replay_counter2, 8) == 0) {

				   cdata.counters = 1;
	                           /* We've collected everything we need. */
        	                   break;

			      } 

			    } 

			    if (cdata.replay_counter3 != 0
			     && cdata.replay_counter4 != 0) {

			      if (memcmp (cdata.replay_counter3,
			                  cdata.replay_counter4, 8) == 0) {

				    cdata.counters = 1;
				    /* We've collected everything we need. */
				    break;

			      }

			    }
						
                        }
                    }
                }
        }

        closepcap(&capdata);

        if (!(cdata.aaset && cdata.spaset && cdata.snonceset &&
              cdata.anonceset && cdata.keymicset && cdata.eapolframeset && cdata.counters)) {
            printf("End of pcap capture file, incomplete four-way handshake "
                   "exchange.  Try using a\ndifferent capture.\n");
            exit(-1);
        } else {
            if (cdata.ver == WPA_KEY_INFO_TYPE_HMAC_SHA1_AES) {
                printf("Collected all necessary data to mount crack"
                            " against WPA2/PSK passphrase.\n");
             } else if (cdata.ver == WPA_KEY_INFO_TYPE_HMAC_MD5_RC4) {
                printf("Collected all necessary data to mount crack"
                            " against WPA/PSK passphrase.\n");
            }
        }

        if (opt.verbose > 1) {
            dump_all_fields(cdata, &opt);
        }

        if (opt.checkonly) {
            /* Don't attack the PSK, just return non-error return code */
            return 0;
        }

	/* Zero mic and length data for hmac-md5 calculation */
	eapkeypacket =
	    (struct wpa_eapol_key *)&cdata.eapolframe[EAPDOT1XOFFSET];
	memset(&eapkeypacket->key_mic, 0, sizeof(eapkeypacket->key_mic));
	if (opt.nonstrict == 0) {
		eapkeypacket->key_data_length = 0;
	}

	printf("Starting dictionary attack.  Please be patient.\n");
	fflush(stdout);

	signal(SIGINT, cleanup);
	signal(SIGTERM, cleanup);
	signal(SIGQUIT, cleanup);

	gettimeofday(&start, 0);

	if (!IsBlank(opt.hashfile)) {
		ret = hashfile_attack(&opt, passphrase, &cdata);
	} else if (!IsBlank(opt.dictfile)) {
		ret = dictfile_attack(&opt, passphrase, &cdata);
	} else {
		usage("Must specify dictfile or hashfile (-f or -d)");
		exit(-1);
	}

	if (ret == 0) {
		printf("\nThe PSK is \"%s\".\n", passphrase);
		gettimeofday(&end, 0);
		printstats(start, end, wordstested);
		return 0;
	} else {
		printf("Unable to identify the PSK from the dictionary file. " 
	       		"Try expanding your\npassphrase list, and double-check"
		        " the SSID.  Sorry it didn't work out.\n");
		gettimeofday(&end, 0);
		printstats(start, end, wordstested);
		return 1;
	}

	return 1;

}
Exemple #22
0
int main(int argc, char *argv[])
{
    struct gw_host *gw;
    struct ini_file *ini;
    struct ini_section *sec;
    sigset_t bmask;
    int idx;

    debug_stream = stderr;

    parseopts(argc, argv);

    ini = read_configfile(cfgfile, &sec);
    free(cfgfile);

    proc_per_gw = pflock_new(NULL, NULL);

    sigemptyset(&bmask);
    sigaddset(&bmask ,SIGUSR1);
    sigaddset(&bmask ,SIGTERM);
    if(sigprocmask(SIG_BLOCK, &bmask, NULL) < 0)
        log_exit_perror(FATAL_ERROR, "sigprocmask() blocking setup");

    while(sec)	{
        if(pflock_fork_data(proc_per_gw, sec) == NULL)	{
            pflock_destroy(proc_per_gw);
            prog_name = safemalloc(64, "new progname");
            snprintf(prog_name, 63, "autotun-%s", sec->name);
            debug("New child process pid %d", getpid());

            setup_signals_for_child();
            gw = process_section_to_gw(sec);
            ini_free_data(ini);

            connect_ssh_session(&gw->session);
            authenticate_ssh_session(gw->session);
            return run_gateway(gw);
        }
        sec = sec->next;
    }

    setup_signals_parent();

    debug("Signal children GO");
    pflock_sendall(proc_per_gw, SIGUSR1);
    sigprocmask(SIG_UNBLOCK, &bmask, NULL);


    do	{
        idx = pflock_wait_remove(proc_per_gw, PF_KILLED);
        debug("pflock_wait(): returned %d%s", idx,
              (idx == PFW_REMOVED) ? ": Removed proc from flock" : "");
        if(finish_main_loop != 0)	{
            debug("Sending %s to all", !hard_shutdown ? "SIGINT" : "SIGTERM");
            pflock_sendall(proc_per_gw, hard_shutdown ? SIGTERM : SIGINT );
            finish_main_loop = 0;
        }
    } while(idx != PFW_NOCHILD && idx != PFW_ERROR && !hard_shutdown);

    if(pflock_get_numrun(proc_per_gw) > 0)
        pflock_sendall(proc_per_gw, SIGTERM);

    ini_free_data(ini);
    pflock_destroy(proc_per_gw);
    return 0;
}
Exemple #23
0
int
main(int argc, const char *argv[])
{
  if (argc < 2) {
    usage(); 
    exit(EXIT_FAILURE);   
  } 

  parseopts(argv[1]);  

  nfc_init(&context);
  if (context == NULL) {
    ERR("Unable to init libnfc (malloc)");
    exit(EXIT_FAILURE);
  }

// Try to open the NFC reader
  pnd = nfc_open(context, NULL);
  if (pnd == NULL) {
    ERR("Error opening NFC reader");
    nfc_exit(context);
    exit(EXIT_FAILURE);
  }

  if (nfc_initiator_init(pnd) < 0) {
    nfc_perror(pnd, "nfc_initiator_init");
    nfc_close(pnd);
    nfc_exit(context);
    exit(EXIT_FAILURE);
  };

// Let the reader only try once to find a tag
  if (nfc_device_set_property_bool(pnd, NP_INFINITE_SELECT, false) < 0) {
    nfc_perror(pnd, "nfc_device_set_property_bool");
    nfc_close(pnd);
    nfc_exit(context);
    exit(EXIT_FAILURE);
  }
// Disable ISO14443-4 switching in order to read devices that emulate Mifare Classic with ISO14443-4 compliance.
  if (nfc_device_set_property_bool(pnd, NP_AUTO_ISO14443_4, false) < 0) {
    nfc_perror(pnd, "nfc_device_set_property_bool");
    nfc_close(pnd);
    nfc_exit(context);
    exit(EXIT_FAILURE);
  }
  // Configure the CRC
  if (nfc_device_set_property_bool(pnd, NP_HANDLE_CRC, false) < 0) {
    nfc_perror(pnd, "nfc_device_set_property_bool");
    nfc_close(pnd);
    nfc_exit(context);
    exit(EXIT_FAILURE);
  }
  // Use raw send/receive methods
  if (nfc_device_set_property_bool(pnd, NP_EASY_FRAMING, false) < 0) {
    nfc_perror(pnd, "nfc_device_set_property_bool");
    nfc_close(pnd);
    nfc_exit(context);
    exit(EXIT_FAILURE);
  }

  printf("NFC reader: %s opened\n", nfc_device_get_name(pnd));

// Try to find a MIFARE Classic tag
  if (select_target(pnd, &nt) <= 0) {
    printf("Error: no tag was found\n");
    nfc_close(pnd);
    nfc_exit(context);
    exit(EXIT_FAILURE);
  }
// Test if we are dealing with a MIFARE compatible tag
  if ((nt.nti.nai.btSak & 0x08) == 0) {
    printf("Warning: tag is probably not a MFC!\n");
  }

  printf("Found MIFARE Classic card:\n");
  nt.nm = nmMifare;
  print_nfc_target(&nt, false);


// Guessing size
  if ((nt.nti.nai.abtAtqa[1] & 0x02) == 0x02)
// 4K
    uiBlocks = 0xff;
  else if ((nt.nti.nai.btSak & 0x01) == 0x01)
// 320b
    uiBlocks = 0x13;
  else
// 1K/2K, checked through RATS
    uiBlocks = 0x3f;

    printf("Guessing size: seems to be a %i-byte card\n", (uiBlocks + 1) * 16);

  if (parse_card()) {
	printf("Done, %d blocks read.\n", uiBlocks + 1);
	fflush(stdout);
  }

  if(is_addv) if(!easy_add_value(0xff) || !parse_card()) printf("Failed Add Value!!\n");    

  printTag(&e); 

  nfc_close(pnd);
  nfc_exit(context);
  exit(EXIT_SUCCESS);
}
Exemple #24
0
int
main(int argc, char *argv[])
{
	char *types = NULL, data[512] = "", *resolvpath = NULL;
	char *files[] = { "/proc/mounts", "/etc/fstab", NULL };
	const char *source, *target;
	struct mntent *me = NULL;
	int aflag = 0, oflag = 0, status = 0, i, r;
	unsigned long flags = 0;
	FILE *fp;

	ARGBEGIN {
	case 'B':
		argflags |= MS_BIND;
		break;
	case 'M':
		argflags |= MS_MOVE;
		break;
	case 'R':
		argflags |= MS_REC;
		break;
	case 'a':
		aflag = 1;
		break;
	case 'o':
		oflag = 1;
		argopts = EARGF(usage());
		parseopts(argopts, &flags, data, sizeof(data));
		break;
	case 't':
		types = EARGF(usage());
		break;
	case 'n':
		break;
	default:
		usage();
	} ARGEND;

	if (argc < 1 && aflag == 0) {
		if (!(fp = fopen(files[0], "r")))
			eprintf("fopen %s:", files[0]);
		concat(fp, files[0], stdout, "<stdout>");
		fclose(fp);
		return 0;
	}

	if (aflag == 1)
		goto mountall;

	source = argv[0];
	target = argv[1];

	if (!target) {
		target = argv[0];
		source = NULL;
		if (!(resolvpath = realpath(target, NULL)))
			eprintf("realpath %s:", target);
		target = resolvpath;
	}

	for (i = 0; files[i]; i++) {
		if (!(fp = setmntent(files[i], "r"))) {
			if (strcmp(files[i], "/proc/mounts") != 0)
				weprintf("setmntent %s:", files[i]);
			continue;
		}
		while ((me = getmntent(fp))) {
			if (strcmp(me->mnt_dir, target) == 0 ||
			   strcmp(me->mnt_fsname, target) == 0 ||
			   (source && strcmp(me->mnt_dir, source) == 0) ||
			   (source && strcmp(me->mnt_fsname, source) == 0)) {
				if (!source) {
					target = me->mnt_dir;
					source = me->mnt_fsname;
				}
				if (!oflag)
					parseopts(me->mnt_opts, &flags, data, sizeof(data));
				if (!types)
					types = me->mnt_type;
				goto mountsingle;
			}
		}
		endmntent(fp);
		fp = NULL;
	}
	if (!source)
		eprintf("can't find %s in /etc/fstab\n", target);

mountsingle:
	r = mounthelper(source, target, types);
	if (r == -1)
		status = 1;
	if (r > 0 && mount(source, target, types, argflags | flags, data) < 0) {
		weprintf("mount: %s:", source);
		status = 1;
	}
	if (fp)
		endmntent(fp);
	free(resolvpath);
	return status;

mountall:
	if (!(fp = setmntent("/etc/fstab", "r")))
		eprintf("setmntent %s:", "/etc/fstab");
	while ((me = getmntent(fp))) {
		/* has "noauto" option or already mounted: skip */
		if (hasmntopt(me, MNTOPT_NOAUTO) || mounted(me->mnt_dir))
			continue;
		flags = 0;
		parseopts(me->mnt_opts, &flags, data, sizeof(data));
		/* if -t types specified:
		 * if non-match, skip
		 * if match and prefixed with "no", skip */
		if (types &&
		    ((types[0] == 'n' && types[1] == 'o' &&
		     findtype(types + 2, me->mnt_type)) ||
		     (!findtype(types, me->mnt_type))))
			continue;

		r = mounthelper(me->mnt_fsname, me->mnt_dir, me->mnt_type);
		if (r > 0 && mount(me->mnt_fsname, me->mnt_dir, me->mnt_type,
		                   argflags | flags, data) < 0) {
			weprintf("mount: %s:", me->mnt_fsname);
			status = 1;
		}
	}
	endmntent(fp);

	return status;
}
Exemple #25
0
int main(int argc, char *argv[])
{
 if(!init_cfg())
 {
  fprintf(stderr, "Unable to open config file or invalid content in config file.\n");
  exit(1);
 }
 
 parseopts(argc, argv, conf);

 if(conf->msg)
 {
  if(!open_producer())
  {
   printf("Unable to contact Bluemote server!\n");
   exit(1);
  }
  if(ipc_write(conf->device, strlen(conf->device))<=0)
  {
   printf("Unable to send message to Bluemote server!\n");
   close_producer();
   exit(1);
  }
  close_producer();
  exit(0);
 }
 else
 {
  if(!get_lock())
  {
   printf("Another instance of Bluemote already running!\n");
   exit(1);
  }

  if(!open_consumer())
  {
   printf("Unable to listen for messages!\n");
   exit(1);
  }
 }

 strcpy(logfile, getenv("HOME"));
 strcat(logfile, BLUEMOTEDIR);
 strcat(logfile, LOGFILE);

 printf("Setting up signal handlers.\n");
 logger("INIT", "Setting up signal handlers");
 if(!init_signals())
 {
  perror("init_signals()");
  exit(1);
 }

 if(conf->daemon)
 {
  printf("Entering daemon mode.\n");
  logger("INIT", "Entering daemon mode.\n");
  if(daemon(TRUE, FALSE)==-1)
  {
   printf("Unable to enter daemon mode. Exiting.\n");
   logger("ERROR", "Unable to enter daemon mode. Exiting.\n");
   exit(1);
  }
 }

 while(TRUE)
 {
  closeport();

  printf("Connecting to phone...\n");
  logger("INIT", "Connecting to phone...");
  while(openport(conf->device) == -1)
  {
   sprintf(buf,"Unable to connect to phone. Will retry after %d secs.",conf->retrysecs);
   logger("INIT", buf);
   sleep(conf->retrysecs);
   logger("INIT", "Retrying...");
  }
  printf("Connected to phone.\n");
  logger("INIT", "Connected to phone.");
  
  printf("Initialising the connection.\n");
  logger("INIT", "Initialising the connection.\n");
  if(!initport()) exit(1);

  printf("Waiting for commands from phone\n");
  logger("INIT", "Waiting for commands from phone\n");

  /* Not looping to take care of timeout because timeout is very unlikely and
   * this function is called again inside remote(). In the worst case, the I/O
   * commands for Connect event won't have any effect. */
  if(init_mainmenu()==-1) continue;

  exec_event("Connect");
  if(!manual)
  {
   exec_event("MoveIn");
  }
  manual = FALSE;
  remote();
  if(!manual)
  {
   exec_event("MoveOut");
  }
  exec_event("Disconnect");
 }
 return(0);
}
Exemple #26
0
int
main(int argc, char *argv[])
#endif
{
	char fromhost[MAX_RDC_HOST_SIZE];
	char tohost[MAX_RDC_HOST_SIZE];
	char fromfile[NSC_MAXPATH];
	char tofile[NSC_MAXPATH];
	char frombitmap[NSC_MAXPATH];
	char tobitmap[NSC_MAXPATH];
	char directfile[NSC_MAXPATH];
	char diskqueue[NSC_MAXPATH];
	char group[NSC_MAXPATH];
	char lhost[MAX_RDC_HOST_SIZE];
	int pairs;
	int pid;
	int flag = 0;
	int doasync;
	int rc;
	char *required;
	int setid;

	(void) setlocale(LC_ALL, "");
	(void) textdomain("rdc");

	program = basename(argv[0]);

	rc = rdc_check_release(&required);
	if (rc < 0) {
		rdc_err(NULL,
		    gettext("unable to determine the current "
		    "Solaris release: %s\n"), strerror(errno));
	} else if (rc == FALSE) {
		rdc_err(NULL,
		    gettext("incorrect Solaris release (requires %s)\n"),
		    required);
	}

	rdc_maxsets = rdc_get_maxsets();
	if (rdc_maxsets == -1) {
		spcs_log("sndr", NULL,
		    gettext("%s unable to get maxsets value from kernel"),
		    program);

		rdc_err(NULL,
		    gettext("unable to get maxsets value from kernel"));
	}

	pair_list = calloc(rdc_maxsets, sizeof (*pair_list));
	if (pair_list == NULL) {
		rdc_err(NULL,
		    gettext(
			"unable to allocate pair_list"
			" array for %d sets"),
			rdc_maxsets);
	}

	if (parseopts(argc, argv, &flag))
		return (1);
	pairs = read_libcfg(flag);

	if (flag == RDC_CMD_FIXSETIDS) {
		if (pairs) {
			spcs_log("sndr", NULL, gettext("Fixed %d Remote Mirror"
				    " set IDs"), pairs);
#ifdef DEBUG
			rdc_warn(NULL, gettext("Fixed %d Remote Mirror set "
				    "IDs"), pairs);
#endif
		}
		return (0);
	}

	if (pairs == 0) {
#ifdef DEBUG
		rdc_err(NULL,
		    gettext("Config contains no dual copy sets"));
#else
		return (0);
#endif
	}

	while (pairs--) {
		pid = fork();
		if (pid == -1) {		/* error forking */
			perror("fork");
			continue;
		}

		if (pid > 0)		/* this is parent process */
			continue;

/*
 * At this point, this is the child process.  Do the operation
 */

		strncpy(fromfile,
			pair_list[pairs].ffile, NSC_MAXPATH);
		strncpy(tofile,
			pair_list[pairs].tfile, NSC_MAXPATH);
		strncpy(frombitmap,
			pair_list[pairs].fbitmap, NSC_MAXPATH);
		strncpy(fromhost,
			pair_list[pairs].fhost, MAX_RDC_HOST_SIZE);
		strncpy(tohost,
			pair_list[pairs].thost, MAX_RDC_HOST_SIZE);
		strncpy(tobitmap,
			pair_list[pairs].tbitmap, NSC_MAXPATH);
		strncpy(directfile,
			pair_list[pairs].directfile, NSC_MAXPATH);
		strncpy(diskqueue,
			pair_list[pairs].diskqueue, NSC_MAXPATH);
		strncpy(group,
			pair_list[pairs].group, NSC_MAXPATH);
		strncpy(lhost,
			pair_list[pairs].lhost, MAX_RDC_HOST_SIZE);

		doasync = pair_list[pairs].doasync;
		setid = pair_list[pairs].setid;
		if (rdc_operation(fromhost, fromfile, frombitmap,
		    tohost, tofile, tobitmap, flag, directfile, group,
		    diskqueue, doasync, lhost, setid)
		    < 0) {
			exit(255);
		}

		exit(0);
	}

	while ((wait((int *)0) > 0))
		;
	return (0);
}
Exemple #27
0
static xiosingle_t *xioparse_single(const char **addr) {
    xiofile_t *xfd;
    xiosingle_t *sfd;
    struct addrname *ae;
    const struct addrdesc *addrdesc = NULL;
    const char *ends[4+1];
    const char *hquotes[] = {
        "'",
        NULL
    } ;
    const char *squotes[] = {
        "\"",
        NULL
    } ;
    const char *nests[] = {
        "'", "'",
        "(", ")",
        "[", "]",
        "{", "}",
        NULL
    } ;
    char token[512], *tokp;
    size_t len;
    int i;

    /* init */
    i = 0;
    /*ends[i++] = xioopts.chainsep;*/	/* default: "|" */
    ends[i++] = xioopts.pipesep;		/* default: "!!" */
    ends[i++] = ","/*xioopts.comma*/;		/* default: "," */
    ends[i++] = ":"/*xioopts.colon*/;		/* default: ":" */
    ends[i++] = NULL;

    if ((xfd = xioallocfd()) == NULL) {
        return NULL;
    }
    sfd = &xfd->stream;
    sfd->argc = 0;

    len = sizeof(token);
    tokp = token;
    if (nestlex(addr, &tokp, &len, ends, hquotes, squotes, nests,
                true, true, false) < 0) {
        Error2("keyword too long, in address \"%s%s\"", token, *addr);
    }
    *tokp = '\0';  /*! len? */
    ae = (struct addrname *)
         keyw((struct wordent *)&addressnames, token,
              sizeof(addressnames)/sizeof(struct addrname)-1);

    if (ae) {
        addrdesc = ae->desc;
        /* keyword */
        if ((sfd->argv[sfd->argc++] = strdup(token)) == NULL) {
            Error1("strdup(\"%s\"): out of memory", token);
        }
    } else {
        if (false) {
            ;
#if WITH_FDNUM
        } else if (isdigit(token[0]&0xff) && token[1] == '\0') {
            Info1("interpreting address \"%s\" as file descriptor", token);
            addrdesc = &addr_fd;
            if ((sfd->argv[sfd->argc++] = strdup("FD")) == NULL) {
                Error("strdup(\"FD\"): out of memory");
            }
            if ((sfd->argv[sfd->argc++] = strdup(token)) == NULL) {
                Error1("strdup(\"%s\"): out of memory", token);
            }
            /*! check argc overflow */
#endif /* WITH_FDNUM */
#if WITH_GOPEN
        } else if (strchr(token, '/')) {
            Info1("interpreting address \"%s\" as file name", token);
            addrdesc = &addr_gopen;
            if ((sfd->argv[sfd->argc++] = strdup("GOPEN")) == NULL) {
                Error("strdup(\"GOPEN\"): out of memory");
            }
            if ((sfd->argv[sfd->argc++] = strdup(token)) == NULL) {
                Error1("strdup(\"%s\"): out of memory", token);
            }
            /*! check argc overflow */
#endif /* WITH_GOPEN */
        } else {
            Error1("unknown device/address \"%s\"", token);
            /*!!! free something*/ return NULL;
        }
    }

    sfd->tag  = XIO_TAG_RDWR;
    sfd->addr = addrdesc;

    while (!strncmp(*addr, xioopts.paramsep, strlen(xioopts.paramsep))) {
        *addr += strlen(xioopts.paramsep);
        len = sizeof(token);
        tokp = token;
        if (nestlex(addr, &tokp, &len, ends, hquotes, squotes, nests,
                    true, true, false) != 0) {
            Error2("syntax error in address \"%s%s\"", token, *addr);
        }
        *tokp = '\0';
        if ((sfd->argv[sfd->argc++] = strdup(token)) == NULL) {
            Error1("strdup(\"%s\"): out of memory", token);
        }
    }

    if (parseopts(addr, addrdesc->groups, &sfd->opts) < 0) {
        free(xfd);
        return NULL;
    }

    return sfd;
}
Exemple #28
0
int
getoptx(int argc, const char **argv, const char *minus, const char *plus)
{
	Opttable *tab;
	Optentry *ent = NULL;
	boolean single = FALSE;
	int code = '?';
	Params param = NONE;
	int loc = 1;

	if (minustab == NULL)
		minustab = new_opttable();

	if (plustab == NULL)
		plustab = new_opttable();

	if (minustab == NULL || plustab == NULL)
		return EOF;

	if (minus == NULL)
		minus = "";

	if (plus == NULL)
		plus = "";

	if (optind < 1 || lastargc != argc || lastargv != argv ||
			lastminus == NULL || !streq(lastminus, minus) ||
			lastplus == NULL || !streq(lastplus, plus))
	{
		lastargc = argc;
		lastargv = argv;
		lastminus = minus;
		lastplus = plus;
		optind = 0;
		endflag = FALSE;
		singlechars = NULL;
		lasttab = NULL;
		parseopts(minustab, minus);
		parseopts(plustab, plus);
	}

	if (endflag)
		return EOF;

	if (singlechars != NULL && singlechars[0] != '\0')
	{
		char name[2];

		name[0] = *singlechars++;
		name[1] = '\0';
		tab = lasttab;
		ent = find_opttable(tab, name);
		single = TRUE;
	}
	else
	{
		optind++;

		if (optind >= argc)
		{
			endflag = TRUE;
			return EOF;
		}

		/* --opt is same as +opt */
		if (argv[optind][0] == '+' ||
				(argv[optind][0] == '-' && argv[optind][1] == '-' &&
						argv[optind][2]))
		{
			if (argv[optind][0] != '+')
				loc++;

			tab = plustab;
			optsign = '+';
		}
		else if (argv[optind][0] == '-')
		{
			if (argv[optind][1] == '\0')
			{
				endflag = TRUE;
				return EOF;
			}
			else if (argv[optind][1] == '-' && argv[optind][2] == '\0')
			{
				optind++;
				endflag = TRUE;
				return EOF;
			}

			tab = minustab;
			optsign = '-';
		}
		else
		{
			endflag = TRUE;
			return EOF;
		}

		ent = find_opttable(tab, &argv[optind][loc]);	/* multi-char name */

		if (ent == NULL)		/* did not find it */
		{
			char name[2];
			name[0] = argv[optind][loc];
			name[1] = '\0';
			ent = find_opttable(tab, name);	/* single-char name */

			if (ent == NULL && (isdigit(name[0]) || name[0] == '-'))
				ent = find_opttable(tab, "(#)");	/* numeric */
			else				/* do not care if found or not found */
			{
				single = TRUE;
				singlechars = &argv[optind][loc + 1];
				lasttab = tab;
			}
		}
	}

	if (ent != NULL)
	{
		code = ent->code;
		param = ent->params;
		optname = ent->name;
	}
	else
		optname = NULL;

	switch (param)
	{
	case PARAM:
		if (single && singlechars[0] != '\0')
		{
			optarg = (char *)singlechars;
			singlechars = NULL;
		}
		else
		{
			optind++;

			if (optind >= argc)
			{
				optarg = NULL;
				return '?';
			}

			optarg = (char *)argv[optind];
		}

		break;

	case NUMERIC:
		optarg = (char *)&argv[optind][loc];

		if (streq(optarg, "(#)"))
			optarg = NULL;

		break;

	default:
		optarg = NULL;
		break;
	}

	return code;
}
Exemple #29
0
int dictfile_attack(struct user_opt *opt, char *passphrase, 
	struct crack_data *cdata)
{
	
	FILE *fp;
	int fret;
	u8 pmk[32];
	u8 ptk[64];
	u8 keymic[16];
	struct wpa_ptk *ptkset;

#ifdef FPGA
//	int i;
	opt_g = opt;
	cdata_g = cdata;
	if(usefpga)
		initfpga();
#endif

	/* Open the dictionary file */
	if (*opt->dictfile == '-') {
		printf("Using STDIN for words.\n");
		fp = stdin;
	} else {
		fp = fopen(opt->dictfile, "r");
		if (fp == NULL) {
			perror("fopen");
			exit(-1);
		}
	}


	while (feof(fp) == 0 && sig == 0) {

		/* Populate "passphrase" with the next word */
		fret = nextdictword(passphrase, fp);
		if (fret < 0) {
			break;
		}

		if (opt->verbose > 1) {
			printf("Testing passphrase: %s\n", passphrase);
		}

		/*
		 * Test length of word.  IEEE 802.11i indicates the passphrase
		 * must be at least 8 characters in length, and no more than 63 
		 * characters in length. 
		 */
		if (fret < 8 || fret > 63) {
			if (opt->verbose) {
				printf("Invalid passphrase length: %s (%d).\n",
				       passphrase, strlen(passphrase));
			}
			continue;
		} else {
			/* This word is good, increment the words tested
			counter */
			wordstested++;
		}

		/* Status display */
#ifdef FPGA
		if ((wordstested % 100) == 0) {
#else
		if ((wordstested % 1000) == 0) {
#endif
			printf("key no. %ld: %s\n", wordstested, passphrase);
			fflush(stdout);
		}

		if (opt->verbose > 1) {
			printf("Calculating PMK for \"%s\".\n", passphrase);
		}
		
		pbkdf2_sha1(passphrase, opt->ssid, strlen(opt->ssid), 4096,
			    pmk, sizeof(pmk), USECACHED);

#ifdef FPGA
		if (!usefpga) {
#endif
		if (opt->verbose > 2) {
			printf("PMK is");
			lamont_hdump(pmk, sizeof(pmk));
		}

		if (opt->verbose > 1) {
			printf("Calculating PTK with collected data and "
			       "PMK.\n");
		}

#ifdef FPGA
/*
		for(i = 0; i < 32; i++)
			printf("%02x ", pmk[i]);
		printf("\n");
*/
#endif

		wpa_pmk_to_ptk(pmk, cdata->aa, cdata->spa, cdata->anonce,
			       cdata->snonce, ptk, sizeof(ptk));

		if (opt->verbose > 2) {
			printf("Calculated PTK for \"%s\" is", passphrase);
			lamont_hdump(ptk, sizeof(ptk));
		}

		ptkset = (struct wpa_ptk *)ptk;

		if (opt->verbose > 1) {
			printf("Calculating hmac-MD5 Key MIC for this "
			       "frame.\n");
		}

		hmac_md5(ptkset->mic_key, 16, cdata->eapolframe,
			 sizeof(cdata->eapolframe), keymic);

		if (opt->verbose > 2) {
			printf("Calculated MIC with \"%s\" is", passphrase);
			lamont_hdump(keymic, sizeof(keymic));
		}

		if (memcmp(&cdata->keymic, &keymic, sizeof(keymic)) == 0) {
			return 0;
		} else {
			continue;
		}
#ifdef FPGA
		}
#endif
	}

#ifdef FPGA
	if(usefpga) {	
		printf("waiting..."); fflush(stdout);
		finishreg();
		printf("\ndone\n");
	}
#endif

	return 1;
}

int main(int argc, char **argv)
{
	struct user_opt opt;
	struct crack_data cdata;
	struct capture_data capdata;
	struct wpa_eapol_key *eapkeypacket;
	u8 eapolkey_nomic[99];
	struct timeval start, end;
	int ret;
	char passphrase[MAXPASSLEN + 1];

	printf("%s %s - WPA-PSK dictionary attack. <*****@*****.**>\n",
	       PROGNAME, VER);

	memset(&opt, 0, sizeof(struct user_opt));
	memset(&capdata, 0, sizeof(struct capture_data));
	memset(&cdata, 0, sizeof(struct crack_data));
	memset(&eapolkey_nomic, 0, sizeof(eapolkey_nomic));

	/* Collect and test command-line arguments */
	parseopts(&opt, argc, argv);
	testopts(&opt);
	printf("\n");

	/* Populate capdata struct */
	strncpy(capdata.pcapfilename, opt.pcapfile,
		sizeof(capdata.pcapfilename));
	if (openpcap(&capdata) != 0) {
		printf("Unsupported or unrecognized pcap file.\n");
		exit(1);
	}

	/* populates global *packet */
	while (getpacket(&capdata) > 0) {
		if (opt.verbose > 2) {
			lamont_hdump(packet, h->len);
		}
		/* test packet for data that we are looking for */
		if (memcmp(&packet[capdata.l2type_offset], DOT1X_LLCTYPE, 2) ==
		    0 && (h->len >
			capdata.l2type_offset + sizeof(struct wpa_eapol_key))) {
			/* It's a dot1x frame, process it */
			handle_dot1x(&cdata, &capdata);
			if (cdata.aaset && cdata.spaset && cdata.snonceset &&
			    cdata.anonceset && cdata.keymicset
			    && cdata.eapolframeset) {
				/* We've collected everything we need. */
				break;
			}
		}
	}

	closepcap(&capdata);

	if (!(cdata.aaset && cdata.spaset && cdata.snonceset &&
	      cdata.anonceset && cdata.keymicset && cdata.eapolframeset)) {
		printf("End of pcap capture file, incomplete TKIP four-way "
		       "exchange.  Try using a\ndifferent capture.\n");
		exit(1);
	} else {
		printf("Collected all necessary data to mount crack against "
		       "passphrase.\n");
	}

	if (opt.verbose > 1) {
		dump_all_fields(cdata);
	}

	/* Zero mic and length data for hmac-md5 calculation */
	eapkeypacket =
	    (struct wpa_eapol_key *)&cdata.eapolframe[EAPDOT1XOFFSET];
	memset(&eapkeypacket->key_mic, 0, sizeof(eapkeypacket->key_mic));
	eapkeypacket->key_data_length = 0;

	printf("Starting dictionary attack.  Please be patient.\n");
	fflush(stdout);

//	signal(SIGINT, cleanup);
//	signal(SIGTERM, cleanup);
//	signal(SIGQUIT, cleanup);

	gettimeofday(&start, NULL);
#ifdef FPGA
	start_g = start;
#endif

	if (!IsBlank(opt.hashfile)) {
		ret = hashfile_attack(&opt, passphrase, &cdata);
	} else if (!IsBlank(opt.dictfile)) {
		ret = dictfile_attack(&opt, passphrase, &cdata);
	} else {
		usage("Must specify dictfile or hashfile (-f or -d)");
		exit(1);
	}

	if (ret == 0) {
		printf("\nThe PSK is \"%s\".\n", passphrase);
	} else {
		printf("Unable to identify the PSK from the dictionary file. " 
	       		"Try expanding your\npassphrase list, and double-check"
		        " the SSID.  Sorry it didn't work out.\n");
	}

	gettimeofday(&end, NULL);
	printstats(start, end, wordstested);
	return (1);
}
Exemple #30
0
/*
 * Main entry point
 */
int main(int argc, char *argv[]) {
    p = parseopts(argc, argv);

    if (p == INVALID_PARAMETER) {
        usage(EXIT_FAILURE);
    }

    int num_params = parseinput(argc, argv);

    if (num_params == 0) {
        usage(EXIT_FAILURE);
    }

    // Everything should be okay from here on

    double sigma = MODEL_PARAMS[s].sigma;
    double epsilon = MODEL_PARAMS[s].epsilon;
    double m = MODEL_PARAMS[s].m;
    double r = MODEL_PARAMS[s].r_nn;

    if (p == OMEGA || p == GAMMA) {
        vec3 dq = { 0, 0, 0 };

        if (num_params == 2) {
            dq[X] = (q2[X] - q1[X])/(npoints - 1);
            dq[Y] = (q2[Y] - q1[Y])/(npoints - 1);
            dq[Z] = (q2[Z] - q1[Z])/(npoints - 1);
        }

        if (p == OMEGA) {
            vec3 omega;
            double a = A(epsilon, sigma, r);
            double b = B(epsilon, sigma, r);

            if (num_params == 1) {
                frequencies(a, b, m, q1, omega, NULL);
                print_result(q1, omega);
            }

            else if (num_params == 2) {
                for (int i = 0; i < npoints; i++) {
                    frequencies(a, b, m, q1, omega, NULL);
                    print_result(q1, omega);
                    q1[X] += dq[X];
                    q1[Y] += dq[Y];
                    q1[Z] += dq[Z];
                }
            }

        }

        else { // Gamma
            vec3 gamma;
            double delta = 1e-20;

            if (num_params == 1) {
                calc_gamma(gamma, q1, delta, r, sigma, epsilon, m);
                print_result(q1, gamma);
            }

            else if (num_params == 2) {
                for (int i = 0; i < npoints; i++) {
                    calc_gamma(gamma, q1, delta, r, sigma, epsilon, m);
                    print_result(q1, gamma);
                    q1[X] += dq[X];
                    q1[Y] += dq[Y];
                    q1[Z] += dq[Z];
                }
            }
        }
    }

    else { // Cv
        double cv;

        if (num_params == 1) {
            cv = calc_cv(t1, r, sigma, epsilon, m);
            printf("%g %g\n", t1, cv);
        }

        else if (num_params == 2) {
            double dt = (t2 - t1)/(npoints - 1);

            for (int i = 0; i < npoints; i++) {
                cv = calc_cv(t1, r, sigma, epsilon, m);
                printf("%g %g\n", t1, cv);
                t1 += dt;
            }
        }
    }

    return 0;
}