Skip to content

Commit 04de4ed

Browse files
authored
Merge branch 'master' into quick_fixes
Signed-off-by: Benjamin Cance <[email protected]>
2 parents 68f4b06 + e6591dc commit 04de4ed

16 files changed

+1545
-8
lines changed

CHANGES.md

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,26 @@
11

2-
# AnalyzeMFT Change Log
2+
## Versions 3.0.2 and 3.0.3 (2024-09-04)
33

4-
This document lists the changes and version history for the AnalyzeMFT script and component scripts.
4+
### Changes
5+
- Brought back XML, JSON outputs
6+
- Added optional Excel output (requires openpyxl)
7+
- Restored type hints
8+
- Tinkered a little more with the attribute specific functions
9+
10+
### Fixes
11+
- Fixed a minor CSV formatting error where path names weren't being correctly parsed.
12+
13+
### To do
14+
- Fix the root path file name - currently the parser picks up everything after the `C:\`, I'd like to have the target drive letter also
15+
- Add verbose and very verbose output to accompany debug
16+
- Create tests for each class, module, and output type.
17+
- Finish migrating the `MFTRecord.To_CSV()` functionality to `FileWriters.WriteCSV()`
18+
- Should I be making a new module called `Output_Format`, thus invoking items like `Output_Format.TO_CSV()` .. seems like a lot of work for marginal gain.
19+
- Better utilize Python built-ins like `@dataclass` and `@staticmethod` on items that would be equivalent to C's `enums` and `structs`.
20+
- Sort out the documentation and steps to implement a SQLite or PostgreSQL database and use that as an output format.
21+
22+
### Big thanks!
23+
To my wife, Jessica, for giving me the motivation to pick this project back up and get it back to a stable, working state. Also thank you to the Reddit Arduino community for helping me consolidate my thoughts on this and some other projects.
524

625
## Version 3.0.1 (2024-09-03)
726

analyzeMFT.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
import asyncio
21
import sys
2+
import asyncio
33
from src.analyzeMFT.cli import main
44

55
# Adds the current directory to the path to ensure our file calls are consistent.
66
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), 'src')))
77

88
if __name__ == "__main__":
99
if sys.platform == "win32":
10-
# This sets the event loop policy to use the ProactorEventLoop on Windows
11-
asyncio.set_event_loop_policy(asyncio.WindowsProactorEventLoopPolicy())
12-
10+
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
1311
asyncio.run(main())

requirements-dev.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
pytest
2+
pytest-cov
3+
pytest-mock
4+
pytest-asyncio

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
openpyxl==3.0.10

src/analyzeMFT/cli.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,43 @@ async def main():
4141

4242
(options, args) = parser.parse_args()
4343

44-
if not options.filename or not options.output_file:
44+
if not options.filename:
4545
parser.print_help()
46+
print("\nError: No input file specified. Use -f or --file to specify an MFT file.")
47+
sys.exit(1)
48+
49+
if not options.output_file:
50+
parser.print_help()
51+
print("\nError: No output file specified. Use -o or --output to specify an output file.")
4652
sys.exit(1)
4753

4854
# Default to CSV if no format specified
4955
if not options.export_format:
5056
options.export_format = "csv"
5157

58+
5259
analyzer = MftAnalyzer(options.filename, options.output_file, options.debug, options.very_debug,
5360
options.verbosity, options.compute_hashes, options.export_format)
5461
await analyzer.analyze()
5562
print(f"Analysis complete. Results written to {options.output_file}")
5663

64+
try:
65+
analyzer = MftAnalyzer(options.filename, options.output_file, options.debug, options.compute_hashes, options.export_format)
66+
await analyzer.analyze()
67+
print(f"Analysis complete. Results written to {options.output_file}")
68+
except FileNotFoundError:
69+
print(f"Error: The file '{options.filename}' was not found.")
70+
sys.exit(1)
71+
except PermissionError:
72+
print(f"Error: Permission denied when trying to read '{options.filename}' or write to '{options.output_file}'.")
73+
sys.exit(1)
74+
except Exception as e:
75+
print(f"An unexpected error occurred: {str(e)}")
76+
if options.debug:
77+
import traceback
78+
traceback.print_exc()
79+
sys.exit(1)
80+
master
81+
5782
if __name__ == "__main__":
5883
asyncio.run(main())

src/analyzeMFT/mft_record.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44
import zlib
55
from .constants import *
66
from .windows_time import WindowsTime
7+
78
from typing import Dict, Set, List, Optional, Any, Union
89

910

11+
1012
class MftRecord:
1113
def __init__(self, raw_record: bytes, compute_hashes: bool = False) -> None:
1214
self.raw_record = raw_record

tests/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)