How to use ftp-srv - 1 common examples

To help you get started, we’ve selected a few ftp-srv examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github montrehack / challenges / 2019-12-18_h0h0h0 / challenges / north-pole-server / ftp.ts View on Github external
import { FtpSrv } from "ftp-srv";
import * as redis from "redis";
import * as fs from "fs";

import { md5 } from "./utils/crypto";

const redisClient = redis.createClient({
    host: "127.0.0.1",
    port: 6379
});

const ftpServer = new FtpSrv({
    url: `ftp://0.0.0.0:${process.env.FTP_PORT || 5001}`,
    blacklist: ["MKD", "XMKD", "RMD", "XRMD"],
    greeting: "h0h0h0",
    pasv_url: `ftp://${process.env.FTP_PASV_IP || "127.0.0.1"}`,
    pasv_min: Number(process.env.FTP_PASV_MIN || 5002),
    pasv_max: Number(process.env.FTP_PASV_MAX || 5020)
});

ftpServer.on("login", (data, resolve, reject) => {
    if (
        !/^[A-z0-9]{8,32}$/.test(data.username) ||
        !/^[A-z0-9]{8,32}$/.test(data.password)
    ) {
        reject(
            new Error(
                "Both username and password must match /^[A-z0-9]{8,32}$/ regex"

ftp-srv

Modern, extensible FTP Server

MIT
Latest version published 7 months ago

Package Health Score

64 / 100
Full package analysis

Popular ftp-srv functions