Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add password parameter to auth command #244

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion certipy/commands/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ def __init__(
self,
target: Target = None,
pfx: str = None,
password: str = None,
cert: x509.Certificate = None,
key: rsa.RSAPublicKey = None,
no_save: bool = False,
Expand All @@ -123,6 +124,7 @@ def __init__(
):
self.target = target
self.pfx = pfx
self.password = password
self.cert = cert
self.key = key
self.no_save = no_save
Expand All @@ -144,8 +146,13 @@ def __init__(
self.lm_hash: str = None

if self.pfx is not None:
password = None
if self.password:
password = self.password.encode()
with open(self.pfx, "rb") as f:
self.key, self.cert = load_pfx(f.read())
pfx = f.read()
self.key, self.cert = load_pfx(pfx, password)


def authenticate(
self, username: str = None, domain: str = None, is_key_credential=False
Expand Down
4 changes: 4 additions & 0 deletions certipy/commands/parsers/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ def add_subparser(subparsers: argparse._SubParsersAction) -> Tuple[str, Callable
required=True,
)

subparser.add_argument(
"-password", action="store", metavar="password", help="Set import password"
)

subparser.add_argument(
"-no-save", action="store_true", help="Don't save TGT to file"
)
Expand Down