c - Brute forcing crypt() if salt and password hash are known? -


playing through wargames , curious if possible (they want solve in different way, still).

there's .c file function has code looks this:

char buffer[20]; scanf("%s", buffer); char* hash = crypt(buffer, "$6$") char* password = "$6$123456abcdef" #long string  if (strcmp(password, hash) == 0) supersecretfunction(); 

is there way brute force considering salt , hashed password known already?

unlike original des-based crypt() algorithm used in older unix variants, brute forced relatively modest modern resources, newer unices including gnu/linux flavours use extended encrypted password specification. can recognize if encrypted password (or salt) start "$id$" "id" algorithm identifier, see table below.

"$6$" indicates sha-512 used encryption (well, hashing actually). after second '$' comes salt, '$' , sha-512 of password.

the sha-512 algorithm used decribed in detail here: ftp://ftp.arlut.utexas.edu/pub/java_hashes/sha-crypt.txt

this algorithm involves, default, 5000 rounds of sha-512 encrypting single password. doing brute force attack computationally infeasible moderate length/complexity passwords. dictionary based attack feasible still time consuming shorter, less complex passwords.

for format of password field, see above linked article or summary see http://man7.org/linux/man-pages/man3/crypt.3.html, quoted in part below:

   if salt character string starting characters "$id$"    followed string terminated "$":            $id$salt$encrypted     instead of using des machine, id identifies encryption    method used , determines how rest of password    string interpreted.  following values of id supported:            id  | method           ─────────────────────────────────────────────────────────           1   | md5           2a  | blowfish (not in mainline glibc; added in               | linux distributions)           5   | sha-256 (since glibc 2.7)           6   | sha-512 (since glibc 2.7)     $5$salt$encrypted sha-256 encoded password ,    $6$salt$encrypted sha-512 encoded one.     "salt" stands 16 characters following "$id$" in    salt.  encrypted part of password string actual    computed password.  size of string fixed:     md5     | 22 characters    sha-256 | 43 characters    sha-512 | 86 characters     characters in "salt" , "encrypted" drawn set    [a-za-z0-9./].  in md5 , sha implementations entire key    significant (instead of first 8 bytes in des). 

edit: article may of interest: https://www.win.tue.nl/~aeb/linux/hh/hh-4.html


Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -