dissect.target 3.17.dev18__py3-none-any.whl → 3.17.dev19__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
@@ -512,34 +512,66 @@ class TargetCli(TargetCmd):
512
512
  @arg("-l", action="store_true")
513
513
  @arg("-a", "--all", action="store_true") # ignored but included for proper argument parsing
514
514
  @arg("-h", "--human-readable", action="store_true")
515
+ @arg("-R", "--recursive", action="store_true", help="recursively list subdirectories encountered")
516
+ @arg("-c", action="store_true", dest="use_ctime", help="show time when file status was last changed")
517
+ @arg("-u", action="store_true", dest="use_atime", help="show time of last access")
515
518
  def cmd_ls(self, args: argparse.Namespace, stdout: TextIO) -> Optional[bool]:
516
519
  """list directory contents"""
517
520
 
518
521
  path = self.resolve_path(args.path)
519
522
 
523
+ if args.use_ctime and args.use_atime:
524
+ print("can't specify -c and -u at the same time")
525
+ return
526
+
520
527
  if not path or not path.exists():
521
528
  return
522
529
 
530
+ self._print_ls(args, path, 0, stdout)
531
+
532
+ def _print_ls(self, args: argparse.Namespace, path: fsutil.TargetPath, depth: int, stdout: TextIO) -> None:
533
+ path = self.resolve_path(path)
534
+ subdirs = []
535
+
523
536
  if path.is_dir():
524
537
  contents = self.scandir(path, color=True)
525
538
  elif path.is_file():
526
539
  contents = [(path, path.name)]
527
540
 
541
+ if depth > 0:
542
+ print(f"\n{str(path)}:", file=stdout)
543
+
528
544
  if not args.l:
529
- print("\n".join([name for _, name in contents]), file=stdout)
545
+ for target_path, name in contents:
546
+ print(name, file=stdout)
547
+ if target_path.is_dir():
548
+ subdirs.append(target_path)
530
549
  else:
531
550
  if len(contents) > 1:
532
551
  print(f"total {len(contents)}", file=stdout)
533
552
  for target_path, name in contents:
534
- self.print_extensive_file_stat(stdout=stdout, target_path=target_path, name=name)
553
+ self.print_extensive_file_stat(args=args, stdout=stdout, target_path=target_path, name=name)
554
+ if target_path.is_dir():
555
+ subdirs.append(target_path)
556
+
557
+ if args.recursive and subdirs:
558
+ for subdir in subdirs:
559
+ self._print_ls(args, subdir, depth + 1, stdout)
535
560
 
536
- def print_extensive_file_stat(self, stdout: TextIO, target_path: fsutil.TargetPath, name: str) -> None:
561
+ def print_extensive_file_stat(
562
+ self, args: argparse.Namespace, stdout: TextIO, target_path: fsutil.TargetPath, name: str
563
+ ) -> None:
537
564
  """Print the file status."""
538
565
  try:
539
566
  entry = target_path.get()
540
567
  stat = entry.lstat()
541
568
  symlink = f" -> {entry.readlink()}" if entry.is_symlink() else ""
542
- utc_time = datetime.datetime.utcfromtimestamp(stat.st_mtime).isoformat()
569
+ show_time = stat.st_mtime
570
+ if args.use_ctime:
571
+ show_time = stat.st_ctime
572
+ elif args.use_atime:
573
+ show_time = stat.st_atime
574
+ utc_time = datetime.datetime.utcfromtimestamp(show_time).isoformat()
543
575
 
