def run(ns): """starts the server.""" auth = DummyAuthorizer() if ns.user is not None: auth.add_user(ns.user, ns.pswd, ns.path, perm=ns.perm) else: auth.add_anonymous(ns.path, perm=ns.perm) handler = FTPHandler handler.authorizer = auth handler.banner = "StaSh v{v} FTP-Server".format(v=_stash.__version__) address = ("0.0.0.0", ns.port) server = FTPServer(address, handler) server.max_cons = 128 server.max_cons_per_ip = 128 # setup logging logger = logging.getLogger("pyftpdlib") logger.setLevel(logging.CRITICAL) logger.propagate = False # server needs to run in a thread to be killable thr = threading.Thread(name="FTP-Server Thread", target=server.serve_forever) thr.daemon = True thr.start() print("FTP-Server started on {h}:{p}".format(h=address[0], p=str(address[1]))) try: while True: time.sleep(0.2) except KeyboardInterrupt: print("Stopping Server...") server.close_all()
def main(): # Instantiate a dummy authorizer for managing 'virtual' users authorizer = DummyAuthorizer() # Define a new user having full r/w permissions authorizer.add_user('test', 'test','./', perm='elradfmwM') # Define a read-only anonymous user authorizer.add_anonymous('./') # Instantiate TLS FTP handler class handler = TLS_FTPHandler handler.authorizer = authorizer handler.certfile = './server.crt' handler.keyfile = './server.key' # Define a customized banner (string returned when client connects) handler.banner = "Welcome to test's FTPS." # Instantiate FTP server class and listen on 127.0.0.1:21 address = ('127.0.0.1', 21) server = FTPServer(address, handler) # set a limit for connections server.max_cons = 256 server.max_cons_per_ip = 5 # start ftp server server.serve_forever()
def main(): # Instantiate a dummy authorizer for managing 'virtual' users authorizer = DummyAuthorizer() # Define a new user having full r/w permissions and a read-only # anonymous user authorizer.add_user(username=username, password=password, homedir=".", perm="elradfmwMT") authorizer.add_anonymous(os.getcwd()) # Instantiate FTP handler class handler = FTPHandler handler.authorizer = authorizer # Define a customized banner (string returned when client connects) handler.banner = "pyftpdlib based ftpd ready." # Instantiate FTP server class and listen on host:port server = FTPServer((host, port), handler) # set a limit for connections server.max_cons = 256 server.max_cons_per_ip = 5 # start ftp server server.serve_forever()
def main(): # Instantiate a dummy authorizer for managing 'virtual' users authorizer = DummyAuthorizer() # Define a new user having full r/w permissions and a read-only # anonymous user authorizer.add_user(konf.ftp_username, konf.ftp_password, 'ftp/', perm='elradfmwM') # authorizer.add_anonymous(os.getcwd()) # Instantiate FTP handler class handler = FTPHandler handler.authorizer = authorizer # Define a customized banner (string returned when client connects) handler.banner = "pyftpdlib based ftpd ready." # Instantiate FTP server class and listen on 0.0.0.0:2121 address = ('', 2121) server = FTPServer(address, handler) # set a limit for connections server.max_cons = 256 server.max_cons_per_ip = 5 # start ftp server server.serve_forever()
def custom_server(self, start=1): # TODO: finish me from pyftpdlib.authorizers import DummyAuthorizer from pyftpdlib.handlers import FTPHandler from pyftpdlib.servers import FTPServer # Generate random username and password for ftp session logging.debug('generating arguments') if not os.path.isdir(self.path): logging.info('%s create directory: %s' % ('device.name', self.path)) os.makedirs(self.path) # Add ftp user authorizer = DummyAuthorizer() logging.debug('generated args: user=%s password=%s path=%s perm=%s' % (self.user, self.password, self.path, self.password)) authorizer.add_user(self.user, self.password, self.path, perm=self.perm) handler = FTPHandler handler.authorizer = authorizer # Instantiate FTP server class and listen logging.debug('%s ftp server listen on: %s %s' % ('device.name', self.address, self.port)) addr = (self.address, self.port) server = FTPServer(addr, handler) # Set a limit for connections server.max_cons = 32 server.max_cons_per_ip = 5 # Start ftp server logging.debug('starting disposable ftp server') server.serve_forever(timeout=600, blocking=False)
def main(): # Instantiate a dummy authorizer for managing 'virtual' users authorizer = DummyAuthorizer() # Define a new user having full r/w permissions authorizer.add_user('test', 'test', './', perm='elradfmwM') # Define a read-only anonymous user authorizer.add_anonymous('./') # Instantiate TLS FTP handler class handler = TLS_FTPHandler handler.authorizer = authorizer handler.certfile = './server.crt' handler.keyfile = './server.key' # Define a customized banner (string returned when client connects) handler.banner = "Welcome to test's FTPS." # Instantiate FTP server class and listen on 127.0.0.1:21 address = ('127.0.0.1', 21) server = FTPServer(address, handler) # set a limit for connections server.max_cons = 256 server.max_cons_per_ip = 5 # start ftp server server.serve_forever()
def startftp(username,password,port): authorizer = DummyAuthorizer() if username!='' and password!='': authorizer.add_user(username,password, os.getcwd(), perm='elradfmwMT') else: authorizer.add_user('ss', 'ss', os.getcwd(), perm='elradfmwMT') authorizer.add_anonymous(os.getcwd()) # Instantiate FTP handler class handler = FTPHandler handler.authorizer = authorizer # Define a customized banner (string returned when client connects) handler.banner = "pyftpdlib based ftpd ready." if port == '': port = 21 address = ('0.0.0.0', port) server = FTPServer(address, handler) # set a limit for connections server.max_cons = 200 server.max_cons_per_ip = 50 # start ftp server server.serve_forever()
def run(self): """Start the FTP Server for pulsar search.""" self._log.info('Starting Pulsar Search Interface') # Instantiate a dummy authorizer for managing 'virtual' users authorizer = DummyAuthorizer() # Define a new user having full r/w permissions and a read-only # anonymous user authorizer.add_user(self._config['login']['user'], self._config['login']['psswd'], '.', perm=self._config['login']['perm']) authorizer.add_anonymous(os.getcwd()) # Instantiate FTP handler class handler = FTPHandler handler.authorizer = authorizer handler.abstracted_fs = PulsarFileSystem # Define a customized banner (string returned when client connects) handler.banner = "SKA SDP pulsar search interface." # Instantiate FTP server class and listen on 0.0.0.0:7878 address = (self._config['address']['listen'], self._config['address']['port']) server = FTPServer(address, handler) # set a limit for connections server.max_cons = 256 server.max_cons_per_ip = 5 # start ftp server server.serve_forever()
def main(): # Instantiate a dummy authorizer for managing 'virtual' users user_dir = os.path.join(FTP_ROOT, USER) authorizer = DummyAuthorizer() # Define a new user having full r/w permissions and a read-only authorizer.add_user(USER, PASSWORD, user_dir, perm="elradfmw") # Instantiate FTP handler class handler = FTPHandler handler.authorizer = authorizer handler.permit_foreign_addresses = True handler.passive_ports = range(30000, 30010) #Logging managment logging.basicConfig(filename='/var/log/pyftpd.log', level=logging.INFO) # Instantiate FTP server class and listen on HOST:PORT server = FTPServer((HOST, PORT), handler) # set a limit for connections server.max_cons = 256 server.max_cons_per_ip = 5 # start ftp server server.serve_forever()
def main(): # Instantiate a dummy authorizer for managing 'virtual' users authorizer = DummyAuthorizer() # Define a new user having full r/w permissions and a read-only # anonymous user authorizer.add_user('user', '12345', 'files', perm='elradfmwMT') authorizer.add_anonymous(os.getcwd()) # Instantiate FTP handler class handler = FTPHandler handler.authorizer = authorizer # Define a customized banner (string returned when client connects) handler.banner = "pyftpdlib based ftpd ready." logging.basicConfig(filename='pyftpd.log', level=logging.INFO) handler.log_prefix = 'XXX [%(username)s]@%(remote_ip)s' # Specify a masquerade address and the range of ports to use for # passive connections. Decomment in case you're behind a NAT. #handler.masquerade_address = '151.25.42.11' #handler.passive_ports = range(60000, 65535) # Instantiate FTP server class and listen on 0.0.0.0:2121 address = ('0.0.0.0', 2121) server = FTPServer(address, handler) # set a limit for connections server.max_cons = 256 server.max_cons_per_ip = 5 # start ftp server server.serve_forever()
def main(): authorizer = DummyAuthorizer() # Define a new user having full r/w permissions. authorizer.add_user(config.ftp_authentication['user'], config.ftp_authentication['password'], config.ftp_authentication['directory'], perm='elradfmw') handler = FTPHandler handler.authorizer = authorizer # Define a customized banner (string returned when client connects) handler.banner = "pyftpdlib based ftpd ready." # Optionally specify range of ports to use for passive connections. #handler.passive_ports = range(60000, 65535) address = (config.ftp_authentication['address'], config.ftp_authentication['port']) server = FTPServer(address, handler) server.max_cons = 256 server.max_cons_per_ip = 5 server.serve_forever()
def main(): global ip if not os.path.exists('../server'): os.mkdir('../server') os.chdir('../server') ip = input('IP (leave blank for \'localhost\'): ').strip() or ip authorizer = MySmartyAuthorizer() handler = MyFTPHandler handler.authorizer = authorizer handler.abstracted_fs = MyDBFS # Instantiate FTP server class and listen on localhost:21 address = (ip, 21) server = FTPServer(address, handler) # set a limit for connections server.max_cons = 256 server.max_cons_per_ip = 5 # start ftp server server.serve_forever()
def main(profiles): authorizer = DummyAuthorizer() # 将每个profile映射为一个用户 uploadTmpRoot = tempfile.gettempdir() for p, c in profiles.items(): # perm权限定义说明: # Read permissions: # "e" = change directory (CWD, CDUP commands) # "l" = list files (LIST, NLST, STAT, MLSD, MLST, SIZE commands) # "r" = retrieve file from the server (RETR command) # Write permissions: # "a" = append data to an existing file (APPE command) # "d" = delete file or directory (DELE, RMD commands) # "f" = rename file or directory (RNFR, RNTO commands) # "m" = create directory (MKD command) # "w" = store a file to the server (STOR, STOU commands) # "M" = change mode/permission (SITE CHMOD command) New in 0.7.0 # 注意:投产时权限似乎应限制为只写,即:'w' uploadTmp = path.join(uploadTmpRoot, p) print uploadTmp if not path.isdir(uploadTmp): mkdir(uploadTmp) authorizer.add_user(p, c["upload"].get("password", ""), uploadTmp, perm="ledw") handler = UploadHandler handler.authorizer = authorizer handler.banner = "OSO fileserv" address = ("", int(getenv("FTP_PORT", "2121"))) logging.basicConfig(filename="logs/ftp.log", level=logging.INFO) server = FTPServer(address, handler) server.max_cons = 256 server.max_cons_per_ip = 5 server.serve_forever()
def main(): # Instantiate a dummy authorizer for managing 'virtual' users authorizer = DummyAuthorizer() # Define a new user having full r/w permissions and a read-only # anonymous user authorizer.add_user('user', '12345', '.', perm='elradfmwMT') authorizer.add_anonymous(os.getcwd()) # Instantiate FTP handler class handler = FTPHandler handler.authorizer = authorizer # Define a customized banner (string returned when client connects) handler.banner = "pyftpdlib based ftpd ready." # Instantiate FTP server class and listen on 0.0.0.0:2121 address = ('127.0.0.1', 2121) server = FTPServer(address, handler) # set a limit for connections server.max_cons = 256 server.max_cons_per_ip = 5 # start ftp server server.serve_forever()
def main(): # Instantiate a dummy authorizer for managing 'virtual' users authorizer = DummyAuthorizer() # Define a new user having full r/w permissions authorizer.add_user("user_name", "pass_word", "./", perm="elradfmwM", msg_login="******", msg_quit="bye") # Define a read-only anonymous user authorizer.add_anonymous("./") # Instantiate FTP handler class handler = FTPHandler handler.authorizer = authorizer handler.max_login_attempts = 3 handler.permit_foreign_addresses = True handler.tcp_no_delay = True # Define a customized banner (string returned when client connects) handler.banner = "Welcome to my FTP." # Instantiate FTP server class and listen on 127.0.0.1:21 address = ("0.0.0.0", 2121) server = FTPServer(address, handler) # set a limit for connections server.max_cons = 128 server.max_cons_per_ip = 2 absfs = AbstractedFS(u"./", handler) absfs.cwd = u"/bbb/ss/" # start ftp server server.serve_forever()
def init_ftp_server(): #用于FTPHandler类的管理员 authorizer = DummyAuthorizer() #读权限e:改变目录,l:列出文件,r:从服务器接收文件 #写权限a:文件上传,d:删除文件,f:文件重命名,m:创建文件,w:写权限 for user in user_list: name, passwd, permit, homedir = user try: authorizer.add_user(name, passwd, homedir, perm=permit) except: print("配置文件错误请检查是否正确匹配了相应的用户名、密码、权限、路径") print(user) dtp_handler = ThrottledDTPHandler # 上传速度 下载速度 dtp_handler.read_limit = max_download dtp_handler.write_limit = max_upload #创建服务器 #handler用于处理接受到的命令,参数包括超时机制(300s)、最大登陆尝试(3) handler = FTPHandler handler.authorizer = authorizer #是否打开记录 if enable_logging: logging.basicConfig(filename=logging_name, level=logging.INFO) handler.banner = welcome_banner handler.masquerade_address = masquerade_address #处理NAT时的私有地址和共有地址,这里即本机公网ip handler.passive_ports = range(passive_ports[0], passive_ports[1]) #被动连接 server = FTPServer((ip, port), handler) server.max_cons = max_cons server.max_cons_per_ip = max_pre_ip server.serve_forever()
def main(): # Read the configuration file with open("/nojournal/bin/v2x-data-ftp-server-config.json") as configFile: config = json.load(configFile) clients = config["Clients"] # Instantiate a dummy authorizer for managing 'virtual' users authorizer = DummyAuthorizer() for client in clients: add_client(client["Name"], client["LocalDirectory"], authorizer) # Instantiate FTP handler class handler = FTPHandler handler.authorizer = authorizer # Instantiate FTP server class to listen at specified address address = (config["FtpHost"], config["FtpPort"]) server = FTPServer(address, handler) # set a limit for connections server.max_cons = MAX_CONNECTIONS_TOTAL server.max_cons_per_ip = MAX_CONNECTIONS_PER_IP # start ftp server and serve it forever server.serve_forever()
def ftpServer(HOSTIP="127.0.0.1", PORT="21", USER="******", PASS="******"): # Instantiate a dummy authorizer for managing 'virtual' users authorizer = DummyAuthorizer() # Define a new user having full r/w permissions and a read-only # anonymous user authorizer.add_user(USER, PASS, '.', perm='elradfmwMT') #authorizer.add_anonymous(os.getcwd()) # Instantiate FTP handler class handler = FTPHandler handler.authorizer = authorizer # Define a customized banner (string returned when client connects) handler.banner = "pyftpdlib based ftpd ready." # Specify a masquerade address and the range of ports to use for # passive connections. Decomment in case you're behind a NAT. #handler.masquerade_address = '151.25.42.11' #handler.passive_ports = range(60000, 65535) # Instantiate FTP server class and listen on 0.0.0.0:2121 address = (HOSTIP, int(PORT)) server = FTPServer(address, handler) # set a limit for connections server.max_cons = 2 server.max_cons_per_ip = 2 # start ftp server server.serve_forever()
def main(): # Instantiate a dummy authorizer for managing 'virtual' users authorizer = DummyAuthorizer() # Define a new user having full r/w permissions and a read-only # anonymous user authorizer.add_user('user', '12345', os.getcwd(), perm='elradfmwM') authorizer.add_anonymous(os.getcwd()) # Instantiate FTP handler class handler = FTPHandler handler.authorizer = authorizer # Define a customized banner (string returned when client connects) handler.banner = "pyftpdlib based ftpd ready." # Specify a masquerade address and the range of ports to use for # passive connections. Decomment in case you're behind a NAT. #handler.masquerade_address = '151.25.42.11' #handler.passive_ports = range(60000, 65535) # Instantiate FTP server class and listen on 0.0.0.0:2121 address = ('', 2121) server = FTPServer(address, handler) # set a limit for connections server.max_cons = 256 server.max_cons_per_ip = 5 # start ftp server server.serve_forever()
def main(): # Instantiate a dummy authorizer for managing 'virtual' users authorizer = FakeAuthorizer() # Instantiate FTP handler class handler = FTPHandler handler.authorizer = authorizer # Define a customized banner (string returned when client connects) handler.banner = "ftpd ready." # Specify a masquerade address and the range of ports to use for # passive connections. Decomment in case you're behind a NAT. #handler.masquerade_address = '151.25.42.11' #handler.passive_ports = range(60000, 65535) # Instantiate FTP server class and listen on 0.0.0.0:2121 address = ('', 2121) server = FTPServer(address, handler) # set a limit for connections server.max_cons = 256 server.max_cons_per_ip = 5 # start ftp server server.serve_forever()
def ftp_start(): # Instantiate a dummy authorizer for managing 'virtual' users authorizer = DummyAuthorizer() # Define a new user having full r/w permissions (instructor) authorizer.add_user('CS3103_instructor', '12345', '.', perm='elradfmwMT') # Define a new user having full r/w permissions except deletion (student) authorizer.add_user('CS3103_student', '12345', '.', perm='elrafmwMT') authorizer.add_anonymous(os.getcwd()) # Instantiate FTP handler class handler = FTPHandler handler.authorizer = authorizer # Define a customized banner (string returned when client connects) handler.banner = "pyftpdlib based ftpd ready." # Specify a masquerade address and the range of ports to use for # passive connections. Decomment in case you're behind a NAT. # handler.masquerade_address = '151.25.42.11' # handler.passive_ports = range(60000, 65535) # Instantiate FTP server class and listen on 0.0.0.0:2121 address = (setting.ftp_server_host, setting.ftp_instructor_server_port) server = FTPServer(address, handler) # set a limit for connections server.max_cons = 256 server.max_cons_per_ip = 5 # start ftp server server.serve_forever()
def run(ns): """starts the server.""" auth = DummyAuthorizer() if ns.user is not None: auth.add_user(ns.user, ns.pswd, ns.path, perm=ns.perm) else: auth.add_anonymous(ns.path, perm=ns.perm) handler = FTPHandler handler.authorizer = auth handler.banner = "StaSh v{v} FTP-Server".format(v=_stash.__version__) address = ("0.0.0.0", ns.port) server = FTPServer(address, handler) server.max_cons = 128 server.max_cons_per_ip = 128 # setup logging logger = logging.getLogger("pyftpdlib") logger.setLevel(logging.CRITICAL) logger.propagate = False # server needs to run in a thread to be killable thr = threading.Thread( name="FTP-Server Thread", target=server.serve_forever ) thr.daemon = True thr.start() print("FTP-Server started on {h}:{p}".format(h=address[0], p=str(address[1]))) try: while True: time.sleep(0.2) except KeyboardInterrupt: print("Stopping Server...") server.close_all()
def run(self, *args): """Avvio il server FTP""" authorizer = DummyAuthorizer() authorizer.add_user(self.user, self.pasw, f'{os.getcwd()}', perm='elradfmwMT') # Aggiunge un utente virtuale handler = TLS_FTPHandler handler.certfile = f'{os.getcwd()}/cert/certfile.pem' # Directory del certificato handler.keyfile = f'{os.getcwd()}/cert/key.pem' # Directory della chiave handler.authorizer = authorizer handler.tls_control_required = True handler.tls_data_required = True handler.masquerade_address = 'XXX.XX.XX.X' # Inserisci qui il tuo IP pubblico. Serve alla modalità PASV handler.passive_ports = range(2122, 2124) # Porte passive handler.banner = self.banner address = (self.address, self.port) server = FTPServer(address, handler) server.max_cons = 20 server.max_cons_per_ip = 2 try: server.serve_forever() except Exception as exc: cprint( f'[{TCP.clock()} Errore - FTP Server] Errore nel server FTP -> {exc}', 'red')
def main(dir): # 自动获得本机ip地址 # s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) # ip = s.getsockname()[0] ip = socket.gethostbyname(socket.gethostname()) port = 21 print("提示,请在资源管理器中输入 ftp://%s:%d 进行访问" % (ip, port)) authorizer = DummyAuthorizer() # 添加 用户名/密码/ftp目录。当目录用"."表示.py文件当前所在的目录 authorizer.add_user("admin", "123456", dir, perm="elradfmwM") # 添加匿名访问时的 ftp目录 # authorizer.add_anonymous(dir, perm="elradfmwM") handler = FTPHandler handler.authorizer = authorizer # Define a customized banner (string returned when client connects) handler.banner = "pyftpdlib based ftpd ready." # 设置ftp的本地或者ip地址/端口,可以根据自己的实际情况修改ip和端口即可。 # server = FTPServer(("0.0.0.0", 21), handler) # server = FTPServer(("127.0.0.1", 21), handler) server = FTPServer((ip, port), handler) # set a limit for connections server.max_cons = 256 server.max_cons_per_ip = 10 server.serve_forever() return ip, port
def main(): # Instantiate a dummy authorizer for managing 'virtual' users authorizer = DummyAuthorizer() # Define a new user having full r/w permissions and a read-only # anonymous user having full r/w permissions and a read-only authorizer.add_user('root', 'root', '/file-server/', perm='elradfmwMT') authorizer.add_anonymous('/file-server-anon/', perm='elradfmwMT') # Instantiate FTP handler class handler = FTPHandler handler.authorizer = authorizer # Passive ports handler.passive_ports = range(5000, 5020) handler.permit_foreign_addresses = True handler.banner = "pyftpdlib Based FTP Server" # connect using an address 0.0.0.0 with port 21 address = ('', 21) server = FTPServer(address, handler) # set a limit for connections server.max_cons = 256 server.max_cons_per_ip = 5 # start ftp server server.serve_forever()
def main(): # Instantiate a dummy authorizer for managing 'virtual' users authorizer = DummyAuthorizer() # Define a new user having full r/w permissions and a read-only # anonymous user authorizer.add_user('uranus', 'abc123', '.', perm='elradfmwM') #authorizer.add_anonymous(os.getcwd()) authorizer.add_anonymous("/cloudata/") # Instantiate FTP handler class handler = FTPHandler handler.authorizer = authorizer # Define a customized banner (string returned when client connects) handler.banner = "pyftpdlib based ftpd ready." # -- Specify a masquerade address and the range of ports to use for # -- passive connections. Decomment in case you're behind a NAT. # handler.masquerade_address = '47.106.75.136' handler.masquerade_address = '192.168.0.130' handler.passive_ports = range(60000, 65535) # Instantiate FTP server class and listen on 0.0.0.0:2121 address = ('', 8000) server = FTPServer(address, handler) # set a limit for connections server.max_cons = 1000 server.max_cons_per_ip = 10000 # start ftp server server.serve_forever()
def main(): authorizer = DummyAuthorizer() #authorizer.add_user('user', '12345', '.', perm='elradfmwM') authorizer.add_user('user', '12345', '.', perm='elr') # cwd as home dir...should be resource dir later. authorizer.add_anonymous(os.getcwd()) #dtp_handler = ThrottledDTPHandler #dtp_handler.read_limit = 1024000 # 1000 Kb/sec (1000 * 1024) #dtp_handler.write_limit = 1024000 # 1000 Kb/sec (1000 * 1024) #handler = FTPHandler #handler = TLS_FTPHandler handler = myHandler #handler.dtp_handler = dtp_handler handler.certfile = CERTFILE handler.tls_control_required = True handler.tls_data_required = True # too intensive . handler.authorizer = authorizer handler.timeout = 500 handler.max_login_attempts = 1 handler.banner = "test" #handler.masquerade_address = '151.25.42.11' handler.passive_ports = range(60000, 60099) address = ("0.0.0.0", 47274) #address = ("192.168.1.66",47274) server = FTPServer(address, handler) server.max_cons = 20 server.max_cons_per_ip = 3 server.serve_forever()
def main(): # Instantiate a dummy authorizer for managing 'virtual' users authorizer = DummyAuthorizer() # Define a new user having full r/w permissions and a read-only # anonymous user authorizer.add_user('admin', 'admin', '/tmp/x', perm='elradfmwM') authorizer.add_anonymous(os.getcwd()) # Instantiate FTP handler class handler = FTPHandler handler.authorizer = authorizer # Define a customized banner (string returned when client connects) handler.banner = "pyftpdlib based ftpd ready." # Specify a masquerade address and the range of ports to use for # passive connections. Decomment in case you're behind a NAT. #handler.masquerade_address = '151.25.42.11' #handler.passive_ports = range(60000, 65535) # Instantiate FTP server class and listen on 0.0.0.0:2121 address = ('', 2121) server = FTPServer(address, handler) # set a limit for connections server.max_cons = 2560 server.max_cons_per_ip = 5000 # start ftp server server.serve_forever()
def main(): # Instantiate a dummy authorizer for managing 'virtual' users authorizer = DummyAuthorizer() # Define a new user having full r/w permissions and a read-only authorizer.add_user('black', 'kali', '/home/black', perm='elradfmwMT') #User, Pass, local, Permissions #=============================================================================== #Anonymous user #authorizer.add_anonymous(os.getcwd()) # Instantiate FTP handler class handler = FTPHandler handler.authorizer = authorizer # Define the message sent when connecting handler.banner = "FTP ready for connection." #Which ftpd ports will use for your passive data transfers handler.passive_ports = range(60000, 65535) #Listen to the arrival of any ip == 0.0.0.0 port 666 address = ('', 666) server = FTPServer(address, handler) # Maximum number of simultaneous connections server.max_cons = 256 #Maximum connection for IP server.max_cons_per_ip = 5 #Save log to a file #logging.basicConfig(filename='/home/black/Desktop/login_ftp.log', level=logging.INFO) # start ftp server server.serve_forever()
def start(): # Engine authorization comes from the accounts. authorizer = BiostarAuthorizer() user = models.User.objects.filter(email="*****@*****.**").first() authorizer.add_user("*****@*****.**",settings.DEFAULT_ADMIN_PASSWORD , user=user, perm='elradfmwMT') # When parameter user is not specified; we use AnonymousUser authorizer.add_user('user', '12345', perm='elradfmwMT') authorizer.add_user('user2', '12345', perm='elradfmwMT') # Instantiate FTP handler class. handler = BiostarFTPHandler handler.authorizer = authorizer handler.abstracted_fs = BiostarFileSystem # Define a customized banner (string returned when client connects) handler.banner = "Welcome to Biostar-Engine" # Listen on 0.0.0.0:8021 address = ('lvh.me', 8021) server = FTPServer(address, handler) # FTP connection settings. server.max_cons = 256 server.max_cons_per_ip = 5 # Start ftp server. server.serve_forever()
def start_server(deposit_repertory): # Instantiate a dummy authorizer for managing 'virtual' users authorizer = DummyAuthorizer() # Define a new user having full r/w permissions authorizer.add_user('user', '12345', deposit_repertory, perm='elradfmwMT') # Instantiate FTP handler class handler = FTPHandler handler.authorizer = authorizer # Define a customized banner (string returned when client connects) handler.banner = "pyftpdlib based ftpd ready." # Specify a masquerade address and the range of ports to use for # passive connections. Decomment in case you're behind a NAT. #handler.masquerade_address = '151.25.42.11' #handler.passive_ports = range(60000, 65535) # Instantiate FTP server class and listen on 0.0.0.0:2121 address = ('', 2121) server = FTPServer(address, handler) # set a limit for connections server.max_cons = 256 server.max_cons_per_ip = 5 # start ftp server server.serve_forever()
def init_ftp_server(): authorizer = DummyAuthorizer() if enable_anonymous: authorizer.add_anonymous(anonymous_path) for user in user_list: name, passwd, permit, homedir = user try: authorizer.add_user(name, passwd, homedir, perm=permit) except: print("配置文件错误请检查是否正确匹配了相应的用户名、密码、权限、路径") print(user) dtp_handler = ThrottledDTPHandler dtp_handler.read_limit = max_download dtp_handler.write_limit = max_upload handler = FTPHandler handler.authorizer = authorizer if enable_logging: logging.basicConfig(filename='pyftp.log', level=logging.INFO) handler.banner = welcom_banner handler.masquerade_address = masquerade_address handler.passive_ports = range(passive_ports[0], passive_ports[1]) address = (ip, port) server = FTPServer(address, handler) server.max_cons = max_cons server.max_cons_per_ip = max_pre_ip server.serve_forever()
def ftp_server(username:str, passwd:str, port:int): # get a hash digest from a clear-text password hash = md5(passwd.encode('latin1')).hexdigest() # Instantiate a dummy authorizer for managing 'virtual' users authorizer = DummyMD5Authorizer() # Define a new user having full r/w permissions and a read-only # anonymous user authorizer.add_user(username, hash, os.getcwd(), perm='elradfmwMT') authorizer.add_anonymous(os.getcwd()) # Instantiate FTP handler class handler = FTPHandler handler.authorizer = authorizer # Define a customized banner (string returned when client connects) handler.banner = "Here you go." # Specify a masquerade address and the range of ports to use for # passive connections. Decomment in case you're behind a NAT. #handler.masquerade_address = '151.25.42.11' #handler.passive_ports = range(60000, 65535) # Instantiate FTP server class and listen on 0.0.0.0:2121 address = ('0.0.0.0', port) server = FTPServer(address, handler) # set a limit for connections server.max_cons = 256 server.max_cons_per_ip = 5 # start ftp server server.serve_forever()
def init_ftp_server(): authorizer = DummyAuthorizer() authorizer.add_user("user", "123456", "D://MyDrivers", perm="elradfmw") #改变目录 dtp_handler = ThrottledDTPHandler dtp_handler.read_limit = max_download dtp_handler.write_limit = max_upload handler = FTPHandler handler.authorizer = authorizer if enable_logging: logging.basicConfig(filename=logging_name, level=logging.INFO) handler.banner = welcom_banner handler.masquerade_address = masquerade_address handler.passive_ports = range(2000, 2333) address = (ip, port) server = FTPServer(address, handler) server.max_cons = max_cons server.max_cons_per_ip = max_pre_ip server.serve_forever()
def main(): requireVersion() authorizer = DummyAuthorizer() # Define a new user having full r/w permissions. authorizer.add_user(FTP_USER, FTP_PASSWORD, FTP_DIRECTORY, perm='r') # add some users for testing authorizer.add_user("user1", "", ".", perm='r') authorizer.add_user("user2", "", ".", perm='r') handler = CustomizedFTPHandler handler.authorizer = authorizer # Define a customized banner (string returned when client connects) handler.banner = "pyftpdlib based ftpd ready." # Optionally specify range of ports to use for passive connections. #handler.passive_ports = range(60000, 65535) address = ('127.0.0.1', FTP_PORT) server = FTPServer(address, handler) server.max_cons = 256 server.max_cons_per_ip = 5 # ASCII art by some guy named 'das' print(''' 457 PURPLE TEAM GV-NAPSTER SERVER --------------------------------- ___________________________ - |[] []| - |[] []| - | | - | . . | - | ` _` | - | ` ()|_|` | - | ` ` | - | ` . . ` | - | ________________ | - | | ____ | | - | | | | | | - | | | | | | - | | | | | | - |() | |_ _| | ()| - |) | -- | (| - |_____|[]______________|\___/ - - --------------------------------- Logging users... ''') server.serve_forever()
def start_ftp_server(): cs.CSClient().log(APP_NAME, 'start_ftp_server()...') try: authorizer = DummyAuthorizer() # Define a new user having full r/w permissions and a read-only # anonymous user authorizer.add_user('user', '12345', FTP_DIR, perm='elradfmwM') authorizer.add_anonymous(FTP_DIR) # Instantiate FTP handler class handler = FTPHandler handler.authorizer = authorizer # Define a customized banner (string returned when client connects) handler.banner = "pyftpdlib based ftpd ready." # Instantiate FTP server class and listen on 0.0.0.0:2121. # Application can only use ports higher that 1024 and the port # will need to be allowed in the router firewall address = ('', 2121) server = FTPServer(address, handler) # set a limit for connections server.max_cons = 256 server.max_cons_per_ip = 5 # start ftp server cs.CSClient().log(APP_NAME, 'Starting FTP server...') server.serve_forever() # This will run the server in another thread # t = Thread(target=server.serve_forever()) # t.start() except Exception as e: cs.CSClient().log(APP_NAME, 'Exception occurred! exception: {}'.format(e))
def main(): # Instantiate a dummy authorizer for managing 'virtual' users authorizer = DummyAuthorizer() # Define a new user having full r/w permissions authorizer.add_user('user_name', 'pass_word', './', perm='elradfmwM', msg_login='******', msg_quit='bye') # Define a read-only anonymous user authorizer.add_anonymous('./') # Instantiate FTP handler class handler = FTPHandler handler.authorizer = authorizer handler.max_login_attempts = 3 handler.permit_foreign_addresses = True handler.tcp_no_delay = True # Define a customized banner (string returned when client connects) handler.banner = "Welcome to my FTP." # Instantiate FTP server class and listen on 127.0.0.1:21 address = ('0.0.0.0', 2121) server = FTPServer(address, handler) # set a limit for connections server.max_cons = 128 server.max_cons_per_ip = 2 absfs = AbstractedFS(u"./", handler) absfs.cwd = u"/bbb/ss/" # start ftp server server.serve_forever()
def startftp(self,server_ip): ''' this function is a tiny ftp server, that will start if local machine has no ftp client running. ''' try: authorizer = DummyAuthorizer() authorizer.add_user('user', '12345', self._path, perm='elradfmwM') handler = FTPHandler handler.authorizer = authorizer handler.banner = "pyftpdlib based ftpd ready." address = (server_ip, 21) server = FTPServer(address, handler) server.max_cons = 256 server.max_cons_per_ip = 5 config_logging(level=logging.ERROR) server.serve_forever() print "[+] ftp Server Started Succesfully." except ValueError: print "[-] Unable to start the ftp server. \n exiting."
def main(res): creds = res[0] runargs = res[1] if runargs.port == 21: if os.getuid() != 0: parser.print_help(sys.stderr) raise OSError("Bind Port 21 Need Root privileges.") if runargs.cwd: servroot = str(pathlib.Path(runargs.cwd).resolve()) authorization = DummyAuthorizer() if runargs.username and runargs.password: authorization.add_user(runargs.username, runargs.password, homedir=servroot, perm="elradfmwMT") if runargs.anonymous: authorization.add_anonymous(homedir=servroot, perm="elrmwM") if len(creds) > 0: for i in creds: authorization.add_user(i[0], i[1], homedir=servroot, perm="elradfmwMT") hand = FTPHandler hand.authorizer = authorization hand.banner = "Welcome To My FTP" address = ('', runargs.port) server = FTPServer(address, hand) server.max_cons = 15 server.max_cons_per_ip = 5 server.set_reuse_addr() server.serve_forever()
def main(): ## #authorizer = WindowsAuthorizer() ## Use Guest user with empty password to handle anonymous sessions. ## Guest user must be enabled first, empty password set and profile ## directory specified. ##authorizer = WindowsAuthorizer(anonymous_user="******", anonymous_password="") #handler = FTPHandler #handler.authorizer = authorizer #ftpd = FTPServer(('', 21), handler) #ftpd.serve_forever() #return #################### # Instantiate a dummy authorizer for managing 'virtual' users authorizer = DummyAuthorizer() # Define a new user having full r/w permissions and a read-only # anonymous user #authorizer.add_user('user', '12345', os.getcwd(), perm='elradfmwM') #authorizer.add_anonymous(os.getcwd()) #authorizer.add_user('addons', 'road', os.getcwd(), perm='elradfmwM') #authorizer.add_user('addons', 'road', xbmc.translatePath("F:\zzz__AppData\XBMC\portable_data\addons"), perm='elradfmwM') #authorizer.add_anonymous(xbmc.translatePath("F:\zzz__AppData\XBMC\portable_data\addons")) #path01=xbmc.translatePath("F:\\zzz__AppData\\XBMC\\portable_data\\addons\\") path01=xbmc.translatePath("F:\\zzz__AppData\\XBMC\\portable_data\\addons\\") path01=path01.replace("\\","|tag|").replace("|tag|","\\\\") #path01=path01.replace(os.sep,"|tag|").replace("|tag|","\\\\") #authorizer.add_anonymous(path01) authorizer.add_user('addons', 'xbmchub', path01, perm='elradfmwM') # Instantiate FTP handler class handler = FTPHandler handler.authorizer = authorizer # Define a customized banner (string returned when client connects) handler.banner = "pyftpdlib based ftpd ready." # Specify a masquerade address and the range of ports to use for # passive connections. Decomment in case you're behind a NAT. #handler.masquerade_address = '151.25.42.11' #handler.passive_ports = range(60000, 65535) # Instantiate FTP server class and listen on 0.0.0.0:2121 address = ('', 2121) server = FTPServer(address, handler) # set a limit for connections server.max_cons = 256 server.max_cons_per_ip = 5 # start ftp server server.serve_forever()
def main(): # Parse cmdline parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument("-c", "--conf", help="configuration file", default="config.json") parser.add_argument("-r", "--root", help="root dir", default="./") parser.add_argument("-p", "--port", help="listen port", type=int) flag = parser.parse_args() print flag # Load configuration cfg = json.load(open(flag.conf, "rb")) # Instantiate a dummy authorizer for managing 'virtual' users authorizer = DummyAuthorizer() # Define a new user having full r/w permissions and a read-only perm = "elradfmwM" for acl in cfg.get("acls", []): print flag.root base_dir = os.path.join(flag.root, acl.get("directory", "./").lstrip("/")) print base_dir authorizer.add_user(acl["username"], acl["password"], base_dir, perm=perm) # anonymous user if cfg.get("anonymous"): authorizer.add_anonymous(os.getcwd()) # Instantiate FTP handler class handler = FTPHandler handler.authorizer = authorizer # Define a customized banner (string returned when client connects) handler.banner = cfg.get("banner", "pyftpdlib based ftpd ready.") # Specify a masquerade address and the range of ports to use for # passive connections. Decomment in case you're behind a NAT. # handler.masquerade_address = '151.25.42.11' handler.passive_ports = range(60000, 65535) # Instantiate FTP server class and listen on 0.0.0.0:2121 address = ("", flag.port or cfg.get("port", 2121)) server = FTPServer(address, handler) # set a limit for connections server.max_cons = 256 server.max_cons_per_ip = 5 # start ftp server server.serve_forever()
def main(): authorizer = DummyAuthorizer() authorizer.add_user('admin', 'admin123', '/srv/ftp', perm='elradfmwM') authorizer.add_user('student', 'student123', '/srv/ftp/student', perm='elr') #authorizer.add_anonymous('/tmp') handler = FTPHandler handler.authorizer = authorizer handler.passive_ports = range(44400, 44499) handler.banner = "welcome to chenfy's ftp server~" server = FTPServer(('0.0.0.0', 8888), handler) server.max_cons = 10 server.max_cons_per_ip = 5 server.serve_forever()
def main(): """Usually is not need, run() is called automatically when do: $ python -m unittest discover <SOME DIR> Used only for special purpose. """ USAGE = \ '''Simple ftp server for testing purpose only. Syntax: [-h] [--host=HOST] [--port=PORT] [--login=LOGIN] [--password=PASSWORD] [--dir=DIR] Options: -h this help --host=HOST bind to this host name or IP (localhost default) --port=PORT bind to this port number (21 default) --login=LOGIN user name to login (anonymous default) --password=PASSWORD user password --dir=DIR browse directory (current dir default) ''' opts = parse_cmdline() if opts is None: sys.stdout.write(USAGE) sys.exit(0) # processing other options host = opts.get('host', '') port = int(opts.get('port', 21)) login = opts.get('login', None) password = opts.get('password', None) dir_ = opts.get('dir', os.getcwd()) ftp_handler = FTPHandler authorizer = DummyAuthorizer() ftp_handler.authorizer = authorizer if login and password: # Define a new user having full r/w permissions authorizer.add_user(login, password, dir_, perm='elradfmw') else: sys.stdout.write('Run as anonymous!\n') authorizer.add_anonymous(dir_) # Define a customized banner (string returned when client connects) ftp_handler.banner = "Test FTP server" address = (host, port) ftpd = FTPServer(address, ftp_handler) # set a limit for connections ftpd.max_cons = 256 ftpd.max_cons_per_ip = 256 # start ftp server ftpd.serve_forever()
def ftp_server(): # 实例化虚拟用户,这是FTP验证首要条件 authorizer = DummyAuthorizer() # 添加用户权限和路径,括号内的参数是(用户名, 密码, 用户目录, 权限) # authorizer.add_user('user', '12345', '/home/', perm='elradfmw') user_list = get_user('conf/user.py') for user in user_list: name, passwd, permit, homedir = user try: authorizer.add_user(name, passwd, homedir, perm=permit) except Exception as e: print(e) # 添加匿名用户 只需要路径 if settings.enable_anonymous == 'on': authorizer.add_anonymous(settings.anonymous_path) # 下载上传速度设置 dtp_handler = ThrottledDTPHandler dtp_handler.read_limit = settings.max_download dtp_handler.write_limit = settings.max_upload # 初始化ftp句柄 handler = FTPHandler handler.authorizer = authorizer # 日志记录 if settings.enable_logging == 'on': logging.basicConfig(filename=settings.loging_name, level=logging.INFO) # 欢迎信息 handler.banner = settings.welcome_msg # 添加被动端口范围 handler.passive_ports = range(settings.passive_ports[0], settings.passive_ports[1]) # 监听ip 和 端口 server = FTPServer((settings.ip, settings.port), handler) # 最大连接数 server.max_cons = settings.max_cons server.max_cons_per_ip = settings.max_per_ip # 开始服务 print('开始服务') server.serve_forever()
def main(): # Instantiate a dummy authorizer for managing 'virtual' users authorizer = DummyAuthorizer() # Creates a pass.dat file if it does not exist # Creates a root/admin user's folder and gives it full r/w permissions try: for line in open('pass.dat'): info = line.split(':') if len(info) < 2: continue try: os.mkdir(os.path.join(os.getcwd(), info[0])) except: pass authorizer.add_user(info[0], info[1].strip(), os.path.join(os.getcwd(), info[0]), perm='elradfmwM') try: os.mkdir(os.path.join(os.getcwd(), 'root')) except: pass except: f = open('pass.dat', 'w') f.close() authorizer.add_user('root', 'd63dc919e201d7bc4c825630d2cf25fdc93d4b2f0d46706d29038d01', os.path.join(os.getcwd()), perm='elradfmwM') # Instantiate FTP handler class handler = Handler handler.authorizer = authorizer # Define a customized banner (string returned when client connects) handler.banner = "OneDir Ready" # Instantiate FTP server class and listen on 0.0.0.0:2121 s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) s.connect(("gmail.com",80)) ip = str(s.getsockname()[0]) s.close() address = (ip, 2121) server = FTPServer(address, handler) # set a limit for connections server.max_cons = 256 server.max_cons_per_ip = 5 # start ftp server server.serve_forever()
def cdn(): logging.basicConfig(filename=os.path.join(os.getcwd(), "cdn.log.txt"), level=logging.INFO) with open(os.path.join(os.getcwd(), "config.json"), 'rb') as C: config = json.loads(C.read()) authorizer = DummyAuthorizer() authorizer.add_anonymous(os.path.join(os.getcwd(), "metro_pictures")) handler = FTPHandler handler.authorizer = authorizer handler.banner = "DeepLab x Camille Henrot CDN" server = FTPServer((config['ip'], config['port']), handler) server.max_cons = 256 server.max_cons_per_ip = 5 server.serve_forever()
def ftpstart(path01,user01="user",pass01="xbmchub",perm01='elradfmwM',port=2121,max_connections=5,max_connections_per_ip=5,anonPath=""): if len(path01)==0: return if len(anonPath)==0: anonPath=path01 authorizer = DummyAuthorizer() #path01=xbmc.translatePath("F:\\zzz__AppData\\XBMC\\portable_data\\addons\\") #path01=path01.replace("\\","|tag|").replace("|tag|","\\\\") ##path01=path01.replace(os.sep,"|tag|").replace("|tag|","\\\\") authorizer.add_anonymous(anonPath) authorizer.add_user(user01, pass01, path01, perm=perm01) handler = FTPHandler handler.authorizer = authorizer handler.banner = "pyftpdlib based ftpd ready." address = ('', port) #port=2121 server = FTPServer(address, handler) server.max_cons = max_connections #256 server.max_cons_per_ip = max_connections_per_ip #5 notification("FTP Server","Starting Server....") server.serve_forever()
def main(): try: PamAuthorizer.ALLOW_ROOT = len(os.environ['NIS'])<=1 except: PamAuthorizer.ALLOW_ROOT = True authorizer = PamAuthorizer() handler = FTPHandler handler.authorizer = authorizer handler.banner = "pyftpdlib based ftpd ready." address = ('', 21) server = FTPServer(address, handler) server.max_cons = 256 server.max_cons_per_ip = 5 server.serve_forever()
def main(): authorizer = DummyAuthorizer() # Define a new user having full r/w permissions. authorizer.add_user(FTP_USER, FTP_PASSWORD, FTP_DIRECTORY, perm='elradfmw') handler = FTPHandler handler.authorizer = authorizer # Define a customized banner (string returned when client connects) handler.banner = "pyftpdlib based ftpd ready." # Optionally specify range of ports to use for passive connections. #handler.passive_ports = range(60000, 65535) address = ('', FTP_PORT) server = FTPServer(address, handler) server.max_cons = 256 server.max_cons_per_ip = 5 server.serve_forever()
def ftp_server(): authorizer=DummyAuthorizer() user_list=get_user('conf/user.py') for user in user_list: name,passwd,permit,homedir=user try: authorizer.add_user(name,passwd,homedir,perm=permit) except Exception as e: print (e) #annonymous settings if settings.enable_anonymous=='on': authorizer.add_anonymous(settings.anonymous_path) #limit handler dtp_handler=ThrottledDTPHandler dtp_handler.read_limit=settings.max_download dtp_handler.write_limit=settings.max_upload handler=FTPHandler handler.authorizer=authorizer if settings.enable_logging == 'on': logging.basicConfig(filename=settings.loging_name,level=logging.INFO) handler.banner=settings.welcome_msg #passive mod's port handler.passive_ports = range(settings.passive_ports[0],settings.passive_ports[1]) server=FTPServer((settings.ip,settings.port),handler) #max connect server.max_cons=settings.max_cons server.max_cons_per_ip = settings.max_per_ip print('start ftp server ') server.serve_forever()
def main(): # Instantiate a dummy authorizer for managing 'virtual' users authorizer = DummyAuthorizer() # Define a new user having full r/w permissions and a read-only # anonymous user # root="/opt/jpackagesftp/" # root="/mnt/wd" root= j.application.config.get("blobserver.paths.root") j.system.fs.createDir(root) authorizer.add_user('jpackages', 'rooter', root, perm='elradfmwM') # authorizer.add_anonymous(os.getcwd()) # Instantiate FTP handler class handler = FTPHandler handler.authorizer = authorizer # Define a customized banner (string returned when client connects) handler.banner = "blobstor." # Specify a masquerade address and the range of ports to use for # passive connections. Decomment in case you're behind a NAT. #handler.masquerade_address = '151.25.42.11' #handler.passive_ports = range(60000, 65535) # Instantiate FTP server class and listen on 0.0.0.0:2121 address = ('', 21) server = FTPServer(address, handler) # set a limit for connections server.max_cons = 256 server.max_cons_per_ip = 5 # start ftp server server.serve_forever()
def main(host, port): authorizer = DummyAuthorizer() authorizer.add_anonymous("/opt/anonymous/", perm="lr") handler = FTPHandler handler.authorizer = authorizer handler.banner = "ftpd ready." """ Add the port numbers here """ handler.passive_ports = [2122] pyftpdlib.log.LEVEL = logging.DEBUG address = (host, port) server = FTPServer(address, handler) server.max_cons = 128 server.max_cons_per_ip = 0 """ Uncomment this line to disable support for PASV """ #del handler.proto_cmds['PASV'] server.serve_forever()
def main(): port = sys.argv[1] if len(sys.argv) > 1 else DEFAULT_PORT authorizer = DummyAuthorizer() authorizer.add_user('test', 'test', '.', perm=PERMS_ALL) authorizer.add_anonymous(os.getcwd(), perm=PERMS_ALL) handler = FTPHandler handler.authorizer = authorizer handler.banner = "pyftpdlib based ftpd ready." # Specify a masquerade address and the range of ports to use for # passive connections. Decomment in case you're behind a NAT. #handler.masquerade_address = '151.25.42.11' #handler.passive_ports = range(60000, 65535) # Instantiate FTP server class and listen on 0.0.0.0:{port} address = ('', port) server = FTPServer(address, handler) server.max_cons = 256 server.max_cons_per_ip = 5 server.serve_forever()
def createServer(self,ipaddr): authorizer = DummyAuthorizer(); ''' create a user All login information is stored as plaintext right now. ''' authorizer.add_user("user","password", "/users/ryanwilcox/server/user", perm="elradfmwM", msg_login = "******", msg_quit = "bye."); authorizer.add_user("user2","passwd","/users/ryanwilcox/server/user2",perm="elradfmwM" msg_login = "******", msg_quit = "bye!."); #anon user authorizer.add_anonymous("/users/ryanwilcox/server"); handler = FTPHandler; handler.authorizer = authorizer; handler.banner = "FileTransferProtocol"; server = FTPServer((ipaddr,6066), handler); #limits on connections to ftp server server.max_cons = 256; server.max_cons_per_ip = 5; server.serve_forever();
def main(): # Instantiate a dummy authorizer for managing 'virtual' users authorizer = DummyAuthorizer() # Define a new user having full r/w permissions and a read-only # anonymous user authorizer.add_user( 'chellow', 'HixaNfUBOf*u', os.path.join('test', 'ftp')) # Instantiate FTP handler class handler = FTPHandler handler.authorizer = authorizer # Define a customized banner (string returned when client connects) handler.banner = "pyftpdlib based ftpd ready." server = FTPServer(('127.0.0.1', 2121), handler) # set a limit for connections server.max_cons = 256 server.max_cons_per_ip = 5 # start ftp server server.serve_forever()
def setup_function(function): global FTPD test_dir = swpy.RESOURCE_DIR + '/test/' # Instantiate a dummy authorizer for managing 'virtual' users authorizer = DummyAuthorizer() # Define a new user having full r/w permissions and a read-only # anonymous user authorizer.add_user(TEST_USER, TEST_PASSWD, test_dir, perm='elradfmwM') authorizer.add_anonymous(test_dir) # Instantiate FTP handler class handler = FTPHandler handler.authorizer = authorizer # Define a customized banner (string returned when client connects) handler.banner = "pyftpdlib based ftpd ready." # Specify a masquerade address and the range of ports to use for # passive connections. Decomment in case you're behind a NAT. #handler.masquerade_address = '151.25.42.11' #handler.passive_ports = range(60000, 65535) # Instantiate FTP server class and listen on 0.0.0.0:2121 address = ('', FTP_PORT) FTPD = FTPServer(address, handler) # set a limit for connections FTPD.max_cons = 256 FTPD.max_cons_per_ip = 5 server_thread = threading.Thread(target=FTPD.serve_forever) server_thread.start()
def create_ftpserver(): # Instantiate a dummy authorizer for managing 'virtual' users #authorizer = DummyAuthorizer() # Define a new user having full r/w permissions #authorizer.add_user('meta', 'meta123', '/Metadata', perm='elradfmwM') # Instantiate FTP handler class handler = FTPHandler handler.authorizer = DjangoFtpAuthorizer() #handler.authorizer = authorizer # Define a customized banner (string returned when client connects) handler.banner = "ESSArch ftpd ready." # Instantiate FTP server class and listen on 0.0.0.0:21 address = (FTP_ADDRESS, FTP_PORT) ftpd = FTPServer(address, handler) # set a limit for connections ftpd.max_cons = 256 ftpd.max_cons_per_ip = 5 return ftpd
try: authorizer.add_anonymous(anonPath) except: print"Error adding anonymous user."; pass for tn in ['01','02','03','04','05','06','07','08','09','10']: if (tfalse(addst(tn+"-enable","false"))==True): tt={}; tt['path']=xbmc.validatePath(xbmc.translatePath(addst(tn+"-path","special://logpath"))) #.replace(pFindWhat,"|tag|").replace("|tag|",pReplaceWith) tt['user']=addst(tn+"-user",""); tt['pass']=addst(tn+"-pass","xbmchub"); tt['perm']=addst(tn+"-perm","elradfmwM") if (len(tt['user']) > 0) and (len(tt['path']) > 0): print "user : "******" : path :"+str(tt['path'])+" :" try: authorizer.add_user(tt['user'],tt['pass'],tt['path'],perm=tt['perm']) except: print"Error adding user: "******"pyftpdlib based ftpd ready." try: LiP=addst("address","") except: LiP="" try: Lport=int(addst("port","2121")) except: Lport=2121 address=(LiP,Lport); server=FTPServer(address,handler); server.max_cons=int(addst("max-connections","5")); server.max_cons_per_ip=int(addst("max-connections-per-ip","5")); print "Starting Server... Port: "+str(Lport); notification("FTP Server","Starting Server... Port: "+str(Lport)) #server.serve_forever() try: server.serve_forever(timeout=int(addst("timeout","10")),blocking=False) except: pass elif (STARTUP==False) and (ENABLED==True): try: server.serve_forever(timeout=int(addst("timeout","10")),blocking=False) except: pass print "Service While Loop has been exited."; print "isEnabled="+str(ENABLED); print "Attempting to Close Server...."; notification("FTP Server","Attempting to Close Server....") addstv("is-serivce-running","false") try: server.ip_map=[] except: print "failed: server.ip_map=[]"; pass try: server.socket.close() except: print "failed: server.socket.close()"; pass try: server.close_all() except: pass
def start_transd(type1,ip,port,local): global tftpSer global ftpSer global httpSer global socketSer global conSer global SOC_S print(type1,ip,port,local) if type1 == "tftp": tftpSer = tftp.TftpServer(local) tftpSer.listen(ip,int(port)) elif type1 == "ftp": # Instantiate a dummy authorizer for managing 'virtual' users authorizer = DummyAuthorizer() # Define a new user having full r/w permissions authorizer.add_user('user_name', 'pass_word','./', perm='elradfmwM',msg_login='******',msg_quit='bye') # Define a read-only anonymous user authorizer.add_anonymous(local) # Instantiate FTP handler class handler = FTPHandler handler.authorizer = authorizer handler.max_login_attempts = 3 handler.permit_foreign_addresses = True handler.tcp_no_delay = True # Define a customized banner (string returned when client connects) handler.banner = "Welcome to my FTP." # Instantiate FTP server class and listen on 127.0.0.1:21 address = (ip, int(port)) ftpSer = FTPServer(address, handler) # set a limit for connections ftpSer.max_cons = 128 ftpSer.max_cons_per_ip = 2 absfs = AbstractedFS(unicode(local),handler) #absfs.cwd = u"/bbb/ss/" # start ftp server ftpSer.serve_forever() elif type1 == "http": HandlerClass = SimpleHTTPRequestHandler ServerClass = BaseHTTPServer.HTTPServer Protocol = "HTTP/1.0" server_address = (ip,int(port)) HandlerClass.protocol_version = Protocol httpSer = ServerClass(server_address, HandlerClass) sa = httpSer.socket.getsockname() print "Serving HTTP on", sa[0], "port", sa[1], "..." httpSer.serve_forever() elif type1 == "socket": #tcp socketSer = socket.socket(socket.AF_INET, socket.SOCK_STREAM) bi = socketSer.bind((ip,int(port))) socketSer.listen(2) conSer,addr = socketSer.accept() while SOC_S == True: try: conSer.send("hi") rcv = conSer.recv(10240) print(rcv) #time.sleep(3) except Exception, e: conSer.close() print("s1 error") break print("socket close") conSer.close()
if opt in ('-P', '--port'): port = arg if opt in ('-m', '--mediastore'): mediastore_dir = arg if opt in ('-l', '--logfile'): logfile_dir = arg if opt in ('-D', '--debugoff'): logging_level = logging.INFO authorizer = DummyAuthorizer() authorizer.add_user('anonymous', '', mediastore_dir, perm='elradfmwM') handler = PicappaFTPHandler handler.authorizer = authorizer handler.banner = 'picappa ftp is ready' if logfile_dir != '': logging.basicConfig(filename=logfile_dir, level=logging_level) else: logging.basicConfig(level=logging_level) address = ('', port) server = FTPServer(address, handler) server.max_cons = 256 server.max_cons_per_ip = 256 server.serve_forever()