This project retrieves and analyzes secrets and certificates from Azure AD and Azure B2C applications. The collected data is formatted and exported into JSON files and tabular output for better insights.
- Multi-Tenant Support: Retrieve secrets and certificates from Azure AD and Azure B2C directories.
- Detailed Analysis: Classify secrets and certificates into active, expiring soon, or expired.
- Export Options: Generate structured JSON and formatted text output.
- Automation-Friendly: JSON output can integrate directly with Azure Logic Apps for automation.
- PowerShell Version: 5.1 or higher
- Azure CLI: Installed and configured
- JSON File Parsing: Python 3.x with the
prettytablelibrary
- Clone the repository:
git clone https://github.com/murat-kaya/azure-secret-certificate-monitoring.git cd azure-secret-certificate-monitoring - Update the tenant information in the PowerShell script:
Important
You should update this field with your own tenant information. The name can be anything you want...
$tenants = @(
@{ "TenantId" = "your-tenant-id"; "Name" = "Your Tenant Name" }
)
- Run the script:
.\azure-secret-and-certificate-collector.ps1- Install required Python libraries:
pip install prettytable- Execute the Python script:
python azure-secret-certificate-remaining-days-to-expire.pyThe PowerShell script retrieves secrets and certificates for each tenant and generates a JSON file as output:
- Output:
AppCredentials.json
The Python script processes the JSON file from PowerShell to generate:
- Detailed Analysis:
detailed_output.json - Filtered Results:
filtered_output.json - Tabular Summary:
main_output_table.txt, expiring_table.txt
The JSON output can be directly used in Azure Logic Apps for:
- Mapping fields instead of using python script to extract information from json and send direct mail or alert to whom concern.
- Automating alerts or actions based on filters (remaining days etc.)
Example: Automate email notifications for secrets expiring in 30 days.
[
{
"TenantName": "Azure ENT",
"AppId": "a124e46e-e1ac-3a18-bee5-7cc1238312b",
"DisplayName": "ExampleApp",
"Secrets": {
"Active": ["Secret1", "Secret2"],
"ExpiringSoon": ["Secret3"],
"Expired": []
},
"Certificates": {
"Active": ["Cert1"],
"ExpiringSoon": ["Cert2"],
"Expired": []
}
}
]+--------------------------------------+-------------------+--------+---------+----------------+
| AppId | DisplayName | Type | Name | Days Remaining |
+--------------------------------------+-------------------+--------+---------+----------------+
| a312346e-eb99-4ac8-1235-744057083deb | ExampleApp | Secret | Secret3 | 7 |
| f123274d-36a3-4218-a123-3754f123cef4 | AnotherApp | Secret | Secret1 | 3 |
+--------------------------------------+-------------------+--------+---------+----------------+This project is licensed under the GPLv3 License - see the LICENSE file for details.
Warning: This script generates highly sensitive information, including secrets and certificates. Ensure all files and outputs are stored in a secure environment with proper access controls to prevent unauthorized access.