pyth0n3 Posted January 10, 2012 Report Share Posted January 10, 2012 (edited) Features Added :-Progress bar while downloanding-Support for the latest US Firefox version Tested on: Debian, Fedora Should work also under other distroNote:If you create an entry in crontab it will upgrade firefox automatically #!/usr/bin/python#Date:Jan 10 2012 Updated#Purpose: Download and install latest US firefox version in Linux #Author: pyth0n3 #Blog: http://pyth0n3.blogspot.com/import osimport ftplibimport globimport tarfileimport shutilimport time import sysimport threadingprint "[+]This script will download && install the latest firefox US version for Linux" var = raw_input ("Do you want to continue?Type |yes/no| : ")if var.lower() == "no": sys.exit()elif var.lower() == 'yes' : ###making a temp directory in local print "[+]Creating a temporary directory for work.. " time.sleep(2) if not os.path.exists("/tmp/firefox"): os.mkdir("/tmp/firefox") os.chdir("/tmp/firefox/") print "[+]Connecting..." ftp = ftplib.FTP("releases.mozilla.org") ftp.login("anonymous", "anonymous") directory = '/pub/mozilla.org/firefox/releases/latest/linux-i686/en-US/' match = '*.bz2' ftp.cwd(directory) print "[+]Searching the latest version..." for f1 in ftp.nlst(match): var = open(f1, 'wb') class loading_bar(threading.Thread): def run(self): global stop, kill sys.stdout.write("[+]Downloading"+ " "+ f1 +" "+"Please wait...") sys.stdout.flush() type = 0 while stop != True: if type == 0: sys.stdout.write("\b/") if type == 1: sys.stdout.write("\b-") if type == 2: sys.stdout.write("\b\\") if type == 3: sys.stdout.write("\b|") type += 1 if type == 4: type = 0 sys.stdout.flush() time.sleep(0.2) if kill == True: print "\b\b\b\b [+]Aborting!" else: print "\b\b[+]Download done!" stop = kill = False loading_bar_control = loading_bar() loading_bar_control.start() try: ftp.retrbinary('RETR ' + f1, var.write) var.close() except KeyboardInterrupt or EOFError: kill = True; stop = True stop = True print "[+]Extracting files... " def extract_file(path, dst='/usr/lib/'): if path.endswith('.tar.bz2'): opener, mode = tarfile.open, 'r:bz2' cwd = os.getcwd() os.chdir(dst) try: file = opener(path, mode) try: file.extractall() finally: file.close() finally: os.chdir(cwd) var1 = glob.glob('/tmp/firefox/*.bz2') var2 = ','.join(var1) extract_file (var2) print "[+]Setting up the browser..." time.sleep(3) if os.path.islink("/usr/bin/firefox"): os.remove("/usr/bin/firefox") os.symlink("/usr/lib/firefox/firefox", "/usr/bin/firefox") print "[+]Removing temporary files..." shutil.rmtree("/tmp/firefox") print '[+]Done'sys.exit()#END#Downloadwget http://sprunge.us/YaVg -O getfox.pyWork's on 32 bit system only, for 64 bit must change the url This part of codedirectory = '/pub/mozilla.org/firefox/releases/latest/linux-i686/en-US/'Todirectory = '/pub/mozilla.org/firefox/releases/latest/linux-x86_64/en-US/'Old Version , supports only 3.6.x version Edited January 10, 2012 by pyth0n3 1 Quote Link to comment Share on other sites More sharing options...
cmiN Posted January 30, 2012 Report Share Posted January 30, 2012 Dragut scriptul, dar n-am apucat sa vad loading barul deoarece ingheata imediat dupa [+]Searching the latest version cred ca intr-un retrieve_lines din ftp.nlst. Pe backtrack kde @ vbox. Quote Link to comment Share on other sites More sharing options...
malsploit Posted January 30, 2012 Report Share Posted January 30, 2012 Eu am crezut, pana acum ca pyth0n3 == cmin.Pot sa spun, fara nici o umbra de indoiala, ca toti de aici care au invatat python sau au de gand sa invete, au fost indrumati de unul din voi.Cand am venit pe forum, am vorbit pe messenger cu unul din voi care mi-a vorbit atat de frumos despre python, incat ma hotarasem ca daca nu ajung sa gandesc in python, trebuie sa ma las de toate.Au venit problemele(responsabilitati noi,facultate) si tot nu am trecut de bariera sintaxei.Dar nu ma las! Quote Link to comment Share on other sites More sharing options...
cmiN Posted January 30, 2012 Report Share Posted January 30, 2012 (edited) Suntem 2 persoane diferite cu arii de exploatare diferite, totusi e de ajuns sa cauti prin search dupa Python si gasesti multe posturi pe care le citesti de placere indiferent daca ai sau nu vreo tangenta cu programarea. E cam singurul limbaj in care iti permiti sa prosperi cu ceva in lumea virtuala, sa te faci cumva remarcat si sa poti atinge aproape instantaneu placerea aia a programarii pe care altii nu o vad nici cand se angajeaza.Imi aduc aminte si acum ... ca aveam cont pe Mortal-Team (care devenise insecurity) si faceam scripturi/automatizari simple in batch @ win si mi-a zis cineva, nu mai stiu daca tw8, nosferatu sau HrN sau cine era, oricum postase unul din ei in threadul ala in care vorbeam eu de un loop of death sau si de alte lucruri in batch (nu e postul asta de pe rst, e altul mai vechi care era si pe insecurity dar disparuse la un moment dat) si mi-a zis sa ma apuc de un limbaj de programare, am ceva potential numai ca in batch sunt "ca un leu in cusca", citatul il tin minte si acum, inca nu am gasit postul in cache in ceva, oricum ii multumesc aceluia, si tot am cautat pana am dat de Python. Conteaza foarte mult prima "iubire" iti decide istoria. Edited January 30, 2012 by cmiN Quote Link to comment Share on other sites More sharing options...
malsploit Posted January 30, 2012 Report Share Posted January 30, 2012 Suntem 2 persoane diferite cu arii de exploatare diferite, totusi e de ajuns sa cauti prin search dupa Python si gasesti multe posturi pe care le citesti de placere indiferent daca ai sau nu vreo tangenta cu programarea. E cam singurul limbaj in care iti permiti sa prosperi cu ceva in lumea virtuala, sa te faci cumva remarcat si sa poti atinge aproape instantaneu placerea aia a programarii pe care altii nu o vad nici cand se angajeaza.Imi aduc aminte si acum ... ca aveam cont pe Mortal-Team (care devenise insecurity) si faceam scripturi/automatizari simple in batch @ win si mi-a zis cineva, nu mai stiu daca tw8, nosferatu sau HrN sau cine era, oricum postase unul din ei in threadul ala in care vorbeam eu de un loop of death sau si de alte lucruri in batch (nu e postul asta de pe rst, e altul mai vechi care era si pe insecurity dar disparuse la un moment dat) si mi-a zis sa ma apuc de un limbaj de programare, am ceva potential numai ca in batch sunt "ca un leu in cusca", citatul il tin minte si acum, inca nu am gasit postul in cache in ceva, oricum ii multumesc aceluia, si tot am cautat pana am dat de Python. Conteaza foarte mult prima "iubire" iti decide istoria.V-am spus eu!Cum sa nu te apuci de python cand auzi asa ceva! Quote Link to comment Share on other sites More sharing options...
pyth0n3 Posted February 1, 2012 Author Report Share Posted February 1, 2012 Dragut scriptul, dar n-am apucat sa vad loading barul deoarece ingheata imediat dupa cred ca intr-un retrieve_lines din ftp.nlst. Pe backtrack kde @ vbox.Am observat ca da probleme cateodata la conexiune ftp Quote Link to comment Share on other sites More sharing options...