commit
a22cb81b2e
|
@ -13,9 +13,9 @@ const (
|
||||||
START_UPPER string = `^[A-Z][^A-Z]+$`
|
START_UPPER string = `^[A-Z][^A-Z]+$`
|
||||||
END_UPPER string = `^[^A-Z]+[A-Z]$'`
|
END_UPPER string = `^[^A-Z]+[A-Z]$'`
|
||||||
ALL_UPPER string = `^[A-Z]+$`
|
ALL_UPPER string = `^[A-Z]+$`
|
||||||
NUM_YEARS = float64(119) // years match against 1900 - 2019
|
NUM_YEARS = float64(119) // years match against 1900 - 2019
|
||||||
NUM_MONTHS = float64(12)
|
NUM_MONTHS = float64(12)
|
||||||
NUM_DAYS = float64(31)
|
NUM_DAYS = float64(31)
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
package entropy
|
package entropy
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/stretchr/testify/assert"
|
|
||||||
"github.com/nbutton23/zxcvbn-go/match"
|
"github.com/nbutton23/zxcvbn-go/match"
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
func TestDictionaryEntropyCalculation(t *testing.T) {
|
func TestDictionaryEntropyCalculation(t *testing.T) {
|
||||||
match := match.Match{
|
match := match.Match{
|
||||||
Pattern: "dictionary",
|
Pattern: "dictionary",
|
||||||
|
@ -22,31 +21,31 @@ func TestDictionaryEntropyCalculation(t *testing.T) {
|
||||||
|
|
||||||
func TestSpatialEntropyCalculation(t *testing.T) {
|
func TestSpatialEntropyCalculation(t *testing.T) {
|
||||||
matchPlain := match.Match{
|
matchPlain := match.Match{
|
||||||
Pattern: "spatial",
|
Pattern: "spatial",
|
||||||
I: 0,
|
I: 0,
|
||||||
J: 5,
|
J: 5,
|
||||||
Token: "asdfgh",
|
Token: "asdfgh",
|
||||||
DictionaryName:"qwerty",
|
DictionaryName: "qwerty",
|
||||||
}
|
}
|
||||||
entropy := SpatialEntropy(matchPlain, 0, 0)
|
entropy := SpatialEntropy(matchPlain, 0, 0)
|
||||||
assert.Equal(t, 9.754887502163468, entropy)
|
assert.Equal(t, 9.754887502163468, entropy)
|
||||||
|
|
||||||
matchShift := match.Match{
|
matchShift := match.Match{
|
||||||
Pattern: "spatial",
|
Pattern: "spatial",
|
||||||
I: 0,
|
I: 0,
|
||||||
J: 5,
|
J: 5,
|
||||||
Token: "asdFgh",
|
Token: "asdFgh",
|
||||||
DictionaryName:"qwerty",
|
DictionaryName: "qwerty",
|
||||||
}
|
}
|
||||||
entropyShift := SpatialEntropy(matchShift, 0, 1)
|
entropyShift := SpatialEntropy(matchShift, 0, 1)
|
||||||
assert.Equal(t, 12.562242424221072, entropyShift)
|
assert.Equal(t, 12.562242424221072, entropyShift)
|
||||||
|
|
||||||
matchTurn := match.Match{
|
matchTurn := match.Match{
|
||||||
Pattern: "spatial",
|
Pattern: "spatial",
|
||||||
I: 0,
|
I: 0,
|
||||||
J: 5,
|
J: 5,
|
||||||
Token: "asdcxz",
|
Token: "asdcxz",
|
||||||
DictionaryName:"qwerty",
|
DictionaryName: "qwerty",
|
||||||
}
|
}
|
||||||
entropyTurn := SpatialEntropy(matchTurn, 2, 0)
|
entropyTurn := SpatialEntropy(matchTurn, 2, 0)
|
||||||
assert.Equal(t, 14.080500893768884, entropyTurn)
|
assert.Equal(t, 14.080500893768884, entropyTurn)
|
||||||
|
|
|
@ -1,15 +1,13 @@
|
||||||
package matching
|
package matching
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/nbutton23/zxcvbn-go/entropy"
|
||||||
"github.com/nbutton23/zxcvbn-go/match"
|
"github.com/nbutton23/zxcvbn-go/match"
|
||||||
"strings"
|
|
||||||
"regexp"
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
"github.com/nbutton23/zxcvbn-go/entropy"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func checkDate(day, month, year int64) (bool, int64, int64, int64) {
|
func checkDate(day, month, year int64) (bool, int64, int64, int64) {
|
||||||
if (12 <= month && month <= 31) && day <= 12 {
|
if (12 <= month && month <= 31) && day <= 12 {
|
||||||
day, month = month, day
|
day, month = month, day
|
||||||
|
@ -31,11 +29,11 @@ func dateSepMatcher(password string) []match.Match {
|
||||||
var matches []match.Match
|
var matches []match.Match
|
||||||
for _, dateMatch := range dateMatches {
|
for _, dateMatch := range dateMatches {
|
||||||
match := match.Match{
|
match := match.Match{
|
||||||
I:dateMatch.I,
|
I: dateMatch.I,
|
||||||
J:dateMatch.J,
|
J: dateMatch.J,
|
||||||
Entropy:entropy.DateEntropy(dateMatch),
|
Entropy: entropy.DateEntropy(dateMatch),
|
||||||
DictionaryName:"date_match",
|
DictionaryName: "date_match",
|
||||||
Token:dateMatch.Token,
|
Token: dateMatch.Token,
|
||||||
}
|
}
|
||||||
|
|
||||||
matches = append(matches, match)
|
matches = append(matches, match)
|
||||||
|
@ -55,7 +53,7 @@ func dateSepMatchHelper(password string) []match.DateMatch {
|
||||||
day, _ := strconv.ParseInt(splitV[0][4], 10, 16)
|
day, _ := strconv.ParseInt(splitV[0][4], 10, 16)
|
||||||
month, _ := strconv.ParseInt(splitV[0][2], 10, 16)
|
month, _ := strconv.ParseInt(splitV[0][2], 10, 16)
|
||||||
year, _ := strconv.ParseInt(splitV[0][6], 10, 16)
|
year, _ := strconv.ParseInt(splitV[0][6], 10, 16)
|
||||||
match := match.DateMatch{Day: day, Month: month, Year: year, Separator: splitV[0][5], I: i, J: j, Token:password[i:j]}
|
match := match.DateMatch{Day: day, Month: month, Year: year, Separator: splitV[0][5], I: i, J: j, Token: password[i:j]}
|
||||||
matches = append(matches, match)
|
matches = append(matches, match)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,7 +65,7 @@ func dateSepMatchHelper(password string) []match.DateMatch {
|
||||||
day, _ := strconv.ParseInt(splitV[0][4], 10, 16)
|
day, _ := strconv.ParseInt(splitV[0][4], 10, 16)
|
||||||
month, _ := strconv.ParseInt(splitV[0][6], 10, 16)
|
month, _ := strconv.ParseInt(splitV[0][6], 10, 16)
|
||||||
year, _ := strconv.ParseInt(splitV[0][2], 10, 16)
|
year, _ := strconv.ParseInt(splitV[0][2], 10, 16)
|
||||||
match := match.DateMatch{Day: day, Month: month, Year: year, Separator: splitV[0][5], I: i, J: j, Token:password[i:j]}
|
match := match.DateMatch{Day: day, Month: month, Year: year, Separator: splitV[0][5], I: i, J: j, Token: password[i:j]}
|
||||||
matches = append(matches, match)
|
matches = append(matches, match)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,22 +90,23 @@ type DateMatchCandidate struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type DateMatchCandidateTwo struct {
|
type DateMatchCandidateTwo struct {
|
||||||
Day string
|
Day string
|
||||||
Month string
|
Month string
|
||||||
Year string
|
Year string
|
||||||
I, J int
|
I, J int
|
||||||
}
|
}
|
||||||
func dateWithoutSepMatch(password string) ([]match.Match) {
|
|
||||||
|
func dateWithoutSepMatch(password string) []match.Match {
|
||||||
dateMatches := dateWithoutSepMatchHelper(password)
|
dateMatches := dateWithoutSepMatchHelper(password)
|
||||||
|
|
||||||
var matches []match.Match
|
var matches []match.Match
|
||||||
for _, dateMatch := range dateMatches {
|
for _, dateMatch := range dateMatches {
|
||||||
match := match.Match{
|
match := match.Match{
|
||||||
I:dateMatch.I,
|
I: dateMatch.I,
|
||||||
J:dateMatch.J,
|
J: dateMatch.J,
|
||||||
Entropy:entropy.DateEntropy(dateMatch),
|
Entropy: entropy.DateEntropy(dateMatch),
|
||||||
DictionaryName:"date_match",
|
DictionaryName: "date_match",
|
||||||
Token:dateMatch.Token,
|
Token: dateMatch.Token,
|
||||||
}
|
}
|
||||||
|
|
||||||
matches = append(matches, match)
|
matches = append(matches, match)
|
||||||
|
@ -115,6 +114,7 @@ func dateWithoutSepMatch(password string) ([]match.Match) {
|
||||||
|
|
||||||
return matches
|
return matches
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO Has issues with 6 digit dates
|
//TODO Has issues with 6 digit dates
|
||||||
func dateWithoutSepMatchHelper(password string) (matches []match.DateMatch) {
|
func dateWithoutSepMatchHelper(password string) (matches []match.DateMatch) {
|
||||||
matcher := regexp.MustCompile(DATE_WITHOUT_SEP_MATCH)
|
matcher := regexp.MustCompile(DATE_WITHOUT_SEP_MATCH)
|
||||||
|
@ -140,16 +140,15 @@ func dateWithoutSepMatchHelper(password string) (matches []match.DateMatch) {
|
||||||
candidatesRoundOne = append(candidatesRoundOne, buildDateMatchCandidate(v[0:lastIndex-3], v[lastIndex-3:], i, j))
|
candidatesRoundOne = append(candidatesRoundOne, buildDateMatchCandidate(v[0:lastIndex-3], v[lastIndex-3:], i, j))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
var candidatesRoundTwo []DateMatchCandidateTwo
|
var candidatesRoundTwo []DateMatchCandidateTwo
|
||||||
for _, c := range candidatesRoundOne {
|
for _, c := range candidatesRoundOne {
|
||||||
if len(c.DayMonth) == 2 {
|
if len(c.DayMonth) == 2 {
|
||||||
candidatesRoundTwo = append(candidatesRoundTwo, buildDateMatchCandidateTwo(c.DayMonth[0:0], c.DayMonth[1:1], c.Year, c.I, c.J))
|
candidatesRoundTwo = append(candidatesRoundTwo, buildDateMatchCandidateTwo(c.DayMonth[0:0], c.DayMonth[1:1], c.Year, c.I, c.J))
|
||||||
} else if len(c.DayMonth) == 3 {
|
} else if len(c.DayMonth) == 3 {
|
||||||
candidatesRoundTwo = append(candidatesRoundTwo, buildDateMatchCandidateTwo(c.DayMonth[0:2],c.DayMonth[2:2], c.Year, c.I, c.J))
|
candidatesRoundTwo = append(candidatesRoundTwo, buildDateMatchCandidateTwo(c.DayMonth[0:2], c.DayMonth[2:2], c.Year, c.I, c.J))
|
||||||
candidatesRoundTwo = append(candidatesRoundTwo, buildDateMatchCandidateTwo(c.DayMonth[0:0],c.DayMonth[1:3], c.Year, c.I, c.J))
|
candidatesRoundTwo = append(candidatesRoundTwo, buildDateMatchCandidateTwo(c.DayMonth[0:0], c.DayMonth[1:3], c.Year, c.I, c.J))
|
||||||
} else if len(c.DayMonth) == 4 {
|
} else if len(c.DayMonth) == 4 {
|
||||||
candidatesRoundTwo = append(candidatesRoundTwo, buildDateMatchCandidateTwo(c.DayMonth[0:2],c.DayMonth[2:4], c.Year, c.I, c.J))
|
candidatesRoundTwo = append(candidatesRoundTwo, buildDateMatchCandidateTwo(c.DayMonth[0:2], c.DayMonth[2:4], c.Year, c.I, c.J))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,21 +158,19 @@ func dateWithoutSepMatchHelper(password string) (matches []match.DateMatch) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
intMonth, err := strconv.ParseInt(candidate.Month, 10, 16)
|
intMonth, err := strconv.ParseInt(candidate.Month, 10, 16)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
intYear, err := strconv.ParseInt(candidate.Year, 10, 16)
|
intYear, err := strconv.ParseInt(candidate.Year, 10, 16)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if ok, _, _, _:= checkDate(intDay, intMonth, intYear); ok{
|
if ok, _, _, _ := checkDate(intDay, intMonth, intYear); ok {
|
||||||
matches = append(matches, match.DateMatch{Token:password, Pattern:"date", Day:intDay, Month:intMonth, Year:intYear, I:i, J:j })
|
matches = append(matches, match.DateMatch{Token: password, Pattern: "date", Day: intDay, Month: intMonth, Year: intYear, I: i, J: j})
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package matching
|
package matching
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/nbutton23/zxcvbn-go/match"
|
|
||||||
"github.com/nbutton23/zxcvbn-go/entropy"
|
"github.com/nbutton23/zxcvbn-go/entropy"
|
||||||
|
"github.com/nbutton23/zxcvbn-go/match"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
package matching
|
package matching
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/nbutton23/zxcvbn-go/match"
|
|
||||||
"github.com/nbutton23/zxcvbn-go/entropy"
|
"github.com/nbutton23/zxcvbn-go/entropy"
|
||||||
|
"github.com/nbutton23/zxcvbn-go/match"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
func l33tMatch(password string) []match.Match {
|
func l33tMatch(password string) []match.Match {
|
||||||
|
|
||||||
substitutions := relevantL33tSubtable(password)
|
substitutions := relevantL33tSubtable(password)
|
||||||
|
@ -16,7 +16,7 @@ func l33tMatch(password string) []match.Match {
|
||||||
|
|
||||||
for _, permutation := range permutations {
|
for _, permutation := range permutations {
|
||||||
for _, mather := range DICTIONARY_MATCHERS {
|
for _, mather := range DICTIONARY_MATCHERS {
|
||||||
matches = append(matches,mather(permutation)...)
|
matches = append(matches, mather(permutation)...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,13 +37,13 @@ func getAllPermutationsOfLeetSubstitutions(password string, substitutionsMap map
|
||||||
for _, sub := range splice {
|
for _, sub := range splice {
|
||||||
if string(char) == sub {
|
if string(char) == sub {
|
||||||
var permutation string
|
var permutation string
|
||||||
permutation = password[:index]+value+password[index+1:]
|
permutation = password[:index] + value + password[index+1:]
|
||||||
|
|
||||||
permutations = append(permutations, permutation)
|
permutations = append(permutations, permutation)
|
||||||
if index < len(permutation) {
|
if index < len(permutation) {
|
||||||
tempPermutations := getAllPermutationsOfLeetSubstitutions(permutation[index + 1:], substitutionsMap)
|
tempPermutations := getAllPermutationsOfLeetSubstitutions(permutation[index+1:], substitutionsMap)
|
||||||
for _, temp := range tempPermutations {
|
for _, temp := range tempPermutations {
|
||||||
permutations = append(permutations, permutation[:index + 1] + temp)
|
permutations = append(permutations, permutation[:index+1]+temp)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -65,4 +65,4 @@ func relevantL33tSubtable(password string) map[string][]string {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return relevantSubs
|
return relevantSubs
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,10 +8,10 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
DICTIONARY_MATCHERS []func(password string) []match.Match
|
DICTIONARY_MATCHERS []func(password string) []match.Match
|
||||||
MATCHERS []func(password string) []match.Match
|
MATCHERS []func(password string) []match.Match
|
||||||
ADJACENCY_GRAPHS []adjacency.AdjacencyGraph
|
ADJACENCY_GRAPHS []adjacency.AdjacencyGraph
|
||||||
L33T_TABLE adjacency.AdjacencyGraph
|
L33T_TABLE adjacency.AdjacencyGraph
|
||||||
|
|
||||||
SEQUENCES map[string]string
|
SEQUENCES map[string]string
|
||||||
)
|
)
|
||||||
|
@ -74,6 +74,4 @@ func loadFrequencyList() {
|
||||||
MATCHERS = append(MATCHERS, dateSepMatcher)
|
MATCHERS = append(MATCHERS, dateSepMatcher)
|
||||||
MATCHERS = append(MATCHERS, dateWithoutSepMatch)
|
MATCHERS = append(MATCHERS, dateWithoutSepMatch)
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
package matching
|
package matching
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/stretchr/testify/assert"
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
"github.com/nbutton23/zxcvbn-go/match"
|
"github.com/nbutton23/zxcvbn-go/match"
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
"log"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
"fmt"
|
|
||||||
"encoding/json"
|
|
||||||
"log"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
//DateSepMatch("1991-09-11jibjab11.9.1991")
|
//DateSepMatch("1991-09-11jibjab11.9.1991")
|
||||||
|
@ -123,18 +123,16 @@ func TestDateWithoutSepMatch(t *testing.T) {
|
||||||
matches := dateWithoutSepMatch("11091991")
|
matches := dateWithoutSepMatch("11091991")
|
||||||
assert.Len(t, matches, 1, "Lenght should be 1")
|
assert.Len(t, matches, 1, "Lenght should be 1")
|
||||||
|
|
||||||
|
|
||||||
matches = dateWithoutSepMatch("20010911")
|
matches = dateWithoutSepMatch("20010911")
|
||||||
assert.Len(t, matches, 1, "Lenght should be 1")
|
assert.Len(t, matches, 1, "Lenght should be 1")
|
||||||
log.Println(matches)
|
log.Println(matches)
|
||||||
|
|
||||||
|
|
||||||
//matches := dateWithoutSepMatch("110991")
|
//matches := dateWithoutSepMatch("110991")
|
||||||
//assert.Len(t, matches, 21, "Lenght should be blarg")
|
//assert.Len(t, matches, 21, "Lenght should be blarg")
|
||||||
}
|
}
|
||||||
|
|
||||||
//l33t
|
//l33t
|
||||||
func TestLeetSubTable(t *testing.T){
|
func TestLeetSubTable(t *testing.T) {
|
||||||
subs := relevantL33tSubtable("password")
|
subs := relevantL33tSubtable("password")
|
||||||
assert.Len(t, subs, 0, "password should produce no leet subs")
|
assert.Len(t, subs, 0, "password should produce no leet subs")
|
||||||
|
|
||||||
|
@ -146,42 +144,39 @@ func TestLeetSubTable(t *testing.T){
|
||||||
assert.Equal(t, subs["i"][0], "1")
|
assert.Equal(t, subs["i"][0], "1")
|
||||||
assert.Equal(t, subs["l"][0], "1")
|
assert.Equal(t, subs["l"][0], "1")
|
||||||
|
|
||||||
|
|
||||||
subs = relevantL33tSubtable("4pple@pple")
|
subs = relevantL33tSubtable("4pple@pple")
|
||||||
assert.Len(t, subs, 1, "4pple@pple should produce 1 subs")
|
assert.Len(t, subs, 1, "4pple@pple should produce 1 subs")
|
||||||
assert.Len(t, subs["a"], 2)
|
assert.Len(t, subs["a"], 2)
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestPermutationsOfLeetSubstitutions(t *testing.T){
|
func TestPermutationsOfLeetSubstitutions(t *testing.T) {
|
||||||
password := "p4ssw0rd" //[passw0rd, password, p4ssword]
|
password := "p4ssw0rd" //[passw0rd, password, p4ssword]
|
||||||
possibleSubs := relevantL33tSubtable(password)
|
possibleSubs := relevantL33tSubtable(password)
|
||||||
|
|
||||||
permutations := getAllPermutationsOfLeetSubstitutions(password, possibleSubs)
|
permutations := getAllPermutationsOfLeetSubstitutions(password, possibleSubs)
|
||||||
|
|
||||||
assert.Len(t, permutations, 3, "There should be 3 permutations for "+password)
|
assert.Len(t, permutations, 3, "There should be 3 permutations for "+password)
|
||||||
|
|
||||||
password = "p4$sw0rd" //[pa$sw0rd, passw0rd, password, pa$sword, p4ssw0rd, p4ssword, p4$sword]
|
password = "p4$sw0rd" //[pa$sw0rd, passw0rd, password, pa$sword, p4ssw0rd, p4ssword, p4$sword]
|
||||||
possibleSubs = relevantL33tSubtable(password)
|
possibleSubs = relevantL33tSubtable(password)
|
||||||
|
|
||||||
permutations = getAllPermutationsOfLeetSubstitutions(password, possibleSubs)
|
permutations = getAllPermutationsOfLeetSubstitutions(password, possibleSubs)
|
||||||
assert.Len(t, permutations, 7, "There should be 7 (? check my math) permutations for "+password)
|
assert.Len(t, permutations, 7, "There should be 7 (? check my math) permutations for "+password)
|
||||||
|
|
||||||
password = "p4$$w0rd" //[pa$sw0rd, passw0rd, password, pa$sword, p4ssw0rd, p4ssword, p4$sword]
|
password = "p4$$w0rd" //[pa$sw0rd, passw0rd, password, pa$sword, p4ssw0rd, p4ssword, p4$sword]
|
||||||
possibleSubs = relevantL33tSubtable(password)
|
possibleSubs = relevantL33tSubtable(password)
|
||||||
|
|
||||||
permutations = getAllPermutationsOfLeetSubstitutions(password, possibleSubs)
|
permutations = getAllPermutationsOfLeetSubstitutions(password, possibleSubs)
|
||||||
assert.Len(t, permutations, 15, "Check my math 2*2*2*2 - 1 "+password)
|
assert.Len(t, permutations, 15, "Check my math 2*2*2*2 - 1 "+password)
|
||||||
|
|
||||||
|
|
||||||
password = "1337"
|
password = "1337"
|
||||||
possibleSubs = relevantL33tSubtable(password)
|
possibleSubs = relevantL33tSubtable(password)
|
||||||
permutations = getAllPermutationsOfLeetSubstitutions(password, possibleSubs)
|
permutations = getAllPermutationsOfLeetSubstitutions(password, possibleSubs)
|
||||||
assert.Len(t, permutations, 35, "check my math 3*2*2*3 -1 ")
|
assert.Len(t, permutations, 35, "check my math 3*2*2*3 -1 ")
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestLeet(t *testing.T){
|
func TestLeet(t *testing.T) {
|
||||||
password := "1337"
|
password := "1337"
|
||||||
matches := l33tMatch(password)
|
matches := l33tMatch(password)
|
||||||
bytes, _ := json.Marshal(matches)
|
bytes, _ := json.Marshal(matches)
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
package matching
|
package matching
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/nbutton23/zxcvbn-go/match"
|
|
||||||
"github.com/nbutton23/zxcvbn-go/entropy"
|
"github.com/nbutton23/zxcvbn-go/entropy"
|
||||||
|
"github.com/nbutton23/zxcvbn-go/match"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
func repeatMatch(password string) []match.Match {
|
func repeatMatch(password string) []match.Match {
|
||||||
var matches []match.Match
|
var matches []match.Match
|
||||||
|
|
||||||
|
@ -57,4 +56,4 @@ func repeatMatch(password string) []match.Match {
|
||||||
matches = append(matches, matchRepeat)
|
matches = append(matches, matchRepeat)
|
||||||
}
|
}
|
||||||
return matches
|
return matches
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
package matching
|
package matching
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/nbutton23/zxcvbn-go/match"
|
|
||||||
"github.com/nbutton23/zxcvbn-go/entropy"
|
"github.com/nbutton23/zxcvbn-go/entropy"
|
||||||
|
"github.com/nbutton23/zxcvbn-go/match"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
func sequenceMatch(password string) []match.Match {
|
func sequenceMatch(password string) []match.Match {
|
||||||
var matches []match.Match
|
var matches []match.Match
|
||||||
for i := 0; i < len(password); {
|
for i := 0; i < len(password); {
|
||||||
|
@ -39,12 +38,12 @@ func sequenceMatch(password string) []match.Match {
|
||||||
for {
|
for {
|
||||||
var prevN, curN int
|
var prevN, curN int
|
||||||
if j < len(password) {
|
if j < len(password) {
|
||||||
prevChar, curChar := password[j - 1], password[j]
|
prevChar, curChar := password[j-1], password[j]
|
||||||
prevN, curN = strings.Index(seq, string(prevChar)), strings.Index(seq, string(curChar))
|
prevN, curN = strings.Index(seq, string(prevChar)), strings.Index(seq, string(curChar))
|
||||||
}
|
}
|
||||||
|
|
||||||
if j == len(password) || curN - prevN != seqDirection {
|
if j == len(password) || curN-prevN != seqDirection {
|
||||||
if j - i > 2 {
|
if j-i > 2 {
|
||||||
matchSequence := match.Match{
|
matchSequence := match.Match{
|
||||||
Pattern: "sequence",
|
Pattern: "sequence",
|
||||||
I: i,
|
I: i,
|
||||||
|
@ -66,4 +65,4 @@ func sequenceMatch(password string) []match.Match {
|
||||||
i = j
|
i = j
|
||||||
}
|
}
|
||||||
return matches
|
return matches
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
package matching
|
package matching
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/nbutton23/zxcvbn-go/match"
|
|
||||||
"github.com/nbutton23/zxcvbn-go/entropy"
|
|
||||||
"strings"
|
|
||||||
"github.com/nbutton23/zxcvbn-go/adjacency"
|
"github.com/nbutton23/zxcvbn-go/adjacency"
|
||||||
|
"github.com/nbutton23/zxcvbn-go/entropy"
|
||||||
|
"github.com/nbutton23/zxcvbn-go/match"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
func spatialMatch(password string) (matches []match.Match) {
|
func spatialMatch(password string) (matches []match.Match) {
|
||||||
|
@ -78,4 +78,3 @@ func spatialMatchHelper(password string, graph adjacency.AdjacencyGraph) (matche
|
||||||
}
|
}
|
||||||
return matches
|
return matches
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,8 +7,8 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
//password :="Testaaatyhg890l33t"
|
//password :="Testaaatyhg890l33t"
|
||||||
//fmt.Println(zxcvbn.PasswordStrength(password, nil))
|
//fmt.Println(zxcvbn.PasswordStrength(password, nil))
|
||||||
|
|
||||||
length := 5
|
length := 5
|
||||||
//pass := "68f9698fe2540c525fe35b15c6ae1a1788e079962b2ada3d1872c7665c95e148"
|
//pass := "68f9698fe2540c525fe35b15c6ae1a1788e079962b2ada3d1872c7665c95e148"
|
||||||
|
|
|
@ -7,7 +7,6 @@ import (
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
func PasswordStrength(password string, userInputs []string) scoring.MinEntropyMatch {
|
func PasswordStrength(password string, userInputs []string) scoring.MinEntropyMatch {
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
matches := matching.Omnimatch(password, userInputs)
|
matches := matching.Omnimatch(password, userInputs)
|
||||||
|
|
|
@ -28,7 +28,7 @@ var numTestRan int
|
||||||
|
|
||||||
func TestPasswordStrength(t *testing.T) {
|
func TestPasswordStrength(t *testing.T) {
|
||||||
|
|
||||||
// Expected calculated by running zxcvbn-python
|
// Expected calculated by running zxcvbn-python
|
||||||
runTest(t, "zxcvbn", float64(6.845490050944376))
|
runTest(t, "zxcvbn", float64(6.845490050944376))
|
||||||
runTest(t, "Tr0ub4dour&3", float64(17.296))
|
runTest(t, "Tr0ub4dour&3", float64(17.296))
|
||||||
runTest(t, "qwER43@!", float64(26.44))
|
runTest(t, "qwER43@!", float64(26.44))
|
||||||
|
@ -36,8 +36,8 @@ func TestPasswordStrength(t *testing.T) {
|
||||||
runTest(t, "coRrecth0rseba++ery9.23.2007staple$", float64(66.018))
|
runTest(t, "coRrecth0rseba++ery9.23.2007staple$", float64(66.018))
|
||||||
runTest(t, "D0g..................", float64(20.678))
|
runTest(t, "D0g..................", float64(20.678))
|
||||||
runTest(t, "abcdefghijk987654321", float64(11.951))
|
runTest(t, "abcdefghijk987654321", float64(11.951))
|
||||||
runTest(t, "neverforget", float64(2)) // I think this is wrong. . .
|
runTest(t, "neverforget", float64(2)) // I think this is wrong. . .
|
||||||
runTest(t, "13/3/1997", float64(2)) // I think this is wrong. . .
|
runTest(t, "13/3/1997", float64(2)) // I think this is wrong. . .
|
||||||
runTest(t, "neverforget13/3/1997", float64(32.628))
|
runTest(t, "neverforget13/3/1997", float64(32.628))
|
||||||
runTest(t, "1qaz2wsx3edc", float64(19.314))
|
runTest(t, "1qaz2wsx3edc", float64(19.314))
|
||||||
runTest(t, "temppass22", float64(22.179))
|
runTest(t, "temppass22", float64(22.179))
|
||||||
|
|
Loading…
Reference in New Issue