Commit 7c84a03c authored by Nong Hoang Tu's avatar Nong Hoang Tu
Browse files

Upgrade mask crafting. Now mask allows user to choose multiple charset

parent a0dd9b00
Pipeline #3484 failed with stages
......@@ -107,7 +107,7 @@ def parse_options():
group_wordlist.add_argument(
"-pM",
"--pass-mask",
help="Generate password from mask",
help="Generate password from mask. Mask format ?awWds",
metavar="awWds"
)
# TODO gen sqli
......@@ -208,17 +208,25 @@ class ProgOptions:
import string
charsets = []
for mask in self.user_options.pass_mask:
if mask == "a":
charsets.append(tuple(string.ascii_letters))
elif mask == "w":
charsets.append(tuple(string.ascii_lowercase))
elif mask == "W":
charsets.append(tuple(string.ascii_uppercase))
elif mask == "d":
charsets.append(tuple(string.digits))
elif mask == "s":
charsets.append(tuple(string.punctuation))
if not self.user_options.pass_mask.startswith("?") or self.user_options.pass_mask.endswith("?"):
raise ValueError("Invalid format")
for mask in self.user_options.pass_mask.split("?")[1:]:
final_mask = ()
for char_mask in mask:
if char_mask == "a":
final_mask += tuple(string.ascii_letters)
elif char_mask == "w":
final_mask += tuple(string.ascii_lowercase)
elif char_mask == "W":
final_mask += tuple(string.ascii_uppercase)
elif char_mask == "d":
final_mask += tuple(string.digits)
elif char_mask == "s":
final_mask += tuple(string.punctuation)
if not final_mask:
raise ValueError("Empty mask. Please check your format")
charsets.append(final_mask)
return charsets
def __validate_threads(self):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment