Skip to content

Commit 2c739f3

Browse files
committed
fix PMC formatbug when handling PMC with more than 256 rules #28
1 parent 31a1a72 commit 2c739f3

File tree

3 files changed

+22
-25
lines changed

3 files changed

+22
-25
lines changed

docs/PMC Format.md

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ a record structure, that contains the name of the option and its value. The reco
77

88
**CONFIGURATION_RECORD**
99

10-
| Data Type | Description |
11-
| --------- | ------------------------------------------------------------ |
12-
| Uint32 | The size of the record |
13-
| Uint32 | The size of the first 4 fields (0x10) |
14-
| Uint32 | The size of the first 5 fields (0x10 plus name size in bytes) |
15-
| Uint32 | The size of the data |
16-
| Wchar_t[] | The name of the configuration option |
10+
| Data Type | Description |
11+
|-----------|------------------------------------------------------------------------------|
12+
| Uint32 | The size of the record |
13+
| Uint32 | The size of the first 4 fields (0x10) |
14+
| Uint32 | The size of the first 5 fields (0x10 plus name size in bytes) |
15+
| Uint32 | The size of the data |
16+
| Wchar_t[] | The name of the configuration option |
1717
| Byte[] | the value of the configuration option (format depends on which option it is) |
1818

1919
In the default configuration of Procmon, there are 20 configuration options:
@@ -44,23 +44,22 @@ The filter rules are represented by the following layout:
4444
**FILTER_RULES**
4545

4646
| Data Type | Description |
47-
| ------------- | -------------------------------- |
47+
|---------------|----------------------------------|
4848
| Byte | Unknown |
49-
| Byte | the number of rules in the array |
49+
| Uint32 | the number of rules in the array |
5050
| FILTER_RULE[] | array of all the rules |
51-
| Byte[3] | Unknown |
5251

5352
Each filter rule contains the column type it checks (like "PID", "Path", ...), the relation type (like "is", "contains", "starts with", ...) and the value to compare to, and whether to include events that matches this rule or exclude them. A rule is represented by the following layout:
5453

5554
**FILTER_RULE**
5655

57-
| Data Type | Description |
58-
| --------- | ------------------------------------------------------------ |
59-
| Byte[3] | Unknown |
60-
| Uint32 | Column type - see ```class Column(enum.IntEnum)``` in [consts.py](../procmon_parser/consts.py) |
56+
| Data Type | Description |
57+
|-----------|---------------------------------------------------------------------------------------------------------|
58+
| Uint32 | Column type - see ```class Column(enum.IntEnum)``` in [consts.py](../procmon_parser/consts.py) |
6159
| Uint32 | Relation type - see ```class RuleRelation(enum.IntEnum)``` in [consts.py](../procmon_parser/consts.py) |
62-
| Byte | Whether to include this filter if it matches an event or exclude it. |
63-
| Uint32 | The length of the value string in bytes |
64-
| Wchar_t[] | The value |
65-
| Byte[5] | Unknown |
60+
| Byte | Whether to include this filter if it matches an event or exclude it. |
61+
| Uint32 | The length of the value string in bytes |
62+
| Wchar_t[] | The value |
63+
| Uint32 | The value as integer |
64+
| Uint32 | Unknown |
6665

procmon_parser/configuration_format.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ def get_rule_integer_value(column, value):
7070
RawRuleStruct = """
7171
Struct that contains a single rule which can be applied on the process monitor events.
7272
""" * Struct(
73-
"reserved1" / Default(Bytes(3), 0) * "!!Unknown field!!",
7473
"column" / ColumnType,
7574
"relation" / RuleRelationType,
7675
"action" / RuleActionType,
@@ -80,9 +79,9 @@ def get_rule_integer_value(column, value):
8079
"value" / FixedUTF16CString(lambda this: this.value_length, "value"),
8180
"after_value_offset" / Tell, # NOT IN THE REAL FORMAT - USED FOR BUILDING ONLY
8281
"int_value" / Rebuild(Int32ul, lambda this: get_rule_integer_value(this.column, this.value)),
83-
"reserved2" / Default(Bytes(1), 0) * "!!Unknown field!!",
82+
"reserved" / Default(Int32ul, 0) * "!!Unknown field!!",
8483

85-
# To calculate value string in build time
84+
# NOT IN THE REAL FORMAT - used to calculate value string in build time
8685
"value_length" / Pointer(lambda this: this.value_offset,
8786
Default(Int32ul, lambda this: this.after_value_offset - this.before_value_offset))
8887
)
@@ -101,10 +100,9 @@ def _encode(self, obj, context, path):
101100
RawRulesStruct = """
102101
Struct that contains a list of procmon rules.
103102
""" * Struct(
104-
"reserved1" / Const(1, Int8ul) * "!!Unknown field!!",
105-
"rules_count" / Rebuild(Int8ul, lambda this: len(this.rules)),
103+
"reserved" / Const(1, Int8ul) * "!!Unknown field!!",
104+
"rules_count" / Rebuild(Int32ul, lambda this: len(this.rules)),
106105
"rules" / Array(lambda this: this.rules_count, RuleStruct),
107-
"reserved1" / Default(Bytes(3), 0) * "!!Unknown field!!",
108106
)
109107

110108

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setuptools.setup(
77
name="procmon-parser",
8-
version="0.3.12",
8+
version="0.3.13",
99
author="Ely Ronnen",
1010
author_email="elyronnen@gmail.com",
1111
description="Parser to Procmon configuration and log files formats",

0 commit comments

Comments
 (0)