Skip to main content

Secure network file sharing tool for local WiFi networks

Project description

NetShare

1763844410242 A secure, Python-based network file sharing tool that enables easy sharing of folders from Windows, Mac, or Linux computers to Android devices, Quest VR headsets, and other devices over your local WiFi network.

๐Ÿš€ Features

  • ๐Ÿ”’ Security First: Built-in rate limiting, file extension filtering, and path traversal protection
  • ๐Ÿ“ฑ Mobile Friendly: QR code generation for instant mobile access
  • ๐ŸŽฏ Simple Setup: GUI and command-line options for easy folder selection
  • โšก Fast Transfer: Direct WiFi connection with no external servers
  • ๐Ÿ›ก๏ธ Configurable Security: Customizable file size limits, extension blocking, and access controls
  • ๐ŸŒ Cross-Platform: Works on Windows, macOS, and Linux
  • ๐Ÿ“Š Access Logging: Optional request logging for monitoring

๐Ÿ“‹ Requirements

  • Python 3.7 or higher
  • Local WiFi network (same network for sharing device and receiving device)
  • Modern web browser on receiving device

๐Ÿ”ง Installation

From PyPI (Recommended)

The easiest way to install NetShare is via pip:

pip install netshare

Then run it with:

netshare --gui              # GUI mode
netshare --folder /path     # Specify folder
netshare --help             # Show all options

From Source

  1. Clone or download this repository:

    git clone https://github.com/yourusername/netshare.git
    cd netshare
    
  2. Install dependencies:

    pip install -r requirements.txt
    
  3. Run NetShare:

    python netshare.py --gui
    

Using Virtual Environment (Recommended)

  1. Create virtual environment:

    python -m venv netshare-env
    
    # Windows
    netshare-env\Scripts\activate
    
    # macOS/Linux
    source netshare-env/bin/activate
    
  2. Install dependencies:

    pip install -r requirements.txt
    
  3. Run the application:

    python netshare.py --gui
    

๐Ÿš€ Quick Start

Method 1: GUI Mode (Easiest)

If installed via pip:

netshare --gui

If running from source:

python netshare.py --gui
  1. Select folders using the graphical interface
  2. Server starts automatically
  3. Scan the QR code with your mobile device or use the displayed URL

Method 2: Command Line

If installed via pip:

netshare --folder "C:\Users\YourName\Documents" --port 8000

If running from source:

python netshare.py --folder "C:\Users\YourName\Documents" --port 8000

Method 3: Interactive Mode

If installed via pip:

netshare

If running from source:

python netshare.py

Follow the prompts to enter folder paths.

๐Ÿ“– Detailed Usage

Command Line Options

python netshare.py [options]

Options:
  --gui                 Use GUI to select folders
  --folder FOLDER       Folder to share (can be used multiple times)
  --port PORT          Port to run server on (default: 5000)
  -h, --help           Show help message

Examples:
  netshare.py --gui                                    # GUI mode
  netshare.py --folder /path/to/share                  # Share single folder
  netshare.py --folder "C:\Documents" --folder "C:\Pictures" --port 8000   # Multiple folders, custom port

