This script is designed to extract and reformat sensitive information (like URLs, usernames, and passwords) from specific log files. Below is an explanation of how it works and its key features.
-
π Automated File Traversal:
Automatically scans the selected directory and subdirectories for target files, reducing manual effort. -
π Pattern Matching with Regular Expressions:
Extracts data using robust regular expressions, ensuring flexibility and accuracy. -
π Dynamic Output File Naming:
Names the output file based on the input directory, making it easy to identify the source of extracted data. -
β‘ Error Resilience:
Gracefully handles errors (e.g., file encoding issues, missing patterns) and logs them for debugging. -
π₯ User-Friendly Interface:
Uses Tkinter to provide a graphical interface for directory selection, making it accessible to non-technical users. -
π Scalability:
Efficiently handles large datasets with multiple subdirectories and files. -
π Formatted and Readable Output:
Outputs credentials in a structured format (URL|username|password
) that can be directly used or parsed by other tools. -
π Cross-Platform Compatibility:
Built with standard Python libraries (os
,re
,tkinter
), ensuring compatibility across Windows, macOS, and Linux.
-
Python Environment:
- Python 3.6 or higher installed.
Verify using:python --version
- Python 3.6 or higher installed.
-
Required Libraries:
- os: For directory and file operations.
- re: For regular expression matching.
- tkinter: For the graphical file selection dialog.
Linux Users: Install
tkinter
(if missing):sudo apt-get install python3-tk
-
Supported Operating Systems:
- Windows
- macOS
- Linux
-
Target Files:
- Files named
All Passwords.txt
orPasswords.txt
must exist in the directory you select.
- Files named
-
π» Install Python (if not already installed):
- Download and install from python.org.
-
π Save the Script:
- Save the script as
LogsSorterULP.py
(or any other name).
- Save the script as
-
π Prepare Log Files:
- Place files (
All Passwords.txt
orPasswords.txt
) in the directory you want to process.
- Place files (
-
π§ Set Up a Virtual Environment (Optional but Recommended):
- Create and activate a virtual environment:
python -m venv env source env/bin/activate # On Windows: .\env\Scripts\activate
- Create and activate a virtual environment:
-
βΆ Run the Script:
- Execute the script:
python LogsSorterULP.py
- Execute the script:
-
π Select Directory:
- A graphical window will open; select the folder containing the log files.
-
β View Results:
- The script saves the extracted credentials to a file named:
<InputDirectoryName>_credentials.txt
- The file is located in the current working directory.
- The script saves the extracted credentials to a file named:
For a file with the following entries:
URL: https://example.com
Username: user1
Password: pass123
The script generates:
https://example.com|user1|pass123
- Credential Analysis: Helps analyze credential data for audits or investigations.
- Data Migration: Formats credentials for easy migration to secure password managers.
- Cybersecurity Audits: Assists in identifying and managing exposed credentials.
This script is ideal for IT professionals, auditors, and penetration testers handling sensitive information efficiently!