Skip to content

File Manager - From "Hello World" to Enterprise Security What started as a simple beginner project with basic "create, read, delete" operations somehow evolved into a full-blown security fortress .

Notifications You must be signed in to change notification settings

INikolOFF/FileManager

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 

Repository files navigation

FileManager

Enterprise-Grade File Management System with Security & Encryption

A sophisticated desktop file manager built with Python and Tkinter, featuring military-grade security, encrypted storage, smart trash recovery, comprehensive audit logging, and protected system path validation. This project demonstrates professional software engineering practices including authentication systems, cryptographic encryption, metadata management, and event-driven GUI architecture.

Key Technologies: Python 3.x | Tkinter/ttk | Cryptography (Fernet) | SHA-256 Hashing | JSON Metadata | Activity Logging

Complexity Level: Intermediate to Advanced

Python Version License Status


Table of Contents


Overview

What started as a simple beginner project with basic "create, read, delete" operations somehow evolved into a full-blown security fortress with SHA-256 password hashing, Fernet encryption, brute-force protection, smart trash recovery, metadata preservation, and system path validation. Now featuring 800+ lines of code, login attempt tracking, audit logging, and enough security features to make even paranoid sysadmins feel safe - because apparently "just delete a file" wasn't exciting enough!

  • Secure Authentication System with brute-force protection
  • Encrypted Configuration Storage using industry-standard cryptography
  • Smart Trash System with metadata preservation and full file recovery
  • Comprehensive Activity Logging for audit trails
  • Protected System Paths to prevent accidental system damage
  • Modern GUI Interface with tabbed navigation and real-time updates

Key Features

Security & Authentication

  • Password Protection: SHA-256 hashed passwords with encrypted storage
  • Brute-Force Protection: Maximum 3 login attempts with 5-minute account lockout
  • Encrypted Configuration: Sensitive files encrypted using Fernet (symmetric encryption)
  • Activity Logging: All operations logged with timestamps and results
  • Protected Paths: Automatic blocking of system-critical directories

File Management

  • Create Files: Write new files with custom content
  • Read Files: View file contents in integrated text editor
  • Edit & Save: Modify existing files with real-time editing
  • Delete Files: Safe deletion with trash system (no permanent loss)
  • Copy Files: Duplicate files with automatic naming
  • Rename Files: Change file names with validation

Directory Operations

  • Navigation: Browse directories with up/down/home controls
  • Create Folders: Make new directories on-the-fly
  • Tree View: Visual directory structure with icons
  • Size Calculation: Recursive folder size computation
  • Timestamps: Display modification dates for all items
  • Double-Click Navigation: Quick folder access

Smart Trash System

  • Safe Deletion: Files moved to .trash directory instead of permanent deletion
  • Metadata Preservation: Original path, deletion time, and size stored
  • Full Restoration: Restore deleted files to their original locations
  • Permanent Deletion: Option to remove files forever from trash
  • Trash Browser: Dedicated tab to view and manage deleted items

Additional Features

  • File Size Formatting: Human-readable sizes (KB, MB, GB, TB)
  • Protected File Detection: Visual indicators (lock icon) for system directories
  • Context Menus: Right-click operations in file explorer
  • Error Handling: Comprehensive try-catch blocks for stability
  • Cross-Platform: Works on Windows, macOS, and Linux

Screenshots

Login Screen

Secure login with attempt tracking and lockout protection

File Operations Tab

Create, read, edit, and manage files with integrated text editor

Explorer Tab

Visual file browser with folder sizes and modification dates

Trash Tab

Recover or permanently delete files with metadata view

Installation

Prerequisites

  • Python 3.x (3.7 or higher recommended)
  • pip package manager

Step 1: Clone or Download

# Clone the repository
git clone https://github.com/yourusername/FileManager.git
cd FileManager

# Or download the file_manager.py directly

Step 2: Install Dependencies

pip install cryptography

Step 3: Run the Application

python file_manager.py

Usage

First Launch

  1. Login: Use the default password admin123
  2. Main Window: Three tabs will appear (Files, Explorer, Trash)
  3. Change Password (recommended): Modify PASSWORD_HASH in the code or use password change feature

File Operations Tab

Creating a File:

1. Enter filename in the "File Name" field (e.g., "notes.txt")
2. Type content in the text editor
3. Click "Create" button

Reading a File:

1. Enter filename or use "Browse" button
2. Click "Read" button
3. Content appears in the text editor

Editing a File:

1. Read the file first
2. Modify content in the editor
3. Click "Save" to update the file

Deleting a File:

1. Enter filename
2. Click "Delete" button
3. Confirm to move file to trash

Explorer Tab

Navigation:

