Advertisement
Guest User

Untitled

a guest
Mar 27th, 2015
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. chpasswd -R /path/to/build/tree <passwords.txt
  2.  
  3. root:swordfish
  4. alibaba:opensesame
  5.  
  6. #!/usr/bin/python
  7. import base64, crypt, os, re, sys
  8. for line in sys.stdin.readlines():
  9. (username, password) = line.strip().split(":")
  10. salt = "$6$" + base64.b64encode(os.urandom(6))
  11. hashes[username] = crypt.crypt(password, salt)
  12. old_shadow = open("etc/shadow")
  13. new_shadow = open("etc/shadow.making", "w")
  14. for line in old_shadow.readlines():
  15. (username, password, trail) = line.lstrip().split(":", 3)
  16. if hashes.has_key(username):
  17. line = username + ":" + hashes[username] + ":" + trail
  18. new_shadow.write(line)
  19. old_shadow.close()
  20. new_shadow.close()
  21. os.rename("etc/shadow.making", "etc/shadow")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement