Esempio n. 1
0
    def Login(self):
        try:
            #getting username and password
            username = self.user.text
            password = self.pswd.text

            #This will decide which user to allow access
            authorizer = DummyAuthorizer()
            authorizer.add_user(username, password, LoginPage.p)
            #update authorization settings in the FTP handler
            handler = FTPHandler
            handler.authorizer = authorizer

            # getting ip address
            hostname = socket.gethostname()
            ip = socket.gethostbyname(hostname)

            #creating server
            LoginPage.server = FTPServer((ip, 1238), handler)
            LoginPage.server.serve_forever()
        except Exception as e:
            print("something went wrong", e)
        else:
            print("Successful!")
Esempio n. 2
0
 def start_listen(self):
     # authorizer = DummyAuthorizer()
     try:
         authorizer = FakeAuthorizer(self.logger, self.logs, self.bind_ip)
         handler = FTPHandler
         handler.banner = "FTP service is ready"
         handler.authorizer = authorizer
         address = (self.bind_ip, self.ports)
         server = FTPServer(address, handler)
         handler.timeout = 600
         server.max_cons = 256
         server.max_cons_per_ip = 5
         server.serve_forever()
     except timeout:
         pass
     except OSError:
         print("service", self.name, "find ports", self.ports, "already in used, please check again")
         print("close service", self.name)
         exit()
     except KeyboardInterrupt:
         print('Detected interruption, terminating...')
     except Exception as e:
         print(e)
         pass
Esempio n. 3
0
def start_FTP_server():
    global authorizer, handler, server

    # Instantiate a dummy authorizer for managing 'virtual' users
    authorizer = DummyAuthorizer()

    # Define two users with full r/w permissions, one for each camera
    user_home_folder = os.getenv("HOME")
    authorizer.add_user('right_cam',
                        'yumiPC',
                        user_home_folder,
                        perm='elradfmwM')
    authorizer.add_user('left_cam',
                        'yumiPC',
                        user_home_folder,
                        perm='elradfmwM')

    # Instantiate FTP handler class
    handler = CamerasFTPHandler
    handler.authorizer = authorizer

    # Define a customized banner (string returned when client connects)
    handler.banner = "pyftpdlib based ftpd ready."
    handler.permit_privileged_ports = True

    # Instantiate FTP server class and listen on 0.0.0.0:2121
    address = ('192.168.125.50', 2121)
    server = FTPServer(address, handler)

    # set a limit for connections
    server.max_cons = 512
    server.max_cons_per_ip = 0  # 0 == no limit

    rospy.loginfo("FTP server ready, listening on Port 21")
    # start ftp server
    server.serve_forever()
Esempio n. 4
0
"""
Run like
    $ python -m test.ftp_server
"""
import os

from pyftpdlib.authorizers import DummyAuthorizer
from pyftpdlib.handlers import FTPHandler
from pyftpdlib.servers import FTPServer

from .fixture_tools import PYFTPSYNC_TEST_FOLDER

directory = os.path.join(PYFTPSYNC_TEST_FOLDER, "remote")

authorizer = DummyAuthorizer()
authorizer.add_user("tester", "secret", directory, perm="elradfmwMT")
authorizer.add_anonymous(directory, perm="elradfmwMT")

handler = FTPHandler
handler.authorizer = authorizer

server = FTPServer(("127.0.0.1", 8021), handler)
server.serve_forever()
Esempio n. 5
0
File: run.py Progetto: Simhs/APad
class MyHandler(FTPHandler):
    def on_file_received(self, file):
        global playFileName
        dirlist = os.listdir(DOWNLOAD_DIR)
        downloadFile = os.path.basename(file)
        for i in dirlist:
            if i == downloadFile:
                pass
            else:
                print DOWNLOAD_DIR+i
                os.remove(DOWNLOAD_DIR+i)
        print "now FTPDownload folder state :",os.listdir(DOWNLOAD_DIR)
        print "@@@@@@@@@@@@@@@@@@@@"
        playFileName = file
        print "####################"
        

authorizer = DummyAuthorizer()
authorizer.add_user("sim", "1234", DOWNLOAD_DIR, perm="elradfmw")

handler = MyHandler
handler.passive_ports = range(60000, 65535)
handler.authorizer = authorizer
server = FTPServer(("", 21), handler)

display = RGBMatrixDisplay()
thread.start_new_thread(display.show,())

