Secure XML with Python

Moderator: Project members

Post Reply
Message
Author
necromoine
504 Command not implemented
Posts: 9
Joined: 2011-08-14 20:58
First name: Guigui
Last name: Toutou

Secure XML with Python

#1 Post by necromoine » 2011-08-14 21:06

Hello, I made a little program with python, this code modify the sources of Filezilla to protect the XML used by Filezilla.
I think my program works but it can't compile the sources after that.
Source code of my tool :

Code: Select all

#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

code = generation() 
phrase = 'Bind(insertServerQuery_, server_table_column_names::password, EncryptString(server.GetPass(), "' + code + '"));'
remplacement('filezilla-3.5.0/src/interface/queue_storage.cpp', 610, phrase)
phrase = 'pass = DecryptString(GetColumnText(selectServersQuery_, server_table_column_names::password), "' + code + '");'
remplacement('filezilla-3.5.0/src/interface/queue_storage.cpp', 878, phrase)
phrase = 'AddTextElement(node, "Pass", EncryptString(server.GetPass()), "' + code + '");'
remplacement('filezilla-3.5.0/src/interface/xmlfunctions.cpp', 690, phrase)
phrase = 'pass = DecryptString(GetTextElement(node, "Pass"), "' + code + '");'
remplacement('filezilla-3.5.0/src/interface/xmlfunctions.cpp', 585, 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 
	dir = 'filezilla-3.5.0/compile'
	os.makedirs(dir)
	os.chdir(dir)
	os.popen('chmod +x ../configure')
	os.popen('../configure && make && make install')
	print ('Filezilla Patcher a correctement effectue les modifications au logiciel')	#
raw_input('Appuyez sur une touche pour quitter')
I'm french so the tool is in french but if you have any questions ask, and I'll try to awnser faster as I can.

(Sorry for my english xD)
Necromoine

User avatar
botg
Site Admin
Posts: 35563
Joined: 2004-02-23 20:49
First name: Tim
Last name: Kosse

Re: Secure XML with Python

#2 Post by botg » 2011-08-14 21:08

What's wrong with a simple unified context diff?

necromoine
504 Command not implemented
Posts: 9
Joined: 2011-08-14 20:58
First name: Guigui
Last name: Toutou

Re: Secure XML with Python

#3 Post by necromoine » 2011-08-14 21:22

With a diff, I can't generate an random key used to crypt and decrypt
And this is a compilation error, not a patch error.

tateu
450 Internal Error
Posts: 38
Joined: 2004-11-13 01:19

Re: Secure XML with Python

#4 Post by tateu » 2011-08-14 23:34

Well, your python script doesn't include the actual EncryptString or DecryptString functions so, of course, it won't compile.

necromoine
504 Command not implemented
Posts: 9
Joined: 2011-08-14 20:58
First name: Guigui
Last name: Toutou

Re: Secure XML with Python

#5 Post by necromoine » 2011-08-15 07:33

And what is the actual EncryptString or DecryptString functions ?

tateu
450 Internal Error
Posts: 38
Joined: 2004-11-13 01:19

Re: Secure XML with Python

#6 Post by tateu » 2011-08-15 17:11

necromoine wrote:And what is the actual EncryptString or DecryptString functions ?
That's a question you have to answer. I thought you wrote this python script. In the first post you said:
necromoine wrote:Hello, I made a little program with python
If you did indeed write the script and you are asking that question...I'm afraid that the answer is going to be a little beyond your abilities. If you did not write it, then you need to go back to where ever you got it from and ask them, although I still think it is going to be beyond your abilities to implement and compile.

necromoine
504 Command not implemented
Posts: 9
Joined: 2011-08-14 20:58
First name: Guigui
Last name: Toutou

Re: Secure XML with Python

#7 Post by necromoine » 2011-08-15 17:44

I saw you post here :
http://forum.filezilla-project.org/view ... =3&t=20633

But I made the python script who modify the filezilla's code automatically.
I had never use C++ so I really don't know what is wrong in my script, and I ask again, what is the actual EncryptString function please.

tateu
450 Internal Error
Posts: 38
Joined: 2004-11-13 01:19

Re: Secure XML with Python

#8 Post by tateu » 2011-08-15 18:09

From the thread you mentioned:
tateu wrote:First, you need encrypt and decrypt string functions, let's call them EncryptString and DecryptString. GnuTLS is needed to compile FileZilla and GnuTLS uses libgcrypt, so you could use the libgcrypt library to write the encryption/decryption functions. I am more familiar with Crypto++.
You have to write those functions yourself. You will need to learn C++ if you plan to implement this and I don't recommend this as your first project. EncryptString should take plain text and turn it into cipher text. DecryptString should take cipher text and turn it into plain text.

Look up information about C++ encryption libraries and how to use them to encrypt and decrypt data. I think that goes beyond the scope of this forum.

necromoine
504 Command not implemented
Posts: 9
Joined: 2011-08-14 20:58
First name: Guigui
Last name: Toutou

Re: Secure XML with Python

#9 Post by necromoine » 2011-08-15 18:11

I'm sorry :oops:
I was thinking that en EncryptString function was already exist.

Post Reply