Skip to content

Commit 3adbc6b

Browse files
committed
Multiple changes.
* Update version to 3.4.5.1. * Update fleetspeak binary dependency. * Adding more logging to proto deserialization. * Add tests for title in Netstat results. * Fleetspeak server wrapper: remove obsolete config initialization. * Config updater: add support for rotating fleetspeak certificate. * Use material table for displaying Netstat results. * Format NetworkConnectionFamily and NetworkConnectionType in Netstat Results table. * MSI: MSI templates can't be bulk signed. * Increasing min time between stop checks to 30 seconds.
1 parent e178e55 commit 3adbc6b

File tree

20 files changed

+412
-87
lines changed

20 files changed

+412
-87
lines changed

grr/client/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ def run(self):
138138
PYTSK3,
139139
"retry==0.9.2",
140140
"libfsntfs-python==20210503",
141-
"fleetspeak-client-bin==0.1.9",
141+
"fleetspeak-client-bin==0.1.11",
142142
],
143143
extras_require={
144144
# The following requirements are needed in Windows.

grr/client_builder/grr_response_client_builder/client_build.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,10 @@ def RepackTemplates(self,
328328
passwd = self.GetWindowsPassphrase()
329329
repack_args.append("--sign")
330330
else:
331-
bulk_sign_installers = True
331+
if template.endswith(".msi.zip"):
332+
repack_args.append("--sign")
333+
else:
334+
bulk_sign_installers = True
332335
if signed_template:
333336
repack_args.append("--signed_template")
334337
elif template.endswith(".rpm.zip"):

grr/client_builder/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def make_release_tree(self, base_dir, files):
6868
"grr-response-client==%s" % VERSION.get("Version", "packagedepends"),
6969
"grr-response-core==%s" % VERSION.get("Version", "packagedepends"),
7070
"PyInstaller==3.6",
71-
"fleetspeak-client-bin==0.1.9",
71+
"fleetspeak-client-bin==0.1.11",
7272
"olefile==0.46",
7373
],
7474

grr/core/grr_response_core/lib/rdfvalues/structs.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1750,8 +1750,8 @@ def FromSerializedBytes(cls, value: bytes):
17501750
try:
17511751
ReadIntoObject(value, 0, instance)
17521752
except ValueError:
1753-
logging.error("Error in ReadIntoObject for bytes, extract: %r",
1754-
value[:1000])
1753+
logging.error("Error in ReadIntoObject. %d bytes, extract: %r",
1754+
len(value), value[:1000])
17551755
raise
17561756

17571757
instance.dirty = True
@@ -1879,7 +1879,7 @@ def Get(self, attr, allow_set_default=True):
18791879
The attribute's value, or the attribute's type's default value, if unset.
18801880
"""
18811881
entry = self._data.get(attr)
1882-
# We dont have this field, try the defaults.
1882+
# We don't have this field, try the defaults.
18831883
if entry is None:
18841884
type_descriptor = self._GetTypeDescriptor(attr)
18851885
default = type_descriptor.GetDefault(container=self)

grr/proto/grr_response_proto/sysinfo.proto

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,8 +321,15 @@ message WindowsServiceInformation {
321321
SERVICE_KERNEL_DRIVER = 0x1;
322322
SERVICE_FILE_SYSTEM_DRIVER = 0x2;
323323
SERVICE_ADAPTER_ARGS = 0x4;
324+
SERVICE_RECOGNIZER_DRIVER = 0x8;
324325
SERVICE_WIN32_OWN_PROCESS = 0x10;
325326
SERVICE_WIN32_SHARE_PROCESS = 0x20;
327+
SERVICE_USER_OWN_PROCESS = 0x50;
328+
SERVICE_USER_SHARE_PROCESS = 0x60;
329+
SERVICE_INTERACTIVE_PROCESS = 0x100;
330+
SERVICE_INSTANCE_USER_SHARE_PROCESS = 0xe0;
331+
SERVICE_INTERACTIVE_WIN32_OWN_PROCESS = 0x110;
332+
SERVICE_INTERACTIVE_WIN32_SHARE_PROCESS = 0x120;
326333
}
327334

328335
optional ServiceType service_type = 12 [(sem_type) = {

grr/server/grr_response_server/bin/config_updater.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,11 @@ def main(args):
411411
maintenance_utils.RotateServerKey(
412412
cn=args.common_name, keylength=keylength)
413413

414+
if grr_config.CONFIG["Server.fleetspeak_enabled"]:
415+
config_updater_util.FleetspeakConfig().RotateKey()
416+
print("Fleetspeak server key rotated, "
417+
"please restart fleetspeak-server.")
418+
414419

415420
def Run():
416421
app.run(main, flags_parser=lambda argv: parser.parse_args(argv[1:]))

grr/server/grr_response_server/bin/config_updater_util.py

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"""Utilities for modifying the GRR server configuration."""
33

44
import argparse
5+
import datetime
56
import getpass
67
import os
78
import re
@@ -372,6 +373,18 @@ def Write(self, config):
372373
else:
373374
self._WriteDisabled(config)
374375

376+
def RotateKey(self):
377+
now_str = datetime.datetime.now().isoformat()
378+
# Move the old server keys
379+
for cert_file in ("server_cert.pem", "server_cert_key.pem"):
380+
old_file = f"old_{now_str}_{cert_file}"
381+
os.rename(self._ConfigPath(cert_file), self._ConfigPath(old_file))
382+
# Run fleetspeak-config to regenerate them
383+
subprocess.check_call([
384+
self._fleetspeak_config_command_path, "-config",
385+
self._ConfigPath("fleetspeak_config.config")
386+
])
387+
375388
def _ConfigPath(self, *path_components: str) -> str:
376389
return os.path.join(self.config_dir, *path_components)
377390

@@ -482,12 +495,13 @@ def _WriteEnabled(self, config):
482495
cp.darwin_client_configuration_file = self._ConfigPath(
483496
"darwin_client.config")
484497

485-
p = subprocess.Popen(
486-
[self._fleetspeak_config_command_path, "-config", "/dev/stdin"],
487-
stdin=subprocess.PIPE)
488-
p.communicate(input=text_format.MessageToString(cp).encode())
489-
if p.wait() != 0:
490-
raise RuntimeError("fleetspeak-config command failed.")
498+
with open(self._ConfigPath("fleetspeak_config.config"), "w") as f:
499+
f.write(text_format.MessageToString(cp))
500+
501+
subprocess.check_call([
502+
self._fleetspeak_config_command_path, "-config",
503+
self._ConfigPath("fleetspeak_config.config")
504+
])
491505

492506
# These modules don't exist on Windows, so importing locally.
493507
# pylint: disable=g-import-not-at-top

grr/server/grr_response_server/bin/fleetspeak_server_wrapper.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
from absl import app
1717

18-
from grr_response_core.lib import config_lib
1918
from grr_response_core.lib import package
2019

2120

@@ -24,7 +23,6 @@ class Error(Exception):
2423

2524

2625
def main(argv):
27-
config_lib.ParseConfigCommandLine()
2826
config_dir = package.ResourcePath(
2927
"fleetspeak-server-bin", "fleetspeak-server-bin/etc/fleetspeak-server")
3028
if not os.path.exists(config_dir):

grr/server/grr_response_server/gui/ui/components/flow_details/helpers/module.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
1010
import {RouterModule} from '@angular/router';
1111
import {ExpandableHashModule} from '@app/components/expandable_hash/module';
1212
import {FileModePipe} from '@app/components/flow_details/helpers/file_mode_pipe';
13+
import {NetworkConnectionFamilyPipe, NetworkConnectionTypePipe} from '@app/components/flow_details/helpers/network_connection_pipes';
1314
import {HumanReadableSizeModule} from '@app/components/human_readable_size/module';
1415
import {TimestampModule} from '@app/components/timestamp/module';
1516

@@ -46,6 +47,8 @@ import {ResultAccordion} from './result_accordion';
4647
declarations: [
4748
FileResultsTable,
4849
FileModePipe,
50+
NetworkConnectionFamilyPipe,
51+
NetworkConnectionTypePipe,
4952
OsqueryResultsTable,
5053
ResultAccordion,
5154
LoadFlowResultsDirective,
@@ -54,6 +57,8 @@ import {ResultAccordion} from './result_accordion';
5457
exports: [
5558
FileResultsTable,
5659
FileModePipe,
60+
NetworkConnectionFamilyPipe,
61+
NetworkConnectionTypePipe,
5762
OsqueryResultsTable,
5863
ResultAccordion,
5964
LoadFlowResultsDirective,
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import {Pipe, PipeTransform} from '@angular/core';
2+
3+
import {NetworkConnectionFamily, NetworkConnectionType} from '../../../lib/api/api_interfaces';
4+
5+
const NETWORK_CONNECTION_FAMILY_MAP:
6+
ReadonlyMap<NetworkConnectionFamily, string> = new Map([
7+
[NetworkConnectionFamily.INET, 'IPv4'],
8+
[NetworkConnectionFamily.INET6, 'IPv6'],
9+
[NetworkConnectionFamily.INET6_WIN, 'IPv6'],
10+
[NetworkConnectionFamily.INET6_OSX, 'IPv6'],
11+
]);
12+
13+
const NETWORK_CONNECTION_TYPE_MAP: ReadonlyMap<NetworkConnectionType, string> =
14+
new Map([
15+
[NetworkConnectionType.UNKNOWN_SOCKET, '?'],
16+
[NetworkConnectionType.SOCK_STREAM, 'TCP'],
17+
[NetworkConnectionType.SOCK_DGRAM, 'UDP'],
18+
]);
19+
20+
/**
21+
* Converts a given NetworkConnectionFamily (IP Version) enum to a more
22+
* human readable format.
23+
*/
24+
@Pipe({name: 'networkConnectionFamily'})
25+
export class NetworkConnectionFamilyPipe implements PipeTransform {
26+
transform(family: NetworkConnectionFamily|undefined): string {
27+
if (family === undefined) {
28+
return '-';
29+
}
30+
return NETWORK_CONNECTION_FAMILY_MAP.get(family) ?? '-';
31+
}
32+
}
33+
34+
/**
35+
* Converts a given NetworkConnectionType (IP Version) enum to a more
36+
* human readable format.
37+
*/
38+
@Pipe({name: 'networkConnectionType'})
39+
export class NetworkConnectionTypePipe implements PipeTransform {
40+
transform(type: NetworkConnectionType|undefined): string {
41+
if (type === undefined) {
42+
return '-';
43+
}
44+
return NETWORK_CONNECTION_TYPE_MAP.get(type) ?? '-';
45+
}
46+
}

0 commit comments

Comments
 (0)