server.serve_forever()
Esempio n. 6
0
from pyftpdlib.authorizers import DummyAuthorizer  #bibliotēka
from pyftpdlib.handlers import FTPHandler
from pyftpdlib.servers import FTPServer

authorizer = DummyAuthorizer()  #lietotāju klase
authorizer.add_user("elvish", "12345", "/home/elvish/ftp",
                    perm="elradfmw")  #definē lietotāju
authorizer.add_anonymous("/home/elvish",
                         perm="elradfmw")  #nedefinēts lietotājs

handler = FTPHandler  #autorizācijas veids
handler.authorizer = authorizer

server = FTPServer(("127.0.0.1", 1026), handler)  #definē serveri
server.serve_forever()
Esempio n. 7
0
#! /usr/bin/Python
from pyftpdlib.authorizers import DummyAuthorizer
from pyftpdlib.handlers import FTPHandler
from pyftpdlib.servers import FTPServer

authorizer = DummyAuthorizer()
authorizer.add_user("1", "1", "/home/bartek/python/project/JPO", perm="elradfmw")
#authorizer.add_anonymous("/home/bartek/python/project/JPO/nobody")

handler = FTPHandler
handler.authorizer = authorizer

server = FTPServer(("10.22.114.17", 2121), handler)
server.max_cons = 50
server.serve_forever()
 def __init__(self):
     super().__init__()
     self.authorizer = DummyAuthorizer()
     handler = FTPHandler
     handler.authorizer = self.authorizer
     self.server = FTPServer(("127.0.0.1", 0), handler)
from pyftpdlib.authorizers import DummyAuthorizer
from pyftpdlib.handlers import FTPHandler
from pyftpdlib.servers import FTPServer

authorizer = DummyAuthorizer()

authorizer.add_user("user",
                    "12345",
                    "C:\\Users\\th\\Down loads\\FTPserver",
                    perm="elradfmw")
authorizer.add_anonymous("C:\\Users\\th\\Downloads\\FTP server",
                         perm="elradfmw")

handler = FTPHandler
handler.authorizer = authorizer

