[PHP] FileZilla Password Decoder

2007-10-11 Thread Amos Vryhof

Good Morning everyone,

This week, I switched from FileZilla 2 to FileZilla 3, and much to my 
dismay the import function doesn't import the local and remote folders 
properly.


Looking at the FZ2 and FZ3 XML files, it appears that it would be a 
simple task to write a converter that does.  I have a good start on one, 
(so far it takes all of the parameters in the FZ2 lines and converts 
them into an array that I will just write back out in XML format) but 
FZ3 stores the passwords while FZ2 used encoded passwords.


I found a Python script at http://www.petersblog.org/node/1152 that is 
supposed to decode the passwords to plain text -


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)]);
$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!

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] FileZilla Password Decoder --- $i think therefore $i am

2007-10-11 Thread Jochem Maas
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!
 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] FileZilla Password Decoder --- $i think therefore $i am

2007-10-11 Thread Amos Vryhof

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!



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php