Giter Club home page Giter Club logo

pyrobox's Introduction

pyrobox ๐Ÿ”ฅ

Note : DEFAULT UPLOAD PASSWORD: SECret

  • you can change it by editing the code (see config class at top)
  • to set password from command line, use -k or --password flag

Status

Downloads

Requesting for more suggesions and ideas

Feel Free to Support Me

Buy Me A Coffee

Basic FEATURES

  • File Hosting system (Serve files from local Storage system)
  • Access Shared File System from Multiple Devices
  • Has optional account system (Admin can add users or allow signup) (Check Advanced Account System section)
  • Set Server Permission (Check Customization Options section)

Extra FEATURES

  • ๐Ÿ”ฝ DOWNLOAD AND VIDEO STREAM WITH PAUSE AND RESUME
  • ๐Ÿ”ผ UPLOAD WITH PASSWORD (User password or server-wide password)
  • ๐Ÿ‘Œ HTML5 drag and drop uploader
  • ๐Ÿ“ˆ MULTIPLE FILE UPLOAD
  • ๐Ÿ“ RENAME
  • ๐Ÿ“ FOLDER DOWNLOAD as ZIP (uses temp folder)
  • โฏ Built-in VIDEO PLAYER
  • ๐Ÿ” DELETE FILE (MOVE TO RECYCLE BIN)
  • ๐Ÿ”ฅ PERMANENTLY DELETE
  • โ›“ File manager like NAVIGATION BAR
  • ๐Ÿ“‘ Right click Context menu (Tap n hold on touch device)
  • ๐Ÿงจ RELOAD SERVER FROM REMOTE [DEBUG PURPOSE]
  • ๐Ÿ†• FOLDER CREATION
  • ๐Ÿ’ฌ Pop-up messages UI(from my Web leach repo)
  • ๐ŸŒ (Didn't test yet) If you are using REAL IP AND ALLOW PYTHON TO USE PUBLIC NETWORK, YOUR SERVER CAN BE VISIBLE AROUND THE GLOBE. (also vulnerable, since you can't control access yet)
  • ๐Ÿงฌ Clone entire directory from Host to Client with least changes (last modified preserved)
  • ๐Ÿ”œ More comming soon
  • All of these without the need of any internet connection (having connection will provide better experience)

Server side requirement

  • Python 3.7 or higher. Older support available.1
  • Basic knowledge about Python
  • send2trash, natsort python modules

Installation

  1. Install Python 3.7 or higher
  2. Close older pyrobox process if already running
  3. Install using PIP

On Windows

  1. Open CMD or PowerShell
  2. Run pip install -U pyrobox
  3. Run pyrobox to launch the server on the Terminal Current Working Directory.

On Linux

  1. Open Terminal
  2. Run pip3 install -U pyrobox
  3. Run pyrobox to launch the server on the Terminal Current Working Directory.

CHECK FAQ FOR FUTURE HELP AND ISSUE FIX

Customization

  1. Simply running the code on will create a server on CURRENT WORKING DIRECTORY on Port: 6969

  2. On browser (on device under same router/wifi network), go to deviceIP:port_number to see the output like this: http://192.168.0.101:6969/

    • you must allow python in firewall to access network, check FAQ for more help
  3. To change the server running directory,

    • i) either edit the code (see config class at top)
    • ii) or add -d or --directory command line argument when launching the program
      • pyrobox -d . to launch the server in current directory (where the file is)
      • pyrobox -d "D:\Server\Public folder\" (Use Double-Quotation while directory has space)
      • pyrobox -d "D:/Server/Public folder" (Forward or backward slash really doesn't matter, unless your terminal thinks otherwise)
  4. To change port number

    • i) just edit the code for permanent change (see config class at top)
    • ii) or add the port number at the end of the command line arg
      • pyrobox 45678 # will run on port 45678
      • pyrobox -d . 45678 # will run on port 45678 in current directory
  5. To specify alternate bind address

    • Add bind add -bind {address} # ie: -bind 127.0.0.2 or -bind 127.0.0.99
  6. To change upload password

    • i) or add -k or --password command line argument when launching the program
      • pyrobox -k "my new password" to launch the server with new password
      • pyrobox -k "" to launch the server without password
      • pyrobox to launch the server with default password (SECret)
    • ii) just edit the code for permanent change (see config class at top)
  7. Optional configurations

