[MOD] [DRFTPD 2.0.3] DISABLE FXP TO OTHER SITES AND TO YOURS

A place for mods with no support from someone in the "developers" group

Moderator: developers

IS THAT DAMN GOOD???

YES
10
63%
NO
6
38%
 
Total votes : 16

[MOD] [DRFTPD 2.0.3] DISABLE FXP TO OTHER SITES AND TO YOURS

Postby yam » Fri Aug 04, 2006, 3:17 pm

Hello guys,

i have a little mod to disable the fucking fxp to other sites and to your site. :twisted: :twisted: :twisted: :twisted:

Change this in perms.conf(you dont need that, but its better):

Code: Select all
# TLS enforcements.
userrejectsecure        !*
userrejectinsecure      *
denydiruncrypted        *
denydatauncrypted       *


and upload my classfile to

Code: Select all
classes/net/sf/drftpd/master/command/plugins


to disable fxp on a user add him/her to the group "fxpdenied" with

Code: Select all
site chgrp <user> fxpdenied


if he tries to FXP it only says:

[L] 1337 - - YAM DON'T WANT THAT U FXP



just code that for all payboxes, and i know thats needed ;) .. nobody need it for other things :lol: :lol: :lol:


if you download the mod, pls add a comment if it's good and it does work,
thanks alot... only works with drftpd 2.0.3, i can apply it for other versions
too, just add a comment which version and i give u the mod for your
version. i dont give the sources to anybody.

To get support just go to #drftpd @ efnet my nick is "yam" or "_yam", or just post here ;)

here we are:
You do not have the required permissions to view the files attached to this post.
yam
 
Posts: 3
Joined: Fri Aug 04, 2006, 2:44 pm

Postby BotzCare » Fri Aug 04, 2006, 4:09 pm

Thanks for sharing this. But the problem is if you aint give the source / diff i'm not going to use it. Reason if theres a svn update for DataConnectionHandler.java it will stop working is my idea after compile.
Anyway its a good thing to have for some that run a server with friends on it that may leech and be able to block them to send to their freinds and abuse your maximum trafic a month you pay for.
BotzCare
Node's little helper
 
Posts: 100
Joined: Fri Mar 04, 2005, 12:54 pm

Postby teslafan1971 » Fri Aug 04, 2006, 10:23 pm

i totally agree with BotzCare so yam i would def make a diff so this can be usefull cause people already patched their .java and wont over rite what u have made so please make a diff for this.
teslafan1971
Node's little helper
 
Posts: 152
Joined: Fri Dec 03, 2004, 9:12 am
Location: South Carolina

Postby yam » Fri Aug 04, 2006, 10:56 pm

i try to make a diff, i dont know to do but i try :lol:
yam
 
Posts: 3
Joined: Fri Aug 04, 2006, 2:44 pm

Postby tworkemon » Sat Aug 05, 2006, 1:39 pm

Try something like
Code: Select all
diff from-file to-file > fxp.diff
or something like that
_Dink @ #drftpd
tworkemon
Node's little helper
 
Posts: 258
Joined: Fri Dec 10, 2004, 9:15 pm

Postby latdna » Sun Aug 06, 2006, 3:20 pm

Decompiled that .class file. I hope this help someone to make .diff file for it and add maybe feature not deny FXP uploads.

Code: Select all

package net.sf.drftpd.master.command.plugins;

import java.io.*;
import java.net.*;
import java.util.*;
import javax.net.ssl.*;
import net.sf.drftpd.*;
import net.sf.drftpd.event.TransferEvent;
import net.sf.drftpd.master.BaseFtpConnection;
import net.sf.drftpd.master.FtpRequest;
import net.sf.drftpd.master.command.CommandManager;
import net.sf.drftpd.master.command.CommandManagerFactory;
import net.sf.drftpd.master.config.ConfigInterface;
import net.sf.drftpd.master.config.ZipscriptConfig;
import org.apache.log4j.Logger;
import org.drftpd.*;
import org.drftpd.commands.*;
import org.drftpd.dynamicdata.KeyedMap;
import org.drftpd.master.*;
import org.drftpd.remotefile.*;
import org.drftpd.slave.*;
import org.drftpd.slaveselection.SlaveSelectionManagerInterface;
import org.drftpd.usermanager.User;
import org.drftpd.usermanager.UserFileException;
import org.tanesha.replacer.ReplacerEnvironment;

