Guest User

Untitled

a guest
Jan 2nd, 2017
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. import subprocess
  2. import smtplib
  3. from email.mime.text import MIMEText
  4. import datetime
  5.  
  6. # Account Information
  7. gmail_user = '[email protected]'
  8. gmail_password = 'pass'
  9.  
  10. arg='ip route list'
  11. p=subprocess.Popen(arg,shell=True,stdout=subprocess.PIPE)
  12. data = p.communicate()
  13.  
  14. # Split IP text block into three, and divide the two containing IPs into words.
  15. ip_lines = data[0].splitlines()
  16. split_line_a = ip_lines[1].split()
  17.  
  18. # con_type variables for the message text. ex) 'ethernet', 'wifi', etc.
  19. ipaddr_a = split_line_a[split_line_a.index('src')+1]
  20. my_ip_a = 'Your ip is %s' % (ipaddr_a)
  21.  
  22. today = datetime.date.today()
  23. # Creates the text, subject, 'from', and 'to' of the message.
  24. msg = MIMEText(my_ip_a + "\n")
  25. msg['Subject'] = 'IP For Kali on %s' % today.strftime('%b %d %Y')
  26. msg['From'] = gmail_user
  27. msg['To'] = to
  28.  
  29. # Sends the message
  30. smtpserver = smtplib.SMTP('smtp.gmail.com', 587)
  31. smtpserver.ehlo()
  32. smtpserver.starttls()
  33. smtpserver.ehlo()
  34. smtpserver.login(gmail_user, gmail_password)
  35. smtpserver.sendmail(gmail_user, [to], msg.as_string())
  36. # Closes the smtp server.
  37. smtpserver.quit()
Advertisement
Add Comment
Please, Sign In to add comment