From c28cb8d48acd70f6bb47e62d79e5f2b5ffdc5d7f Mon Sep 17 00:00:00 2001 From: Grigoryev Ilya Alekseevich Date: Tue, 31 Mar 2026 01:08:22 +0500 Subject: [PATCH] init commit --- README.md | 46 ++++++++++++++++++++++++++++++ app/main.go | 1 + go.mod | 5 ++++ go.sum | 2 ++ internal/cmd/cmd.go | 69 +++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 123 insertions(+) create mode 100644 README.md create mode 100644 app/main.go create mode 100644 go.mod create mode 100644 go.sum create mode 100644 internal/cmd/cmd.go diff --git a/README.md b/README.md new file mode 100644 index 0000000..1e4ee5a --- /dev/null +++ b/README.md @@ -0,0 +1,46 @@ +# MFTECmd + +## Command Line Interface + +```sh +MFTECmd version 0.5.0.1 + + f File to process ($MFT | $J | $LogFile | $Boot | $SDS). Required + + json Directory to save JSON formatted results to. This or --csv required unless --de or --body is specified + jsonf File name to save JSON formatted results to. When present, overrides default name + csv Directory to save CSV formatted results to. This or --json required unless --de or --body is specified + csvf File name to save CSV formatted results to. When present, overrides default name + + body Directory to save bodyfile formatted results to. --bdl is also required when using this option + bodyf File name to save body formatted results to. When present, overrides default name + bdl Drive letter (C, D, etc.) to use with bodyfile. Only the drive letter itself should be provided + blf When true, use LF vs CRLF for newlines. Default is FALSE + + dd Directory to save exported FILE record. --do is also required when using this option + do Offset of the FILE record to dump as decimal or hex. Ex: 5120 or 0x1400 Use --de or --vl 1 to see offsets + + de Dump full details for entry/sequence #. Format is 'Entry' or 'Entry-Seq' as decimal or hex. Example: 5, 624-5 or 0x270-0x5. + fls When true, displays contents of directory specified by --de. Ignored when --de points to a file. + ds Dump full details for Security Id as decimal or hex. Example: 624 or 0x270 + + dt The custom date/time format to use when displaying time stamps. Default is: yyyy-MM-dd HH:mm:ss.fffffff + sn Include DOS file name types. Default is FALSE + fl Generate condensed file listing. Requires --csv. Default is FALSE + at When true, include all timestamps from 0x30 attribute vs only when they differ from 0x10. Default is FALSE + + vss Process all Volume Shadow Copies that exist on drive specified by -f . Default is FALSE + dedupe Deduplicate -f & VSCs based on SHA-1. First file found wins. Default is FALSE + + debug Show debug information during processing + trace Show trace information during processing + + + Examples: MFTECmd -f "C:\Temp\SomeMFT" --csv "c:\temp\out" --csvf MyOutputFile.csv + MFTECmd -f "C:\Temp\SomeMFT" --csv "c:\temp\out" + MFTECmd -f "C:\Temp\SomeMFT" --json "c:\temp\jsonout" + MFTECmd -f "C:\Temp\SomeMFT" --body "c:\temp\bout" --bdl c + MFTECmd -f "C:\Temp\SomeMFT" --de 5-5 + + Short options (single letter) are prefixed with a single dash. Long commands are prefixed with two dashes +``` \ No newline at end of file diff --git a/app/main.go b/app/main.go new file mode 100644 index 0000000..06ab7d0 --- /dev/null +++ b/app/main.go @@ -0,0 +1 @@ +package main diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..ce91eb3 --- /dev/null +++ b/go.mod @@ -0,0 +1,5 @@ +module mftecmd + +go 1.25.3 + +require github.com/fred1268/go-clap v1.2.1 // indirect diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..68054e4 --- /dev/null +++ b/go.sum @@ -0,0 +1,2 @@ +github.com/fred1268/go-clap v1.2.1 h1:wi8Tokb2zmOEuwwTTfKX5Sj1h6ZpT2BxRtx1/ZJsol4= +github.com/fred1268/go-clap v1.2.1/go.mod h1:A5/yYBapOy6UyujlbxL7p/bX9J7bzyoMRzQKFwveXF0= diff --git a/internal/cmd/cmd.go b/internal/cmd/cmd.go new file mode 100644 index 0000000..2b4eb5f --- /dev/null +++ b/internal/cmd/cmd.go @@ -0,0 +1,69 @@ +package cmd + +import ( + "os" + + "github.com/fred1268/go-clap/clap" +) + +// Перечень флагов +type Config struct { + InputFile string `clap:"trailing,mandatory"` // Входящий файл $MFT, $J, $LogFile, $Boot, $SDS + FileFormat string `clap:"--format,-F,mandatory"` // Формат выходного файла JSON, CSV, bodyfile. По умолчанию CSV + OutputDirectory string `clap:"--output,-o,mandatory"` // Путь выходного файла + DiskLetter string `clap:"--disk-later,-bdl"` // Буква диска для bodyfile + LineFeed bool `clap:"--line-feed,-blf"` // Используемый конец строки bodyfile. true - LF, false - CRLF. По умолчанию false + // TODO: Найти описание аргументов + DD string `clap:"-dd"` // -dd + DO string `clap:"-do"` // -do + DE string `clap:"-de"` // -de + FLS bool `clap:"-fls"` // -fls + SecurityIdentifier bool `clap:"--security-identifier,-ds"` // Выводит полные детали для идентификатора безопасности в десятичном или шестнадцатеричном виде + DatetimeFormat string `clap:"--date-format,-dt"` // Формат даты и времени. По умолчанию yyyy-MM-dd HH:mm:ss.fffffff + FilenameType bool `clap:"--filename-type,-sn"` // Включает типы имён файлов DOS. По умолчанию false + FileListingBrief bool `clap:"--brief-filelisting,-fl"` // Включает сокращённый список файлов. Используется с CSV + AttributeLabel bool `clap:"--atribute-label,-at"` // Включает все временные метки из атрибута 0x30, а не только когда они отличаются от 0x10. По умолчанию false + VolumeShadowCopy bool `clap:"--volume-shadow-copy,-vss"` // Включает все теневые копии томов, которые существуют на диске. По умолчанию false + Dedup bool `clap:"--dedup"` // Убирает все дубликаты в теневых копиях на основе SHA1. Первый кандидат выигрывает. По умолчанию false + + Debug bool `clap:"--debug"` // Вывод дебаг-информации. По умолчанию false + Trace bool `clap:"--trace"` // Вывод информации трассировки. По умолчанию false +} + +// Установка значений по умолчанию для параметров +func setDefault() *Config { + cfg := &Config{ + FileFormat: "csv", + LineFeed: false, + DatetimeFormat: "yyyy-MM-dd HH:mm:ss.fffffff", + FilenameType: false, + AttributeLabel: false, + VolumeShadowCopy: false, + Dedup: false, + Debug: false, + Trace: false, + } + + return cfg +} + +// Запуск утилиты +// TODO: Поправить парсинг аргументов из консоли +func Init(args []string) (*clap.Results, error) { + cfg := setDefault() // Импорт параметров по умолчанию + + var ( + results *clap.Results // Массив результатов + err error + ) + + // Получение аргументов + if results, err = clap.Parse(args, cfg); err != nil { + return nil, err + } + + return results, nil +} + +func Run(results *clap.Results) { +}