Package org.owasp.passfault

Examples of org.owasp.passfault.PasswordPattern


      if (ithPatterns != null) {
        PathCost pathCost = ithSmallestCost(ithPatterns);
        counter++;

        //random characters between startChar and the next found pattern
        PasswordPattern randomPattern = getRandomPattern(startChar, i);

        if (randomPattern != null) {
          pathCost.addPattern(randomPattern);
        }
        if (pathCost.getRelativeCost() < smallestCost) {
          smallestCost = pathCost.getRelativeCost();
          smallestCostPath = pathCost;
        }
      }
    }
    if (smallestCostPath.getPath().size() == 0) {
      PasswordPattern randomPattern = getRandomPattern(startChar, password.length());
      if (randomPattern != null) {
        smallestCostPath.addPattern(randomPattern);
      }
    }
    return smallestCostPath;
View Full Code Here


      //report every sequence from the first type to the current index
      for(int i=start; i <= start + countOfType - threshold; i++){
        CharSequence chars = pass.getCharSequence().subSequence(i, currentIndex+1);
        double size = Math.pow(type.getSize(),  countOfType);
       
        PasswordPattern pattern = new PasswordPattern(
            i, chars.length(), chars, size,
            "Random Characters with:" + type.name(), RandomPattern.RANDOM_PATTERN, type.name());
        pass.foundPattern(pattern);
      }
    }
View Full Code Here

        int start = matcher.start();
        int end = matcher.end();
        int length = end-start;
        CharSequence matchString = chars.subSequence(start, end);

        pass.foundPattern(new PasswordPattern(
            start, length, matchString, dateSize, "Date Format", DATE_PATTERN, null));
      }
    } while (found);
  }
View Full Code Here

  public PathCost process(PathCost cost, PasswordResults password) {
    PathCost newPath = new PathCost(password);
    List<PasswordPattern> path = cost.getPath();
    for (int len = path.size() - 1, i = len; i >= 0; i--) {
      PasswordPattern pass = path.get(i);
      boolean foundDuplicate = false;
      for (int j = i - 1; j >= 0; j--) {
        PasswordPattern toCompare = path.get(j);
        if (!toCompare.getName().equals(RandomPattern.RANDOM_PATTERN)
            && toCompare.getName().equals(pass.getName())
            && toCompare.getMatchString().equals(pass.getMatchString())) {
          //repeated-duplicate pattern instance
          foundDuplicate = true;
          break;
        }
      }
      if (foundDuplicate) {
        PasswordPattern dupp = new PasswordPattern(pass.getStartIndex(), pass.getLength(), pass.getMatchString(), 1,
            "Duplication of an earlier pattern: " + pass.getName(), DUPLICATE_PATTERN, null);
        newPath.addPattern(dupp);
      } else {
        newPath.addPattern(pass);
      }
View Full Code Here

      patternSize *= 2//two possibilities, all upper, or all lower
    }
    CharSequence passString;
    passString = pass.getCharSequence().subSequence(start, length + start);
    pass.foundPattern(
        new PasswordPattern(start, length, passString,
        patternSize, pattern.toString(), patternName, keys.getName()));
  }
View Full Code Here

  }
 
  @Test
  public void onePattern_Middle() {
    PasswordAnalysis_Unoptimized pa = new PasswordAnalysis_Unoptimized("1234");
    pa.foundPattern(new PasswordPattern(1, 2, "23", 4, "testPattern"));
   
    PathCost patterns = pa.calculateHighestProbablePatterns();
   
    List<PasswordPattern> list = patterns.getPath();
    assertEquals(3, list.size());
View Full Code Here

  }

  @Test
  public void onePattern_End() {
    PasswordAnalysis_Unoptimized pa = new PasswordAnalysis_Unoptimized("1234");
    pa.foundPattern(new PasswordPattern(2, 2, "34", 4, "testPattern"));
   
    PathCost patterns = pa.calculateHighestProbablePatterns();
   
    List<PasswordPattern> list = patterns.getPath();
    assertEquals(2, list.size());
View Full Code Here

 

  @Test
  public void onePattern_beginning() {
    PasswordAnalysis_Unoptimized pa = new PasswordAnalysis_Unoptimized("1234");
    pa.foundPattern(new PasswordPattern(0, 2, "12", 4, "testPattern"));
   
    PathCost patterns = pa.calculateHighestProbablePatterns();
   
    List<PasswordPattern> list = patterns.getPath();
    assertEquals(2, list.size());
View Full Code Here

  }
 
  @Test
  public void twoPattern_middle() {
    PasswordAnalysis_Unoptimized pa = new PasswordAnalysis_Unoptimized("12345");
    pa.foundPattern(new PasswordPattern(1, 1, "2", 2, "testPattern"));
    pa.foundPattern(new PasswordPattern(3, 1, "4", 2, "testPattern"));
   
    PathCost patterns = pa.calculateHighestProbablePatterns();
   
    List<PasswordPattern> list = patterns.getPath();
    assertEquals(5, list.size());
View Full Code Here

  }

  @Test
  public void onePattern_overlap(){
    PasswordAnalysis_Unoptimized pa = new PasswordAnalysis_Unoptimized("12345");
    pa.foundPattern(new PasswordPattern(1, 2, "23", 15, "worstPattern"));
    pa.foundPattern(new PasswordPattern(1, 2, "23", 4, "bestPattern"));
    pa.foundPattern(new PasswordPattern(1, 2, "23", 20, "worsePattern"));
    pa.foundPattern(new PasswordPattern(1, 2, "23", 23, "worserPattern"));
   
    PathCost patterns = pa.calculateHighestProbablePatterns();
   
    List<PasswordPattern> list = patterns.getPath();
    assertEquals(3, list.size());
View Full Code Here

TOP

Related Classes of org.owasp.passfault.PasswordPattern

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.