IdleCrypt is a macOS-based security tool that automatically encrypts the contents of a sensitive folder when the system is left unattended for a specified period of time.
The project is designed to mitigate risks caused by unlocked systems in shared workspaces where temporary physical access can lead to data exposure.
- The script monitors keyboard and mouse activity to determine user presence.
- If no activity is detected for a configurable idle period (default: 10 minutes), the tool triggers encryption.
- All files inside the target folder are encrypted recursively.
- Encrypted files are marked with a
.encextension. - A separate script is used to decrypt the files when access is required.
Note: This project encrypts file contents, not the folder metadata itself.
- Language: Python
- Cryptography:
cryptography(Fernet + PBKDF2) - Activity Monitoring:
pynput - Platform: macOS
Clone the repository and install dependencies:
git clone https://github.com/FatimaZ-tech/IdleCrypt.git
cd idlelock
pip install -r requirements.txtmacOS restricts keyboard input monitoring by default.
IdleCrypt requires explicit permission to detect user activity.
You must allow the following permissions:
- Accessibility
- Input Monitoring
- Open System Settings
- Navigate to Privacy & Security
- Enable the following sections:
- Accessibility
- Input Monitoring
- Add:
- Terminal (or the Python executable)
Note: Restart Terminal after granting permissions for the changes to take effect.
You must configure the same folder path in both scripts.
TARGET_FOLDER = "FolderPath"folder = "FolderPath"Run the encryption monitor:
python encrypt_on_idle.pyYou will be prompted to set a password.
After starting, the script will:
- Monitor user keyboard and mouse activity
- Detect periods of inactivity
- Encrypt the files in the target folder after the idle timeout is reached
When you want access to your files again, run:
python decrypt_folder.pyEnter the same password used during encryption. Encrypted files (.enc) will be restored to their original form
- Password-based key derivation uses PBKDF2 + SHA-256
- A random salt is generated once and stored locally in a
.saltfile - The salt is not secret, but is required for correct decryption
- Encrypted files are marked with a
.encextension - This prevents accidental double encryption
IdleCrypt does not implement any auto-run or persistence mechanism.
The tool in its current state is designed to be executed manually to keep the codebase portable and transparent.
Users who require automatic execution at login may implement their own persistence mechanism (for example, using macOS LaunchAgents) by modifying the code and providing system-specific absolute paths.
No auto-run functionality is included in this project.
The idle timeout is configurable directly in the code.
In encrypt_on_idle.py, adjust the following value:
IDLE_LIMIT = 600 # idle time in seconds- This is not full-disk encryption
- Folder metadata (names and directory structure) remains visible
- No protection against attackers with administrative privileges
- If the password is lost, encrypted data cannot be recovered
IdleCrypt demonstrates techniques that may resemble those used by malware (e.g., file encryption and persistence).
The project is intended strictly for educational and research purposes.
This project is licensed under the MIT License.
See the LICENSE file for full license text.
Developed by Fatima Z.