LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 09-13-2013, 05:12 PM   #1
abefroman
Senior Member
 
Registered: Feb 2004
Location: lost+found
Distribution: CentOS
Posts: 1,429

Rep: Reputation: 55
How can I convert a sha-512 /etc/shadow hash to base64?


How can I convert a sha-512 /etc/shadow hash to base64?

Example here is the base64 of the unsalted hash of 1234:
{SHA512}1ARVn2Auq2/WAqx2gNrL+q3RNjAzXpUfCXrzkA6d4Xa22yhRLy4AC50E+6UTPoscbo31nbOoq51gvkuXzJ6B2w==

In /etc/shadow the hash of 1234 with a random salt of ZjXUzK2H is:
$6$ZjXUzK2H$08jUtpo6jck5fswOU3b0SoZhB8m4dfFU8hJ1WGoR8fUtmfXOZ/3DRX/W1AQii4C.kgGn6R9CPdrlwE0TIfMRN.

Here is a base64 of a salted sha512 hash of 1234, with a random salt:
{SSHA512}9ThBtv7S4b7CGM6i0Q5suNqL2OscjutP5xeyGX7Kh6QEwqzc3V6ieO+OGZFS9xIDWOlsUOYeytjCFBRliG0BLEdLXEM =

How can I get the /etc/shadow hash compatible with the base64 format?

TIA!
 
Old 09-15-2013, 10:47 AM   #2
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,441

Rep: Reputation: 1702Reputation: 1702Reputation: 1702Reputation: 1702Reputation: 1702Reputation: 1702Reputation: 1702Reputation: 1702Reputation: 1702Reputation: 1702Reputation: 1702
According to wikipedia:
Quote:
A base 64 encoding is used to store password hashes computed with crypt in the /etc/passwd. Its alphabet starts with '.' for zero, then '/' for one, followed by 0-9, A-Z and a-z. Padding is not used.
To translate to standard base64 you can use tr:
Code:
% echo '08jUtpo6jck5fswOU3b0SoZhB8m4dfFU8hJ1WGoR8fUtmfXOZ/3DRX/W1AQii4C.kgGn6R9CPdrlwE0TIfMRN.' | tr ./0-9A-Za-z A-Za-z0-9+/
CKvg510IvowHr48agFnCe0ltNKyGprRgKtVDiS0dKrg5yrjalBFPdjBiDMcuuGOAwsSzIdLObp3x8QCfUrYdZA
Then you have to add padding, which will always be "==" for sha512 (3 - (512/8) mod 3 => 2).
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] How to use an encrypted sha-512 bootloader password in Kickstart script ? Rogue45 Linux - Server 1 05-02-2013 12:52 PM
Can I use base64 as a hash function? fantasy1215 Programming 8 01-13-2013 01:04 AM
NIST's search for the super hash just five candidates left in SHA-3 final win32sux Linux - Security 0 12-10-2010 02:58 PM
How to convert an MD5 hash into shadow format SentralOrigin Linux - Software 1 11-28-2010 09:11 PM
Shadow passwords - Changing encryption method from MD5 to SHA Phaethar Linux - Security 1 11-04-2009 04:38 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 06:13 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration