Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- chpasswd -R /path/to/build/tree <passwords.txt
- root:swordfish
- alibaba:opensesame
- #!/usr/bin/python
- import base64, crypt, os, re, sys
- for line in sys.stdin.readlines():
- (username, password) = line.strip().split(":")
- salt = "$6$" + base64.b64encode(os.urandom(6))
- hashes[username] = crypt.crypt(password, salt)
- old_shadow = open("etc/shadow")
- new_shadow = open("etc/shadow.making", "w")
- for line in old_shadow.readlines():
- (username, password, trail) = line.lstrip().split(":", 3)
- if hashes.has_key(username):
- line = username + ":" + hashes[username] + ":" + trail
- new_shadow.write(line)
- old_shadow.close()
- new_shadow.close()
- os.rename("etc/shadow.making", "etc/shadow")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement