Windows 8.1 Build 9600.16610 DISM Now Can Work On ESD

Discussion in 'Windows 8' started by FaiKee, Feb 10, 2014.

  1. abbodi1406

    abbodi1406 MDL KB0000001

    Feb 19, 2011
    17,472
    92,659
    340
    I believe nothing is read from the actual data, and xml meta contains very much all the info needed for such operation

    you mean "copy /b file1+file2+.. finalfile"
    but the xml is not always at the exact end of wim file
     
  2. woebetide

    woebetide MDL Member

    May 28, 2007
    240
    78
    10
    #62 woebetide, Feb 18, 2014
    Last edited by a moderator: Apr 20, 2017
    Testeing the /apply-image
    Created a VHD mounted and now applying index:4 of the install.esd.

    Code:
    C:\windows\system32>DISM.exe /Apply-Image /ImageFile:s:\test\install.esd /Index:
    4 /ApplyDir:t:\
    
    Deployment Image Servicing and Management tool
    Version: 6.3.9600.16610
    
    Applying image
    [==========================100.0%==========================]
    The operation completed successfully.
    
    C:\windows\system32>
    index:4 -> 7.47 gig
    Applyed index:3 ..... setup.exe in root and only 937 MB
     
  3. murphy78

    murphy78 MDL DISM Enthusiast

    Nov 18, 2012
    7,432
    11,762
    240
    #63 murphy78, Feb 18, 2014
    Last edited by a moderator: Apr 20, 2017
    We're trying to extract the freshly downloaded esd files, not the already extracted install.esd version.
    We've already established that we can extract those since they are not encrypted.
     
  4. JeepWillys58

    JeepWillys58 MDL Addicted

    Nov 6, 2010
    604
    380
    30
    #64 JeepWillys58, Mar 1, 2014
    Last edited by a moderator: Apr 20, 2017
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  5. JeepWillys58

    JeepWillys58 MDL Addicted

    Nov 6, 2010
    604
    380
    30
    #65 JeepWillys58, Mar 1, 2014
    Last edited: Mar 1, 2014
    I tried using DISM/GET-WIMNFO, but it didn't work returned error 11, can you help me? below is the command and his return:

    DISM/Get-WIMInfo >/WIMFile C:\Windows\system32: C:\ESD\Windows\sources\install.e
    (d)

    Tool of deployment image servicing and management
    Version: 6.3.9600.16384


    Error: 11

    An attempt was made to load a program with an incorrect format.

    The DISM log file can be found on C:\Windows\Logs\DISM\dism.log




    I try this command too: DISM /APPLY-IMAGE /IMAGEFILE:C:\ESD\Windows\sources\install.esd /INDEX:1 /APPLYDIR:N:\

    and got the same error message....:confused:

    Can someone help-me?
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  6. murphy78

    murphy78 MDL DISM Enthusiast

    Nov 18, 2012
    7,432
    11,762
    240
    It only works in the dism from 8.1 update 1 that wzt leaked. It didn't work in any previous versions of dism.
    Are you using update 1?
     
  7. FaiKee

    FaiKee Misinformation spreader

    Jul 24, 2009
    4,303
    5,816
    150
    He used RTM

     
  8. chinobino

    chinobino MDL Member

    Jul 28, 2009
    184
    72
    10
    What is the new build string? 6.3.9600.17019?
     
  9. qad

    qad MDL Member

    Dec 17, 2012
    218
    829
    10
    #69 qad, Mar 19, 2014
    Last edited: Mar 19, 2014
    I see the <CryptoKey> is actually an RSA key pair in CSP blob format (and it's in plaintext).
    But it seems the <Key> from embedded XML is not simply an RSA encrypted session key.
    It forms 256 bytes after base64 decoded (which is the block size of RSA-2048) and,
    in common practice, it should be an encrypted session key by using the public key.
    But I can neither decrypt it with the private key nor import it as a simple key blob into CSP.
    Crypto API just fails with the error code NTE_BAD_DATA whenever I try to decrypt/import it.
    Any thoughts?

    Thanks
     
  10. qad

    qad MDL Member

    Dec 17, 2012
    218
    829
    10
    Seems I misunderstood the endianness of the <Key> data.
    I peeked the actual key data with debugger (I can see the decryption routine is run in WinDlp.dll with normal Crypto APIs).
    It needs to be swapped in byte array and, if that's been done, the base64 decoded <Key> is also an AES-256 session key blob (encrypted with the RSA pubkey).
    Also, there is no initial vector for AES-256 and the encrypted blocks are independent from one another.

    Thx to nosferati87 for giving info.
     
  11. Stannieman

    Stannieman MDL Guru

    Sep 4, 2009
    2,228
    1,817
    90
    What is exactly new?
    IIRC we already could extract and capture esd files, right? And dism always worked on an extracted windows image.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  12. murphy78

    murphy78 MDL DISM Enthusiast

    Nov 18, 2012
    7,432
    11,762
    240
    I already love you qad, but if you get this decrypter working I'll love you even more :)
     
  13. Superfly

    Superfly MDL Expert

    Jan 12, 2010
    1,142
    543
    60
    #73 Superfly, Mar 29, 2014
    Last edited by a moderator: Apr 20, 2017
    I'm not clued up on crypto so just wanna get some insight into this thing... but here's a snippet with what I came up with so far...
    Code:
        byte[] GetEncryptedData(int startoffset, int endoffset, string ESDfile)
            {
                using (BinaryReader b = new BinaryReader(File.Open(ESDfile,FileMode.Open)))
                {
                    int length = (int)b.BaseStream.Length;
                    int pos = startoffset;
                    int required = endoffset - startoffset;
                    // Seek the required index.
                    b.BaseStream.Seek(pos, SeekOrigin.Begin);
                         return b.ReadBytes(required);
                }        
                
            }
    
            private static String DecryptIt(String s, byte[] key, byte[] IV)
            {
                String result;
    
                RijndaelManaged rijn = new RijndaelManaged();
                rijn.Mode = CipherMode.CBC;
                rijn.Padding = PaddingMode.Zeros;
    
                using (MemoryStream msDecrypt = new MemoryStream(Convert.FromBase64String(s)))
                {
                    using (ICryptoTransform decryptor = rijn.CreateDecryptor(key, IV))
                    {
                        using (CryptoStream csDecrypt = new CryptoStream(msDecrypt, decryptor, CryptoStreamMode.Read))
                        {
                            using (StreamReader swDecrypt = new StreamReader(csDecrypt))
                            {
                                result = swDecrypt.ReadToEnd();
                            }
                        }
                    }
                }
                rijn.Clear();
    
                return result;
            }
        }
    }
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  14. qad

    qad MDL Member

    Dec 17, 2012
    218
    829
    10
    #74 qad, Mar 31, 2014
    Last edited by a moderator: Apr 20, 2017
  15. murphy78

    murphy78 MDL DISM Enthusiast

    Nov 18, 2012
    7,432
    11,762
    240
  16. qad

    qad MDL Member

    Dec 17, 2012
    218
    829
    10
  17. Superfly

    Superfly MDL Expert

    Jan 12, 2010
    1,142
    543
    60
    #77 Superfly, Mar 31, 2014
    Last edited by a moderator: Apr 20, 2017
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  18. murphy78

    murphy78 MDL DISM Enthusiast

    Nov 18, 2012
    7,432
    11,762
    240
    #78 murphy78, Mar 31, 2014
    Last edited: Mar 31, 2014
    Here's a pre-compiled I tested as working guys...
    Obviously it's 10x better that qad hooked us up with a source, but a lot of guys may not want to go through hassle of installing the vs. You might need vs2013 runtime... don't know...
    Usage is just as qad suggested... just esddecrypt esdfile.esd
    The extra argument would be for if you had an esd file with a different decryption (which we haven't seen yet)
    EDIT: I *MIGHT* make an iso creation tool for this later...
    I've already got a lot on my plate with my diskpart/apply project
    qad-decrypt-proof.jpg
     

    Attached Files:

  19. NiFu

    NiFu MDL Member

    Jun 29, 2013
    129
    134
    10
    Would be nice to have the feature "export each index to separate WIM file"
     
  20. murphy78

    murphy78 MDL DISM Enthusiast

    Nov 18, 2012
    7,432
    11,762
    240
    #80 murphy78, Apr 1, 2014
    Last edited: Apr 1, 2014
    DISM can't export an esd to a wim.
    You can apply to a directory and re-capture it to a wim though.

    You wouldn't really need to for the main install index, but if you wanted to modify it, you could.
    You'd have to apply/capture the setup and/or the winpe index though for a full iso.
    Really it would be much easier to just cut/paste the decrypted install.esd to a GA iso, but all of the iso elements are there.
    I'll see about getting a script for this made when I'm done testing my diskpart/apply script.