belier-1.2/0000755000175000017500000000000011273371413012022 5ustar chaicachaicabelier-1.2/i18n/0000755000175000017500000000000011273371413012601 5ustar chaicachaicabelier-1.2/i18n/fr/0000755000175000017500000000000011273371413013210 5ustar chaicachaicabelier-1.2/i18n/fr/bel.mo0000644000175000017500000000465611273370402014317 0ustar chaicachaical  81"j(, 04)e^O,(A*j0(5%D_{?./72j q}<Cr>y:(, 1I 2{      %s : no such directory%s : no such file%s is not a directory%s is not a fileA hostname must contain at least two characters (rfc952)A port number can not exceed 65535A port number should only contain digitsBelier has been stopped manually by the userDELAYDIRECTORYFILEIncorrect argument number on the order file lineThe file format is invalid It may be a binary file ?The given value is not valid%sThe delay value must be >= -1 and <= value of an integer on your systemYou should have two tunnel options arguments (source port and destination port)Your domain name size exceeds 255 charactersYour hostname size exceeds 64 characterscontains the orders to generate the scriptin seconds the time between each order executionthe directory to store generated scriptsProject-Id-Version: Belier 1.1 Report-Msgid-Bugs-To: POT-Creation-Date: 2009-10-05 22:24+0200 PO-Revision-Date: 2009-10-05 22:24+0200 Last-Translator: Carl Chenet Language-Team: FRENCH MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Le répertoire %s n'existe pasLe fichier %s n'existe pas%s n'est pas un répertoire%s n'est pas un fichierUn nom d'hôte doit contenir au moins deux caractères (rfc952)Un numéro de port ne peut pas dépasser 65535Un numéro de port ne contient que des chiffresBélier a été arrêté manuellement par l'utilisateurDÉLAIRÉPERTOIREFICHIERNombre invalide d'arguments sur la ligne du fichier d'ordresFormat du fichier d'ordres invalide Peut-être un fichier binaire ?La valeur indiqué n'est pas valide%sLa valeur délai doit être >= -1 et <= valeur d'un entier sur votre systèmeDeux valeurs sont nécessaires : le port source et destinationLa taille de votre nom de domaine dépasse 255 caractèresYour hostname size exceeds 64 characterscontient les ordres pour générer le scripten secondes pour exécuter une commande du scriptrépertoire où entreposer les fichiers générésbelier-1.2/setup.py0000644000175000017500000000334211273370402013533 0ustar chaicachaica# -*- coding: utf-8 -*- # Copyright © 2008 Carl Chenet # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from distutils.core import setup import os.path CLASSIFIERS = [ 'Intended Audience :: System Administrators', 'Development Status :: 5 - Production/Stable', 'Environment :: Console', 'License :: OSI Approved :: GNU General Public License (GPL)', 'Operating System :: OS Independent', 'Natural Language :: French', 'Programming Language :: Python', ] setup(name = 'belier', version = '1.2', license = 'GNU GPL v3', description = 'Ssh connection generation tool', long_description = 'Belier allows automated openings of a shell or command executions on remote computers through ssh. The main feature is Belier\'s ability to cross several computers before joining the final machine.', classifiers = CLASSIFIERS, author = 'Carl Chenet', author_email = 'chaica@ohmytux.com', url = 'http://www.ohmytux.com/belier', download_url = 'http://www.ohmytux.com/belier', packages = ['belier'], scripts = ['bel'], data_files=[(os.path.join('share','locale','fr','LC_MESSAGES'), ['i18n/fr/bel.mo'])] ) belier-1.2/README0000644000175000017500000002660511273370402012710 0ustar chaicachaicaBelier ====== What's for ? ------------ Belier allows opening a shell or executing a command on a remote computer through a SSH connection. The main feature of Belier is its ability to cross several intermediate computers before realizing the job. - Belier reaches the final computer through intermediate machines. - You can execute commands with any account available on the remote computer. - It is possible to switch account on intermediate computers before accessing the final computer. - You can open a data tunnel through every host you cross to the final host. - Belier generates one script for each final computer to reach. License ------- GPLv3 and more What you need before installing Belier -------------------------------------- - Python >= 2.4 - Expect >= 5.42.1 Debian : ------------------------------- # apt-get install python expect ------------------------------- Installation ------------ From sources ~~~~~~~~~~~~ ----------------------- $ tar zxvf $ cd belier-1.1 $ su - # python setup.py install ------------------------- Easy_install ~~~~~~~~~~~~ --------------------- # easy_install belier --------------------- Source code ----------- ---------------------------------------- $ git clone git://git.ohmytux.com/belier ---------------------------------------- Howtos ------ Information file syntax ~~~~~~~~~~~~~~~~~~~~~~~ ------------------------------------------------- [user@]host[:port] [pass|user [pass]] [-c|-t|-ot] ------------------------------------------------- Open a remote shell as root ~~~~~~~~~~~~~~~~~~~~~~~~~~~ We first write a file which defines information to access the final computer : ------------------------------- admin@host Ic4r3 root jkw!po12; ------------------------------- Belier generates the script : --------------------- $ bel --entree=ordres $ ls ordres host.sh ---------------- Execution of the script (only the script is executed here, the other lines are self-generated) : ------------------------------- user@localhost:~$ ./host.sh spawn ssh host admin@host's password: admin@host:~$ su - root Password: root@host:~# ------------ Let's be more verbose about this example : . We write a file with the mandatory information to connect the remote computer. The first field is composed by a login followed by '@' and the hostname (could be an ip address). You can omit the login and in this case, the actual login of your shell session will be used. . The second field is a password to access the remote computer. It could be omitted if you exchanged ssh keys between the both computers. . The third field is the login you want to switch to after beeing connected to the remote computer. It could be omitted if you don't need to switch. . The fourth and last field is the required password for the user switching. Could be omitted too. . You generate the connection script. You could use standard input but in our example we use --entree option to pinpoint the information file. . You launch the script and you reach the final computer. Open a remote shell with several intermediate computers ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ We first write a file which defines information to access the final host: ---------------------------- middlehost1 admin azer0;lp!Z admin@middlehost2 admin@lasthost root jkw!po12; ----------------------------- Belier generates the script: --------------------- $ bel --entree=ordres $ ls ordres lasthost.sh -------------------- Execution of the script (only the script is executed here, the other lines are self-generated): ------------------------------- user@localhost:~$ ./lasthost.sh spawn ssh middlehost1 user@middlehost1's password: user@middlehost1:~$ su - admin Password: admin@middlehost1:~$ ssh admin@middlehost2 admin@middlehost2:~$ ssh admin@lasthost admin@lasthost's password: admin@lasthost:~$ su - root Password: root@lasthost:~# ---------------- Let's be more verbose about this example: . The first line of the information file defines the first intermediate computer to reach. On this one we also define a user switch. . The second line defines the second intermediate computer. . The third line defines the final computer. On this computer we switch to root. . You generate the connection script. You could use standard input but in our example we use --entree option to pinpoint the information file. . You launch the script and you reach the final computer. Execute a command on a remote computer as root ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ We first write a file which defines information to access the final computer : --------------------------- middlehost admin azer0;lp!Z admin@lasthost root !ZuP3r; -c df -h ----- Belier generates the script : --------------------- $ bel --entree=ordres $ ls ordres lasthost.sh -------------------- Here is the output of the execution of the generated script : ------------------------------- user@localhost:~$ ./lasthost.sh spawn ssh middlehost user@middlehost's password: user@middlehost:~$ su - admin Password: admin@middlehost:~$ ssh admin@lasthost admin@lasthost's password: admin@lasthost:~$ su - root Password: root@lasthost:~# df -h Sys. de fich. Tail. Occ. Disp. %Occ. Monté sur /dev/sda2 453G 61G 393G 14% / varrun 2,0G 112K 2,0G 1% /var/run varlock 2,0G 0 2,0G 0% /var/lock udev 2,0G 48K 2,0G 1% /dev devshm 2,0G 24K 2,0G 1% /dev/shm lrm 2,0G 36M 1,9G 2% /lib/modules/2.6.24-21-generic/volatile root@lasthost:~# ---------------- Let's be more verbose about this example : . The first line of the information file defines the first intermediate computer to reach. On this one we also define a user switch. . The second line defines the second intermediate computer. . The third line defines the final computer. On this computer we switch to root. . The fourth line defines the command we want to execute on the final computer. . You generate the connection script. You could use standard input but in our example we use --entree option to pinpoint the information file. . You launch the script and you reach the final computer. Open a tunnel for data while connecting to a host ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ We want to send a big file through several hosts. Copying it through the different hosts would be painful. Bélier offers an elegant solution to solve that case by opening on your source computer a network port sending data directly on the final machine you want to work on. By default this network port has the following number : 9999. Lets take the following order file : ------------------------ middlehost azer0;lp!z -t admin@lasthost root jkw!po12; ----------------------------- Belier generates the script : --------------------- $ bel --entree=ordres $ ls ordres lasthost.sh -------------------- Let's be more verbose about this example : . That's a pretty common order file but you have at the end of the line the -t (for tunnel) option, which means you want a data tunnel to this machine. . That's pretty much what you need. executing this script you'll connect and open a shell on the final host, as usual. . But moreover, you have on your source host an open port allowing you to send data directly to the final host, using the scp command. Execution of the script (only the script is executed here, the other lines are self-generated) : ------------------------------- user@localhost:~$ ./lasthost.sh user@middlehost's password: user@middlehost:~$ ssh admin@lasthost admin@lasthost:~$ su - root password: root@lasthost:~# ---------------- And now, leave this shell alone (don't close it or you'll lose the connection) and in a new one you'll use the scp command: -------------------------------------------------------------- user@localhost:~$ scp -p 9999 my-big-file.iso root@127.0.0.1:~ root@127.0.0.1's password: toto 100% 19 0.0kb/s 00:00 user@localhost:~$ ----------------- Your file has been successfully sent through every computers you usually have to cross! And you can use every command you want through this port, e.g ftp, rsync, whatever. Open a tunnel for data with a specified port number while connecting to a host ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ We want to send a big file through several hosts. Copying it through the different hosts would be painful. Bélier offers an elegant solution to solve that case by opening on your source computer a network port sending data directly on the final machine you want to work on. By default this network port has the following number : 9999. lets take the following order file : ------------------------- middlehost azer0;lp!z -ot 8888 7777 admin@lasthost root jkw!po12; ----------------------------- Belier generates the script : --------------------- $ bel --entree=ordres $ ls ordres lasthost.sh -------------------- Let's be more verbose about this example : . That's a pretty common order file but you have at the end of the line the -ot (for tunnel options) option, which means you want a data tunnel to this machine. . On the line following the one finishing by -ot you have to give to arguments: the local port you want to use and the remote port which is going to be opened. . That's pretty much what you need. Executing this script you'll connect and open a shell on the final host, as usual. . But moreover, you have on your source host an open port allowing you to send data directly to the final host, using the scp command. execution of the script (only the script is executed here, the other lines are self-generated) : ------------------------------- user@localhost:~$ ./lasthost.sh user@middlehost's password: user@middlehost:~$ ssh admin@lasthost admin@lasthost:~$ su - root password: root@lasthost:~# ---------------- And now, leave this shell alone (don't close it or you'll lose the connection) and in a new one you'll use the scp command: -------------------------------------------------------------- user@localhost:~$ scp -p 8888 my-big-file.iso root@127.0.0.1:~ root@127.0.0.1's password: toto 100% 19 0.0kb/s 00:00 user@localhost:~$ ----------------- Your file has been successfully sent through every computer you usually have to cross! And you can use every command you want through the port you want to use, e.g ftp, rsync, whatever. Useful to know with passwords in Belier ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ If one of your passwords in the information file has a space in it, you need to wrap your password between quotation marks (character ") : ----------------------------- admin@serveur "My Passw0rd " ----------------------------- If one of your passwords in the information file has a quotation mark in it, you need to put a backslash before (character \) : ------------------------------- admin@serveur "My \"Pass word " ------------------------------- Code quality ------------ Since the version 0.4, Belier has been tested (functional tests and regression tests). The code is parsed with Pylint. I also use a fuzzer called Fusil written by Victor Stinner. If you find a bug, please contact me. Help / bugreports / feature requests ------------------------------------ - Users list - please suscribe to link:https://lists.sourceforge.net/mailman/listinfo/belier-users[the users mailing list]. - Developers list - please suscribe to link:https://lists.sourceforge.net/mailman/listinfo/belier-devel[the developers mailing list]. mailto:please-use-chaica@ohmytux.com['Carl Chenet aka Chaica'] belier-1.2/belier/0000755000175000017500000000000011273371413013264 5ustar chaicachaicabelier-1.2/belier/__init__.py0000644000175000017500000000135111273370402015372 0ustar chaicachaica# -*- coding: utf-8 -*- # Copyright © 2008 Carl Chenet # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # Fichier vide pour le paquet """Module belier""" belier-1.2/belier/corps.py0000644000175000017500000000171011273370402014760 0ustar chaicachaica# -*- coding: utf-8 -*- # Copyright © 2008 Carl Chenet # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . #Deroulement principal de belier """Déroulement principal de bélier""" from belier.terminal import Terminal from belier.options import Options class Corps: """Classe principale de bélier""" def __init__(self): opts = Options() Terminal(opts) belier-1.2/belier/terminal.py0000644000175000017500000003227111273370402015453 0ustar chaicachaica# -*- coding: utf-8 -*- # Copyright © 2008 Carl Chenet # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . #Ouvre un terminal sur une machine distante """Ouvre un terminal sur une machine distante""" import sys import stat from os import linesep, chmod, sep from os.path import expanduser, abspath, join from optionstunnel import OptionsTunnel SSHOPTS = '-o NoHostAuthenticationForLocalhost=yes -o StrictHostKeyChecking=no' class Terminal: """Ouvre un shell sur une machine distante""" def __init__(self, opts): self._ordres = [] self._est_premiereligne = True self._a_commande = False self._a_tunnel = False self._port = '' self._pdest = '' self._a_optstunnel = False self._dernierssh = 0 self._destination = '' self._machinefinale = '' self._extfichier = '.sh' self._jetons = {} self._indice = 0 delai = opts.lesoptions()[0].delai self._entetel1 = '#!/usr/bin/expect -f%s' % linesep self._entetel2 = 'set timeout %s%s%s' % (str(delai), linesep, linesep) self._script = [self._entetel1, self._entetel2] if opts.lesoptions()[0].repsortie is not None: self._destination = opts.lesoptions()[0].repsortie + sep else: self._destination = '' self.extrait_ordres(opts.lesoptions()[0].nomfichier) def extrait_ordres(self, nomfichier): """Extrait les ordres du fichier d'ordres""" # on récupère les ordres (fichiers ou entrée standard) try: if nomfichier is not None: self._ordres = open(expanduser(nomfichier), 'r').readlines() else: self._ordres = sys.stdin.readlines() except IOError, message: print message sys.exit(1) except KeyboardInterrupt: print _("Belier has been stopped manually by the user") sys.exit(1) # deux passes pour étudier les ordres for boucle in xrange(2): for num in xrange(len(self._ordres)): # 1ère passe : on écarte les erreurs banales if boucle == 0 and self._ordres[num] != linesep: if '\0' in self._ordres[num]: print _("The file format is invalid \ It may be a binary file ?") sys.exit(1) self._ordres[num] = self.remplace_guillemets_motdepasse( self._ordres[num]) if len(self._ordres[num].split(' ')) > 5: print _("Incorrect argument number \ on the order file line") sys.exit(1) identifiant = self._ordres[num].split(' ')[0] if len(identifiant) <= 2 and identifiant != linesep: print _("A hostname must contain at \ least two characters (rfc952)") sys.exit(1) ipoudns = identifiant.split('@')[-1] if len(ipoudns) > 255: print _('Your domain name size \ exceeds 255 characters') sys.exit(1) for hostname in ipoudns.split('.'): if len(hostname) > 64: print _("Your hostname size \ exceeds 64 characters") sys.exit(1) if self._ordres[num].split()[-1] == '-c'+ linesep or \ self._ordres[num].split()[-1] == '-c': break # 2ème passe : on génère les scripts if boucle == 1: self.interprete_ordres(num) self.fin_liste_ordres(num) def remplace_guillemets_motdepasse(self, ligne): """On remplace les mots de passe par un jeton""" est_temoin = True est_vraiefin = False motdepasse = '"' # on transforme les mots de passe entre guillemets en jeton # on évite ainsi les caractères d'espacement gênants while est_temoin: debut = ligne.find(' "') if debut != -1: intermediaire = ligne[debut+2:] while not est_vraiefin: if '"' in intermediaire: prochain = intermediaire.find('"') motdepasse = motdepasse + intermediaire[:prochain+1] if motdepasse[-2] == '\\': intermediaire = intermediaire[prochain+1:] else: est_vraiefin = True else: est_vraiefin = True chaine = motdepasse motdepasse = '"' est_vraiefin = False nomjeton = 'jeton%s' % str(self._indice) self._jetons[nomjeton] = chaine.strip('"') ligne = ligne.replace(chaine, nomjeton, 1) self._indice = self._indice + 1 else: est_temoin = False return ligne def fin_liste_ordres(self, num): """On traite la fin d'une liste d'ordres""" if (self._ordres[num] == linesep and self._script[-1] != self._entetel2) or ( num + 1 == len(self._ordres) and self._script[-1] != self._entetel2): # remplace les numéros de port du tunnel if self._a_tunnel: if self._pdest: if self._port: self._script[self._dernierssh] = self._script[ self._dernierssh].replace( '-L9999:127.0.0.1:9999','-L%s:127.0.0.1:%s' % ( self._pdest, self._port),1) else: self._script[self._dernierssh] = self._script[ self._dernierssh].replace( '-L9999:127.0.0.1:9999','-L%s:127.0.0.1:22' % ( self._pdest),1) else: if self._port: self._script[self._dernierssh] = self._script[ self._dernierssh].replace( '127.0.0.1:9999','127.0.0.1:%s'% self._port, 1) else: self._script[self._dernierssh] = self._script[ self._dernierssh].replace( '127.0.0.1:9999','127.0.0.1:22', 1) # dernière ligne du script en fonction mode commande if not self._a_commande: self._script.append('interact +++ return%s' % linesep) else: self._script.append('expect eof%s' % linesep) resultat = abspath(join(self._destination, ''.join([self._machinefinale, self._extfichier]))) # écriture du script try: open(resultat, 'w').writelines(self._script) chmod(resultat, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR ) except IOError, message: print message sys.exit(1) # compteur à zéro pour le prochain bloc d'ordres self._script = [self._entetel1, self._entetel2] self._est_premiereligne = True self._a_commande = False def interprete_ordres(self, num): """On interprete un ordre""" psource = '' pdestination = '' ligne = self._ordres[num] if ligne != linesep: if self._a_commande: # on traite le cas spécial du mode commande self.traite_commande(ligne) elif self._a_optstunnel: # on prepare les options du tunnel optstunnel = OptionsTunnel(ligne) psource, pdestination = \ optstunnel.retourne_options() nligne = '-L%s:127.0.0.1:%s' % (psource, pdestination) self._pdest = pdestination self._script[self._dernierssh] = self._script[ self._dernierssh].replace( '-L9999:127.0.0.1:9999', nligne) self._a_optstunnel = False else: if ligne.split()[-1] == '-t': self._a_tunnel = True if ligne.split()[-1] == '-ot': self._a_tunnel = True self._a_optstunnel = True machine = ligne.split()[0] self._machinefinale = ligne.split()[0].split('@')[-1] self._port = '' if ':' in self._machinefinale: self._machinefinale, self._port = \ self._machinefinale.split(':') machine = ligne.split()[0].split(':')[0] if self._a_tunnel: tunnelopts = '-L9999:127.0.0.1:9999' else: tunnelopts = '' if self._est_premiereligne: # première connexion if not self._port: self._script.append('spawn ssh %s %s %s%s' % ( SSHOPTS, tunnelopts, machine, linesep)) else: self._script.append('spawn ssh -p %s %s %s %s%s' % (self._port, SSHOPTS, tunnelopts, machine, linesep)) self._est_premiereligne = False else: if not self._port: self._script.append('send -- "ssh %s %s %s\\r"%s' % (SSHOPTS, tunnelopts, machine, linesep)) else: self._script.append( 'send -- "ssh -p %s %s %s %s\\r"%s' % (self._port, SSHOPTS, tunnelopts, machine, linesep)) if self._a_tunnel: self._dernierssh = len(self._script) - 1 if ligne.split()[-1] == '-c': self.avec_commande(ligne) self._a_commande = True elif ligne.split()[-1] == '-t' or ligne.split()[-1] == '-ot': self.avec_commande(ligne) else: self.sans_commande(ligne) def avec_commande(self, ligne): """La ligne du fichier d'ordre contient le symbole commande""" if len(ligne.split()) == 2: self.prepare_prompt() if len(ligne.split()) == 3: self.envoie_motdepasse_ssh(ligne.split()[1]) if len(ligne.split()) == 4 : self.prepare_prompt() self.change_utilisateur(ligne.split()[1], ligne.split()[2]) if len(ligne.split()) == 5 : self.envoie_motdepasse_ssh(ligne.split()[1]) self.change_utilisateur(ligne.split()[2], ligne.split()[3]) def sans_commande(self, ligne): """La ligne du fichier d'ordre ne contient pas le symbole commande""" if len(ligne.split()) == 1: self.prepare_prompt() if len(ligne.split()) == 2: self.envoie_motdepasse_ssh(ligne.split()[1]) if len(ligne.split()) == 3 : self.prepare_prompt() self.change_utilisateur(ligne.split()[1], ligne.split()[2]) if len(ligne.split()) == 4 : self.envoie_motdepasse_ssh(ligne.split()[1]) self.change_utilisateur(ligne.split()[2], ligne.split()[3]) def traite_commande(self, ligne): """Traite la commande contenue dans la ligne courante""" self._script.append('send -- "%s\\r"%s' % (ligne.rstrip(linesep), linesep)) self.prepare_prompt() def change_utilisateur(self, utilisateur, motdepasse): """Génère le script pour changer d'utilisateur""" if motdepasse in self._jetons: motdepasse = self._jetons[motdepasse] self._script.append('send -- "su - %s\\r"%s' % (utilisateur, linesep)) self._script.append('expect ":"%s' % linesep) self._script.append('send -- "%s\\r"%s' % (motdepasse, linesep)) self.prepare_prompt() def prepare_prompt(self): """Prépare le prompt en fonction de l'identité de l'utilisateur""" self._script.append('expect -re "(%s|#|\\\\$) $"%s' % ('%', linesep)) def envoie_motdepasse_ssh(self, motdepasse): """Envoie le mot de passe lors d'une connexion ssh""" if motdepasse in self._jetons: motdepasse = self._jetons[motdepasse] self._script.append('expect -re {@[^\\n]*:}%s' % linesep) self._script.append('send -- "%s\\r"%s' % (motdepasse, linesep)) self.prepare_prompt() belier-1.2/belier/optionstunnel.py0000644000175000017500000000353311273370402016560 0ustar chaicachaica# -*- coding: utf-8 -*- # Copyright © 2008 Carl Chenet # Ce programme est un logiciel libre ; vous pouvez le redistribuer et/ou le # modifier au titre des clauses de la Licence Publique Générale GNU, telle que # publiée par la Free Software Foundation ; soit la version 2 de la Licence, # ou (à votre discrétion) une version ultérieure quelconque. # # Ce programme est distribué dans l'espoir qu'il sera utile, mais SANS AUCUNE # GARANTIE ; sans même une garantie implicite de COMMERCIABILITE ou DE # CONFORMITE A UNE UTILISATION PARTICULIERE. # # Voir la Licence Publique Générale GNU pour plus de détails. Vous devriez # avoir reçu un exemplaire de la Licence Publique Générale GNU avec ce # programme ; si ce n'est pas le cas, écrivez à la Free Software Foundation # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #Extraction des options du tunnel """Extraction des options du tunnel""" import sys class OptionsTunnel: """Extraction des options du tunnel""" def __init__(self, ligne): self._source = '' self._destination = '' self.parse_ligne(ligne) def parse_ligne(self, ligne): """Parse la ligne qui indique les numéros de ports""" if len(ligne.split()) != 2: print _('You should have two tunnel options arguments \ (source port and destination port)') sys.exit(1) for port in ligne.split(): if not port.isdigit(): print _('A port number should only contain digits') sys.exit(1) if int(port) > 65535: print _('A port number can not exceed 65535') sys.exit(1) self._source, self._destination = ligne.split() def retourne_options(self): """Retourne les options du tunnel""" return (self._source, self._destination) belier-1.2/belier/options.py0000644000175000017500000000646311273370402015337 0ustar chaicachaica# -*- coding: utf-8 -*- # Copyright © 2008 Carl Chenet # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . #Extraction des options de la ligne de commande """Options de la ligne de commande""" from os import linesep from os.path import exists, abspath, isdir, isfile, expanduser from optparse import OptionParser import sys class Options: """Extrait les options de la ligne de commande""" def __init__(self): self._options = () parser = OptionParser(version="%prog 1.2") self.definit_options(parser) self.teste_options() def definit_options(self, parser): """Définition des options""" parser.add_option("-e", "--entree", dest="nomfichier", action="store", type="string", help=_("contains the orders to generate the script"), metavar=_("FILE")) parser.add_option("-s", "--repertoire-sortie", dest="repsortie", action="store", type="string", help=_("the directory to store generated scripts"), metavar=_("DIRECTORY")) parser.add_option("-d", "--delai", dest="delai", action="store", type="int", default=10, help=_("in seconds the time between each order execution"), metavar=_("DELAY")) self._options = parser.parse_args() def teste_options(self): """Teste les options""" if self._options[0].nomfichier is not None: fichierentree = abspath(expanduser(self._options[0].nomfichier)) if not exists(fichierentree): print _("%s : no such file") % fichierentree sys.exit(1) elif not isfile(fichierentree): print _("%s is not a file") % fichierentree sys.exit(1) else: self._options[0].nomfichier = fichierentree if self._options[0].repsortie is not None: repertoiresortie = abspath(expanduser(self._options[0].repsortie)) if not exists(repertoiresortie): print _("%s : no such directory") % repertoiresortie sys.exit(1) elif not isdir(repertoiresortie): print _("%s is not a directory") % repertoiresortie sys.exit(1) else: self._options[0].repsortie = repertoiresortie if self._options[0].delai is not None: if self._options[0].delai < -1 or \ self._options[0].delai > sys.maxint: print _("The given value is not valid%sThe delay value \ must be >= -1 and <= value of an integer on your system" % linesep) sys.exit(1) def lesoptions(self): """Retourne les options de la ligne de commande""" return self._options belier-1.2/bel0000755000175000017500000000154211273370402012511 0ustar chaicachaica#!/usr/bin/env python # -*- coding: utf-8 -*- # Copyright © 2008 Carl Chenet # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . """Corps de bélier""" from belier.corps import Corps import gettext if __name__ == '__main__': gettext.install('bel', unicode=1) Corps() belier-1.2/PKG-INFO0000644000175000017500000000146511273371413013125 0ustar chaicachaicaMetadata-Version: 1.0 Name: belier Version: 1.2 Summary: Ssh connection generation tool Home-page: http://www.ohmytux.com/belier Author: Carl Chenet Author-email: chaica@ohmytux.com License: GNU GPL v3 Download-URL: http://www.ohmytux.com/belier Description: Belier allows automated openings of a shell or command executions on remote computers through ssh. The main feature is Belier's ability to cross several computers before joining the final machine. Platform: UNKNOWN Classifier: Intended Audience :: System Administrators Classifier: Development Status :: 5 - Production/Stable Classifier: Environment :: Console Classifier: License :: OSI Approved :: GNU General Public License (GPL) Classifier: Operating System :: OS Independent Classifier: Natural Language :: French Classifier: Programming Language :: Python