programming4us
programming4us
ENTERPRISE

Windows 7 : Interacting with the Built-In Security Features - ACCESSING APPLOCKER (part 2) - Reading AppLocker Entries

- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019

3. Reading AppLocker Entries

Reading the AppLocker entries means locating the entries in the registry and then parsing them. You have no way of knowing how many entries the registry will contain (if it contains any entries at all). Listing 2 parses the entries using the assumption that the registry might not contain any entries.

Example 2. Reading the AppLocker entries from a known location
private void btnList_Click(object sender, EventArgs e)
{
// Clear the previous entries.
lstEntries.Items.Clear();

// Open the AppLocker registry key.
RegistryKey AppLock =
Registry.LocalMachine.OpenSubKey(
@"SOFTWARE\Policies\Microsoft\Windows\SrpV2");

// Obtain the kinds of entries that the application can create.
String[] EntryTypes = AppLock.GetSubKeyNames();

// Process each entry in turn.
foreach (String EntryType in EntryTypes)
{
// Display the entry type.
lstEntries.Items.Add(EntryType);

// Open the associated subkey.
RegistryKey ThisType = AppLock.OpenSubKey(EntryType);

// Obtain a list of entries within the type.
String[] AppLockEntries = ThisType.GetSubKeyNames();

// Process each of the individual entries.
foreach (String AppLockEntry in AppLockEntries)
{
// Display the individual entry GUID.
lstEntries.Items.Add("\t" + AppLockEntry);

// Open the individual entry.
RegistryKey ThisEntry = ThisType.OpenSubKey(AppLockEntry);

// Obtain the XML value of the entry.
XmlDocument Entry = new XmlDocument();
Entry.LoadXml(ThisEntry.GetValue("Value").ToString());

// Obtain the root element.
XmlNode TheRule = Entry.FirstChild;

// Display the overall rule values.
lstEntries.Items.Add("\t\tName: " +
TheRule.Attributes["Name"].Value);
lstEntries.Items.Add("\t\tDescription: " +
TheRule.Attributes["Description"].Value);
lstEntries.Items.Add("\t\tGroup or User SID: " +
TheRule.Attributes["UserOrGroupSid"].Value);
lstEntries.Items.Add("\t\tAction: " +
TheRule.Attributes["Action"].Value);

// Obtain the condition element.


XmlNode Conditions = TheRule.FirstChild;

// Examine the conditions.
foreach (XmlNode Condition in Conditions)
{
// Display the attributes for each condition.
foreach (XmlAttribute Specification in Condition.Attributes)
{
// Show the attribute information.
lstEntries.Items.Add("\t\t\t" + Specification.Name +
": " + Specification.Value);
}
}

// Close the individual entry.
ThisEntry.Close();

// Add a space.
lstEntries.Items.Add("");
}

// Close the entry type.
ThisType.Close();

// Add a space.
lstEntries.Items.Add("");
}

// Close the main key.
AppLock.Close();
}


The example begins by clearing the previous list box entries. It then opens the one key that you can depend on to find AppLocker entries, assuming the target system supports AppLocker. The AppLock object contains a handle to the registry entry after the code calls OpenSubKey() using the Registry.LocalMachine property. The code calls GetSubKeyNames() to obtain a list of entries and places them in EntryTypes (the array should contain the Dll, Exe, Msi, and Script key names). Because Microsoft could decide to change the format of the registry entries, the code uses a foreach loop to parse through whatever entries appear in the EntryTypes String array.

At this point, the code opens a subkey, such as Dll, for processing by calling OpenSubKey(). The code uses the GetSubKeyNames() call to place a list of GUID entries in AppLockEntries. It uses a second foreach loop to process each of the GUID entries that appear as subkeys of EntryType.

As previously mentioned, each GUID entry contains a value named Value that contains XML describing the rule used to define an exception. The code begins by creating an XmlDocument object, Entry, and placing the XML in it by calling LoadXml(). The code processes the XML as you would any XML document. It begins by accessing the <FilePublisherRule> or other rule element, listing the attributes in this element, and then working through the <Conditions> element. The precise order of processing depends on the rule. Figure 2 shows typical output from this example.

Figure 2. The example displays any AppLocker rules configured on your system.

Other  
  •  Windows 7 : Interacting with the Built-In Security Features - WORKING WITH AUTOMATIC UPDATES (part 2)
  •  Windows 7 : Interacting with the Built-In Security Features - WORKING WITH AUTOMATIC UPDATES (part 1)
  •  Windows 8 Architecture from a Developer’s Point of View : Understanding Windows Runtime (part 5) - What’s not in Windows Runtime
  •  Windows 8 Architecture from a Developer’s Point of View : Understanding Windows Runtime (part 4) - Language Projections
  •  Windows 8 Architecture from a Developer’s Point of View : Understanding Windows Runtime (part 3) - Metadata in Windows Runtime - Namespaces
  •  Windows 8 Architecture from a Developer’s Point of View : Understanding Windows Runtime (part 2) - Metadata in Windows Runtime - Metadata Format
  •  Windows 8 Architecture from a Developer’s Point of View : Understanding Windows Runtime (part 1) - Windows Runtime Architecture Overview
  •  Windows 8 Architecture from a Developer’s Point of View : Windows 8 Development Architecture
  •  Windows 7 : Programming KMDF Hardware Driver - Mapping Resources - Code to Map Resources
  •  Windows 7 : Programming KMDF Hardware Driver - Handling Interrupts (part 2) - Deferred Processing for Interrupts
  •  
    Top 10
    Free Mobile And Desktop Apps For Accessing Restricted Websites
    MASERATI QUATTROPORTE; DIESEL : Lure of Italian limos
    TOYOTA CAMRY 2; 2.5 : Camry now more comely
    KIA SORENTO 2.2CRDi : Fuel-sipping slugger
    How To Setup, Password Protect & Encrypt Wireless Internet Connection
    Emulate And Run iPad Apps On Windows, Mac OS X & Linux With iPadian
    Backup & Restore Game Progress From Any Game With SaveGameProgress
    Generate A Facebook Timeline Cover Using A Free App
    New App for Women ‘Remix’ Offers Fashion Advice & Style Tips
    SG50 Ferrari F12berlinetta : Prancing Horse for Lion City's 50th
    - Messages forwarded by Outlook rule go nowhere
    - Create and Deploy Windows 7 Image
    - How do I check to see if my exchange 2003 is an open relay? (not using a open relay tester tool online, but on the console)
    - Creating and using an unencrypted cookie in ASP.NET
    - Directories
    - Poor Performance on Sharepoint 2010 Server
    - SBS 2008 ~ The e-mail alias already exists...
    - Public to Private IP - DNS Changes
    - Send Email from Winform application
    - How to create a .mdb file from ms sql server database.......
    programming4us programming4us
    programming4us
     
     
    programming4us