• Type path and click "Go" - Navigate to specific directory
• Click "Up" - Move to parent directory
• Click "Home" - Return to user home directory
• Double-click folder - Open directory
• Double-click file - Load in editor tab

Creating Folders:

1. Click "New Folder"
2. Enter folder name
3. Folder appears in current directory

Context Menu (Right-Click):

• Open - Navigate into folder or load file
• Move to Trash - Delete selected item
• Refresh - Update directory listing

Trash Tab

Restoring Files:

1. Select file from trash list
2. Click "Restore" button
3. File returns to original location

Permanent Deletion:

1. Select file from trash
2. Click "Delete Permanently"
3. Confirm to remove forever

Security Features

Authentication System

# Password is hashed using SHA-256
PASSWORD_HASH = hashlib.sha256("admin123".encode()).hexdigest()

# Login attempts are tracked
MAX_LOGIN_ATTEMPTS = 3
LOGIN_TIMEOUT = 300  # 5 minutes lockout

Protection Mechanisms:

  • Passwords never stored in plain text
  • Configuration encrypted with Fernet
  • Failed attempts logged with timestamps
  • Automatic account lockout after 3 failures
  • Lockout timer prevents brute-force attacks

Protected Paths

The application blocks operations on critical system directories:

PROTECTED_PATHS = [
    "/System",              # macOS system files
    "/Windows",             # Windows system files
    "/Program Files",       # Windows programs
    "C:\\Windows",          # Windows (absolute)
    "/bin", "/sbin",        # Unix system binaries
    "/usr/bin", "/usr/sbin" # Unix user binaries
]

Application File Protection

The following files are automatically protected from deletion:

  • password.cfg - Encrypted password configuration
  • file_manager.log - Activity log
  • login_attempts.json - Authentication tracking
  • .key - Encryption key

Technical Stack

Component Technology Purpose
Language Python 3.x Core application logic
GUI Framework Tkinter / ttk User interface
Encryption cryptography (Fernet) Secure data storage
Hashing hashlib (SHA-256) Password security
File Operations os, shutil File system management
Path Handling pathlib Cross-platform paths
Data Storage json Metadata and configuration
Date/Time datetime Timestamps and logging
Encoding base64 Binary data encoding

Project Structure

FileManager/
│
├── file_manager.py          # Main application file
├── README.md                # This documentation
│
├── .trash/                  # Deleted files storage (auto-created)
│   ├── 20240214_120530_document.txt
│   ├── 20240214_120530_document.txt.meta
│   └── ...
│
├── .key                     # Encryption key (auto-generated)
├── password.cfg             # Encrypted password hash
├── login_attempts.json      # Login attempt tracking
└── file_manager.log         # Activity log

Generated Files Explained

