Guest User

Untitled

a guest
Mar 7th, 2018
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.15 KB | None | 0 0
  1. python3 -c "import crypt;print(crypt.crypt(input('clear-text pw: '), crypt.mksalt(crypt.METHOD_SHA512)))"
  2.  
  3. python -c 'import crypt; print crypt.crypt("test", "$6$random_salt")'
  4.  
  5. python3 -c 'import crypt; print(crypt.crypt("test", crypt.mksalt(crypt.METHOD_SHA512)))'
  6.  
  7. mkpasswd -m sha-512
  8. mkpasswd -m md5
  9.  
  10. mkpasswd -m help
  11.  
  12. Usage: grub-crypt [OPTION]...
  13. Encrypt a password.
  14.  
  15. -h, --helpPrint this message and exit
  16. -v, --version Print the version information and exit
  17. --md5 Use MD5 to encrypt the password
  18. --sha-256 Use SHA-256 to encrypt the password
  19. **--sha-512 Use SHA-512 to encrypt the password (default)**
  20.  
  21. #define _XOPEN_SOURCE
  22. #include <stdio.h>
  23. #include <stdlib.h>
  24. #include <string.h>
  25. #include <unistd.h>
  26.  
  27. int main(int argc, char *argv[]) {
  28. if ( argc < 3 || (int) strlen(argv[2]) > 16 ) {
  29. printf("usage: %s password saltn", argv[0]);
  30. printf("--salt must not larger than 16 charactersn");
  31. return;
  32. }
  33.  
  34. char salt[21];
  35. sprintf(salt, "$6$%s$", argv[2]);
  36.  
  37. printf("%sn", crypt((char*) argv[1], (char*) salt));
  38. return;
  39. }
  40.  
  41. /usr/bin/gcc -lcrypt -o passwd-sha512 passwd-sha512.c
  42.  
  43. passwd-sha512 <password> <salt (16 chars max)>
  44.  
  45. #Set stronger password hasing
  46. /usr/sbin/authconfig --test | grep sha512 > /dev/null
  47. if [ $? -ne 0 ]; then
  48. echo "Configuring sha512 password hashing"
  49. sudo /usr/sbin/authconfig --enableshadow --passalgo=sha512 --updateall
  50. fi
  51.  
  52. 'password'.crypt('$6$' + rand(36 ** 8).to_s(36))
  53.  
  54. #!/usr/bin/env python
  55.  
  56. import getpass
  57.  
  58. from passlib.hash import sha512_crypt
  59.  
  60. if __name__ == "__main__":
  61. passwd = getpass.getpass('Password to hash: ')
  62. hash = sha512_crypt.encrypt(passwd)
  63.  
  64. print hash
  65.  
  66. import crypt, getpass, pwd, string, sys, random
  67. randomsalt = ""
  68. password = getpass.getpass()
  69. choices = string.ascii_uppercase + string.digits + string.ascii_lowercase
  70. for _ in range(0,8):
  71. randomsalt += random.choice(choices)
  72. print crypt.crypt(password, '$6$%s$' % randomsalt)
  73.  
  74. $ htpasswd -c /tmp/my_hash user1
  75. New password:
  76. Re-type new password:
  77. Adding password for user user1
  78. $ cat /tmp/my_hash
  79. user1:$apr1$oj1ypcQz$4.6lFVtKz2nr8acsQ8hD30
  80.  
  81. #!/bin/bash
  82. read -p "Enter username: " username
  83. read -s -p "Enter password: " mypassword
  84. echo
  85. echo -n $username:$mypassword | chpasswd -S -c SHA512
  86.  
  87. If salt is a character string starting with the characters
  88. "$id$" followed by a string terminated by "$":
  89.  
  90. $id$salt$encrypted
  91.  
  92. then instead of using the DES machine, id identifies the encryp‐
  93. tion method used and this then determines how the rest of the
  94. password string is interpreted. The following values of id are
  95. supported:
  96.  
  97. ID | Method
  98. ─────────────────────────────────────────────────────────
  99. 1 | MD5
  100. 2a | Blowfish (not in mainline glibc; added in some
  101. | Linux distributions)
  102. 5 | SHA-256 (since glibc 2.7)
  103. 6 | SHA-512 (since glibc 2.7)
  104.  
  105. So $5$salt$encrypted is an SHA-256 encoded password and
  106. $6$salt$encrypted is an SHA-512 encoded one.
Add Comment
Please, Sign In to add comment