[Samba] user password hash

Rowland penny rpenny at samba.org
Thu Oct 10 12:42:06 UTC 2019

On 10/10/2019 12:55, mj via samba wrote:
> Hi Rowland, all,
> On 10/9/19 9:11 AM, Rowland penny via samba wrote:
>> You could run something like this on a Samba AD DC:
>> ldbsearch -H /var/lib/samba/private/sam.ldb -b 
>> 'dc=samdom,dc=example,dc=com' -s sub 
>> '(&(objectclass=user)(samaccountname=rowland))' unicodePwd
>> This will get you a users password, you just need to run it through 
>> the reverse of what I posted earlier to see the actual users password.
> Out of curiosity I tried that, and wrote the following little bash 
> script:
>> PASSWORD="zKY\.Jp4jdiJ\_"
>> UNICODEPW_GENERATED="$(echo -n "$PASSWORD" | iconv -f UTF-8 -t 
>> UTF-16LE | base64 -w 0)"

I posted:

UNICODEPW=$(echo -n "\"$PASSWORD\"" | iconv -f UTF-8 -t UTF-16LE | 
base64 -w 0)

Believe it or not, the two escaped double quotes are a must, they become 
part of the password, AD expects them.


More information about the samba mailing list