Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import subprocess
- import smtplib
- from email.mime.text import MIMEText
- import datetime
- # Account Information
- to = 'mail@mail.com'
- gmail_user = 'mail@gmail.com'
- gmail_password = 'pass'
- arg='ip route list'
- p=subprocess.Popen(arg,shell=True,stdout=subprocess.PIPE)
- data = p.communicate()
- # Split IP text block into three, and divide the two containing IPs into words.
- ip_lines = data[0].splitlines()
- split_line_a = ip_lines[1].split()
- # con_type variables for the message text. ex) 'ethernet', 'wifi', etc.
- ipaddr_a = split_line_a[split_line_a.index('src')+1]
- my_ip_a = 'Your ip is %s' % (ipaddr_a)
- today = datetime.date.today()
- # Creates the text, subject, 'from', and 'to' of the message.
- msg = MIMEText(my_ip_a + "\n")
- msg['Subject'] = 'IP For Kali on %s' % today.strftime('%b %d %Y')
- msg['From'] = gmail_user
- msg['To'] = to
- # Sends the message
- smtpserver = smtplib.SMTP('smtp.gmail.com', 587)
- smtpserver.ehlo()
- smtpserver.starttls()
- smtpserver.ehlo()
- smtpserver.login(gmail_user, gmail_password)
- smtpserver.sendmail(gmail_user, [to], msg.as_string())
- # Closes the smtp server.
- smtpserver.quit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement