Note that there are some explanatory texts on larger screens.

plurals
  1. PODecrypting the .ASPXAUTH Cookie WITH protection=validation
    primarykey
    data
    text
    <p>For quite sometime I've been trying to decipher the ASP .ASPXAUTH cookie and decrypt it using PHP. My reasons are huge and I need to do this, there is no alternative. In PHP so far I have successfully managed to read the data from this cookie, but I cannot seem to do it while it is encrypted. Anyway, here it goes...</p> <p>First you need to alter your servers Web.config file (protection needs to be set to Validation):</p> <pre><code> &lt;authentication mode="None"&gt; &lt;forms name=".ASPXAUTH" protection="Validation" cookieless="UseCookies" timeout="10080" enableCrossAppRedirects="true"/&gt; &lt;/authentication&gt; </code></pre> <p>Then in a PHP script on the same domain, you can do the following to read the data, this is a very basic example, but is proof:</p> <pre><code>$authCookie = $_COOKIE['_ASPXAUTH']; echo 'ASPXAUTH: '.$authCookie.'&lt;br /&gt;'."\n";//This outputs your plaintext hex cookie $packed = pack("H*",$authCookie); $packed_exp = explode("\0",$packed);//This will separate your data using NULL $random_bytes = array_shift($packed_exp);//This will shift off the random bytes echo print_r($packed_exp,TRUE); //This will return your cookies data without the random bytes </code></pre> <p>This breaks down the cookie, or at least the unencrypted data:</p> <p><img src="https://i.stack.imgur.com/PkLxA.jpg" alt="http://i.stack.imgur.com/stisu.jpg"></p> <p>Now that I know I can get the data, I removed the 'protection="validation"' string from my Web.config and I tried to decrypt it using PHP mcrypt. I have tried countless methods, but here is a promising example (which fails)...</p> <pre><code>define('ASP_DECRYPT_KEY','0BC95D748C57F6162519C165E0C5DEB69EA1145676F453AB93DA9645B067DFB8');//This is a decryption key found in my Machine.config file (please note this is forged for example) $iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_CBC), MCRYPT_RAND); $decrypted = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, ASP_DECRYPT_KEY, $authCookie, MCRYPT_MODE_CBC, $iv);//$authCookie is the pack()'d cookie data </code></pre> <p>This however fails. I've tried variations of IV with all zeros @ 16 bytes. I've tried different Rijndael sizes (128 vs 256). I've tried base64_decode()ing, nothing seems to work. I've found this <a href="https://stackoverflow.com/questions/7387080/net-and-php-rijndael-encryption-not-matching">stackoverflow post here</a> and started using variations of the key/iv that are made using sha256, but that isn't really working either.</p> <p>Anybody have a clue what I should do?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload