dissect.target 3.19.dev22__py3-none-any.whl → 3.19.dev23__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- dissect/target/helpers/network_managers.py +22 -7
- dissect/target/plugins/os/unix/linux/_os.py +1 -1
- {dissect.target-3.19.dev22.dist-info → dissect.target-3.19.dev23.dist-info}/METADATA +1 -1
- {dissect.target-3.19.dev22.dist-info → dissect.target-3.19.dev23.dist-info}/RECORD +9 -9
- {dissect.target-3.19.dev22.dist-info → dissect.target-3.19.dev23.dist-info}/COPYRIGHT +0 -0
- {dissect.target-3.19.dev22.dist-info → dissect.target-3.19.dev23.dist-info}/LICENSE +0 -0
- {dissect.target-3.19.dev22.dist-info → dissect.target-3.19.dev23.dist-info}/WHEEL +0 -0
- {dissect.target-3.19.dev22.dist-info → dissect.target-3.19.dev23.dist-info}/entry_points.txt +0 -0
- {dissect.target-3.19.dev22.dist-info → dissect.target-3.19.dev23.dist-info}/top_level.txt +0 -0
@@ -7,12 +7,14 @@ from configparser import ConfigParser, MissingSectionHeaderError
|
|
7
7
|
from io import StringIO
|
8
8
|
from itertools import chain
|
9
9
|
from re import compile, sub
|
10
|
-
from typing import Any, Callable, Iterable, Match, Optional
|
10
|
+
from typing import Any, Callable, Iterable, Iterator, Match, Optional
|
11
11
|
|
12
12
|
from defusedxml import ElementTree
|
13
13
|
|
14
14
|
from dissect.target.exceptions import PluginError
|
15
15
|
from dissect.target.helpers.fsutil import TargetPath
|
16
|
+
from dissect.target.plugins.os.unix.log.journal import JournalRecord
|
17
|
+
from dissect.target.plugins.os.unix.log.messages import MessagesRecord
|
16
18
|
from dissect.target.target import Target
|
17
19
|
|
18
20
|
log = logging.getLogger(__name__)
|
@@ -509,14 +511,15 @@ class LinuxNetworkManager:
|
|
509
511
|
return values
|
510
512
|
|
511
513
|
|
512
|
-
def parse_unix_dhcp_log_messages(target) ->
|
514
|
+
def parse_unix_dhcp_log_messages(target: Target, iter_all: bool = False) -> set[str]:
|
513
515
|
"""Parse local syslog, journal and cloud init-log files for DHCP lease IPs.
|
514
516
|
|
515
517
|
Args:
|
516
518
|
target: Target to discover and obtain network information from.
|
519
|
+
iter_all: Parse limited amount of journal messages (first 10000) or all of them.
|
517
520
|
|
518
521
|
Returns:
|
519
|
-
|
522
|
+
A set of found DHCP IP addresses.
|
520
523
|
"""
|
521
524
|
ips = set()
|
522
525
|
messages = set()
|
@@ -530,9 +533,19 @@ def parse_unix_dhcp_log_messages(target) -> list[str]:
|
|
530
533
|
if not messages:
|
531
534
|
target.log.warning(f"Could not search for DHCP leases using {log_func}: No log entries found.")
|
532
535
|
|
533
|
-
|
536
|
+
def records_enumerate(iterable: Iterable) -> Iterator[tuple[int, JournalRecord | MessagesRecord]]:
|
537
|
+
count = 0
|
538
|
+
for rec in iterable:
|
539
|
+
if rec._desc.name == "linux/log/journal":
|
540
|
+
count += 1
|
541
|
+
yield count, rec
|
542
|
+
|
543
|
+
for count, record in records_enumerate(messages):
|
534
544
|
line = record.message
|
535
545
|
|
546
|
+
if not line:
|
547
|
+
continue
|
548
|
+
|
536
549
|
# Ubuntu cloud-init
|
537
550
|
if "Received dhcp lease on" in line:
|
538
551
|
interface, ip, netmask = re.search(r"Received dhcp lease on (\w{0,}) for (\S+)\/(\S+)", line).groups()
|
@@ -576,9 +589,11 @@ def parse_unix_dhcp_log_messages(target) -> list[str]:
|
|
576
589
|
ips.add(ip)
|
577
590
|
continue
|
578
591
|
|
579
|
-
#
|
580
|
-
#
|
581
|
-
if
|
592
|
+
# The journal parser is relatively slow, so we stop when we have read 10000 journal entries,
|
593
|
+
# or if we have found at least one ip address. When `iter_all` is `True` we continue searching.
|
594
|
+
if not iter_all and (ips or count > 10_000):
|
595
|
+
if not ips:
|
596
|
+
target.log.warning("No DHCP IP addresses found in first 10000 journal entries.")
|
582
597
|
break
|
583
598
|
|
584
599
|
return ips
|
@@ -41,7 +41,7 @@ class LinuxPlugin(UnixPlugin, LinuxNetworkManager):
|
|
41
41
|
for ip in ip_set:
|
42
42
|
ips.append(ip)
|
43
43
|
|
44
|
-
for ip in parse_unix_dhcp_log_messages(self.target):
|
44
|
+
for ip in parse_unix_dhcp_log_messages(self.target, iter_all=False):
|
45
45
|
if ip not in ips:
|
46
46
|
ips.append(ip)
|
47
47
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: dissect.target
|
3
|
-
Version: 3.19.
|
3
|
+
Version: 3.19.dev23
|
4
4
|
Summary: This module ties all other Dissect modules together, it provides a programming API and command line tools which allow easy access to various data sources inside disk images or file collections (a.k.a. targets)
|
5
5
|
Author-email: Dissect Team <dissect@fox-it.com>
|
6
6
|
License: Affero General Public License v3
|
@@ -58,7 +58,7 @@ dissect/target/helpers/loaderutil.py,sha256=kiyMWra_gVxfNSGwLlgxLcuuqAYuCMDc5NiC
|
|
58
58
|
dissect/target/helpers/localeutil.py,sha256=Y4Fh4jDSGfm5356xSLMriUCN8SZP_FAHg_iodkAxNq4,1504
|
59
59
|
dissect/target/helpers/mount.py,sha256=JxhUYyEbDnHfzPpfuWy4nV9OwCJPoDSGdHHNiyvd_l0,3949
|
60
60
|
dissect/target/helpers/mui.py,sha256=i-7XoHbu4WO2fYapK9yGAMW04rFlgRispknc1KQIS5Q,22258
|
61
|
-
dissect/target/helpers/network_managers.py,sha256=
|
61
|
+
dissect/target/helpers/network_managers.py,sha256=ByBSe2K3c8hgQC6dokcf-hHdmPcD8PmrOj0xs1C3yhs,25743
|
62
62
|
dissect/target/helpers/polypath.py,sha256=h8p7m_OCNiQljGwoZh5Aflr9H2ot6CZr6WKq1OSw58o,2175
|
63
63
|
dissect/target/helpers/protobuf.py,sha256=b4DsnqrRLrefcDjx7rQno-_LBcwtJXxuKf5RdOegzfE,1537
|
64
64
|
dissect/target/helpers/record.py,sha256=lWl7k2Mp9Axllm0tXzPGJx2zj2zONsyY_p5g424T0Lc,4826
|
@@ -212,7 +212,7 @@ dissect/target/plugins/os/unix/esxi/_os.py,sha256=JOJ6j57vFCojgBNkju-7MG2nQqwl4Q
|
|
212
212
|
dissect/target/plugins/os/unix/etc/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
213
213
|
dissect/target/plugins/os/unix/etc/etc.py,sha256=WNCtO7NWOKRDBiV-XjXqgPuGRDE_Zyw6XWz3kTm__QE,2493
|
214
214
|
dissect/target/plugins/os/unix/linux/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
215
|
-
dissect/target/plugins/os/unix/linux/_os.py,sha256=
|
215
|
+
dissect/target/plugins/os/unix/linux/_os.py,sha256=n6VkfGYIdZUxcK2C1aPDUY_ZZQEIl0GkrpvIKeguv5o,2812
|
216
216
|
dissect/target/plugins/os/unix/linux/cmdline.py,sha256=AyMfndt3UsmJtoOyZYC8nWq2GZg9oPvn8SiI3M4NxnE,1622
|
217
217
|
dissect/target/plugins/os/unix/linux/environ.py,sha256=UOQD7Xmu754u2oAh3L5g5snuz-gv4jbWbVy46qszYjo,1881
|
218
218
|
dissect/target/plugins/os/unix/linux/iptables.py,sha256=qTzY5PHHXA33WnPYb5NESgoSwI7ECZ8YPoEe_Fmln-8,6045
|
@@ -346,10 +346,10 @@ dissect/target/volumes/luks.py,sha256=OmCMsw6rCUXG1_plnLVLTpsvE1n_6WtoRUGQbpmu1z
|
|
346
346
|
dissect/target/volumes/lvm.py,sha256=wwQVR9I3G9YzmY6UxFsH2Y4MXGBcKL9aayWGCDTiWMU,2269
|
347
347
|
dissect/target/volumes/md.py,sha256=j1K1iKmspl0C_OJFc7-Q1BMWN2OCC5EVANIgVlJ_fIE,1673
|
348
348
|
dissect/target/volumes/vmfs.py,sha256=-LoUbn9WNwTtLi_4K34uV_-wDw2W5hgaqxZNj4UmqAQ,1730
|
349
|
-
dissect.target-3.19.
|
350
|
-
dissect.target-3.19.
|
351
|
-
dissect.target-3.19.
|
352
|
-
dissect.target-3.19.
|
353
|
-
dissect.target-3.19.
|
354
|
-
dissect.target-3.19.
|
355
|
-
dissect.target-3.19.
|
349
|
+
dissect.target-3.19.dev23.dist-info/COPYRIGHT,sha256=m-9ih2RVhMiXHI2bf_oNSSgHgkeIvaYRVfKTwFbnJPA,301
|
350
|
+
dissect.target-3.19.dev23.dist-info/LICENSE,sha256=DZak_2itbUtvHzD3E7GNUYSRK6jdOJ-GqncQ2weavLA,34523
|
351
|
+
dissect.target-3.19.dev23.dist-info/METADATA,sha256=c2q_-Jvv4xRoYAE0jWyTGNV-oOKAD73yjU9Rk5-mavY,12719
|
352
|
+
dissect.target-3.19.dev23.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
|
353
|
+
dissect.target-3.19.dev23.dist-info/entry_points.txt,sha256=BWuxAb_6AvUAQpIQOQU0IMTlaF6TDht2AIZK8bHd-zE,492
|
354
|
+
dissect.target-3.19.dev23.dist-info/top_level.txt,sha256=Mn-CQzEYsAbkxrUI0TnplHuXnGVKzxpDw_po_sXpvv4,8
|
355
|
+
dissect.target-3.19.dev23.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
{dissect.target-3.19.dev22.dist-info → dissect.target-3.19.dev23.dist-info}/entry_points.txt
RENAMED
File without changes
|
File without changes
|