Accessing Shared Files

  1. Start NetShare using any method above
  2. Note the server URL displayed in the terminal (e.g., http://192.168.1.100:5000)
  3. On your mobile/target device:
    • Scan the QR code with your camera app, OR
    • Open a web browser and navigate to the displayed URL
  4. Browse and download files through the web interface

Using the Web Interface

  • Home Page: Shows all shared folders
  • Browse: Click folders to navigate directory structure
  • Download: Click files to download them
  • Breadcrumbs: Use the navigation path to go back to parent folders

๐Ÿ”ง Configuration

Security Settings

Edit config.py to customize security settings:

class SecurityConfig:
    # Maximum file size to serve (10GB default)
    MAX_FILE_SIZE = 10 * 1024 * 1024 * 1024

    # Block dangerous file extensions
    BLOCKED_EXTENSIONS = ['.exe', '.bat', '.cmd', '.sh', '.ps1']

    # Allow only specific extensions (empty = allow all)
    ALLOWED_EXTENSIONS = []  # e.g., ['.pdf', '.jpg', '.mp4']

    # Enable/disable features
    ALLOW_DIRECTORY_LISTING = True
    ALLOW_FILE_DOWNLOAD = True

    # Security limits
    MAX_PATH_DEPTH = 20
    RATE_LIMIT = 100  # requests per minute per IP

Application Settings

class AppConfig:
    DEFAULT_PORT = 5000
    SERVER_NAME = "NetShare"
    ENABLE_ACCESS_LOG = True  # Log all requests

๐Ÿ› ๏ธ Advanced Usage

Custom Port Configuration

# Use a different port if 5000 is occupied
python netshare.py --folder ~/Documents --port 8080

Multiple Folder Sharing

# Share multiple folders simultaneously
python netshare.py --folder ~/Documents --folder ~/Pictures --folder ~/Downloads

Running as Background Service

# Run in background (Linux/macOS)
nohup python netshare.py --folder ~/shared &

# Windows (run in separate command window)
start python netshare.py --folder C:\Shared

๐Ÿ“ฑ Mobile Access Tips

Android Devices

  1. Use any web browser (Chrome, Firefox, etc.)
  2. QR code scanner apps work with the generated codes
  3. Bookmark the URL for easy future access

Quest VR Headsets

  1. Use the built-in browser
  2. QR code scanning may require companion mobile app
  3. Save URL in browser bookmarks for easy access

iOS Devices

  1. Use Safari or any web browser
  2. Camera app can scan QR codes directly
  3. Add to home screen for app-like experience

๐Ÿšจ Troubleshooting

Connection Issues

Problem: Cannot access from mobile device

Solutions:
1. Ensure both devices are on the same WiFi network
2. Check if firewall is blocking the port (5000 by default)
3. Try a different port: --port 8080
4. Verify the IP address is correct

Problem: "Connection refused" error

Solutions:
1. Make sure NetShare server is running
2. Check if another application is using the port
3. Try running as administrator (Windows) or with sudo (Linux/Mac)

Windows Firewall Configuration (Windows Only)

If you can access NetShare from the host PC but not from other devices on the same WiFi network, you need to configure Windows Firewall:

Step 1: Run the diagnostic script (optional, to check current settings)

# In PowerShell (as Administrator)
cd path\to\netshare
.\firewall_diagnostic.ps1

Step 2: Fix the firewall rules

  1. Open PowerShell as Administrator:

    • Press Windows key
    • Type "PowerShell"
    • Right-click "Windows PowerShell"
    • Select "Run as Administrator"
  2. Navigate to NetShare directory:

    cd path\to\netshare
    
  3. Run the firewall fix script:

    .\fix_firewall.ps1
    
  4. Test the connection from your mobile device using the displayed URL (e.g., http://192.168.0.96:8080)

Why is this needed? Windows Firewall rules may only apply to "Public" network profiles, while your home network is set to "Private". The fix script creates rules that work on all network profiles.

Alternative: Use firewall-friendly port

# Port 8080 is more commonly allowed by firewalls
python netshare.py --port 8080

File Access Issues

Problem: Cannot download certain files

Solutions:
1. Check BLOCKED_EXTENSIONS in config.py
2. Verify file size under MAX_FILE_SIZE limit
3. Ensure ALLOW_FILE_DOWNLOAD = True in config.py

Problem: Folders not showing

Solutions:
1. Verify folder paths exist and are accessible
2. Check ALLOW_DIRECTORY_LISTING = True in config.py
3. Ensure proper read permissions on folders

Network Connectivity

Problem: QR code doesn't work

Solutions:
1. Manually type the URL into browser
2. Check IP address is reachable: ping [IP_ADDRESS]
3. Restart router if needed
4. Use different QR code scanner app

Performance Issues

Problem: Slow file transfers

Solutions:
1. Check WiFi signal strength
2. Reduce MAX_FILE_SIZE if memory limited
3. Close other network applications
4. Use 5GHz WiFi band if available

๐Ÿ” Security Best Practices

Recommended Security Settings

  1. Limit file types:

    ALLOWED_EXTENSIONS = ['.pdf', '.jpg', '.png', '.mp4', '.doc', '.txt']
    
  2. Reduce file size limits for better performance:

    MAX_FILE_SIZE = 1 * 1024 * 1024 * 1024  # 1GB
    
  3. Enable access logging to monitor usage:

    ENABLE_ACCESS_LOG = True
    
  4. Use non-default ports to reduce discovery:

    python netshare.py --folder ~/Documents --port 8543
    

Network Security

  • Use on trusted networks only (home/office WiFi)
  • Avoid public WiFi for file sharing
  • Stop the server when not needed (Ctrl+C)
  • Monitor access logs for unusual activity
  • Share only necessary folders, not entire drives

๐Ÿ”ง API Reference

NetShare provides a simple REST API:

Get Shared Folders

GET /api/folders

Returns JSON list of available shared folders.

Example response:

[
  {
    "index": 0,
    "name": "Documents",
    "path": "/home/user/Documents"
  }
]

๐Ÿ—๏ธ Architecture

NetShare Architecture:

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   Mobile Device โ”‚โ”€โ”€โ”€โ”€โ”‚  WiFi Router โ”‚โ”€โ”€โ”€โ”€โ”‚  NetShare Host  โ”‚
โ”‚   (Browser)     โ”‚    โ”‚              โ”‚    โ”‚  (Python Flask) โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
         โ”‚                                           โ”‚
         โ”‚              HTTP Requests                โ”‚
         โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                        (Port 5000)

Components:
- Flask web server for HTTP requests
- QR code generator for easy mobile access
- Security middleware for safe file access
- Path validation to prevent directory traversal
- Rate limiting to prevent abuse

๐Ÿ“ Technical Notes

Dependencies

  • Flask 3.0.0: Web server framework
  • qrcode 7.4.2: QR code generation
  • Pillow 10.1.0: Image processing for QR codes

File Structure

netshare/
โ”œโ”€โ”€ netshare.py      # Main application
โ”œโ”€โ”€ config.py        # Configuration settings
โ”œโ”€โ”€ requirements.txt # Python dependencies
โ””โ”€โ”€ README.md       # This documentation

Supported File Operations

  • โœ… Download files
  • โœ… Browse directories
  • โœ… View file information (size, type)
  • โŒ Upload files (not supported)
  • โŒ Delete files (not supported)
  • โŒ Modify files (not supported)

๐Ÿค Contributing

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature-name
  3. Make your changes
  4. Test thoroughly
  5. Submit a pull request

๐Ÿ“„ License

This project is open source. Please check the repository for license details.

๐Ÿ†˜ Support

If you encounter issues:

  1. Check the troubleshooting section above
  2. Verify your Python and dependency versions
  3. Check firewall and network settings
  4. Review the access logs for error details

For persistent issues, please create an issue in the repository with:

  • Operating system and Python version
  • Complete error messages
  • Steps to reproduce the problem

โš ๏ธ Security Notice: NetShare is designed for local network file sharing. Only use on trusted networks and share folders containing non-sensitive files. Always stop the server when not in use.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

netshare-1.0.2.tar.gz (388.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

netshare-1.0.2-py3-none-any.whl (38.2 kB view details)

Uploaded Python 3

File details

Details for the file netshare-1.0.2.tar.gz.

File metadata

  • Download URL: netshare-1.0.2.tar.gz
  • Upload date:
  • Size: 388.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for netshare-1.0.2.tar.gz
Algorithm Hash digest
SHA256 d5aad207d236c79be800bad1df08cc5813938e9110a2d96f635b3960e560806a
MD5 7710105acd119be2bcbecd0f2ba6f8c3
BLAKE2b-256 bd20833376125668e211ca0b2c0fc1bc426b7d0f41f661d416b400c1b74c1950

See more details on using hashes here.

File details

Details for the file netshare-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: netshare-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 38.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for netshare-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a9f4364d8742aba8204c187edda7e8aaab0d041b9a27f276ba36ba7b4f949946
MD5 5f25118ec65155cef49434d03fa07d53
BLAKE2b-256 9551d255fd4f649538aaba79d8f05e418f045e59f9280b5b75997dc2a410b4e0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page