-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
JKS and PKCS12 storages with default passwords
- Loading branch information
Showing
15 changed files
with
321 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import logging | ||
from abc import ABC | ||
from typing import List | ||
|
||
import jks | ||
|
||
from credsweeper.credentials import Candidate | ||
from credsweeper.deep_scanner.abstract_scanner import AbstractScanner | ||
from credsweeper.file_handler.data_content_provider import DataContentProvider | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class JksScanner(AbstractScanner, ABC): | ||
"""Implements jks scanning""" | ||
|
||
def data_scan( | ||
self, # | ||
data_provider: DataContentProvider, # | ||
depth: int, # | ||
recursive_limit_size: int) -> List[Candidate]: | ||
"""Tries to scan JKS to open with standard password""" | ||
candidates = [] | ||
for pw_probe in ["", "changeit", "changeme"]: | ||
try: | ||
keystore = jks.KeyStore.loads(data_provider.data, pw_probe, try_decrypt_keys=True) | ||
if keystore.private_keys or keystore.secret_keys: | ||
candidate = Candidate.get_dummy_candidate(self.config, data_provider.file_path, | ||
data_provider.file_type, | ||
f"{data_provider.info}:'{pw_probe}' - has keys") | ||
else: | ||
candidate = Candidate.get_dummy_candidate(self.config, data_provider.file_path, | ||
data_provider.file_type, | ||
f"{data_provider.info}:'{pw_probe}' - default password") | ||
candidates.append(candidate) | ||
except Exception as jks_exc: | ||
logger.debug(f"{data_provider.file_path}:{pw_probe}:{jks_exc}") | ||
return candidates |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import logging | ||
from abc import ABC | ||
from typing import List | ||
|
||
import cryptography.hazmat.primitives.serialization.pkcs12 | ||
|
||
from credsweeper.credentials import Candidate | ||
from credsweeper.deep_scanner.abstract_scanner import AbstractScanner | ||
from credsweeper.file_handler.data_content_provider import DataContentProvider | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class Pkcs12Scanner(AbstractScanner, ABC): | ||
"""Implements jks scanning""" | ||
|
||
def data_scan( | ||
self, # | ||
data_provider: DataContentProvider, # | ||
depth: int, # | ||
recursive_limit_size: int) -> List[Candidate]: | ||
"""Tries to scan JKS to open with standard password""" | ||
candidates = [] | ||
for pw_probe in [b"", b"changeit", b"changeme"]: | ||
try: | ||
(private_key, certificate, additional_certificates) \ | ||
= cryptography.hazmat.primitives.serialization.pkcs12.load_key_and_certificates(data_provider.data, | ||
pw_probe) | ||
if private_key: | ||
candidate = Candidate.get_dummy_candidate( | ||
self.config, # | ||
data_provider.file_path, # | ||
data_provider.file_type, # | ||
f"{data_provider.info}:'{pw_probe.decode()}' - has keys PKCS12") | ||
else: | ||
candidate = Candidate.get_dummy_candidate( | ||
self.config, # | ||
data_provider.file_path, # | ||
data_provider.file_type, # | ||
f"{data_provider.info}:'{pw_probe.decode()}' - default password PKCS12") | ||
candidates.append(candidate) | ||
except Exception as pkcs_exc: | ||
logger.debug(f"{data_provider.file_path}:{pw_probe.decode()}:{pkcs_exc}") | ||
return candidates |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.