Ejemplo n.º 1
0
/****************************************************************************
apply a function to upper/lower case combinations
of a string and return true if one of them returns true.
try all combinations with up to N uppercase letters.
offset is the first char to try and change (start with 0)
it assumes the string starts lowercased
****************************************************************************/
static BOOL string_combinations(char *s,BOOL (*fn)(char *),int N)
{
  int n;
  for (n=1;n<=N;n++)
    if (string_combinations2(s,0,fn,n)) return(True);
  return(False);
}
Ejemplo n.º 2
0
/****************************************************************************
apply a function to upper/lower case combinations
of a string and return true if one of them returns true.
try all combinations with N uppercase letters.
offset is the first char to try and change (start with 0)
it assumes the string starts lowercased
****************************************************************************/
static NTSTATUS string_combinations2(char *s, int offset, NTSTATUS (*fn) (const char *),
				 int N)
{
	int len = strlen(s);
	int i;
	NTSTATUS nt_status;

#ifdef PASSWORD_LENGTH
	len = MIN(len, PASSWORD_LENGTH);
#endif

	if (N <= 0 || offset >= len)
		return (fn(s));

	for (i = offset; i < (len - (N - 1)); i++) {
		char c = s[i];
		if (!islower(c))
			continue;
		s[i] = toupper(c);
		if (!NT_STATUS_EQUAL(nt_status = string_combinations2(s, i + 1, fn, N - 1),NT_STATUS_WRONG_PASSWORD)) {
			return (nt_status);
		}
		s[i] = c;
	}
	return (NT_STATUS_WRONG_PASSWORD);
}
Ejemplo n.º 3
0
/****************************************************************************
apply a function to upper/lower case combinations
of a string and return true if one of them returns true.
try all combinations with up to N uppercase letters.
offset is the first char to try and change (start with 0)
it assumes the string starts lowercased
****************************************************************************/
static NTSTATUS string_combinations(char *s, NTSTATUS (*fn) (const char *), int N)
{
	int n;
	NTSTATUS nt_status;
	for (n = 1; n <= N; n++)
		if (!NT_STATUS_EQUAL(nt_status = string_combinations2(s, 0, fn, n), NT_STATUS_WRONG_PASSWORD))
			return nt_status;
	return NT_STATUS_WRONG_PASSWORD;
}
Ejemplo n.º 4
0
/****************************************************************************
apply a function to upper/lower case combinations
of a string and return true if one of them returns true.
try all combinations with N uppercase letters.
offset is the first char to try and change (start with 0)
it assumes the string starts lowercased
****************************************************************************/
static BOOL string_combinations2(char *s,int offset,BOOL (*fn)(char *),int N)
{
  int len = strlen(s);
  int i;

#ifdef PASSWORD_LENGTH
  len = MIN(len,PASSWORD_LENGTH);
#endif

  if (N <= 0 || offset >= len)
    return(fn(s));

  for (i=offset;i<(len-(N-1));i++)
    {      
      char c = s[i];
      if (!islower(c)) continue;
      s[i] = toupper(c);
      if (string_combinations2(s,i+1,fn,N-1))
	return(True);
      s[i] = c;
    }
  return(False);
}