Guest User

Untitled

a guest
Nov 9th, 2018
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.29 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # ftpserver-cli.py
  3. import sys
  4. sys.path.append("/home/sam/.local/lib/python2.7/site-packages") # enter your proper path here
  5. import argparse
  6.  
  7. from pyftpdlib.authorizers import DummyAuthorizer
  8. from pyftpdlib.handlers import FTPHandler
  9. from pyftpdlib.servers import FTPServer
  10.  
  11. def processCmdLineOptions():
  12. global optparser
  13. optparser = argparse.ArgumentParser(description="ftpserver-cli",
  14. formatter_class=argparse.RawDescriptionHelpFormatter)
  15. optparser.add_argument('-u', '--username', action='store', type=str,
  16. default="user", help="username")
  17. optparser.add_argument('-p', '--password', action='store', type=str,
  18. default="12345", help="password")
  19. optparser.add_argument('-t', '--port', action='store', type=int,
  20. default="21", help="port")
  21. optparser.add_argument('-d', '--directory', action='store', type=str,
  22. default="/home/stefano/Projekte/", help="port")
  23. optargs = optparser.parse_args(sys.argv[1:]) #(sys.argv)
  24. return optargs
  25.  
  26.  
  27. optargs = processCmdLineOptions()
  28.  
  29. print("Using: user: %s pass: %s port: %d dir: %s" % (optargs.username, optargs.password, optargs.port, optargs.directory))
  30.  
  31. authorizer = DummyAuthorizer()
  32. authorizer.add_user(optargs.username, optargs.password, optargs.directory, perm="elradfmw")
  33. #authorizer.add_anonymous("/home/nobody")
  34.  
  35. handler = FTPHandler
  36. handler.authorizer = authorizer
  37.  
  38. server = FTPServer(("0.0.0.0", optargs.port), handler)
  39. server.serve_forever()
  40.  
  41. #GLWT(Good Luck With That) Public License
  42. #Copyright (c) Everyone, except Author
  43. #The author has absolutely no clue what the code in this project does.
  44. #It might just work or not, there is no third option.
  45. #Everyone is permitted to copy, distribute, modify, merge, sell, publish,
  46. #sublicense or whatever they want with this software but at their OWN RISK.
  47. # GOOD LUCK WITH THAT PUBLIC LICENSE
  48. # TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION, AND MODIFICATION
  49. #0. You just DO WHATEVER YOU WANT TO as long as you NEVER LEAVE A
  50. #TRACE TO TRACK THE AUTHOR of the original product to blame for or hold
  51. #responsible.
  52. #IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  53. #WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  54. #CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  55. #Good luck.
Add Comment
Please, Sign In to add comment