Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- # -*- coding: utf-8 -*-
- # Filename: show_win_credentials.py
- # Version: 1.0.0
- # Author: Jeoi Reqi
- """
- Description:
- This script retrieves and displays all credentials stored in the Windows Credential Manager.
- Requirements:
- - Python 3.x
- - Windows OS (10+)
- - pywin32 (Python extensions for Windows)
- Functions:
- - get_all_credentials():
- Retrieves and prints all credentials stored in Credential Manager.
- Credential Types:
- #1 (GENERIC):
- - Generic credentials that typically store username/password pairs for network resources.
- #2 (DOMAIN_PASSWORD):
- - Credentials used to authenticate against a Windows domain controller using a password.
- #3 (DOMAIN_CERTIFICATE):
- - Credentials that store certificates used for domain authentication.
- #4 (DOMAIN_VISIBLE_PASSWORD):
- - Domain credentials displayed and stored in a visible form.
- #5 (GENERIC_CERTIFICATE):
- - Generic credentials storing certificates for authentication.
- #6 (DOMAIN_EXTENDED):
- - Domain credentials with additional information like smart card data beyond username and password.
- Usage:
- - Ensure Python 3.x is installed.
- - Install pywin32 package (`pip install pywin32`).
- - Run the script (`python show_credentials.py`).
- Additional Notes:
- - Make sure to run the script with appropriate permissions to access Credential Manager.
- """
- import win32cred
- import sys
- def get_all_credentials():
- """
- Retrieves and prints all credentials stored in the Windows Credential Manager.
- Raises:
- Exception: If there is an error while retrieving credentials.
- """
- try:
- creds = win32cred.CredEnumerate()
- if not creds:
- print("No credentials found in Credential Manager")
- return
- for cred in creds:
- target_name = cred['TargetName']
- username = cred['UserName']
- credential_type = cred['Type']
- print(f"- Target Name: {target_name}")
- print(f"- Username: {username if username else 'N/A'}")
- print(f"- Credential Type: {credential_type}")
- print("-----")
- except Exception as e:
- print(f"Failed to retrieve credentials: {str(e)}")
- sys.exit(1)
- if __name__ == "__main__":
- print("\n\t\tGathering Stored Credentials...\n\n-----")
- get_all_credentials()
- print("\n\t\tExiting Program...\t GoodBye!\n")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement