A library for defining and creating structured data (called records) that can be streamed to disk or piped to other tools that use flow.record
Project description
flow.record
A library for defining and creating structured data (called records) that can be streamed to disk or piped to other
tools that use flow.record
.
Records can be read and transformed to other formats by using output adapters, such as CSV and JSON.
For more information on how Dissect uses this library, please see the documentation.
Installation
flow.record
is available on PyPI.
pip install flow.record
Usage
This library contains the tool rdump
. With rdump
you can read, write, interact, and manipulate records from stdin
or from record files saved on disk. Please refer to rdump -h
or to the rdump
documentation for all parameters.
Records are the primary output type when using the various functions of target-query
. The following command shows how
to pipe record output from target-query
to rdump
:
user@dissect~$ target-query -f runkeys targets/EXAMPLE.vmx | rdump
<windows/registry/run hostname='EXAMPLE' domain='EXAMPLE.local' ts=2022-12-09 12:06:20.037806+00:00 name='OneDriveSetup' path='C:/Windows/SysWOW64/OneDriveSetup.exe /thfirstsetup' key='HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Run' hive_filepath='C:\\Windows/ServiceProfiles/LocalService/ntuser.dat' username='LocalService' user_sid='S-1-5-19' user_home='%systemroot%\\ServiceProfiles\\LocalService'>
<...>
Programming example
Define a RecordDescriptor
(schema) and then create a few records and write them to disk
from flow.record import RecordDescriptor, RecordWriter
# define our descriptor
MyRecord = RecordDescriptor("my/record", [
("net.ipaddress", "ip"),
("string", "description"),
])
# define some records
records = [
MyRecord("1.1.1.1", "cloudflare dns"),
MyRecord("8.8.8.8", "google dns"),
]
# write the records to disk
with RecordWriter("output.records.gz") as writer:
for record in records:
writer.write(record)
The records can then be read from disk using the rdump
tool or by instantiating a RecordReader
when using the
library.
$ rdump output.records.gz
<my/record ip=net.ipaddress('1.1.1.1') description='cloudflare dns'>
<my/record ip=net.ipaddress('8.8.8.8') description='google dns'>
Selectors
We can also use selectors
for filtering and selecting records using a query (Python like syntax), e.g.:
$ rdump output.records.gz -s '"google" in r.description'
<my/record ip=net.ipaddress('8.8.8.8') description='google dns'>
$ rdump output.records.gz -s 'r.ip in net.ipnetwork("1.1.0.0/16")'
<my/record ip=net.ipaddress('1.1.1.1') description='cloudflare dns'>
Build and test instructions
This project uses tox
to build source and wheel distributions. Run the following command from the root folder to build
these:
tox -e build
The build artifacts can be found in the dist/
directory.
tox
is also used to run linting and unit tests in a self-contained environment. To run both linting and unit tests
using the default installed Python version, run:
tox
For a more elaborate explanation on how to build and test the project, please see the documentation.
Contributing
The Dissect project encourages any contribution to the codebase. To make your contribution fit into the project, please refer to the style guide.
Copyright and license
Dissect is released as open source by Fox-IT (https://www.fox-it.com) part of NCC Group Plc (https://www.nccgroup.com).
Developed by the Dissect Team (dissect@fox-it.com) and made available at https://github.com/fox-it/dissect.
License terms: AGPL3 (https://www.gnu.org/licenses/agpl-3.0.html). For more information, see the LICENSE file.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file flow.record-3.6.dev9.tar.gz
.
File metadata
- Download URL: flow.record-3.6.dev9.tar.gz
- Upload date:
- Size: 78.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.9.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3daee51263b7b2f0c074dde4e74fb64858ddd74e4650575eeef8faf75fc4f4e5 |
|
MD5 | 9e259f445d1cef38eef39d1cd38cac57 |
|
BLAKE2b-256 | da04b8d59047e80c2eef89b5c14ce489b8c05ee2e1cc3b0eb5254ea9503ddec0 |
Provenance
File details
Details for the file flow.record-3.6.dev9-py3-none-any.whl
.
File metadata
- Download URL: flow.record-3.6.dev9-py3-none-any.whl
- Upload date:
- Size: 62.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.9.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2ae8e90d04064e2e603392a31c2eb28a3735b3722c9735e333b7a5c5a65a7617 |
|
MD5 | 9d6fd8b596ee2ceecdcdbb456eae0ccc |
|
BLAKE2b-256 | 2974c8993b2dfcc557b553512f897b99b7dc06dc2119de23df3f7bfdec63bec4 |