Secure network file sharing tool for local WiFi networks
Project description
NetShare
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
-
Clone or download this repository:
git clone https://github.com/yourusername/netshare.git cd netshare
-
Install dependencies:
pip install -r requirements.txt
-
Run NetShare:
python netshare.py --gui
Using Virtual Environment (Recommended)
-
Create virtual environment:
python -m venv netshare-env # Windows netshare-env\Scripts\activate # macOS/Linux source netshare-env/bin/activate
-
Install dependencies:
pip install -r requirements.txt
-
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
- Select folders using the graphical interface
- Server starts automatically
- 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
- Start NetShare using any method above
- Note the server URL displayed in the terminal (e.g.,
http://192.168.1.100:5000) - On your mobile/target device:
- Scan the QR code with your camera app, OR
- Open a web browser and navigate to the displayed URL
- 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
- Use any web browser (Chrome, Firefox, etc.)
- QR code scanner apps work with the generated codes
- Bookmark the URL for easy future access
Quest VR Headsets
- Use the built-in browser
- QR code scanning may require companion mobile app
- Save URL in browser bookmarks for easy access
iOS Devices
- Use Safari or any web browser
- Camera app can scan QR codes directly
- 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
-
Open PowerShell as Administrator:
- Press Windows key
- Type "PowerShell"
- Right-click "Windows PowerShell"
- Select "Run as Administrator"
-
Navigate to NetShare directory:
cd path\to\netshare
-
Run the firewall fix script:
.\fix_firewall.ps1
-
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
-
Limit file types:
ALLOWED_EXTENSIONS = ['.pdf', '.jpg', '.png', '.mp4', '.doc', '.txt']
-
Reduce file size limits for better performance:
MAX_FILE_SIZE = 1 * 1024 * 1024 * 1024 # 1GB
-
Enable access logging to monitor usage:
ENABLE_ACCESS_LOG = True
-
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
- Fork the repository
- Create a feature branch:
git checkout -b feature-name - Make your changes
- Test thoroughly
- Submit a pull request
๐ License
This project is open source. Please check the repository for license details.
๐ Support
If you encounter issues:
- Check the troubleshooting section above
- Verify your Python and dependency versions
- Check firewall and network settings
- 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters