Skip to main content

Secure network file sharing tool for local WiFi networks

Project description

NetShare

1763844410242 1763936492583 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 in editable mode:

    pip install -e .
    
  3. Run NetShare:

    netshare --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 in editable mode:

    pip install -e .
    
  3. Run the application:

    netshare --gui
    

๐Ÿš€ Quick Start

Method 1: GUI Mode (Easiest)

netshare --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

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

Method 3: Interactive Mode

netshare

Follow the prompts to enter folder paths.

๐Ÿ“– Detailed Usage

Command Line Options

netshare [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 --gui                                    # GUI mode
  netshare --folder /path/to/share                  # Share single folder
  netshare --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 netshare/config.py in your installation directory to customize security settings:

class SecurityConfig:
    # Maximum file size to serve (20GB default)
    MAX_FILE_SIZE = 20 * 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
netshare --folder ~/Documents --port 8080

Multiple Folder Sharing

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

Running as Background Service

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

# Windows (run in separate command window)
start netshare --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
netshare --port 8080

File Access Issues

Problem: Cannot download certain files

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

Problem: Folders not showing

Solutions:
1. Verify folder paths exist and are accessible
2. Check ALLOW_DIRECTORY_LISTING = True in netshare/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:

    netshare --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/
โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”œโ”€โ”€ __main__.py
โ”‚   โ”œโ”€โ”€ app.py          # Main application
โ”‚   โ”œโ”€โ”€ config.py       # Configuration settings
โ”‚   โ””โ”€โ”€ templates/      # HTML templates
โ”‚       โ”œโ”€โ”€ index.html
โ”‚       โ”œโ”€โ”€ browse.html
โ”‚       โ””โ”€โ”€ error.html
โ”œโ”€โ”€ requirements.txt
โ”œโ”€โ”€ pyproject.toml      # Package configuration
โ”œโ”€โ”€ LICENSE
โ””โ”€โ”€ 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.3.tar.gz (445.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.3-py3-none-any.whl (38.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: netshare-1.0.3.tar.gz
  • Upload date:
  • Size: 445.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.3.tar.gz
Algorithm Hash digest
SHA256 63c5f7e58a0cb5aaf566f98b7ee78da1a850ef9d2a8b48c27a38846ac1aeb54f
MD5 8472c78c9855f837d66938415f4d3321
BLAKE2b-256 6b884c6a4c1bec2622a0e7584e88a71b55ef9552822696e82cd7b22f9b3b330f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: netshare-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 38.4 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 66d089a06e8d9232d86995824aa5918f58a193f4bd354c8276fab8064b9d6213
MD5 bc0a2582b0fef7795ad082247bf4c321
BLAKE2b-256 90d6a5b43c96a2d310693209479a0e2bdef43081c7b8dc21d2438144a95f2af2

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