Created
May 17, 2019 11:22
-
-
Save willnix/3e2f795f4586c32c23b6b6ac666cc520 to your computer and use it in GitHub Desktop.
Simple FTP server that accepts any credentials and logs the to stdout
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pyftpdlib.authorizers import DummyAuthorizer | |
from pyftpdlib.handlers import FTPHandler | |
from pyftpdlib.servers import FTPServer | |
from pyftpdlib.log import logger | |
HOMEDIR = "/var/ftp" | |
# Authorizer granting access to everyone and logging the credentials | |
class LoggingAuthorizer(DummyAuthorizer): | |
def validate_authentication(self, username, password, handler): | |
# Add user on the fly if it does not exist yet | |
if not self.has_user(username): | |
self.add_user(username, password, HOMEDIR, perm="elradfmwMT") | |
# Log the credentials | |
logger.info('LOGIN User: "%s" - Password: "%s"' % (username, password)) | |
authorizer = LoggingAuthorizer() | |
handler = FTPHandler | |
handler.authorizer = authorizer | |
server = FTPServer(("0.0.0.0", 2121), handler) | |
server.serve_forever() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment