Guest User

Untitled

a guest
Apr 23rd, 2018
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.50 KB | None | 0 0
  1. import random
  2. import sqlite3
  3. import smtplib
  4.  
  5. conn = sqlite3.connect('example.db')
  6.  
  7. c = conn.cursor()
  8.  
  9. # Create table
  10. c.execute('''CREATE TABLE users
  11. (id int primary key, email text, password text)''')
  12.  
  13. # Insert a row of data
  14. c.execute("INSERT INTO users VALUES ('1','premraval010@gmail.com','testtest')")
  15.  
  16. # Save (commit) the changes
  17. conn.commit()
  18.  
  19. # We can also close the connection if we are done with it.
  20. # Just be sure any changes have been committed or they will be lost.
  21. conn.close()
  22.  
  23. conn = sqlite3.connect('example.db')
  24.  
  25. c = conn.cursor()
  26. email = raw_input("Enter Your Email To Reset Your Password : ")
  27. newpass = password()
  28. x = c.execute("UPDATE users SET password= ? where email =?", [(newpass,), (email,)])
  29. if(x==1):
  30. print("Password Has Been Reset Successfully")
  31. from email.MIMEMultipart import MIMEMultipart
  32. from email.MIMEText import MIMEText
  33. msg = MIMEMultipart()
  34. msg['From'] = 'antid0te1337team@gmail.com'
  35. msg['To'] = email
  36. msg['Subject'] = 'Your Password Has Been Reset'
  37. message = 'Your New Password Is :%s' % (newpass)
  38. msg.attach(MIMEText(message))
  39. mailserver = smtplib.SMTP('smtp.gmail.com',587)
  40. # identify ourselves to smtp gmail client
  41. mailserver.ehlo()
  42. # secure our email with tls encryption
  43. mailserver.starttls()
  44. # re-identify ourselves as an encrypted connection
  45. mailserver.ehlo()
  46. mailserver.login('antid0te1337team@gmail.com', '')
  47. mailserver.sendmail('antid0te1337team@gmail.com','premraval010@gmail.com',msg.as_string())
  48. mailserver.quit()
  49. else:
  50. print("Your Email Doesnt Exist In The Databse")
  51.  
  52. # Save (commit) the changes
  53. conn.commit()
  54.  
  55. # We can also close the connection if we are done with it.
  56. # Just be sure any changes have been committed or they will be lost.
  57. conn.close()
  58. def password():
  59. alphabet = "abcdefghijklmnopqrstuvwxyz"
  60. pw_length = 8
  61. mypw = ""
  62.  
  63. for i in range(pw_length):
  64. next_index = random.randrange(len(alphabet))
  65. mypw = mypw + alphabet[next_index]
  66.  
  67. # replace 1 or 2 characters with a number
  68. for i in range(random.randrange(1,3)):
  69. replace_index = random.randrange(len(mypw)//2)
  70. mypw = mypw[0:replace_index] + str(random.randrange(10)) + mypw[replace_index+1:]
  71.  
  72. # replace 1 or 2 letters with an uppercase letter
  73. for i in range(random.randrange(1,3)):
  74. replace_index = random.randrange(len(mypw)//2,len(mypw))
  75. mypw = mypw[0:replace_index] + mypw[replace_index].upper() + mypw[replace_index+1:]
  76. return mypw
Add Comment
Please, Sign In to add comment