Multi-OEM/Retail Project {MRP} - Mk3

Discussion in 'MDL Projects and Applications' started by mxman2k, Oct 15, 2016.

  1. mxman2k

    mxman2k MDL Developer

    Jun 20, 2007
    5,919
    19,735
    180
    good idea about bde status... Will look into that..

    The fsutil works on 7/8.x/1x i thought i could use it just to test if it was actually on or off, but it seems i got the info wrong :oops:
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  2. mxman2k

    mxman2k MDL Developer

    Jun 20, 2007
    5,919
    19,735
    180
    manage-bde -status C: |findstr /C:"Protection Status" seems to be useful :)

    Powershell version fails :g: Get-BitlockerVolume C: | Select -expand "Protection Status"
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. mxman2k

    mxman2k MDL Developer

    Jun 20, 2007
    5,919
    19,735
    180
    powershell -command (New-Object -ComObject Shell.Application).NameSpace('C:').Self.ExtendedProperty('System.Volume.BitLockerProtection')

    I got 2

    0 = Unencryptable (i think)
    1 = Encrypted
    2 = Not Encrypted - my main pc drive isnt using BL and is set off
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  4. Carlos Detweiller

    Carlos Detweiller Emperor of Ice-Cream

    Dec 21, 2012
    6,476
    7,239
    210
    Code:
    PS E:\> Get-BitlockerVolume C: | Select -expand "Protection Status"
    Get-BitlockerVolume : The term 'Get-BitlockerVolume' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is
    correct and try again.
    At line:1 char:1
    + Get-BitlockerVolume C: | Select -expand "Protection Status"
    + ~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : ObjectNotFound: (Get-BitlockerVolume:String) [], CommandNotFoundException
        + FullyQualifiedErrorId : CommandNotFoundException
    
    PS E:\>
    PS would also not work everywhere.

    Code:
    E:\>manage-bde -status C:
    BitLocker Drive Encryption: Configuration Tool version 6.1.7601
    Copyright (C) Microsoft Corporation. All rights reserved.
    
    ERROR: The volume C: could not be opened by BitLocker. This may be because
    the volume does not exist, or because it is not a valid BitLocker volume.
    
    E:\>
    bde-admin.exe does not list my C: partiton at all.
     
  5. Carlos Detweiller

    Carlos Detweiller Emperor of Ice-Cream

    Dec 21, 2012
    6,476
    7,239
    210
    Code:
    E:\>powershell -command (New-Object -ComObject Shell.Application).NameSpace('C:').Self.ExtendedProperty('System.Volume.BitLockerProtection')
    0
    
    E:\>
    I got 0.
     
  6. mxman2k

    mxman2k MDL Developer

    Jun 20, 2007
    5,919
    19,735
    180
    Hmm why cant m$ make things compatible :(

    I think the bitlocker bits will be for w10+ any way so at least it will be compatible -- i hope!

    Was going to use it in the GUI QT but it appears until i can get some sort of reliable method to parse things it may have to be just w10+ only :(
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  7. mxman2k

    mxman2k MDL Developer

    Jun 20, 2007
    5,919
    19,735
    180
    0 i think is 'Unencryptable' as it cant seem to find it on w7 :g:
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  8. Carlos Detweiller

    Carlos Detweiller Emperor of Ice-Cream

    Dec 21, 2012
    6,476
    7,239
    210
    It seems to be not encryptable, as it isn't listed as a valid BitLocker Volume. Even if I wanted (I don't), I couldn't encrypt it.
     
  9. mxman2k

    mxman2k MDL Developer

    Jun 20, 2007
    5,919
    19,735
    180
    I have a autoit script which i can convert to exe - it uses WMI calls i wonder if that be ok on w7 ?
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  10. mxman2k

    mxman2k MDL Developer

    Jun 20, 2007
    5,919
    19,735
    180
    Converting to non GUI was a bit of a pain :D but will upload to beta test area.

    open admin console then run the exe it should return C:|blah blah or some errors :D

    i got:
    C:|Unprotected

    its a function i found for autoit and if it works ok on w7 too (once i worked the error bits out) then i can add it into the GUI QT later.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  11. mxman2k

    mxman2k MDL Developer

    Jun 20, 2007
    5,919
    19,735
    180
    Found out why the ps code failed for protection status , it not have a space like shown on a ps window :g:

    Open admin cmd prompt and copy/paste below code, it should hopefully show On/Off for the system drive....

    Code:
    
    Powershell -NoProfile "(Get-BitlockerVolume %SystemDrive% | Select -expand 'Protectionstatus')"
    
    
    Saves parsing the mde output if more than one drive present!
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  12. Carlos Detweiller

    Carlos Detweiller Emperor of Ice-Cream

    Dec 21, 2012
    6,476
    7,239
    210
    Code:
    E:\>Powershell -NoProfile "(Get-BitlockerVolume %SystemDrive% | Select -expand 'Protectionstatus')"
    Get-BitlockerVolume : The term 'Get-BitlockerVolume' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is
    correct and try again.
    At line:1 char:2
    + (Get-BitlockerVolume C: | Select -expand 'Protectionstatus')
    +  ~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : ObjectNotFound: (Get-BitlockerVolume:String) [], CommandNotFoundException
        + FullyQualifiedErrorId : CommandNotFoundException
    
    E:\>
    Does simply not exist on Windows 7.
     
  13. mxman2k

    mxman2k MDL Developer

    Jun 20, 2007
    5,919
    19,735
    180
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  14. Carlos Detweiller

    Carlos Detweiller Emperor of Ice-Cream

    Dec 21, 2012
    6,476
    7,239
    210
    There is no such exe in the beta area.
     
  15. mxman2k

    mxman2k MDL Developer

    Jun 20, 2007
    5,919
    19,735
    180
    is now -- i keep forgetting to press start to upload to the ftp :oops:

    Bitlockertest.exe
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  16. Enthousiast

    Enthousiast MDL Tester

    Oct 30, 2009
    47,932
    97,092
    450
  17. mxman2k

    mxman2k MDL Developer

    Jun 20, 2007
    5,919
    19,735
    180
    i'm multi tasking and doing a bad job of it :D
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  18. mxman2k

    mxman2k MDL Developer

    Jun 20, 2007
    5,919
    19,735
    180
    this is the autoit script/function i used in the exe, i just used a part result as it has many many other results it can display.

    Code:
    #RequireAdmin
    #include <array.au3>
    Local $sysdrive = EnvGet("systemdrive")
    
    ; Get information on the C-drive of the current computer + show extra information in the console
    Global $test = _BitlockerDriveInfo($sysdrive, @ComputerName, False)
    If @error Then
        ConsoleWrite("!> _BitlockerDriveInfo() error: " & @error & ". extended: " & @extended & @CRLF)
    ElseIf IsArray($test) Then
        ConsoleWrite($test[0][0] & "|" & $test[0][4] & @CRLF)
    EndIf
    ;
    
    ; #FUNCTION# ====================================================================================================================
    ; Name...........: _BitlockerDriveInfo
    ; Description ...: Get Bitlocker information for one or multiple drives
    ; Syntax.........: _BitlockerDriveInfo([$sDrive[, $sComputer = @ComputerName[, $bDebug = False]]])
    ; Parameters ....: $sDrive  - Optional: The drive. Allowed values are:
    ;                  |""      - Get the info for all available drives
    ;                  |Letter: - Get the info for the specific drive
    ;                  $sComputer - Optional: The computer from which the info should be requested
    ;                  $bDebug  - Optional: Shows the hex ReturnValue from the WMI methods if set to True
    ; Return values .: Success  - Returns a 2D array with the following information
    ;                  |[string] Drive Letter
    ;                  |[string] Drive Label
    ;                  |[string] Volume Type
    ;                  |[bool]   Initialized For Protection
    ;                  |[string] Protection Status
    ;                  |[string] Lock Status
    ;                  |[bool]   Auto Unlock Enabled
    ;                  |[bool]   Auto Unlock Key Stored
    ;                  |[string] Conversion Status
    ;                  |[string] Encryption Method
    ;                  |[int]    Encryption Percentage
    ;                  |[string] Wiping Status
    ;                  |[int]    Wiping Percentage
    ;                  |[array]  Key Protectors (Or [string] "None" if the drive isn't protected)
    ;                  Failure  - 0, sets @error to:
    ;                  |1 - There was an issue retrieving the COM object. @extended returns error code from ObjGet
    ;                  |2 - The specified drive in $Drive doesn't exist
    ;                  |3 - There was an issue running the WMI query
    ; Author ........: colombeen
    ; Modified.......:
    ; Remarks .......: Requires to be run with admin elevation. Windows Vista or newer!
    ;                  A BIG THANKS to everyone from the community who contributed!
    ; Related .......:
    ; Link ..........:
    ; Example .......: #include <Array.au3>
    ;                  $Header = "Drive Letter|Drive Label|Volume Type|Initialized For Protection|Protection Status|" & _
    ;                            "Lock Status|Auto Unlock Enabled|Auto Unlock Key Stored|Conversion Status|Encryption " & _
    ;                            "Method|Encryption Percentage|Wiping Status|Wiping Percentage|Key Protectors"
    ;                  _ArrayDisplay(_BitlockerDriveInfo(), "Bitlocker Drive Info", "", 64, Default, $Header)
    ; ===============================================================================================================================
    Func _BitlockerDriveInfo($sDrive = "", $sComputer = @ComputerName, $bDebug = False)
        Local $aConversionStatusMsg[7]  =   ["Unknown", "Fully Decrypted", "Fully Encrypted", "Encryption In Progress", "Decryption In Progress", "Encryption Paused", "Decryption Paused"]
        Local $aEncryptionMethodMsg[9]  =   ["Unknown", "None", "AES_128_WITH_DIFFUSER", "AES_256_WITH_DIFFUSER", "AES_128", "AES_256", "HARDWARE_ENCRYPTION", "XTS_AES_128", "XTS_AES_256"]
        Local $aKeyProtectorTypeMsg[11] =   ["Unknown or other protector type", "Trusted Platform Module (TPM)", "External key", "Numerical password", "TPM And PIN", "TPM And Startup Key", "TPM And PIN And Startup Key", "Public Key", "Passphrase", "TPM Certificate", "CryptoAPI Next Generation (CNG) Protector"]
        Local $aLockStatusMsg[3]        =   ["Unknown", "Unlocked", "Locked"]
        Local $aProtectionStatusMsg[3]  =   ["Unprotected", "Protected", "Unknown"]
        Local $aVolumeTypeMsg[3]        =   ["Operating System Volume", "Fixed Data Volume", "Portable Data Volume"]
        Local $aWipingStatusMsg[5]      =   ["Unknown", "Free Space Not Wiped", "Free Space Wiped", "Free Space Wiping In Progress", "Free Space Wiping Paused"]
        Local $iRow                     =   0
        Local $sRunMethod, $objWMIService, $objWMIQuery, $sDriveFilter, $iProtectionStatus, $iLockStatus, $bIsAutoUnlockEnabled, $bIsAutoUnlockKeyStored, $iConversionStatus, $iEncryptionPercentage, $iEncryptionFlags, $iWipingStatus, $iWipingPercentage, $iEncryptionMethod, $aVolumeKeyProtectorID, $aVolumeKeyProtectors, $iKeyProtectorType
    
        $objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate,authenticationLevel=pktPrivacy}!\\" & $sComputer & "\root\CIMV2\Security\MicrosoftVolumeEncryption")
        If @error Then Return SetError(1, @error, 0)
    
        If $sDrive <> "" Then
            Local $iDriveType = _WMIPropertyValue("DriveType", "Win32_LogicalDisk", "WHERE DeviceID='" & $sDrive & "'", Default, $sComputer)
            If @error Or ($iDriveType <> 2 And $iDriveType <> 3) Then Return SetError(2, 0, 0)
            $sDriveFilter = " WHERE DriveLetter='" & $sDrive & "'"
        EndIf
    
        $objWMIQuery = $objWMIService.ExecQuery("SELECT * FROM Win32_EncryptableVolume" & $sDriveFilter, "WQL", 0)
        If Not IsObj($objWMIQuery) Then Return SetError(3, 0, 0)
    
        Local $aResult[$objWMIQuery.count][14]
        For $objDrive In $objWMIQuery
            If $bDebug Then ConsoleWrite(@CRLF & "+> " & $objDrive.DriveLetter & @CRLF)
            If _WMIMethodExists($objDrive, "GetConversionStatus") Then
                $sRunMethod = $objDrive.GetConversionStatus($iConversionStatus, $iEncryptionPercentage, $iEncryptionFlags, $iWipingStatus, $iWipingPercentage)
                If $bDebug Then ConsoleWrite("!> GetConversionStatus    0x" & Hex($sRunMethod) & @CRLF)
            Else
                $iConversionStatus      =   -1
                $iWipingStatus          =   -1
                $iEncryptionPercentage  =   0
                $iWipingPercentage      =   0
            EndIf
            If _WMIMethodExists($objDrive, "GetEncryptionMethod") Then
                $sRunMethod = $objDrive.GetEncryptionMethod($iEncryptionMethod)
                If $bDebug Then ConsoleWrite("!> GetEncryptionMethod    0x" & Hex($sRunMethod) & @CRLF)
            Else
                $iEncryptionMethod      =   0
            EndIf
            If _WMIMethodExists($objDrive, "GetKeyProtectors") Then
                $sRunMethod = $objDrive.GetKeyProtectors("0", $aVolumeKeyProtectorID)
                If $bDebug Then ConsoleWrite("!> GetKeyProtectors       0x" & Hex($sRunMethod) & @CRLF)
            Else
                $aVolumeKeyProtectorID  =   0
            EndIf
            If _WMIMethodExists($objDrive, "GetLockStatus") Then
                $sRunMethod = $objDrive.GetLockStatus($iLockStatus)
                If $bDebug Then ConsoleWrite("!> GetLockStatus          0x" & Hex($sRunMethod) & @CRLF)
            Else
                $iLockStatus            =   -1
            EndIf
            If _WMIMethodExists($objDrive, "GetProtectionStatus") Then
                $sRunMethod = $objDrive.GetProtectionStatus($iProtectionStatus)
                If $bDebug Then ConsoleWrite("!> GetProtectionStatus    0x" & Hex($sRunMethod) & @CRLF)
            Else
                $iProtectionStatus      =   2
            EndIf
            If _WMIMethodExists($objDrive, "IsAutoUnlockEnabled") Then
                $sRunMethod = $objDrive.IsAutoUnlockEnabled($bIsAutoUnlockEnabled)
                If $bDebug Then ConsoleWrite("!> IsAutoUnlockEnabled    0x" & Hex($sRunMethod) & @CRLF)
            Else
                $bIsAutoUnlockEnabled   =   "Unknown"
            EndIf
            If _WMIMethodExists($objDrive, "IsAutoUnlockKeyStored") Then
                $sRunMethod = $objDrive.IsAutoUnlockKeyStored($bIsAutoUnlockKeyStored)
                If $bDebug Then ConsoleWrite("!> IsAutoUnlockKeyStored  0x" & Hex($sRunMethod) & @CRLF)
            Else
                $bIsAutoUnlockKeyStored =   "Unknown"
            EndIf
    
            If IsArray($aVolumeKeyProtectorID) And UBound($aVolumeKeyProtectorID) > 0 Then
                Dim $aVolumeKeyProtectors[UBound($aVolumeKeyProtectorID)][2]
    
                For $i = 0 To UBound($aVolumeKeyProtectorID) - 1
                    $aVolumeKeyProtectors[$i][0]        =   $aVolumeKeyProtectorID[$i]
                    If _WMIMethodExists($objDrive, "GetKeyProtectorType") Then
                        If $objDrive.GetKeyProtectorType($aVolumeKeyProtectorID[$i], $iKeyProtectorType) = 0 Then
                            $aVolumeKeyProtectors[$i][1]=   $aKeyProtectorTypeMsg[$iKeyProtectorType]
                        Else
                            $aVolumeKeyProtectors[$i][1]=   "Unknown"
                        EndIf
                    Else
                        $aVolumeKeyProtectors[$i][1]    =   "Unknown"
                    EndIf
                Next
            Else
                $aVolumeKeyProtectors                   =   "None"
            EndIf
    
            ; DriveLetter
            $aResult[$iRow][0]      =   $objDrive.DriveLetter
            ; DriveLabel
            $aResult[$iRow][1]      =   _WMIPropertyValue("VolumeName", "Win32_LogicalDisk", "WHERE DeviceID='" & $objDrive.DriveLetter & "'", Default, $sComputer)
            ; VolumeType
            If _WMIPropertyExists($objDrive, "VolumeType") Then
                $aResult[$iRow][2]  =   $aVolumeTypeMsg[$objDrive.VolumeType]
            Else
                If $objDrive.DriveLetter = _WMIPropertyValue("SystemDrive", "Win32_OperatingSystem", "", Default, $sComputer) Then
                    $aResult[$iRow][2]= $aVolumeTypeMsg[0]
                ElseIf _WMIPropertyValue("DriveType", "Win32_LogicalDisk", "WHERE DeviceID='" & $objDrive.DriveLetter & "'", Default, $sComputer) = 3 Then
                    $aResult[$iRow][2]= $aVolumeTypeMsg[1]
                ElseIf _WMIPropertyValue("DriveType", "Win32_LogicalDisk", "WHERE DeviceID='" & $objDrive.DriveLetter & "'", Default, $sComputer) = 2 Then
                    $aResult[$iRow][2]= $aVolumeTypeMsg[2]
                Else
                    $aResult[$iRow][2]= "Unknown"
                EndIf
            EndIf
            ; IsVolumeInitializedForProtection
            If _WMIPropertyExists($objDrive, "IsVolumeInitializedForProtection") Then
                $aResult[$iRow][3]  =   $objDrive.IsVolumeInitializedForProtection
            Else
                $aResult[$iRow][3]  =   "Unkown"
            EndIf
            ; ProtectionStatus
            $aResult[$iRow][4]      =   $aProtectionStatusMsg[$iProtectionStatus]
            ; LockStatus
            $aResult[$iRow][5]      =   $aLockStatusMsg[$iLockStatus + 1]
            ; IsAutoUnlockEnabled
            $aResult[$iRow][6]      =   $bIsAutoUnlockEnabled
            ; IsAutoUnlockEnabled
            $aResult[$iRow][7]      =   $bIsAutoUnlockKeyStored
            ; ConversionStatus
            $aResult[$iRow][8]      =   $aConversionStatusMsg[$iConversionStatus + 1]
            ; EncryptionMethod
            $aResult[$iRow][9]      =   $aEncryptionMethodMsg[$iEncryptionMethod + 1]
            ; EncryptionPercentage
            $aResult[$iRow][10]     =   $iEncryptionPercentage
            ; WipingStatus
            $aResult[$iRow][11]     =   $aWipingStatusMsg[$iWipingStatus + 1]
            ; WipingPercentage
            $aResult[$iRow][12]     =   $iWipingPercentage
            ; KeyProtectors
            $aResult[$iRow][13]     =   $aVolumeKeyProtectors
    
            $iRow += 1
        Next
        _ArraySort($aResult)
        Return $aResult
    EndFunc   ;==>_BitlockerDriveInfo
    
    Func _WMIPropertyExists($Object, $Property)
        If Not IsObj($Object) Then Return False
        For $sProperty In $Object.Properties_
            If $sProperty.Name = $Property Then Return True
        Next
        Return False
    EndFunc   ;==>_WMIPropertyExists
    
    Func _WMIMethodExists($Object, $Method)
        If Not IsObj($Object) Then Return False
        For $sMethod In $Object.Methods_
            If $sMethod.Name = $Method Then Return True
        Next
        Return False
    EndFunc   ;==>_WMIMethodExists
    
    Func _WMIPropertyValue($sProperty = "", $sClass = "", $sFilter = "", $sNamespace = Default, $sComputer = @ComputerName)
        Local $objWMIService, $objWMIQuery
    
        If $sClass = "" Or $sProperty = "" Then Return SetError(1, 0, 0)
        If $sFilter <> "" Then $sFilter = " " & $sFilter
        If $sNamespace = Default Then $sNamespace = "\root\CIMV2"
    
        $objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate,authenticationLevel=pktPrivacy}!\\" & $sComputer & $sNamespace)
        If @error Then Return SetError(2, @error, 0)
    
        $objWMIQuery = $objWMIService.ExecQuery("SELECT * FROM " & $sClass & $sFilter, "WQL", 0x30)
        If Not IsObj($objWMIQuery) Then Return SetError(3, 0, 0)
    
        For $objItem In $objWMIQuery
            For $Property In $objItem.Properties_
                If $Property.Name = $sProperty Then
                    Return $Property.Value
                EndIf
            Next
        Next
    
        Return SetError(4, 0, 0)
    EndFunc   ;==>_WMIPropertyValue
    
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  19. Carlos Detweiller

    Carlos Detweiller Emperor of Ice-Cream

    Dec 21, 2012
    6,476
    7,239
    210
  20. mxman2k

    mxman2k MDL Developer

    Jun 20, 2007
    5,919
    19,735
    180
    :( im not doing very well with those arrays :D
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...