public class DataConnectionHandler
    implements CommandHandler, CommandHandlerFactory, Cloneable, HandshakeCompletedListener
{

    public DataConnectionHandler()
    {
        _SSLHandshakeClientMode = false;
        _isPasv = false;
        _isPort = false;
        _preTransfer = false;
        _resumePosition = 0L;
        _type = 'A';
        _handshakeCompleted = false;
        try
        {
            _ctx = SSLGetContext.getSSLContext();
        }
        catch(FileNotFoundException e)
        {
            _ctx = null;
            logger.warn("Couldn't load SSLContext, SSL/TLS disabled");
        }
        catch(Exception e)
        {
            _ctx = null;
            logger.warn("Couldn't load SSLContext, SSL/TLS disabled", e);
        }
    }

    private Reply doAUTH(BaseFtpConnection conn)
    {
        Socket s;
        SSLSocket s2;
        if(_ctx == null)
            return new Reply(500, "TLS not configured");
        s = conn.getControlSocket();
        conn.getControlWriter().write((new Reply(234, (new StringBuilder()).append(conn.getRequest().getCommandLine()).append(" successful").toString())).toString());
        conn.getControlWriter().flush();
        s2 = null;
        s2 = (SSLSocket)_ctx.getSocketFactory().createSocket(s, s.getInetAddress().getHostAddress(), s.getPort(), true);
        conn.setControlSocket(s2);
        s2.setUseClientMode(false);
        s2.addHandshakeCompletedListener(this);
        s2.startHandshake();
_L2:
        if(_handshakeCompleted)
            break MISSING_BLOCK_LABEL_192;
        DataConnectionHandler dataconnectionhandler = this;
        JVM INSTR monitorenter ;
        wait(10000L);
          goto _L1
        InterruptedException e;
        e;
        s2.close();
        conn.stop("Took too long to negotiate SSL");
        return new Reply(400, "Took too long to negotiate SSL");
_L1:
        dataconnectionhandler;
        JVM INSTR monitorexit ;
          goto _L2
        Exception exception;
        exception;
        throw exception;
        _handshakeCompleted = false;
        break MISSING_BLOCK_LABEL_244;
        IOException e;
        e;
        logger.warn("", e);
        if(s2 != null)
            try
            {
                s2.close();
            }
            catch(IOException e2)
            {
                logger.debug("error closing SSLSocket connection");
            }
        conn.stop(e.getMessage());
        return null;
        s2 = null;
        return null;
    }

    private Reply doMODE(BaseFtpConnection conn)
    {
        FtpRequest request = conn.getRequest();
        if(!request.hasArgument())
            return Reply.RESPONSE_501_SYNTAX_ERROR;
        if(request.getArgument().equalsIgnoreCase("S"))
            return Reply.RESPONSE_200_COMMAND_OK;
        else
            return Reply.RESPONSE_504_COMMAND_NOT_IMPLEMENTED_FOR_PARM;
    }

    private Reply doPASVandCPSV(BaseFtpConnection conn)
    {
        if(!_preTransfer)
            return new Reply(500, "You need to use a client supporting PRET (PRE Transfer) to use PASV");
        _preTransfer = false;
        if(isPort())
            throw new RuntimeException();
        if(conn.getRequest().getCommand().equals("CPSV"))
            _SSLHandshakeClientMode = true;
        InetSocketAddress address = null;
        if(_preTransferRSlave == null)
            try
            {
                _passiveConnection = new PassiveConnection(_encryptedDataChannel ? _ctx : null, conn.getGlobalContext().getPortRange(), false);
                try
                {
                    address = new InetSocketAddress(conn.getGlobalContext().getConfig().getPasvAddress(), _passiveConnection.getLocalPort());
                }
                catch(NullPointerException e)
                {
                    address = new InetSocketAddress(conn.getControlSocket().getLocalAddress(), _passiveConnection.getLocalPort());
                }
                _isPasv = true;
            }
            catch(Exception ex)
            {
                logger.warn("", ex);
                return new Reply(550, ex.getMessage());
            }
        else
            try
            {
                String index = _preTransferRSlave.issueListenToSlave(_encryptedDataChannel, _SSLHandshakeClientMode);
                ConnectInfo ci = _preTransferRSlave.fetchTransferResponseFromIndex(index);
                _transfer = _preTransferRSlave.getTransfer(ci.getTransferIndex());
                address = new InetSocketAddress(_preTransferRSlave.getPASVIP(), _transfer.getAddress().getPort());
                _isPasv = true;
            }
            catch(SlaveUnavailableException e)
            {
                reset();
                return Reply.RESPONSE_530_SLAVE_UNAVAILABLE;
            }
            catch(RemoteIOException e)
            {
                reset();
                _preTransferRSlave.setOffline("Slave could not listen for a connection");
                logger.error("Slave could not listen for a connection", e);
                return new Reply(500, "Slave could not listen for a connection");
            }
        if(conn.getRequest().getCommand().equals("CPSV"))
            _SSLHandshakeClientMode = false;
        if(address.getAddress() == null || address.getAddress().getHostAddress() == null)
        {
            return new Reply(500, "Address for is unresolvable, check pasv_addr setting");
        } else
        {
            String addrStr = (new StringBuilder()).append(address.getAddress().getHostAddress().replace('.', ',')).append(',').append(address.getPort() >> 8).append(',').append(address.getPort() & 0xff).toString();
            return new Reply(227, (new StringBuilder()).append("Entering Passive Mode (").append(addrStr).append(").").toString());
        }
    }

    private Reply doPBSZ(BaseFtpConnection conn)
        throws UnhandledCommandException
    {
        String cmd = conn.getRequest().getArgument();
        if(cmd == null || !cmd.equals("0"))
            return Reply.RESPONSE_501_SYNTAX_ERROR;
        else
            return Reply.RESPONSE_200_COMMAND_OK;
    }

    private Reply doPORT(BaseFtpConnection conn)
    {
        FtpRequest request = conn.getRequest();
        reset();
        InetAddress clientAddr = null;
        if(!request.hasArgument())
            return Reply.RESPONSE_501_SYNTAX_ERROR;
        StringTokenizer st = new StringTokenizer(request.getArgument(), ",");
        if(st.countTokens() != 6)
            return Reply.RESPONSE_501_SYNTAX_ERROR;
        String dataSrvName = (new StringBuilder()).append(st.nextToken()).append('.').append(st.nextToken()).append('.').append(st.nextToken()).append('.').append(st.nextToken()).toString();
        try
        {
            clientAddr = InetAddress.getByName(dataSrvName);
        }
        catch(UnknownHostException ex)
        {
            return Reply.RESPONSE_501_SYNTAX_ERROR;
        }
        String portHostAddress = clientAddr.getHostAddress();
        String clientHostAddress = conn.getControlSocket().getInetAddress().getHostAddress();
        if(portHostAddress.startsWith("192.168.") && !clientHostAddress.startsWith("192.168.") || portHostAddress.startsWith("10.") && !clientHostAddress.startsWith("10."))
        {
            Reply response = new Reply(501);
            response.addComment("==YOU'RE BEHIND A NAT ROUTER==");
            response.addComment("Configure the firewall settings of your FTP client");
            response.addComment((new StringBuilder()).append("  to use your real IP: ").append(conn.getControlSocket().getInetAddress().getHostAddress()).toString());
            response.addComment("And set up port forwarding in your router.");
            response.addComment("Or you can just use a PRET capable client, see");
            response.addComment("  http://drftpd.org/ for PRET capable clients");
            return response;
        }
        int clientPort;
        try
        {
            int hi = Integer.parseInt(st.nextToken());
            int lo = Integer.parseInt(st.nextToken());
            clientPort = hi << 8 | lo;
        }
        catch(NumberFormatException ex)
        {
            reset();
            return Reply.RESPONSE_501_SYNTAX_ERROR;
        }
        _isPort = true;
        _portAddress = new InetSocketAddress(clientAddr, clientPort);
        if(portHostAddress.startsWith("127."))
            return new Reply(200, "Ok, but distributed transfers won't work with local addresses");
        if(!clientAddr.equals(conn.getControlSocket().getInetAddress()))
            return new Reply(200, (new StringBuilder()).append("FXP allowed. If you're not FXPing then set your IP to ").append(conn.getControlSocket().getInetAddress().getHostAddress()).append(" (usually in firewall settings)").toString());
        else
            return Reply.RESPONSE_200_COMMAND_OK;
    }

    private Reply doPRET(BaseFtpConnection conn)
    {
        FtpRequest ghostRequest;
        String cmd;
        reset();
        FtpRequest request = conn.getRequest();
        ghostRequest = new FtpRequest(request.getArgument());
        cmd = ghostRequest.getCommand();
        if(cmd.equals("LIST") || cmd.equals("NLST") || cmd.equals("MLSD"))
        {
            _preTransferRSlave = null;
            _preTransfer = true;
            return new Reply(200, "OK, will use master for upcoming transfer");
        }
        if(!cmd.equals("RETR"))
            break MISSING_BLOCK_LABEL_191;
        LinkedRemoteFileInterface downFile = conn.getCurrentDirectory().lookupFile(ghostRequest.getArgument());
        _preTransferRSlave = conn.getGlobalContext().getSlaveSelectionManager().getASlave(downFile.getAvailableSlaves(), 'S', conn, downFile);
        _preTransfer = true;
        return new Reply(200, (new StringBuilder()).append("OK, will use ").append(_preTransferRSlave.getName()).append(" for upcoming transfer").toString());
        NoAvailableSlaveException e;
        e;
        return Reply.RESPONSE_530_SLAVE_UNAVAILABLE;
        e;
        return Reply.RESPONSE_550_REQUESTED_ACTION_NOT_TAKEN;
        org.drftpd.remotefile.LinkedRemoteFile.NonExistingFile nef;
        if(!cmd.equals("STOR"))
            break MISSING_BLOCK_LABEL_329;
        nef = conn.getCurrentDirectory().lookupNonExistingFile(ghostRequest.getArgument());
        if(nef.exists())
            return Reply.RESPONSE_553_REQUESTED_ACTION_NOT_TAKEN_FILE_EXISTS;
        if(!ListUtils.isLegalFileName(nef.getPath()))
            return Reply.RESPONSE_553_REQUESTED_ACTION_NOT_TAKEN;
        _preTransferRSlave = conn.getGlobalContext().getSlaveSelectionManager().getASlave(conn.getGlobalContext().getSlaveManager().getAvailableSlaves(), 'R', conn, nef.getFile());
        _preTransfer = true;
        return new Reply(200, (new StringBuilder()).append("OK, will use ").append(_preTransferRSlave.getName()).append(" for upcoming transfer").toString());
        NoAvailableSlaveException e;
        e;
        return Reply.RESPONSE_530_SLAVE_UNAVAILABLE;
        return Reply.RESPONSE_504_COMMAND_NOT_IMPLEMENTED_FOR_PARM;
    }

    private Reply doSSCN(BaseFtpConnection conn)
    {
        if(_ctx == null)
            return new Reply(500, "TLS not configured");
        if(!(conn.getControlSocket() instanceof SSLSocket))
            return new Reply(500, "You are not on a secure channel");
        if(!_encryptedDataChannel)
            return new Reply(500, "SSCN only works for encrypted transfers");
        if(conn.getRequest().hasArgument())
        {
            if(conn.getRequest().getArgument().equalsIgnoreCase("ON"))
                _SSLHandshakeClientMode = true;
            if(conn.getRequest().getArgument().equalsIgnoreCase("OFF"))
                _SSLHandshakeClientMode = false;
        }
        return new Reply(220, (new StringBuilder()).append("SSCN:").append(_SSLHandshakeClientMode ? "CLIENT" : "SERVER").append(" METHOD").toString());
    }

    private Reply doPROT(BaseFtpConnection conn)
        throws UnhandledCommandException
    {
        if(_ctx == null)
            return new Reply(500, "TLS not configured");
        if(!(conn.getControlSocket() instanceof SSLSocket))
            return new Reply(500, "You are not on a secure channel");
        FtpRequest req = conn.getRequest();
        if(!req.hasArgument())
        {
            _encryptedDataChannel = false;
            return Reply.RESPONSE_200_COMMAND_OK;
        }
        if(!req.hasArgument() || req.getArgument().length() != 1)
            return Reply.RESPONSE_501_SYNTAX_ERROR;
        switch(Character.toUpperCase(req.getArgument().charAt(0)))
        {
        case 67: // 'C'
            _encryptedDataChannel = false;
            return Reply.RESPONSE_200_COMMAND_OK;

        case 80: // 'P'
            _encryptedDataChannel = true;
            return Reply.RESPONSE_200_COMMAND_OK;
        }
        return Reply.RESPONSE_501_SYNTAX_ERROR;
    }

    private Reply doREST(BaseFtpConnection conn)
    {
        FtpRequest request = conn.getRequest();
        if(!request.hasArgument())
        {
            reset();
            return Reply.RESPONSE_501_SYNTAX_ERROR;
        }
        String skipNum = request.getArgument();
        try
        {
            _resumePosition = Long.parseLong(skipNum);
        }
        catch(NumberFormatException ex)
        {
            reset();
            return Reply.RESPONSE_501_SYNTAX_ERROR;
        }
        if(_resumePosition < 0L)
        {
            _resumePosition = 0L;
            reset();
            return Reply.RESPONSE_501_SYNTAX_ERROR;
        } else
        {
            return Reply.RESPONSE_350_PENDING_FURTHER_INFORMATION;
        }
    }

    private Reply doSITE_RESCAN(BaseFtpConnection conn)
    {
        FtpRequest request = conn.getRequest();
        boolean forceRescan = request.hasArgument() && request.getArgument().equalsIgnoreCase("force");
        LinkedRemoteFileInterface directory = conn.getCurrentDirectory();
        SFVFile sfv;
        try
        {
            sfv = conn.getCurrentDirectory().lookupSFVFile();
        }
        catch(Exception e)
        {
            return new Reply(200, (new StringBuilder()).append("Error getting SFV File: ").append(e.getMessage()).toString());
        }
        PrintWriter out = conn.getControlWriter();
        Iterator i = sfv.getEntries().entrySet().iterator();
        do
        {
            if(!i.hasNext())
                break;
            java.util.Map.Entry entry = (java.util.Map.Entry)i.next();
            String fileName = (String)entry.getKey();
            Long checkSum = (Long)entry.getValue();
            LinkedRemoteFileInterface file;
            try
            {
                file = directory.lookupFile(fileName);
            }
            catch(FileNotFoundException ex)
            {
                out.write((new StringBuilder()).append("200- SFV: ").append(Checksum.formatChecksum(checkSum.longValue())).append(" SLAVE: ").append(fileName).append(" MISSING").append("\r\n").toString());
                continue;
            }
            long fileCheckSum = 0L;
            try
            {
                if(forceRescan)
                    fileCheckSum = file.getCheckSumFromSlave();
                else
                    fileCheckSum = file.getCheckSum();
            }
            catch(NoAvailableSlaveException e1)
            {
                out.println((new StringBuilder()).append("200- ").append(fileName).append("SFV: ").append(Checksum.formatChecksum(checkSum.longValue())).append(" SLAVE: OFFLINE").toString());
                continue;
            }
            catch(IOException ex)
            {
                out.print((new StringBuilder()).append("200- ").append(fileName).append(" SFV: ").append(Checksum.formatChecksum(checkSum.longValue())).append(" SLAVE: IO error: ").append(ex.getMessage()).toString());
                continue;
            }
            String status;
            if(fileCheckSum == 0L)
                status = "FAILED - failed to checksum file";
            else
            if(checkSum.longValue() == fileCheckSum)
                status = "OK";
            else
                status = "FAILED - checksum mismatch";
            out.println((new StringBuilder()).append("200- ").append(fileName).append(" SFV: ").append(Checksum.formatChecksum(checkSum.longValue())).append(" SLAVE: ").append(Checksum.formatChecksum(checkSum.longValue())).append(" ").append(status).toString());
        } while(true);
        return Reply.RESPONSE_200_COMMAND_OK;
    }

    private Reply doSITE_XDUPE(BaseFtpConnection conn)
    {
        return Reply.RESPONSE_502_COMMAND_NOT_IMPLEMENTED;
    }

    private Reply doSTRU(BaseFtpConnection conn)
    {
        FtpRequest request = conn.getRequest();
        if(!request.hasArgument())
            return Reply.RESPONSE_501_SYNTAX_ERROR;
        if(request.getArgument().equalsIgnoreCase("F"))
            return Reply.RESPONSE_200_COMMAND_OK;
        else
            return Reply.RESPONSE_504_COMMAND_NOT_IMPLEMENTED_FOR_PARM;
    }

    private Reply doSYST(BaseFtpConnection conn)
    {
        return Reply.RESPONSE_215_SYSTEM_TYPE;
    }

    private Reply doTYPE(BaseFtpConnection conn)
    {
        FtpRequest request = conn.getRequest();
        if(!request.hasArgument())
            return Reply.RESPONSE_501_SYNTAX_ERROR;
        if(setType(request.getArgument().charAt(0)))
            return Reply.RESPONSE_200_COMMAND_OK;
        else
            return Reply.RESPONSE_504_COMMAND_NOT_IMPLEMENTED_FOR_PARM;
    }

    public Reply execute(BaseFtpConnection conn)
        throws ReplyException
    {
        String cmd = conn.getRequest().getCommand();
        if("MODE".equals(cmd))
            return doMODE(conn);
        if("PASV".equals(cmd) || "CPSV".equals(cmd))
            return doPASVandCPSV(conn);
        if("PORT".equals(cmd))
            return doPORT(conn);
        if("PRET".equals(cmd))
            return doPRET(conn);
        if("REST".equals(cmd))
            return doREST(conn);
        if("RETR".equals(cmd) || "STOR".equals(cmd) || "APPE".equals(cmd))
            if(conn.getUserNull().isMemberOf("fxpdenied") && "STOR".equals(cmd))
                return new Reply(1337, "- YAM DON'T WANT THAT U FXP");
            else
                return transfer(conn);
        if("SITE RESCAN".equals(cmd))
            return doSITE_RESCAN(conn);
        if("SITE XDUPE".equals(cmd))
            return doSITE_XDUPE(conn);
        if("STRU".equals(cmd))
            return doSTRU(conn);
        if("SYST".equals(cmd))
            return doSYST(conn);
        if("TYPE".equals(cmd))
            return doTYPE(conn);
        if("AUTH".equals(cmd))
            return doAUTH(conn);
        if("PROT".equals(cmd))
            return doPROT(conn);
        if("PBSZ".equals(cmd))
            return doPBSZ(conn);
        if("SSCN".equals(cmd))
        {
            if(conn.getUserNull().isMemberOf("fxpdenied") && "SSCN".equals(cmd))
                return new Reply(1337, "- YAM DON'T WANT THAT U FXP");
            else
                return doSSCN(conn);
        } else
        {
            throw UnhandledCommandException.create(net/sf/drftpd/master/command/plugins/DataConnectionHandler, conn.getRequest());
        }
    }

    public Socket getDataSocket()
        throws IOException
    {
        Socket dataSocket;
        if(isPort())
        {
            try
            {
                ActiveConnection ac = new ActiveConnection(_encryptedDataChannel ? _ctx : null, _portAddress, _SSLHandshakeClientMode);
                dataSocket = ac.connect();
            }
            catch(IOException ex)
            {
                logger.warn("Error opening data socket", ex);
                dataSocket = null;
                throw ex;
            }
            break MISSING_BLOCK_LABEL_132;
        }
        if(!isPasv())
            break MISSING_BLOCK_LABEL_122;
        dataSocket = _passiveConnection.connect();
        if(_passiveConnection != null)
        {
            _passiveConnection.abort();
            _passiveConnection = null;
        }
        break MISSING_BLOCK_LABEL_132;
        Exception exception;
        exception;
        if(_passiveConnection != null)
        {
            _passiveConnection.abort();
            _passiveConnection = null;
        }
        throw exception;
        throw new IllegalStateException("Neither PASV nor PORT");
        return dataSocket;
    }

    public String[] getFeatReplies()
    {
        if(_ctx != null)
            return (new String[] {
                "PRET", "AUTH SSL", "PBSZ", "CPSV", "SSCN"
            });
        else
            return (new String[] {
                "PRET"
            });
    }

    public String getHelp(String cmd)
    {
        ResourceBundle bundle = ResourceBundle.getBundle(net/sf/drftpd/master/command/plugins/DataConnectionHandler.getName());
        if("".equals(cmd))
            return (new StringBuilder()).append(bundle.getString("help.general")).append("\n").toString();
        if("rescan".equals(cmd))
            return (new StringBuilder()).append(bundle.getString("help.rescan")).append("\n").toString();
        else
            return "";
    }

    public RemoteSlave getTranferSlave()
    {
        return _rslave;
    }

    public synchronized RemoteTransfer getTransfer()
        throws ObjectNotFoundException
    {
        if(_transfer == null)
            throw new ObjectNotFoundException();
        else
            return _transfer;
    }

    public LinkedRemoteFileInterface getTransferFile()
    {
        return _transferFile;
    }

    public char getType()
    {
        return _type;
    }

    public CommandHandler initialize(BaseFtpConnection conn, CommandManager initializer)
    {
        return (DataConnectionHandler)clone();
        CloneNotSupportedException e;
        e;
        throw new RuntimeException(e);
    }

    public boolean isEncryptedDataChannel()
    {
        return _encryptedDataChannel;
    }

    public boolean isPasv()
    {
        return _isPasv;
    }

    public boolean isPort()
    {
        return _isPort;
    }

    public boolean isPreTransfer()
    {
        return _preTransfer || isPasv();
    }

    public synchronized boolean isTransfering()
    {
        return _transfer != null && _rslave != null && _transferFile != null;
    }

    public void load(CommandManagerFactory commandmanagerfactory)
    {
    }

    protected synchronized void reset()
    {
        _rslave = null;
        if(_transfer != null)
            try
            {
                _transfer.abort("reset");
            }
            catch(Throwable t)
            {
                logger.debug("reset failed to abort transfer on the slave", t);
            }
        _transfer = null;
        if(_transferFile != null)
        {
            if(_transferFile.getXfertime() == -1L)
                _transferFile.setXfertime(0L);
            _transferFile = null;
        }
        _preTransfer = false;
        _preTransferRSlave = null;
        if(_passiveConnection != null)
            _passiveConnection.abort();
        _isPasv = false;
        _passiveConnection = null;
        _isPort = false;
        _resumePosition = 0L;
    }

    private boolean setType(char type)
    {
        type = Character.toUpperCase(type);
        if(type != 'A' && type != 'I')
        {
            return false;
        } else
        {
            _type = type;
            return true;
        }
    }

    private Reply transfer(BaseFtpConnection conn)
        throws ReplyException
    {
        ReplacerEnvironment env;
        env = new ReplacerEnvironment();
        if(!_encryptedDataChannel && conn.getGlobalContext().getConfig().checkPermission("denydatauncrypted", conn.getUserNull()))
        {
            reset();
            return new Reply(530, "USE SECURE DATA CONNECTION");
        }
        FtpRequest request;
        char direction;
        boolean isStor;
        boolean isRetr;
        String eventType;
        Reply reply1;
        request = conn.getRequest();
        direction = conn.getDirection();
        String cmd = conn.getRequest().getCommand();
        isStor = cmd.equals("STOR");
        isRetr = cmd.equals("RETR");
        boolean isAppe = cmd.equals("APPE");
        boolean isStou = cmd.equals("STOU");
        eventType = isRetr ? "RETR" : "STOR";
        if(isAppe || isStou)
            throw UnhandledCommandException.create(net/sf/drftpd/master/command/plugins/DataConnectionHandler, conn.getRequest());
        if(request.hasArgument())
            break MISSING_BLOCK_LABEL_166;
        reply1 = Reply.RESPONSE_501_SYNTAX_ERROR;
        reset();
        return reply1;
        LinkedRemoteFileInterface targetDir;
        int comparison = 0;
        int count = conn.transferCounter(direction);
        env.add("maxsim", Integer.valueOf(count));
        if(direction == 'R')
        {
            comparison = conn.getUserNull().getMaxSimUp();
            env.add("direction", "upload");
        } else
        {
            comparison = conn.getUserNull().getMaxSimDown();
            env.add("direction", "download");
        }
        if(comparison == 0 || count <= comparison)
            break MISSING_BLOCK_LABEL_282;
        targetDir = new Reply(550, conn.jprintf(net/sf/drftpd/master/command/plugins/DataConnectionHandler, "transfer.err.maxsim", env));
        reset();
        return targetDir;
        if(!isRetr)
            break MISSING_BLOCK_LABEL_389;
        FileNotFoundException ex;
        _transferFile = conn.getCurrentDirectory().lookupFile(request.getArgument());
        if(_transferFile.isFile())
            break MISSING_BLOCK_LABEL_338;
        ex = new Reply(550, "Not a plain file");
        reset();
        return ex;
        String targetFileName;
        targetDir = _transferFile.getParentFileNull();
        targetFileName = _transferFile.getName();
        break MISSING_BLOCK_LABEL_763;
        FileNotFoundException ex;
        ex;
        String checkName = new Reply(550, ex.getMessage());
        reset();
        return checkName;
        if(!isStor)
            break MISSING_BLOCK_LABEL_755;
        org.drftpd.remotefile.LinkedRemoteFile.NonExistingFile ret = conn.getCurrentDirectory().lookupNonExistingFile(conn.getGlobalContext().getConfig().getFileName(request.getArgument()));
        targetDir = ret.getFile();
        targetFileName = ret.getPath();
        if(!ret.exists())
            break MISSING_BLOCK_LABEL_455;
        checkName = Reply.RESPONSE_553_REQUESTED_ACTION_NOT_TAKEN_FILE_EXISTS;
        reset();
        return checkName;
        if(ListUtils.isLegalFileName(targetFileName) && conn.getGlobalContext().getConfig().checkPathPermission("privpath", conn.getUserNull(), targetDir, true))
            break MISSING_BLOCK_LABEL_510;
        checkName = new Reply(553, "Requested action not taken. File name not allowed.");
        reset();
        return checkName;
        ZipscriptConfig zsCfg;
        boolean SfvFirstEnforcedPath;
        checkName = targetFileName.toLowerCase();
        zsCfg = conn.getGlobalContext().getZsConfig();
        SfvFirstEnforcedPath = zsCfg.checkSfvFirstEnforcedPath(targetDir, conn.getUserNull());
        SFVFile sfv;
        Reply reply4;
        sfv = conn.getCurrentDirectory().lookupSFVFile();
        if(!checkName.endsWith(".sfv") || zsCfg.multiSfvAllowed())
            break MISSING_BLOCK_LABEL_591;
        reply4 = new Reply(533, "Requested action not taken. Multiple SFV files not allowed.");
        reset();
        return reply4;
        Iterator iter;
        if(!SfvFirstEnforcedPath || zsCfg.checkAllowedExtension(checkName))
            break MISSING_BLOCK_LABEL_763;
        boolean allow = false;
        if(!zsCfg.restrictSfvEnabled())
            break MISSING_BLOCK_LABEL_763;
        iter = sfv.getNames().iterator();
        do
        {
            if(!iter.hasNext())
                break;
            String name = (String)iter.next();
            if(!name.toLowerCase().equals(checkName))
                continue;
            allow = true;
            break;
        } while(true);
        if(allow)
            break MISSING_BLOCK_LABEL_763;
        iter = new Reply(533, "Requested action not taken. File not found in sfv.");
        reset();
        return iter;
        FileNotFoundException e1;
        e1;
        if(zsCfg.checkAllowedExtension(checkName) || !SfvFirstEnforcedPath)
            break MISSING_BLOCK_LABEL_763;
        allow = new Reply(533, "Requested action not taken. You must upload sfv first.");
        reset();
        return allow;
        e1;
        break MISSING_BLOCK_LABEL_763;
        e1;
        break MISSING_BLOCK_LABEL_763;
        throw UnhandledCommandException.create(net/sf/drftpd/master/command/plugins/DataConnectionHandler, request);
        if(conn.getGlobalContext().getConfig().checkPathPermission("privpath", conn.getUserNull(), targetDir, true))
            break MISSING_BLOCK_LABEL_830;
        ret = new Reply(550, (new StringBuilder()).append(request.getArgument()).append(": No such file").toString());
        reset();
        return ret;
        direction;
        JVM INSTR lookupswitch 2: default 932
    //                   82: 896
    //                   83: 860;
           goto _L1 _L2 _L3
_L3:
        if(conn.getGlobalContext().getConfig().checkPathPermission("download", conn.getUserNull(), targetDir)) goto _L5; else goto _L4
_L4:
        ret = Reply.RESPONSE_530_ACCESS_DENIED;
        reset();
        return ret;
_L2:
        if(conn.getGlobalContext().getConfig().checkPathPermission("upload", conn.getUserNull(), targetDir)) goto _L5; else goto _L6
_L6:
        ret = Reply.RESPONSE_530_ACCESS_DENIED;
        reset();
        return ret;
_L1:
        throw UnhandledCommandException.create(net/sf/drftpd/master/command/plugins/DataConnectionHandler, request);
_L5:
        if(!isRetr || conn.getUserNull().getKeyedMap().getObjectFloat(UserManagement.RATIO) == 0.0F || conn.getGlobalContext().getConfig().getCreditLossRatio(_transferFile, conn.getUserNull()) == 0.0F || conn.getUserNull().getCredits() >= _transferFile.length()) goto _L8; else goto _L7
_L7:
        ret = new Reply(550, "Not enough credits.");
        reset();
        return ret;
_L8:
        if(!isPasv()) goto _L10; else goto _L9
_L9:
        if(!isRetr || _transferFile.getSlaves().contains(_preTransferRSlave)) goto _L12; else goto _L11
_L11:
        ret = Reply.RESPONSE_503_BAD_SEQUENCE_OF_COMMANDS;
        reset();
        return ret;
_L12:
        _rslave = _preTransferRSlave;
          goto _L13
_L10:
        try
        {
            if(direction == 'S')
                _rslave = conn.getGlobalContext().getSlaveSelectionManager().getASlave(_transferFile.getAvailableSlaves(), 'S', conn, _transferFile);
            else
            if(direction == 'R')
                _rslave = conn.getGlobalContext().getSlaveSelectionManager().getASlave(conn.getGlobalContext().getSlaveManager().getAvailableSlaves(), 'R', conn, targetDir);
            else
                throw new RuntimeException();
        }
        // Misplaced declaration of an exception variable
        catch(org.drftpd.remotefile.LinkedRemoteFile.NonExistingFile ret)
        {
            throw new ReplySlaveUnavailableException(ret, 450);
        }
_L13:
        if(isStor)
        {
            if(_rslave == null)
                throw new NullPointerException();
            java.util.List rslaves = Collections.singletonList(_rslave);
            StaticRemoteFile uploadFile = new StaticRemoteFile(rslaves, targetFileName, conn.getUserNull().getName(), conn.getUserNull().getGroup(), 0L, System.currentTimeMillis(), 0L);
            synchronized(this)
            {
                uploadFile.setXfertime(-1L);
                _transferFile = targetDir.addFile(uploadFile);
            }
        }
        if(!isPort()) goto _L15; else goto _L14
_L14:
        try
        {
            String index = _rslave.issueConnectToSlave(_portAddress.getAddress().getHostAddress(), _portAddress.getPort(), _encryptedDataChannel, _SSLHandshakeClientMode);
            ConnectInfo ci = _rslave.fetchTransferResponseFromIndex(index);
            synchronized(this)
            {
                _transfer = _rslave.getTransfer(ci.getTransferIndex());
            }
            break MISSING_BLOCK_LABEL_1509;
        }
        // Misplaced declaration of an exception variable
        catch(String index)
        {
            logger.fatal((new StringBuilder()).append("rslave=").append(_rslave).toString(), index);
            ci = new Reply(450, (new StringBuilder()).append(index.getClass().getName()).append(" from slave: ").append(index.getMessage()).toString());
        }
        reset();
        return ci;
_L15:
        if(isPasv())
            break MISSING_BLOCK_LABEL_1509;
        if(isStor)
            _transferFile.delete();
        index = Reply.RESPONSE_503_BAD_SEQUENCE_OF_COMMANDS;
        reset();
        return index;
        TransferStatus status;
        PrintWriter out = conn.getControlWriter();
        out.write((new Reply(150, (new StringBuilder()).append("File status okay; about to open data connection ").append(isRetr ? "from " : "to ").append(_rslave.getName()).append(".").toString())).toString());
        out.flush();
        status = null;
        if(isRetr)
        {
            _transfer.sendFile(_transferFile.getPath(), getType(), _resumePosition);
            do
            {
                status = _transfer.getTransferStatus();
                if(status.isFinished())
                    break;
                try
                {
                    Thread.sleep(100L);
                }
                catch(InterruptedException e1) { }
            } while(true);
        } else
        if(isStor)
        {
            _transfer.receiveFile(_transferFile.getPath(), getType(), _resumePosition);
            do
            {
                status = _transfer.getTransferStatus();
                _transferFile.setLength(status.getTransfered());
                if(status.isFinished())
                    break;
                try
                {
                    Thread.sleep(100L);
                }
                catch(InterruptedException e1) { }
            } while(true);
        } else
        {
            throw new RuntimeException();
        }
          goto _L16
        IOException ex;
        ex;
        Reply reply2;
        logger.debug("", ex);
        if((ex instanceof TransferFailedException) && isRetr)
            conn.getUserNull().updateCredits(-status.getTransfered());
        Reply reply = null;
        if(isStor)
        {
            _transferFile.delete();
            logger.error("IOException during transfer, deleting file", ex);
            reply = new Reply(426, "Transfer failed, deleting file");
        } else
        {
            logger.error("IOException during transfer", ex);
            reply = new Reply(426, ex.getMessage());
        }
        reply.addComment(ex.getMessage());
        reply2 = reply;
        reset();
        return reply2;
        SlaveUnavailableException e;
        e;
        logger.debug("", e);
        Reply reply = null;
        if(isStor)
        {
            _transferFile.delete();
            logger.error("Slave went offline during transfer, deleting file", e);
            reply = new Reply(426, "Slave went offline during transfer, deleting file");
        } else
        {
            logger.error("Slave went offline during transfer", e);
            reply = new Reply(426, "Slave went offline during transfer");
        }
        reply.addComment(e.getLocalizedMessage());
        reply2 = reply;
        reset();
        return reply2;
_L16:
        Reply response;
        env = new ReplacerEnvironment();
        env.add("bytes", Bytes.formatBytes(status.getTransfered()));
        env.add("speed", (new StringBuilder()).append(Bytes.formatBytes(status.getXferSpeed())).append("/s").toString());
        env.add("seconds", (new StringBuilder()).append("").append((float)status.getElapsed() / 1000F).toString());
        env.add("checksum", Checksum.formatChecksum(status.getChecksum()));
        response = new Reply(226, conn.jprintf(net/sf/drftpd/master/command/plugins/DataConnectionHandler, "transfer.complete", env));
        Reply reply3;
        synchronized(conn.getGlobalContext())
        {
            if(isStor)
            {
                if(_resumePosition == 0L)
                    _transferFile.setCheckSum(status.getChecksum());
                _transferFile.setLastModified(System.currentTimeMillis());
                _transferFile.setLength(status.getTransfered());
                _transferFile.setXfertime(status.getElapsed());
            }
            boolean zipscript = zipscript(isRetr, isStor, status.getChecksum(), response, targetFileName, targetDir);
            if(zipscript)
            {
                if(isRetr)
                {
                    float ratio = conn.getGlobalContext().getConfig().getCreditLossRatio(_transferFile, conn.getUserNull());
                    if(ratio != 0.0F)
                        conn.getUserNull().updateCredits((long)((float)(-status.getTransfered()) * ratio));
                    if(!conn.getGlobalContext().getConfig().checkPathPermission("nostatsdn", conn.getUserNull(), conn.getCurrentDirectory()))
                    {
                        conn.getUserNull().updateDownloadedBytes(status.getTransfered());
                        conn.getUserNull().updateDownloadedTime(status.getElapsed());
                        conn.getUserNull().updateDownloadedFiles(1);
                    }
                } else
                {
                    conn.getUserNull().updateCredits((long)((float)status.getTransfered() * conn.getGlobalContext().getConfig().getCreditCheckRatio(_transferFile, conn.getUserNull())));
                    if(!conn.getGlobalContext().getConfig().checkPathPermission("nostatsup", conn.getUserNull(), conn.getCurrentDirectory()))
                    {
                        conn.getUserNull().updateUploadedBytes(status.getTransfered());
                        conn.getUserNull().updateUploadedTime(status.getElapsed());
                        conn.getUserNull().updateUploadedFiles(1);
                    }
                }
                try
                {
                    conn.getUserNull().commit();
                }
                catch(UserFileException e)
                {
                    logger.warn("", e);
                }
            }
            conn.getGlobalContext().dispatchFtpEvent(new TransferEvent(conn, eventType, _transferFile, conn.getClientAddress(), _rslave, _transfer.getAddress().getAddress(), getType()));
            reply3 = response;
        }
        reset();
        return reply3;
        Exception exception3;
        exception3;
        reset();
        throw exception3;
    }

    public void unload()
    {
    }

    private boolean zipscript(boolean isRetr, boolean isStor, long checksum, Reply response, String targetFileName, LinkedRemoteFileInterface targetDir)
    {
        logger.debug((new StringBuilder()).append("Running zipscript on file ").append(targetFileName).append(" with CRC of ").append(checksum).toString());
        if(isRetr)
        {
            logger.debug((new StringBuilder()).append("checksum from transfer = ").append(checksum).toString());
            if(checksum != 0L)
            {
                response.addComment((new StringBuilder()).append("Checksum from transfer: ").append(Checksum.formatChecksum(checksum)).toString());
                long cachedChecksum = _transferFile.getCheckSumCached();
                if(cachedChecksum == 0L)
                    _transferFile.setCheckSum(checksum);
                else
                if(cachedChecksum != checksum)
                {
                    response.addComment("WARNING: checksum from transfer didn't match cached checksum");
                    logger.info((new StringBuilder()).append("checksum from transfer ").append(Checksum.formatChecksum(checksum)).append("didn't match cached checksum").append(Checksum.formatChecksum(cachedChecksum)).append(" for ").append(_transferFile.toString()).append(" from slave ").append(_rslave.getName()).toString(), new Throwable());
                }
                try
                {
                    long sfvChecksum = _transferFile.getParentFileNull().lookupSFVFile().getChecksum(_transferFile.getName());
                    if(sfvChecksum == checksum)
                        response.addComment("checksum from transfer matched checksum in .sfv");
                    else
                        response.addComment("WARNING: checksum from transfer didn't match checksum in .sfv");
                }
                catch(NoAvailableSlaveException e1)
                {
                    response.addComment("slave with .sfv offline, checksum not verified");
                }
                catch(FileNotFoundException e1) { }
                catch(NoSFVEntryException e1) { }
                catch(IOException e1)
                {
                    logger.info("", e1);
                    response.addComment((new StringBuilder()).append("IO Error reading sfv file: ").append(e1.getMessage()).toString());
                }
            }
            break MISSING_BLOCK_LABEL_579;
        }
        if(!isStor || targetFileName.toLowerCase().endsWith(".sfv"))
            break MISSING_BLOCK_LABEL_579;
        long sfvChecksum = targetDir.lookupSFVFile().getChecksum(targetFileName);
        if(checksum == sfvChecksum)
        {
            response.addComment((new StringBuilder()).append("checksum match: SLAVE/SFV:").append(Long.toHexString(checksum)).toString());
            break MISSING_BLOCK_LABEL_579;
        }
        if(checksum == 0L)
        {
            response.addComment("checksum match: SLAVE/SFV: DISABLED");
            break MISSING_BLOCK_LABEL_579;
        }
        response.addComment((new StringBuilder()).append("checksum mismatch: SLAVE: ").append(Long.toHexString(checksum)).append(" SFV: ").append(Long.toHexString(sfvChecksum)).toString());
        response.addComment(" deleting file");
        response.setMessage("Checksum mismatch, deleting file");
        _transferFile.delete();
        return false;
        NoAvailableSlaveException e;
        e;
        response.addComment("zipscript - SFV unavailable, slave(s) with .sfv file is offline");
        break MISSING_BLOCK_LABEL_579;
        e;
        response.addComment("zipscript - no entry in sfv for file");
        break MISSING_BLOCK_LABEL_579;
        e;
        response.addComment((new StringBuilder()).append("zipscript - SFV unavailable, IO error: ").append(e.getMessage()).toString());
        return true;
    }

    public synchronized void handshakeCompleted(HandshakeCompletedEvent arg0)
    {
        _handshakeCompleted = true;
        notifyAll();
    }

    private static final Logger logger = Logger.getLogger(net/sf/drftpd/master/command/plugins/DataConnectionHandler);
    private SSLContext _ctx;
    private boolean _encryptedDataChannel;
    private boolean _SSLHandshakeClientMode;
    protected boolean _isPasv;
    protected boolean _isPort;
    private InetSocketAddress _portAddress;
    protected boolean _preTransfer;
    private RemoteSlave _preTransferRSlave;
    private long _resumePosition;
    private RemoteSlave _rslave;
    private PassiveConnection _passiveConnection;
    private RemoteTransfer _transfer;
    private LinkedRemoteFileInterface _transferFile;
    private char _type;
    private boolean _handshakeCompleted;

}
latdna
 
