Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- passwordCount := 1024
- passwordMinLength := 8
- passwordMaxLength := 20
- policyType := "L" ; A=All, N=Numbers, L=Lower, U=Upper
- ;=========================
- totalPassed := 0
- policies := genPolicies(policyType)
- policiesCount := policies.Count()
- passwords := genPasswords(passwordCount, passwordMinLength, passwordMaxLength)
- for idx,pwd in passwords
- {
- ; Get random policy
- Random, rnd, 1, % policiesCount
- chr := policies[rnd].chr
- min := policies[rnd].min
- max := policies[rnd].max
- cnt := pos := 0
- while (pos := InStr(pwd, chr, true, ++pos))
- {
- cnt++
- }
- res := "FAIL"
- if (cnt >= min && cnt <= max)
- {
- res := "PASS"
- totalPassed++
- }
- ; OutputDebug, % "`n------------------------"
- ; . "`n" res
- ; . "`n" "Found: " cnt
- ; . "`n" "Policy: " min "-" max ": " chr
- ; . "`n" "Password: " pwd
- }
- OutputDebug, % "Valid passwords: " totalPassed " (out of " passwordCount ")"
- genPasswords(qty := 1024, minLen := 8, maxLen := 20)
- {
- passwords := []
- loop, % qty
- {
- pwd := ""
- Random, len, % minLen, % maxLen
- loop, % len
- {
- Random, chr, 33, 126
- pwd .= Chr(chr)
- }
- passwords.Push(pwd)
- }
- return passwords
- }
- genPolicies(type := "A")
- {
- policies := []
- if (type = "A")
- {
- Loop, 94
- {
- Random, min, 1, 3
- Random, max, % min + 1, 9
- policies.Push({"chr" : Chr(32 + A_Index), "min" : min, "max" : max })
- }
- }
- else if (type = "N")
- {
- loop, 10
- {
- Random, min, 1, 3
- Random, max, % min + 1, 9
- policies.Push({"chr" : A_Index-1, "min" : min, "max" : max })
- }
- }
- else if (type = "L")
- {
- loop, 26
- {
- Random, min, 1, 3
- Random, max, % min + 1, 9
- policies.Push({"chr" : Chr(96 + A_Index), "min" : min, "max" : max })
- }
- }
- else if (type = "U")
- {
- loop, 26
- {
- Random, min, 1, 3
- Random, max, % min + 1, 9
- policies.Push({"chr" : Chr(64 + A_Index), "min" : min, "max" : max })
- }
- }
- return policies
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement