Advertisement
Guest User

Untitled

a guest
Jan 2nd, 2017
161
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. to = 'mail@mail.com'
  8. gmail_user = 'mail@gmail.com'
  9. gmail_password = 'pass'
  10.  
  11. arg='ip route list'
  12. p=subprocess.Popen(arg,shell=True,stdout=subprocess.PIPE)
  13. data = p.communicate()
  14.  
  15. # Split IP text block into three, and divide the two containing IPs into words.
  16. ip_lines = data[0].splitlines()
  17. split_line_a = ip_lines[1].split()
  18.  
  19. # con_type variables for the message text. ex) 'ethernet', 'wifi', etc.
  20. ipaddr_a = split_line_a[split_line_a.index('src')+1]
  21. my_ip_a = 'Your ip is %s' % (ipaddr_a)
  22.  
  23. today = datetime.date.today()
  24. # Creates the text, subject, 'from', and 'to' of the message.
  25. msg = MIMEText(my_ip_a + "\n")
  26. msg['Subject'] = 'IP For Kali on %s' % today.strftime('%b %d %Y')
  27. msg['From'] = gmail_user
  28. msg['To'] = to
  29.  
  30. # Sends the message
  31. smtpserver = smtplib.SMTP('smtp.gmail.com', 587)
  32. smtpserver.ehlo()
  33. smtpserver.starttls()
  34. smtpserver.ehlo()
  35. smtpserver.login(gmail_user, gmail_password)
  36. smtpserver.sendmail(gmail_user, [to], msg.as_string())
  37. # Closes the smtp server.
  38. smtpserver.quit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement