Skip to content

LiamSennitt/registrypol

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RegistryPol

GitHub Workflow Status (branch) PyPI GitHub

The registrypol module allows you to easily parse and create Windows Registry Policy files in Python.

Installation

To install the registrypol module via pip, run the command:

$ pip install registrypol

Usage

Start by importing the registrypol module.

>>> import registrypol

The function registrypol.load, loads an registry policy file.

>>> with open('registry.pol', 'rb') as file:
...     registrypol.load(file)

In addition to loading an existing registry policy, policies created using the relevant Values can be dumped to a file using the registrypol.dump function.

>>> with open('registry.pol', 'wb') as file:
...     registrypol.dump(policy, file)

RegistryValue

To create a registry value as part of an registry policy, a registrypol.values.RegistryValue must be created.

>>> from registrypol.values import RegistryValue

>>> value = RegistryValue(
...     key='Software\Policies\Microsoft\Windows\SrpV2\Exe',
...     value='EnforcementMode',
...     type='REG_DWORD',
...     size=4,
...     data=b'\x01\x00\x00\x00'
... )

RegistryPolicy

To create an registry policy one or more registry values must be created as described above.

These values can then be used to create an registrypol.policy.RegistryPolicy.

>>> from registrypol.policy import RegistryPolicy

>>> policy = RegistryPolicy(
...     values=[
...         value
...     ]
... )