usage: local_server_pyrobox.py [--password PASSWORD] [--no-upload] [--no-zip] [--no-update] [--no-delete] [--no-download] [--read-only] [--view-only] [--bind ADDRESS] [--directory DIRECTORY] [--version] [-h] [port]

Positional Arguments

arg value Description
port Specify alternate port [default: 6969]

Options

Flags/Arg value Description
--password PASSWORD, -k PASSWORD Upload Password (GUESTS users and Nameless server users must use it to upload files)(default: SECret)
--directory DIRECTORY, -d DIRECTORY Specify alternative directory [default: current directory]
--bind ADDRESS, -b ADDRESS Specify alternate bind address [default: all interfaces]
--version, -v show program's version number and exit
-h, --help show this help message and exit
--no-extra-log Disable file path and [= + - #] based logs (default: False)

Customization Options

Flags Description
--no-upload, -nu Files can't be uploaded (default: False)
--no-zip, -nz Disable Folder->Zip downloading (default: False)
--no-modify, -nm Disable File Modification (ie: renaming, overwriting existing files) (On upload, if file exists, will add a number at the end) (default: False)
--no-delete, -nd Disable File Deletion (default: False)
--no-download, -ndw Disable File Downloading [videos won't play either] (default: False)
--read-only, -ro Read Only Mode disables upload and any modifications ie: rename, delete (default: False)
--view-only, -vo Only allowed to see file list, nothing else (default: False)

Advanced Account System

You must give a --name [Name] and --admin-id [USER Name], --admin-pass [PASSWORD] to create an admin account. If guest not allowed --no-guest-allowed User must login to access the server. You can also disable signing up --no-signup (Only admin can add user from admin page). Admin can also update user permission from admin page.

Flags/Arg value Description
--name NAME, -n NAME Name of the user (default: None)
--admin-id ADMIN_ID, -aid ADMIN_ID Admin ID (default: None)
--admin-pass ADMIN_PASS, -ak ADMIN_PASS Admin Password (default: None)
--no-signup, -ns Disable Signing up (Only admin can add user from admin page)(default: False)
--no-guest-allowed, -ng Disable Guest Access (default: False)

Account Example

  1. pyrobox -n "My Server1" -aid "admin" -ak "admin123" -k "Guest_pass" # will allow anyone to access the server, but they must use Guest_pass to upload files
  2. pyrobox -n "My Server2" -aid "admin" -ak "admin123" -ng # If someone wants to access the server they must sign up via signup page first. No guest allowed
  3. pyrobox -n "My Server3" -aid "admin" -ak "admin123" -ng -ns # Only admin can access the server. No guest allowed, no signup allowed. Admin can add user from admin page

TODO

  • #33 Show thumbnails, for png and jpg (how to do with just standard library?), For others, just show extension.
  • #34 Copy stream URL for videos to play with any video player
  • #36 Add side bar to do something ๐Ÿค”
  • check output ip and port accuracy on multiple os
  • #37 Backup code if Reload causes unhandled issue and can't be accessed
  • Add more flags to disable specific features

Support for more features

Context menu

Right click on any file link

FAQ

Using WSL, "PIP not found"

Run this to install pip3 and add pip to path

sudo apt -y purge python3-pip
sudo python3 -m pip uninstall pip
sudo apt -y install python3-pip
pip3 install --upgrade pip
echo "export PATH=\"${HOME}/.local/bin:$PATH\"" >>"${HOME}"/.bashrc

Re-running the file should work.

Using Linux, "PIP not found"

Run this to install pip3

sudo apt -y purge python3-pip
sudo python3 -m pip uninstall pip
sudo apt -y install python3-pip
pip3 install --upgrade pip

Re-running the file should work.

Deleted (Move to Recycle), But WHERE ARE THEY?? [on LINUX & WSL]

Actually the feature is working fine, unfortunately NO-GUI mode linux and WSL don't recycle bin, so you can't find it! And to make things worse, you need to manually clear the recyle bin from ~/.local/share/Trash SO I'D RECOMMAND USING DELETE PARMANENTLY

Running on WINDOWS, but can't access with other device [FIREWALL]

You probably have FireWall ON and not configured. For your safety, I'd recommend you to allow Python on private network and run the server when your network is Private. IN SHORT: ALLOW PYTHON ON FIREWALL, RUN THE SERVER

note: allowed on private but using public network on firewall will cause similar issue, you gotta make both same or allow python both on public and private

Thanks to

  1. https://github.com/bones7456/bones7456/blob/master/SimpleHTTPServerWithUpload.py (the guy who made upload possible)
  2. https://gist.github.com/UniIsland/3346170 (the guy who made multiple file upload possible)
  3. https://github.com/SethMMorton/natsort (sorting titles)
  4. https://github.com/sandes/zipfly (modified lets you see the zip progress)
  5. https://github.com/sampotts/plyr (improved video player)

Disclaimer: the owner or the programmers or any content of this repository hold no responsibility for any kind of data loss or modification on your system and do not warrenty for such actions. I tried my best to prevent all sorts of ways (that I am currently aware of) to prevent data loss or unwanted data modification. See Data Safety Measures taken on this projects to prevent unwanted data loss.

Footnotes

  1. [<=3.4 compatibility] is on the way. โ†ฉ

pyrobox's People

Contributors

rasan147 avatar rexackermann avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

pyrobox's Issues

HIGH CPU after uploading large file >2gb

High CPU usage (on server) after sending a large file to server. File is inaccessible during that time (server has the file open)

Sending zip and force closing the server caused unexpected eof to the

TO TEST:

  • make a file with numbers (size 2 gb)
  • post it to the server
  • Wait till it hits high CPU
  • break the process
  • compare uploaded and original file

To analyze:

  • What is causing this high cpu
  • Why the file is inaccessible after upload
  • is there any unlimited loop

[IDEA] on download folder, scan directory for changes

On 1st time zipping, scan the directory and write .json file {"file name hash": "last modified", ....} And keep it side by side with .zip file in temp folder.

On 2nd run, match the folder with .json and if modified, create new zip (will not delete older because might be in use) however will rewrite the .json

On side by side run, keep track on 1st run, then check for 2nd run, if unchanged, return 1st one handler.

NOTE: in future add cache management per user, so after zipping and downloading user can delete his .zip from temp folder... Maybe. Bcz might be in use by other. So don't do it.....

[FEAT] check if port is open or closed

here's how:

import socket

HOST = "localhost"
PORT = 443

# Creates a new socket
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

# Try to connect to the given host and port
if sock.connect_ex((HOST, PORT)) == 0:
    print("Port " + str(PORT) + " is open") # Connected successfully
else:
    print("Port " + str(PORT) + " is closed") # Failed to connect because port is in use (or bad host)

# Close the connection
sock.close()

[Feat] [MUST] ADD login with permission & IP ban

Required for extreme level security

  • Need to solve #26 first

Add log in feature.
Heres how:

  1. Create account by asking the admin (offline), the admin will create {"username": ["$salted password hash", permission_level]
  2. Also create a list ["token"+"permission_level]

ie: "dhskdh398wjr9" , the last "9" is the permission level

because same user may use multiple PC with multiple browsers.

So the server will generate a token and store it on Cache (use https://docs.python.org/3/library/http.cookies.html and https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies) (use HttpOnly and same-origin?)

Check it with server and on every request, update the hash with new one with a Constant amount of expire days defined in the config

  1. On multiple failure (define in config), put the IP on blocklist
  2. Ask admin to manually remove that...

separate android and linux

Both android and linux tells "linux" in platform.system.

From os import environ
is_android = 'ANDROID_STORAGE' in environ

add 7z linux support

check if 7z installed

  1. sudo apt list --installed | grep 7zip

if you are using zsh

  1. sudo apt search 7zip'*' --installed

if you are using bash

  1. sudo apt search 7zip* --installed

if not

sudo apt-get install 7zip p7zip

Change Project name and Publish to PIP

  1. Change package name to "py_fileserver"
  2. Short name for cmd "py_fs"
  3. Make a development branch to push all dirty changes.
  4. Add Contribution.md and other files like other projects
  5. Maybe ask for donations?
  6. Add "Push to pip" action

make a log file

/?logfile=secRET
Make a log file with password protected system. If possible instead of making link with pass, send password data as post request and get the log

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.