544
576
  print(
545
577
  f"{stat_modestr(stat)} {stat.st_uid:4d} {stat.st_gid:4d} {stat.st_size:6d} {utc_time} {name}{symlink}",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dissect.target
3
- Version: 3.17.dev18
3
+ Version: 3.17.dev19
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
@@ -322,7 +322,7 @@ dissect/target/tools/logging.py,sha256=5ZnumtMWLyslxfrUGZ4ntRyf3obOOhmn8SBjKfdLc
322
322
  dissect/target/tools/mount.py,sha256=L_0tSmiBdW4aSaF0vXjB0bAkTC0kmT2N1hrbW6s5Jow,3254
323
323
  dissect/target/tools/query.py,sha256=6zz9SXS6YnHj7eguORS8Je7N4iM0i1PZDIQ-gyJ1nPY,15593
324
324
  dissect/target/tools/reg.py,sha256=FDsiBBDxjWVUBTRj8xn82vZe-J_d9piM-TKS3PHZCcM,3193
325
- dissect/target/tools/shell.py,sha256=6GF-mr4EpzX34G9sqTNKcccFJXhNTlrUqriRYIW7P7o,43544
325
+ dissect/target/tools/shell.py,sha256=AuFNydQpRjZ0PKXFNTqm4OQwD-xGXShPqtixVgCcwSo,44825
326
326
  dissect/target/tools/utils.py,sha256=sQizexY3ui5vmWw4KOBLg5ecK3TPFjD-uxDqRn56ZTY,11304
327
327
  dissect/target/tools/dump/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
328
328
  dissect/target/tools/dump/run.py,sha256=aD84peRS4zHqC78fH7Vd4ni3m1ZmVP70LyMwBRvoDGY,9463
@@ -336,10 +336,10 @@ dissect/target/volumes/luks.py,sha256=OmCMsw6rCUXG1_plnLVLTpsvE1n_6WtoRUGQbpmu1z
336
336
  dissect/target/volumes/lvm.py,sha256=wwQVR9I3G9YzmY6UxFsH2Y4MXGBcKL9aayWGCDTiWMU,2269
337
337
  dissect/target/volumes/md.py,sha256=j1K1iKmspl0C_OJFc7-Q1BMWN2OCC5EVANIgVlJ_fIE,1673
338
338
  dissect/target/volumes/vmfs.py,sha256=-LoUbn9WNwTtLi_4K34uV_-wDw2W5hgaqxZNj4UmqAQ,1730
339
- dissect.target-3.17.dev18.dist-info/COPYRIGHT,sha256=m-9ih2RVhMiXHI2bf_oNSSgHgkeIvaYRVfKTwFbnJPA,301
340
- dissect.target-3.17.dev18.dist-info/LICENSE,sha256=DZak_2itbUtvHzD3E7GNUYSRK6jdOJ-GqncQ2weavLA,34523
341
- dissect.target-3.17.dev18.dist-info/METADATA,sha256=hkVxbE5ESL9e5xGrI4YY5UYYKF66WwuUIgRb8XRsaaQ,11300
342
- dissect.target-3.17.dev18.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
343
- dissect.target-3.17.dev18.dist-info/entry_points.txt,sha256=tvFPa-Ap-gakjaPwRc6Fl6mxHzxEZ_arAVU-IUYeo_s,447
344
- dissect.target-3.17.dev18.dist-info/top_level.txt,sha256=Mn-CQzEYsAbkxrUI0TnplHuXnGVKzxpDw_po_sXpvv4,8
345
- dissect.target-3.17.dev18.dist-info/RECORD,,
339
+ dissect.target-3.17.dev19.dist-info/COPYRIGHT,sha256=m-9ih2RVhMiXHI2bf_oNSSgHgkeIvaYRVfKTwFbnJPA,301
340
+ dissect.target-3.17.dev19.dist-info/LICENSE,sha256=DZak_2itbUtvHzD3E7GNUYSRK6jdOJ-GqncQ2weavLA,34523
341
+ dissect.target-3.17.dev19.dist-info/METADATA,sha256=c7p2Gn3T7tWRcVQUquv4BDpD2l-3fbvNkkS1VQ2vriA,11300
342
+ dissect.target-3.17.dev19.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
343
+ dissect.target-3.17.dev19.dist-info/entry_points.txt,sha256=tvFPa-Ap-gakjaPwRc6Fl6mxHzxEZ_arAVU-IUYeo_s,447
344
+ dissect.target-3.17.dev19.dist-info/top_level.txt,sha256=Mn-CQzEYsAbkxrUI0TnplHuXnGVKzxpDw_po_sXpvv4,8
345
+ dissect.target-3.17.dev19.dist-info/RECORD,,