Good day. There was a task to decrypt the wi-fi password saved in the system. Example content file (C: \ ProgramData \ Microsoft \ Wlansvc \ Profiles \ Interfaces):

<keyMaterial>01000000D08C9DDF0115D1118C7A00C04FC297EB01000000B5DC49CF346C5441ACC9412051EEA53100000000020000000000106600000001000020000000B0BCA6C2C90D3F05AE7F43835F1CB0E8B9ECBCF351138A83B9E94228181CAC9E000000000E8000000002000020000000630621CC8DE9EBBFBE1089010AE6ABF4C531E277F18DC576E4EBDEB43C0D238110000000778F49BCC7B5CC0D032ECFAD9CD5419E4000000054FCFB5D2A46A1BD944F1A42B27C6B1A0CD19E5101DA4B4307DEBD5ECE980E3AEB62E1959060720459C2A854BA9100C9E912AC076A49D13B0B935942FDF4BF11</keyMaterial> 

The essence of the problem - does not work, throws an exception: CryptUnprotectData failed.

Call:

 string entropy = null; string description; string Pass = @"01000000D08C9DDF0115D1118C7A00C04FC297EB01000000B5DC49CF346C5441ACC9412051EEA53100000000020000000000106600000001000020000000B0BCA6C2C90D3F05AE7F43835F1CB0E8B9ECBCF351138A83B9E94228181CAC9E000000000E8000000002000020000000630621CC8DE9EBBFBE1089010AE6ABF4C531E277F18DC576E4EBDEB43C0D238110000000778F49BCC7B5CC0D032ECFAD9CD5419E4000000054FCFB5D2A46A1BD944F1A42B27C6B1A0CD19E5101DA4B4307DEBD5ECE980E3AEB62E1959060720459C2A854BA9100C9E912AC076A49D13B0B935942FDF4BF11"; byte[] Key = null; // Call DPAPI to decrypt data. string decrypted = DPAPI.Decrypt(Pass, entropy, out description); richTextBox1.Text = decrypted; 

Auxiliary class: http://dumpz.org/1173308/

  • one
    @ z668L Yeah, that's better. Here is a discussion on your problem: < stackoverflow.com/a/10822536/276994 >. (I will also read it now.) - VladD
  • one
    @ z668: Yeah, I think I figured it out. It means so. First, you need to unpack the string first (you think hex-encoded). There may be an error: your code decodes, it seems, from base64 . The second possible problem (after you cope with the first one) is that you need to call CryptUnprotectData from under the Local System account. Do you do that - VladD
  • one
    @ z668: See. If you only need to decode the password, at the end of the answer there is a complete example on the pros. You can just take it. If you want to embed this code in C #, it is possible (not sure!) Just enough to run it as an administrator. If not, you will have to implement the change of the current user with the help of P / Invoke. From here you can get an example; you need the LogonUser function. But here, you may have to experiment further. - VladD
  • one
    @ z668: Oh, better already. And the code from here did not try? And from under the administrator does not go? --- Here is another example . - VladD
  • one
    Ok thank you. I will try, be sure to accomplish the results. From under the amine in any. - Alexis

1 answer 1

(Collected a response from the comments.)

First, you must first unpack the string (you seem to be hex-encoded). There may be an error: your code decodes, it seems, from base64 . The second possible problem (after you cope with the first one) is that you need to call CryptUnprotectData from under the Local System account.

If you only need to decode the password, at the end of this answer there is a complete example on the pros. You can just take it. If you want to embed this code in C #, perhaps (not sure!), You just need to run it as an administrator. If not, you will have to implement the change of the current user with the help of P / Invoke. From here you can get an example; you need the LogonUser function. But here, you may have to experiment further.


As a result of the discussion, PsExec did help.

  • Yes, yes, I'm with PsExec and will do as the most appropriate option. - Alexis
  • Thank you for your help, it is nice when competent experts help to understand the topic, there would be more like you and Oleg from cyber. - Alexis