Esempio n. 1
0
int main(int argc, char **argv) {
	char Buf[256], *cps, *cph;

	Setup();
	ParseOptions(argc, argv);
	if (simple_to_from_hex)
		return simple_convert();

	// if no input redirection then give usage. I 'guess' we could allow
	// a user to type in hashes, but is that really likely?  It is almost
	// certain that if there is no input redirection, the user does not
	// know how to use the tool, so tell him how.
	if (isatty(fileno(stdin)))
		usage(argv[0]);

	FGETS(Buf, sizeof(Buf), stdin);
	while (!feof(stdin)) {
		strtok(Buf, "\r\n");
		if (!leading_salt) {
			cph = Buf;
			cps = &Buf[hash_len];
			if (salt_sep && *cps == salt_sep) ++cps;
		} else {
			cps = Buf;
			cph = &Buf[leading_salt];
			if (salt_sep && *cph == salt_sep) {*cph++ = 0;}
		}
		printf("$dynamic_%d$%*.*s$%s\n", dyna_num, hash_len,hash_len, cph, GetSalt(cps));
		FGETS(Buf, sizeof(Buf), stdin);
	}
	MEMDBG_PROGRAM_EXIT_CHECKS(stderr);
	return 0;
}
Esempio n. 2
0
int main(int argc, char **argv) {
	char Buf[256], *cps, *cph, *dummy;

	// if no input redirection then give usage. I 'guess' we could allow
	// a user to type in hashes, but is that really likely?  It is almost
	// certain that if there is no input redirection, the user does not
	// know how to use the tool, so tell him how.
	if (isatty(fileno(stdin)))
		usage(argv[0]);

	ParseOptions(argc, argv);
	dummy = fgets(Buf, sizeof(Buf), stdin);
	while (!feof(stdin)) {
		strtok(Buf, "\r\n");
		if (!leading_salt) {
			cph = Buf;
			cps = &Buf[32];
			if (salt_sep && *cps == salt_sep) ++cps;
		} else {
			cps = Buf;
			cph = &Buf[leading_salt];
			if (salt_sep && *cph == salt_sep) {*cph++ = 0;}
		}
		printf("$dynamic_%d$%32.32s$%s\n", dyna_num, cph, GetSalt(cps));
		dummy = fgets(Buf, sizeof(Buf), stdin);
	}
	(void) dummy;
	return 0;
}
Esempio n. 3
0
// return 0 on success
unsigned int CNetServer::ValidatePass(unsigned int client)
{
  int nRes;
  unsigned int nSize;
  char * szLogin;
  char * szPass;
  char * szSalt;

// receive login 
  nRes = Recv(client, &nSize, sizeof(unsigned int)); 
  szLogin = (char *) malloc (nSize);
  nRes = Recv(client, szLogin, nSize); 

  showDebug(2, "client %d is %s\n", client, szLogin);

  szSalt = GetSalt(szLogin);
  if (!szSalt)
    szSalt = strdup("");
  nSize = strlen(szSalt)+1;

  nRes = Send(client, &nSize, sizeof(unsigned int));
  nRes = Send(client, szSalt, nSize);

// receive password
  nRes = Recv(client, &nSize, sizeof(unsigned int)); 
  szPass = (char *) malloc (nSize);
  nRes = Recv(client, szPass, nSize); 

  nRes = CheckAccess(g_bMustLogin, szLogin, szPass);
  showDebug(1, "return of checkaccess: %d\n", nRes);
  if (nRes)
    {
      Send(client, "nack", 5);
      Release(client);
    }
  else
    Send(client, " ack", 5);

  free(szPass);
  szPass = NULL;
  free(szLogin);
  szLogin = NULL;
  free(szSalt);
  szSalt = NULL;
  return nRes;
}