server = FTPServer(("127.0.0.1", 1026), handler)
server.serve_forever()
Esempio n. 10
0
'''

if __name__ == '__main__':
    authorizer = DummyAuthorizer()
    '''
        权限说明:
        Read permissions:
         - "e" = change directory (CWD command)
         - "l" = list files (LIST, NLST, STAT, MLSD, MLST, SIZE, MDTM 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 file mode (SITE CHMOD command)
         - "T" = update file last modified time (MFMT command)
    '''
    '''
     这里我们创建一个管理员,拥有所有权限,创建一个普通用户,只拥有浏览权限
    '''
    authorizer.add_user('admin', 'admin', 'F:\\file', perm='elradfmwM')
    authorizer.add_user('user', 'user', 'F:\\file')
    handler = FTPHandler
    handler.authorizer = authorizer
    server = FTPServer(('0.0.0.0', 8888), handler)
    server.serve_forever()
Esempio n. 11
0
import socket
from pyftpdlib.authorizers import DummyAuthorizer
from pyftpdlib.handlers import FTPHandler
from pyftpdlib.servers import FTPServer

print("Por favor ingrese la dirección ip del servidor")
# Dirección ip del servidor
HOST = input()
# Creacion de un autorizador, el cual manejara las autenticaciones y permitira es uso de usuarios anonimos
autorizaciones = DummyAuthorizer()
autorizaciones.add_anonymous("/users")
# El FTPHandler se encarga de implementar el protocolo FTP, en este caso especificando que el autorizador previamente
# creado sera el encargado de las autorizaciones del mismo
handler = FTPHandler
handler.authorizer = autorizaciones
# Se crea el servidor con el manejador indicado, en el puerto predeterminado y la ip escogida
server = FTPServer((HOST, 21), handler)
server.serve_forever()

Esempio n. 12
0
#!/usr/bin/python3

from pyftpdlib.authorizers import DummyAuthorizer
from pyftpdlib.handlers import FTPHandler
from pyftpdlib.servers import FTPServer

authorizer = DummyAuthorizer()
authorizer.add_user("test", "test", "/Users/username", perm="elradfmw")

handler = FTPHandler
handler.authorizer = authorizer
handler.passive_ports = range(60000, 61000)

server = FTPServer(("172.20.10.3", 2000), handler)
server.serve_forever()
Esempio n. 13
0
# python3.5+合并字典
a = {"a":1 ,"b": 2}
b = {"c":3 ,"d": 4}
c = {**a, **b}

# 多条件或
any(a, b, c)

# python开启ftp服务
from pyftpdlib.authorizers import DummyAuthorizer
from pyftpdlib.handlers import FTPHandler
from pyftpdlib.servers import FTPServer
# 实例化虚拟用户,这是FTP验证首要条件
authorizer = DummyAuthorizer()
# 添加用户权限和路径,括号内的参数是(用户名, 密码, 用户目录, 权限)
authorizer.add_user('user', '12345', '/home/homework/user', perm='elradfmw')
# 初始化ftp句柄
handler = FTPHandler
handler.authorizer = authorizer
# 监听ip 和 端口,因为linux里非root用户无法使用21端口,所以我使用了2121端口
server = FTPServer(('192.168.240.13', 2121), handler)
# 开始服务
server.serve_forever()

# pandas排序
df.sort_values("name")

# 获得文件所在路径
os.path.split(os.path.realpath(__file__))[0]
Esempio n. 14
0
from pyftpdlib.authorizers import DummyAuthorizer
from pyftpdlib.servers import FTPServer
from pyftpdlib.handlers import FTPHandler
import os
from threading import Thread

NAME = 'mik'
PASS = '******'

auth = DummyAuthorizer()
# auth.add_anonymous(os.getcwd())

handler = FTPHandler
handler.authorizer = auth

serv = FTPServer(('localhost', 9091), handler)

thread = Thread()
thread.run = lambda: serv.serve_forever()

thread.start()

auth.add_user(NAME, PASS, os.path.join(os.getcwd(), '..\\ftp_storage'), 'wr')
Esempio n. 15
0
##########################################

from pyftpdlib.authorizers import DummyAuthorizer
from pyftpdlib.handlers import FTPHandler
from pyftpdlib.servers import FTPServer

authorizer = DummyAuthorizer()

########### USERS ####################
#first parameter is the username, second one is the password and the third one is the directory to which that particular user has access to

authorizer.add_user("Swapneel", "Swapneel", "D:\Demo", perm="elradfmwMT")
authorizer.add_user("Swarna", "Swarna", "D:\Demo", perm="elradfmwMT")
authorizer.add_user("Sumukh", "Sumukh", "D:\Demo", perm="elradfmwMT")
authorizer.add_user("Suhaas", "Suhaas", "D:\Demo", perm="elradfmwMT")
authorizer.add_user("Param", "Param", "D:\Demo", perm="elradfmwMT")
authorizer.add_user("Akash", "Akash", "D:\Demo", perm="elradfmwMT")
authorizer.add_user("Sumanth", "Sumanth", "D:\Demo", perm="elradfmwMT")

######################################

authorizer.add_anonymous(
    "D:\Demo")  #path of the directory you want to the clients to access
handler = FTPHandler
handler.authorizer = authorizer
server = FTPServer(
    ("192.168.43.115", 21),
    handler)  #the IP address of your system, the one which is the server
server.serve_forever()
Esempio n. 16
0
ENABLE_TELNET = True

FTP_PASSWORD = "******"
TELNET_PASSWORD = "******"

# FTP Server Code
if ENABLE_FTP:
    authorizer = DummyAuthorizer()
    root = os.path.dirname(os.path.realpath(__file__)) + "/ftp_server"
    print root
    authorizer.add_user("root", FTP_PASSWORD, root, perm="elradfmw")

    handler = FTPHandler
    handler.authorizer = authorizer

    server = FTPServer(('', 21), handler)
    server.serve_forever()

# HTTP Server Code
if ENABLE_HTTP:
    Handler = SimpleHTTPServer.SimpleHTTPRequestHandler
    httpd = SocketServer.TCPServer(('', 80), Handler)
    httpd.serve_forever()

# Telnet Server Code
if ENABLE_TELNET:
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    try:
        s.bind(('', 5555))
    except socket.error as msg:
        print 'Bind failed. Error Code : ' + str(msg[0]) + ' Message ' + msg[1]
Esempio n. 17
0
import os
from pyftpdlib.authorizers import DummyAuthorizer
from pyftpdlib.handlers import FTPHandler
from pyftpdlib.servers import FTPServer

auth = DummyAuthorizer();
auth.add_user("test", '504683', os.getcwd(), perm='elradfmw)

handler = FTPHandler
handler.authorizer = auth

server = FTPServer(("127.0.0.1", 3127), handler)
print "server started"
server.serve_forever()
Esempio n. 18
0
def main():
    """Start a stand alone anonymous FTP server."""
    import optparse
    import sys
    import os

    from pyftpdlib.authorizers import DummyAuthorizer
    from pyftpdlib.handlers import FTPHandler
    from pyftpdlib.servers import FTPServer
    from pyftpdlib._compat import getcwdu

    class CustomizedOptionFormatter(optparse.IndentedHelpFormatter):
        """Formats options shown in help in a prettier way."""
        def format_option(self, option):
            result = []
            opts = self.option_strings[option]
            result.append('  %s\n' % opts)
            if option.help:
                help_text = '     %s\n\n' % self.expand_default(option)
                result.append(help_text)
            return ''.join(result)

    usage = "python -m pyftpdlib.ftpserver [options]"
    parser = optparse.OptionParser(usage=usage,
                                   description=main.__doc__,
                                   formatter=CustomizedOptionFormatter())
    parser.add_option('-i',
                      '--interface',
                      default='',
                      metavar="ADDRESS",
                      help="specify the interface to run on (default all "
                      "interfaces)")
    parser.add_option('-p',
                      '--port',
                      type="int",
                      default=21,
                      metavar="PORT",
                      help="specify port number to run on (default 21)")
    parser.add_option('-w',
                      '--write',
                      action="store_true",
                      default=False,
                      help="grants write access for the anonymous user "
                      "(default read-only)")
    parser.add_option('-d',
                      '--directory',
                      default=getcwdu(),
                      metavar="FOLDER",
                      help="specify the directory to share (default current "
                      "directory)")
    parser.add_option('-n',
                      '--nat-address',
                      default=None,
                      metavar="ADDRESS",
                      help="the NAT address to use for passive connections")
    parser.add_option('-r',
                      '--range',
                      default=None,
                      metavar="FROM-TO",
                      help="the range of TCP ports to use for passive "
                      "connections (e.g. -r 8000-9000)")
    parser.add_option('-v',
                      '--version',
                      action='store_true',
                      help="print pyftpdlib version and exit")

    options, args = parser.parse_args()
    if options.version:
        sys.exit("pyftpdlib %s" % __ver__)
    passive_ports = None
    if options.range:
        try:
            start, stop = options.range.split('-')
            start = int(start)
            stop = int(stop)
        except ValueError:
            parser.error('invalid argument passed to -r option')
        else:
            passive_ports = list(range(start, stop + 1))
    # On recent Windows versions, if address is not specified and IPv6
    # is installed the socket will listen on IPv6 by default; in this
    # case we force IPv4 instead.
    if os.name in ('nt', 'ce') and not options.interface:
        options.interface = '0.0.0.0'

    authorizer = DummyAuthorizer()
    perm = options.write and "elradfmwM" or "elr"
    authorizer.add_anonymous(options.directory, perm=perm)
    handler = FTPHandler
    handler.authorizer = authorizer
    handler.masquerade_address = options.nat_address
    handler.passive_ports = passive_ports
    ftpd = FTPServer((options.interface, options.port), FTPHandler)
    ftpd.serve_forever()
Esempio n. 19
0
from pyftpdlib.authorizers import DummyAuthorizer  #Python FTP server library
from pyftpdlib.handlers import FTPHandler
from pyftpdlib.servers import FTPServer

authorizer = DummyAuthorizer()  #dummy authorizer

authorizer.add_anonymous(
    "/home/sree/Desktop/", perm="elradfmw"
)  #adding a user(userid,password) here as anonymous to the server with 										read , write etc permission

handler = FTPHandler
handler.authorizer = authorizer

connection = ('192.168.1.5', 21)  #host address and port number

server = FTPServer(connection, handler)

server.serve_forever()
Esempio n. 20
0
HOST_IP = socket.gethostbyname(USERNAME)
if HOST_IP == "127.0.0.1":
    print(">> Please Connect to Network Before Start FTP...")
    sleep(2)
    sys.exit()
PORT = 8000
HOST = (HOST_IP, PORT)

print(">> Starting FTP...")
sleep(1)

HOME = askdirectory(title='Selct Hosting Folder...')
if HOME == "":
    print(">> FTP Server Terminating...(No Folder Choosed!)")
    sleep(3)
    sys.exit()
Authorizer.add_anonymous(HOME, perm="elr")

print(f">> Server Address             : ftp://{HOST_IP}:{PORT}")
print(
    "                              $ For Download and Upload Data Use Windows Explorer"
)
print(f">> Server Hosted Location     : [ {HOME} ]")
print("\n>> Server Started...")
Handler = FTPHandler
Handler.authorizer = Authorizer
Server = FTPServer(HOST, Handler)
Server.serve_forever()

root.mainloop()
Esempio n. 21
0
from pyftpdlib.authorizers import DummyAuthorizer
from pyftpdlib.handlers import FTPHandler
from pyftpdlib.servers import FTPServer

authorizer = DummyAuthorizer()

authorizer.add_user('user', '12345', 'ftpdfiles', perm='elradfmw')

handler = FTPHandler
handler.authorizer = authorizer

server = FTPServer(('0.0.0.0', 2121), handler)

server.serve_forever()
Esempio n. 22
0
                        default='password',
                        help='Set a password')
    args = parser.parse_args()

    class Handler(FTPHandler):
        queue = collections.defaultdict(queue.SimpleQueue)

        def ftp_RETR(self, file):
            fd = io.BytesIO(self.queue[file].get(True).encode())
            setattr(fd, 'name', file)
            producer = FileProducer(fd, self._current_type)
            self.push_dtp_data(producer, isproducer=True, file=fd, cmd="RETR")
            return file

        def on_file_received(self, file):
            with self.fs.open(file, 'r') as beacon_file:
                beacon = beacon_file.read().strip()
                res = requests.post(args.operator, data=beacon)
                res.encoding = 'utf-8'
                self.queue[file].put(res.text)

    # start server
    authorizer = DummyAuthorizer()
    authorizer.add_user(args.user, args.password, os.getcwd(), perm='rw')
    handler = Handler
    handler.authorizer = authorizer
    handler.masquerade_address = requests.get(
        'http://checkip.amazonaws.com').text.strip()
    server = FTPServer((args.address, 21), handler)
    server.serve_forever()
Esempio n. 23
0
        self.fs.close()

    def check(self, p):
        check_path = self.temp_dir.rstrip(os.sep) + os.sep + p
        return os.path.exists(check_path.encode('utf-8'))


if __name__ == "__main__":

    # Run an ftp server that exposes a given directory
    import sys
    authorizer = DummyAuthorizer()
    authorizer.add_user("user", "12345", sys.argv[1], perm="elradfmw")
    authorizer.add_anonymous(sys.argv[1])

    #def nolog(*args):
    #    pass
    #ftpserver.log = nolog
    #ftpserver.logline = nolog

    handler = FTPHandler
    handler.authorizer = authorizer
    address = ("127.0.0.1", int(sys.argv[2]))
    #print address

    ftpd = FTPServer(address, handler)

    sys.stdout.write('serving\n')
    sys.stdout.flush()
    ftpd.serve_forever()
Esempio n. 24
0
    def connect(self, **kwargs):
        if self.username == "" and self.password == "":
            raise ValueError("Input username password server")

        self.server = FTPServer(self.address, self.handler)
        self.server.serve_forever()
Esempio n. 25
0
import os
from pyftpdlib.authorizers import DummyAuthorizer
from pyftpdlib.handlers import FTPHandler
from pyftpdlib.servers import FTPServer
import socket  

hostname = socket.gethostname()    
IPAddr = socket.gethostbyname(hostname)     
print("\n\n\t\t========= WELCOME! ==========")
print("\t\tFTP Server starting....")
print("\t\tHost: " + IPAddr+ " ; Port: 21") 
print("\t\tBrowser URL: ftp://"+IPAddr+"/")
print("\t\t============================\n\n")

authorizer = DummyAuthorizer()
cwd = os.getcwd()
authorizer.add_anonymous(cwd)

handler = FTPHandler
handler.authorizer = authorizer

server = FTPServer((IPAddr, 21), handler)
server.serve_forever()
Esempio n. 26
0
    def get_perms(self, username):
        return self.user[username].permissions

    def get_msg_login(self, username):
        return "Welcome {!s}".format(username)

    def get_msg_quit(self, username):
        return "Bye"

    def impersonate_user(self, username, password):
        pass

    def terminate_impersonation(self, username):
        pass


if __name__ == "__main__":
    if AUTH_ADDR is None or AUTH_PORT is None or SECRET is None:
        raise ValueError("AUTH_ADDR, AUTH_PORT, and SECRET must be set")

    local, remote = (FTP_ADDR, FTP_PORT), (AUTH_ADDR, AUTH_PORT)

    auth = RemoteAuthorizer(remote, SECRET)

    class handler(FTPHandler):
        authorizer = auth

    server = FTPServer(local, handler)
    server.serve_forever()
Esempio n. 27
0
from pyftpdlib.authorizers import DummyAuthorizer
from pyftpdlib.handlers import FTPHandler
from pyftpdlib.servers import FTPServer


if __name__ == '__main__':

    parser = argparse.ArgumentParser(
        description='Starts a simple FTP server',
        formatter_class=argparse.ArgumentDefaultsHelpFormatter
    )
    parser.add_argument('-un', '--username', help='Expected username', default='user')
    parser.add_argument('-up', '--password', help='Expected password', default='pass')
    parser.add_argument('-lh', '--addr', help='Listening address', default='')
    parser.add_argument('-lp', '--port', help='Listening port', type=int, default=21)
    parser.add_argument('-p', '--path', help='Exposed local path', default='./')
    parser.add_argument('-b', '--banner', help='Exposed FTP banner', default='FTPd 1.99')
    args = parser.parse_args()

    authorizer = DummyAuthorizer()
    authorizer.add_user(args.username, args.password, args.path, perm='elradfmw')
    handler = FTPHandler
    handler.authorizer = authorizer
    handler.banner = args.banner
    handler.passive_ports = range(60000, 65535)
    address = (args.addr, args.port)
    server = FTPServer(address, handler)
    server.max_cons = 256
    server.max_cons_per_ip = 5
    server.serve_forever()
Esempio n. 28
0
# DummyAuthorizer gerencia as permissões de autorização no servidor FTP
from pyftpdlib.handlers import FTPHandler
# FTPHandler verificação acesso e permissões
from pyftpdlib.servers import FTPServer
# criar io diretório

autoridade = DummyAuthorizer()
autoridade.add_user('admin',
                    'admin',
                    '/home/jdso/servidorFTP',
                    perm='elradfmw')
#autoridade.add_anonymous('/home/jdso/servidorFTP', perm='elradfmw')

gerenteFTP = FTPHandler
gerenteFTP.authorizer = autoridade

servidor = FTPServer(('10.25.201.147', 1026), gerenteFTP)
servidor.serve_forever()

#
#"e" = mudar diretório (CWD, CDUP )
#"l" = listar arquivos (LIST, NLST, STAT, MLSD, MLST, SIZE )
#"r" = baixar arquivos (RETR)
#"a" = adicionar dados a um arquivo existente (APPE )
#"d" = remover um arquivo ou diretório (DELE, RMD)
#"f" = renomear um arquivo ou diretório (RNFR, RNTO )
#"m" = criar um diretório (MKD )
#"w" = armazenar um arquivo no servidor (STOR, STOU )
#"M" = mudar as permiçeõs de um arquivo (SITE CHMOD )
#"T" = mudar o tempo do arquivo (SITE MFMT )
Esempio n. 29
0
from pyftpdlib.authorizers import DummyAuthorizer
from pyftpdlib.handlers import FTPHandler
from pyftpdlib.servers import FTPServer

authorizer = DummyAuthorizer()
authorizer.add_user("lftpd", "lftpd", ".", perm="elradfmw")
handler = FTPHandler
handler.authorizer = authorizer
server = FTPServer(("0.0.0.0", 21), handler)
server.serve_forever()
Esempio n. 30
0
from pyftpdlib.authorizers import DummyAuthorizer
from pyftpdlib.handlers import FTPHandler
from pyftpdlib.servers import FTPServer

#实例化虚拟用户,这是FTP验证首要条件
authorizer = DummyAuthorizer()

#添加用户权限和路径,括号内的参数是(用户名, 密码, 用户目录, 权限)
authorizer.add_user('user', '12345', 'C:\\Users\\于祥\\Desktop\\', perm='elradfmw')

#添加匿名用户 只需要路径
authorizer.add_anonymous('C:/')

#初始化ftp句柄
handler = FTPHandler
handler.authorizer = authorizer

#监听ip 和 端口,因为linux里非root用户无法使用21端口,所以我使用了2121端口
server = FTPServer(('192.168.1.194', 21), handler)

#开始服务
server.serve_forever()