-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuserpass.py
More file actions
46 lines (37 loc) · 1.13 KB
/
userpass.py
File metadata and controls
46 lines (37 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/root/python/Python-3.3.0/python
import string
import os
import random
import string
import smtplib
#user1=input('Enter the name of the user ')
user1='darklord'
pass1= ''.join(random.choice(string.ascii_lowercase + string.digits) for x in range(10))
cmd='echo -e "' + pass1 + '\n' + pass1 + '" | passwd ' + user1
if os.system(cmd)!= 0:
print('Invalid User')
else:
print('New password for user ' + user1 + ' is ' + pass1 )
#SMTP_SERVER = 'smtp.gmail.com'
#SMTP_PORT = 587
server = 'smtp.gmail.com'
port = 587
sender = '[email protected]'
recipient = '[email protected]'
subject = 'Change of Password'
body = 'New Password for user ' + user1 + ' is ' + pass1
"Sends an e-mail to the specified recipient."
body = "" + body + ""
headers = ["From: " + sender,
"Subject: " + subject,
"To: " + recipient,
"MIME-Version: 1.0",
"Content-Type: text/html"]
headers = "\r\n".join(headers)
session = smtplib.SMTP(server, port)
session.ehlo()
session.starttls()
session.ehlo
session.login(sender, 'yourpassword')
session.sendmail(sender, recipient, headers + "\r\n\r\n" + body)
session.quit()