Re: FileZilla Password Decoder --- $i think therefore $i am

From: Date: Thu, 11 Oct 2007 15:27:56 +0000
Subject: Re: FileZilla Password Decoder --- $i think therefore $i am
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-263109@lists.php.net to get a copy of this message
Thanks! That Helped Immensely..... the final function is below (with a little documentation)... I'll post my final converter somewhere soon... it's done, and works. // Decodes a FileZilla 2 password function DecodePassword($strPass) { // The Encryption Salt for FileZilla 2 Passwords $strKey = "FILEZILLA1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ"; // Split the encrypted strings into chunks of 3 $passPieces = str_split($strPass,3); // How many characters in the final password $nPassLen = strlen($strPass) / 3; $nOffset = ($nPassLen % strlen($strKey)); // Clear the variable that holds the decoded password $strDecodedPass = ""; // Step through each 3-character chunk foreach($passPieces as $i=>$passPiece) {
    // this should not be needed, but it ensures the correct data type
    // I think it might be just a throwback from converting from the
    // Python script
    $c = intval($passPiece);
    // I don't rightly know what this does, but it seems to work.
    // Like I said, it was converted from a python script that worked.
    $c2 = ord($strKey[($i + $nOffset) % strlen($strKey)]);
    $c3 = chr(($c ^ $c2));
    // Adds the decoded character to the final password String
    $strDecodedPass .= $c3;
} // Spit back the whole collection of decoded characters return $strDecodedPass; } Jochem Maas wrote:
Amos Vryhof wrote:
Good Morning everyone,
....
def DecodePassword( strPass):
    """Decode a filezilla password"""
    strKey = "FILEZILLA1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ"
    nPassLen = len(strPass) / 3
    nOffset = nPassLen % len(strKey)
    strDecodedPass = ""
    for i in range(nPassLen):
        c = int(strPass[i * 3:(i * 3) + 3])
        c2 = ord(strKey[(i + nOffset) % len(strKey)])
        c3 = chr((c ^ c2))
        strDecodedPass += c3
    return strDecodedPass
...and tried to convert it to PHP, but since I don't know Python and there is no documentation in the script to say what it's doing, my function doesn't spit out all of the right characters... (it does some though?? maybe coincidence) function DecodePassword($strPass) {
    $strKey = "FILEZILLA1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    $nPassLen = strlen($strPass) / 3;
    $nOffset = ($nPassLen % strlen($strKey));
    $strDecodedPass = "";
        $passPieces = str_split($strPass,3);
        foreach($passPieces as $passPiece) {
    $c = intval($passPiece);
        $c2 = ord($strKey[($i + $nOffset) % strlen($strKey)]);
			     ^---- WHERE IS $i DEFINED? (hint: it's not :-)
        $c3 = chr(($c ^ $c2));
       $strDecodedPass .= $c3;
    }
    return $strDecodedPass;
} I know I simplified quite a bit, but I might have done it wrong...I tried to convert line-for line, but I'm not sure what the stuff on Lines 10 to 13 do. (Lack of Perl knowledge) There are perl and Javascript functions to do the decoding at http://filezilla.sourceforge.net/forum/viewtopic.php?t=170 I'm not looking for a major undertaking, just something to do the conversion so I don't have to rebuild definitions for 200 and something websites.... If I can get it working properly, I'll probably put a version on my server so people can convert their files as well, as I can see this being a major PITA. Thanks!


« previous php.general (#263109) next »