Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- import sqlite3
- import smtplib
- conn = sqlite3.connect('example.db')
- c = conn.cursor()
- # Create table
- c.execute('''CREATE TABLE users
- (id int primary key, email text, password text)''')
- # Insert a row of data
- c.execute("INSERT INTO users VALUES ('1','premraval010@gmail.com','testtest')")
- # Save (commit) the changes
- conn.commit()
- # We can also close the connection if we are done with it.
- # Just be sure any changes have been committed or they will be lost.
- conn.close()
- conn = sqlite3.connect('example.db')
- c = conn.cursor()
- email = raw_input("Enter Your Email To Reset Your Password : ")
- newpass = password()
- x = c.execute("UPDATE users SET password= ? where email =?", [(newpass,), (email,)])
- if(x==1):
- print("Password Has Been Reset Successfully")
- from email.MIMEMultipart import MIMEMultipart
- from email.MIMEText import MIMEText
- msg = MIMEMultipart()
- msg['From'] = 'antid0te1337team@gmail.com'
- msg['To'] = email
- msg['Subject'] = 'Your Password Has Been Reset'
- message = 'Your New Password Is :%s' % (newpass)
- msg.attach(MIMEText(message))
- mailserver = smtplib.SMTP('smtp.gmail.com',587)
- # identify ourselves to smtp gmail client
- mailserver.ehlo()
- # secure our email with tls encryption
- mailserver.starttls()
- # re-identify ourselves as an encrypted connection
- mailserver.ehlo()
- mailserver.login('antid0te1337team@gmail.com', '')
- mailserver.sendmail('antid0te1337team@gmail.com','premraval010@gmail.com',msg.as_string())
- mailserver.quit()
- else:
- print("Your Email Doesnt Exist In The Databse")
- # Save (commit) the changes
- conn.commit()
- # We can also close the connection if we are done with it.
- # Just be sure any changes have been committed or they will be lost.
- conn.close()
- def password():
- alphabet = "abcdefghijklmnopqrstuvwxyz"
- pw_length = 8
- mypw = ""
- for i in range(pw_length):
- next_index = random.randrange(len(alphabet))
- mypw = mypw + alphabet[next_index]
- # replace 1 or 2 characters with a number
- for i in range(random.randrange(1,3)):
- replace_index = random.randrange(len(mypw)//2)
- mypw = mypw[0:replace_index] + str(random.randrange(10)) + mypw[replace_index+1:]
- # replace 1 or 2 letters with an uppercase letter
- for i in range(random.randrange(1,3)):
- replace_index = random.randrange(len(mypw)//2,len(mypw))
- mypw = mypw[0:replace_index] + mypw[replace_index].upper() + mypw[replace_index+1:]
- return mypw
Add Comment
Please, Sign In to add comment