Posts: 20
Joined: Fri May 06, 2005, 1:27 am

Postby yam » Sun Aug 06, 2006, 6:35 pm

that version doesnt work :oops:

i upload later a working version with a diff file :twisted:
yam
 
Posts: 3
Joined: Fri Aug 04, 2006, 2:44 pm

Postby k2r » Sun Aug 06, 2006, 7:57 pm

There are only 2 modification :

in RETR, STOR Command

Code: Select all
if("RETR".equals(cmd) || "STOR".equals(cmd) || "APPE".equals(cmd)) {
       if(conn.getUserNull().isMemberOf("fxpdenied") && "STOR".equals(cmd)) {
            return new Reply(1337, "- YAM DON'T WANT THAT U FXP");
       } else {
                return transfer(conn);
       }
}


And for the ssl site command :

Code: Select all
if("SSCN".equals(cmd)) {
     if(conn.getUserNull().isMemberOf("fxpdenied") && "SSCN".equals(cmd)) {
         return new Reply(1337, "- YAM DON'T WANT THAT U FXP");
     } else {
         return doSSCN(conn);
     }
}


I dont know if its a good way but you can try.
The drFTPD French Touch ...
k2r
drFTPD French Touch
 
Posts: 488
Joined: Fri Nov 04, 2005, 5:36 pm
Location: .FR