File Description Format
.key Fernet encryption key Binary
password.cfg Encrypted password hash Encrypted text
login_attempts.json Failed login tracking JSON
file_manager.log Operation history Plain text
.trash/*.meta Deleted file metadata JSON

Log File Format

YYYY-MM-DD HH:MM:SS | ACTION          | RESULT  | TARGET | MESSAGE
2024-02-14 15:30:45 | LOGIN           | SUCCESS | file_manager | authentication successful
2024-02-14 15:31:12 | CREATE          | SUCCESS | notes.txt | file created
2024-02-14 15:32:03 | DELETE          | SUCCESS | old_file.txt | moved to trash

Educational Objectives

This project serves as a comprehensive learning tool for several software engineering concepts:

1. Security Implementation

Concepts Demonstrated:

  • Password hashing vs encryption (one-way vs two-way functions)
  • SHA-256 for irreversible password storage
  • Fernet symmetric encryption for reversible data
  • Brute-force attack prevention
  • Account lockout mechanisms

Key Takeaway: Learn the difference between hashing (passwords) and encryption (configuration data), and why each is used in different contexts.

2. State Management & Metadata

Concepts Demonstrated:

  • File state tracking (active vs deleted)
  • Metadata preservation during state transitions
  • JSON-based metadata storage
  • Original context reconstruction

Key Takeaway: Understand how professional applications (like Git, operating systems) manage file states and preserve historical context.

3. I/O Operations & Error Handling

Concepts Demonstrated:

  • File system traversal (os.walk)
  • Exception handling (try-except blocks)
  • Permission management
  • Path validation
  • Cross-platform file operations

Key Takeaway: Learn robust error handling to prevent crashes and provide meaningful feedback to users.

4. Event-Driven GUI Design

Concepts Demonstrated:

  • Tkinter widget hierarchy
  • Event binding (clicks, double-clicks, key presses)
  • Dynamic UI updates
  • Tabbed interface (ttk.Notebook)
  • Context menus

Key Takeaway: Master event-driven programming where user actions trigger specific application responses.

5. Software Architecture Patterns

Concepts Demonstrated:

  • Separation of concerns (UI vs logic)
  • Function decomposition
  • Configuration management
  • Logging and auditing
  • Data validation layers

Key Takeaway: Understand how to structure code for maintainability and scalability.


Future Improvements

Completed Features

  • Append text to existing files
  • Show file sizes in directory listing
  • Confirmation dialogs before deletion
  • Comprehensive error handling with try/except
  • Folder support (create, delete, list)
  • Directory navigation (cd-like behavior)
  • Filter files by extension
  • Timestamps (created/modified dates)
  • Search functionality for files
  • Activity logging
  • User roles (read-only vs admin)
  • GUI using Tkinter
  • Password protection with hashing
  • Encryption for sensitive data
  • Login attempt limits
  • Account lockout mechanism
  • Protected system paths
  • Smart trash system with metadata

Planned Features

  • Search Functionality: Find files by name, content, or date
  • File Preview: Quick view for images, PDFs, and text files
  • Bulk Operations: Select and operate on multiple files
  • Compression: Create and extract ZIP archives
  • File Permissions: Unix-style permission management
  • Favorites/Bookmarks: Quick access to frequently used folders
  • Themes: Dark mode and custom color schemes
  • Keyboard Shortcuts: Power user navigation (Ctrl+N, Ctrl+D, etc.)
  • File Comparison: Side-by-side diff viewer
  • Cloud Integration: Google Drive, Dropbox sync
  • Advanced Search: Regex patterns, file content search
  • Plugin System: Extensible architecture for custom features
  • Multi-Language Support: Internationalization (i18n)
  • Undo/Redo: Operation history with rollback

Advanced Ideas

  • Version Control Integration: Git operations within the file manager
  • Network File Systems: FTP, SFTP, SMB support
  • Database Browser: View and edit SQLite databases
  • Code Editor: Syntax highlighting for programming files
  • Terminal Integration: Embedded command line interface
  • File Watchers: Automatic actions on file changes
  • Tagging System: Organize files with custom tags

Code Examples

Custom Login Validation

def verify_password(password: str) -> bool:
    """Verify password against stored hash"""
    return hashlib.sha256(password.encode()).hexdigest() == PASSWORD_HASH

Encryption Helper

def encrypt_data(data: str) -> str:
    """Encrypt string data using Fernet"""
    key = get_encryption_key()
    f = Fernet(key)
    encrypted = f.encrypt(data.encode())
    return base64.b64encode(encrypted).decode()

Safe File Deletion

def move_to_trash(path: str) -> bool:
    """Move file to trash with metadata preservation"""
    timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
    basename = os.path.basename(path)
    trash_path = os.path.join(TRASH_DIR, f"{timestamp}_{basename}")
    
    # Save metadata
    metadata = {
        "original_path": os.path.abspath(path),
        "deleted_at": datetime.now().isoformat(),
        "size": os.path.getsize(path)
    }
    
    with open(trash_path + ".meta", "w") as f:
        json.dump(metadata, f)
    
    shutil.move(path, trash_path)
    return True

Contributing

Contributions are welcome! Here's how you can help:

Reporting Bugs

  1. Check if the bug is already reported in Issues
  2. Create a new issue with:
    • Clear title and description
    • Steps to reproduce
    • Expected vs actual behavior
    • Screenshots (if applicable)
    • Your environment (OS, Python version)

Suggesting Features

  1. Open an issue with the "enhancement" label
  2. Describe the feature and its benefits
  3. Provide examples of how it would work

Pull Requests

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Code Style

  • Follow PEP 8 guidelines
  • Use descriptive variable names
  • Add comments for complex logic
  • Include docstrings for functions
  • Update README if adding new features

License

This project is licensed under the MIT License - see below for details:

MIT License

Copyright (c) 2024 INikolOFF

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Acknowledgments

  • Python Community for excellent documentation
  • Tkinter for accessible GUI framework
  • cryptography library maintainers for secure encryption tools
  • All contributors and testers who helped improve this project

Support


Disclaimer

For Educational Purposes: This project is designed as a learning tool. While it implements security best practices, it should not be used for managing critical or sensitive data in production environments without additional security audits.

System Files Warning: The application includes protection for common system directories, but users should exercise caution when navigating system areas.


Version History

v1.0.0 (Current)

  • Initial release
  • Core file management features
  • Security implementation
  • Trash system
  • Activity logging

Planned: v1.1.0

  • Search functionality
  • File preview
  • Bulk operations
  • Keyboard shortcuts

Made with Python

Star this project if you find it helpful!

Report Bug · Request Feature · Documentation

About

File Manager - From "Hello World" to Enterprise Security What started as a simple beginner project with basic "create, read, delete" operations somehow evolved into a full-blown security fortress .

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages