[Python] FileZilla Patcher (Secure XML)

Download | Vote Up (0) | Vote Down (0)
#coding=utf-8


#   ___________.__.__                .__.__  .__         
#   _   _____/|__|  |   ____ _______|__|  | |  | _____   
#    |    __)  |  |  | _/ __ \___   /  |  | |  | __   
#   |        |  |  |_  ___/ /    /|  |  |_|  |__/ __ _
#   ___  /   |__|____/___  >_____ __|____/____(____  /
#       /                 /      /                 /
#   __________         __         .__                 
#   ______   _____ _/  |_  ____ |  |__   ___________
#   |     ___/__  \   __/ ___|  |  _/ __ _  __ 
#   |    |     / __ |  |   ___|   Y    ___/|  | /
#   |____|    (____  /__|  ___  >___|  /___  >__|   
#                  /          /     /     /       

##############################################################
#                                              #
# Ce programme protège vos informations sur Filezilla en     #
# cryptant les fichiers contenant ces informations.          #
# une clé de 8 caractères aléatoire est générée puis utilisée#
# Utilisation :                                   #
#   - Placez Filezillapatcher.py dans un dossier          #
#   - Lancez la commande : "python FilezillaPatcher.py"       #
# Attendez la fin du téléchargement et de la compilation puis#
# profitez d'un version sécurisé de Filezilla.             #
# Necromoine (hwc-crew.com)                            #
# Thank's to : Fr0g, Kallimero, Armel                   #
#                                              #
#############################################################

import random
import tarfile
import urllib
import platform
import os

def generation():
   ''' Fonction qui génère une chaine à 8 caractères ''' # create a 8 length varariable
   chaine = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz123456789'
   a = 0
   final = ''
   while a < 9: # nombre de caractères générés par la boucle
      aleatoire = random.randint(0,65) # nombre de caractères de la chaine 'chaine'
      final = final + chaine[aleatoire:aleatoire+1]
      a = a+ 1
   return final
   
def remplacement(fichier, numero, remplacement): # Remplace one line by an other one with the
   ''' Remplace une ligne dans un fichier donné '''
   lignes = []
   with open(fichier, 'r') as fichiers:
      for ligne in fichiers:
         lignes.append(ligne)
   
   code = remplacement + 'n'
   lignes[numero-1] = remplacement
   
   with open(fichier, 'w') as fichiers:
      for ligne in lignes:
         fichiers.write(ligne)
   
   

''' Boucle principale du programme '''

# Prérequis pour la suite

try:
   urllib.urlretrieve('http://sourceforge.net/projects/filezilla/files/FileZilla_Client/3.5.0/FileZilla_3.5.0_src.tar.bz2', 'Filezilla.tar.bz2')
except:
   print 'Impossible de telecharger le programme, verifiez votre connexion internet'
   quit()
else:
   print 'Telechargement du programme...'

   
archive = tarfile.open('Filezilla.tar.bz2', 'r')
archive.extractall()
   
# Partie une : modification des scripts

phrase = '\n wxString EncryptString(std::string toBeEncrypted,std::string sKey){\n std::string sEncrypted(toBeEncrypted);\n unsigned int iKey(sKey.length()), iIn(toBeEncrypted.length()), x(0);\n for(unsigned int i = 0; i < iIn; i++){\n'
phrase += ' sEncrypted[i] = toBeEncrypted[i] ^ sKey[x] & 10;\n if(++x == iKey){ x = 0; }\n }\n wxString toReturn(sEncrypted.c_str(), wxConvUTF8);\n return toReturn;\n }\n'
remplacement('filezilla-3.5.0/src/interface/queue_storage.cpp',20 , phrase)
phrase = '\n wxString EncryptPass(std::string toBeEncrypted,std::string sKey){\n std::string sEncrypted(toBeEncrypted);\n unsigned int iKey(sKey.length()), iIn(toBeEncrypted.length()), x(0);\n for(unsigned int  i = 0; i < iIn; i++){\n'
phrase += ' sEncrypted[i] = toBeEncrypted[i] ^ sKey[x] & 10;\n if(++x == iKey){ x = 0; }\n }\n wxString toReturn(sEncrypted.c_str(), wxConvUTF8);\n return toReturn;\n }\n'
remplacement('filezilla-3.5.0/src/interface/xmlfunctions.cpp', 6, phrase)
code = generation()
phrase = 'Bind(insertServerQuery_, server_table_column_names::password, EncryptString(std::string(server.GetPass().mb_str()), "' + code + '"));'
remplacement('filezilla-3.5.0/src/interface/queue_storage.cpp', 620, phrase)
phrase = 'pass = EncryptString(std::string(GetColumnText(selectServersQuery_, server_table_column_names::password).mb_str()), "' + code + '");'
remplacement('filezilla-3.5.0/src/interface/queue_storage.cpp', 888, phrase)
phrase = 'AddTextElement(node, "Pass", EncryptPass(std::string(server.GetPass().mb_str()), "' + code + '"));'
remplacement('filezilla-3.5.0/src/interface/xmlfunctions.cpp', 700, phrase)
phrase = 'pass = EncryptPass(std::string(GetTextElement(node, "Pass").mb_str()), "' + code + '");'
remplacement('filezilla-3.5.0/src/interface/xmlfunctions.cpp', 595, phrase)


if platform.system() == 'Windows':
         print 'Le script ne comprend pas la compilation sous Windows, compilez à la main (les instructions sont disponibles sur le site de filezilla)' # can't compile if windows
if platform.system() == 'Linux': # if linux, we compile this is here there are problems
   os.chdir('filezilla-3.5.0/')
   os.system('sudo ./configure && make && make install')
   print ('Filezilla Patcher a correctement effectue les modifications au logiciel')  
raw_input('Appuyez sur une touche pour quitter')

ex0ns


Be the first to give feedback !

Please login to comment !