Postby Prometheus » Sun Aug 06, 2006, 10:35 pm

That's not a good way, what if the user want's to download to his pc?
Michel @ #drftpd
Prometheus
Node's little helper
 
Posts: 291
Joined: Sun Dec 12, 2004, 8:19 pm

Postby k2r » Sun Aug 06, 2006, 10:38 pm

he cant :D
The drFTPD French Touch ...
k2r
drFTPD French Touch
 
Posts: 488
Joined: Fri Nov 04, 2005, 5:36 pm
Location: .FR

Postby setti » Thu Aug 10, 2006, 1:44 pm

what the heck should this mod do?
It only denies uploading/downloading (including fxping).

I found no check for ips (connection client, transfer client)
setti
 
Posts: 19
Joined: Tue Mar 07, 2006, 2:12 pm

Postby TheFelin » Fri Aug 25, 2006, 3:51 pm

that does not function, can you detail correctly?
TheFelin
 
Posts: 51
Joined: Wed Jan 18, 2006, 9:42 pm

Postby teslafan1971 » Fri Aug 25, 2006, 5:37 pm

Yam make a .diff so this will be usefull for someone or remove it and dont waste everyones time
teslafan1971
Node's little helper
 
Posts: 152
Joined: Fri Dec 03, 2004, 9:12 am
Location: South Carolina

Postby setti » Fri Aug 25, 2006, 9:39 pm

this damn mod does not do anything, than deny user downloading / uploading if they are in the specific group.
So just ignore it please people.
setti
 
Posts: 19
Joined: Tue Mar 07, 2006, 2:12 pm

Postby fr0w » Sat Sep 02, 2006, 12:15 am

This topic is completelly lame.
Closed, not useful at all.
Distributed File Transfer Protocol Daemon
fr0w
 
Posts: 95
Joined: Wed Feb 16, 2005, 11:14 pm
Location: .BR


Return to New & Rogue Mods

Who is online

Users browsing this forum: Google [Bot] and 1 guest

cron