-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
202 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
// Mount forensic raw or dd disk images for read-only processing. | ||
// | ||
// Usage: | ||
// | ||
// fmount.dd [-fsuzhv] [-H CRC32|MD5|SHA1|SHA256] [-V SUM] [-D DIRECTORY] IMAGE | ||
// | ||
// The flags are: | ||
// | ||
// -D directory | ||
// The mount point directory. | ||
// -H algorithm | ||
// The hash algorithm to use. | ||
// -V sum | ||
// The hash sum to verify. | ||
// -f | ||
// Force type (bypass check). | ||
// -s | ||
// System partition only. | ||
// -u | ||
// Unmount image. | ||
// -z | ||
// Unzip image. | ||
// -h | ||
// Show usage. | ||
// -v | ||
// Show version. | ||
// | ||
// The arguments are: | ||
// | ||
// image | ||
// The disk images filename. | ||
package main | ||
|
||
import ( | ||
"flag" | ||
"io" | ||
"strings" | ||
|
||
"github.com/cuhsat/fact/internal/fact" | ||
"github.com/cuhsat/fact/internal/sys" | ||
"github.com/cuhsat/fact/pkg/fmount" | ||
"github.com/cuhsat/fact/pkg/fmount/dd" | ||
) | ||
|
||
func main() { | ||
D := flag.String("D", "", "Mount point") | ||
H := flag.String("H", "", "Hash algorithm") | ||
V := flag.String("V", "", "Hash sum") | ||
f := flag.Bool("f", false, "Force mounting") | ||
s := flag.Bool("s", false, "System partition only") | ||
u := flag.Bool("u", false, "Unmount image") | ||
z := flag.Bool("z", false, "Unzip image") | ||
h := flag.Bool("h", false, "Show usage") | ||
v := flag.Bool("v", false, "Show version") | ||
|
||
flag.CommandLine.SetOutput(io.Discard) | ||
flag.Parse() | ||
|
||
img := sys.Arg() | ||
|
||
if *v { | ||
sys.Print("fmount.dd", fact.Version) | ||
} | ||
|
||
if *h || len(img) == 0 { | ||
sys.Usage("fmount.dd [-fsuzhv] [-H CRC32|MD5|SHA1|SHA256] [-V SUM] [-D DIRECTORY] IMAGE") | ||
} | ||
|
||
if *z { | ||
ex, err := fmount.Extract(img) | ||
|
||
if err != nil { | ||
sys.Fatal(err) | ||
} else { | ||
img = ex | ||
} | ||
} | ||
|
||
if (len(*H) == 0) != (len(*V) == 0) { | ||
sys.Fatal("hash algorithm and sum are required") | ||
} | ||
|
||
if len(*H) > 0 && len(*V) > 0 { | ||
ok, err := fmount.Verify(img, *H, *V) | ||
|
||
if err != nil { | ||
sys.Fatal(err) | ||
} | ||
|
||
if !ok { | ||
sys.Fatal("hash sum does not match") | ||
} | ||
} | ||
|
||
if !*f { | ||
is, err := dd.Is(img) | ||
|
||
if err != nil { | ||
sys.Fatal(err) | ||
} | ||
|
||
if !is { | ||
sys.Fatal("image type not supported") | ||
} | ||
} | ||
|
||
if *u { | ||
dd.Unmount(img) | ||
return | ||
} | ||
|
||
p, err := dd.Mount(img, *D, *s) | ||
|
||
if err != nil { | ||
sys.Fatal(err) | ||
} | ||
|
||
sys.Print(strings.Join(p, "\n")) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// FACT definitions. | ||
// Fact definitions. | ||
package fact | ||
|
||
// Set at compile time | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// FACT 3rd party functions. | ||
// Fact implementation details. | ||
package fact | ||
|
||
import ( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Fact implementation tests. | ||
package fact | ||
|
||
import ( | ||
"os" | ||
"testing" | ||
) | ||
|
||
func TestTools(t *testing.T) { | ||
cases := []struct { | ||
name, tool string | ||
}{ | ||
{ | ||
name: "Test for EvtxECmd", | ||
tool: "EvtxECmd.dll", | ||
}, | ||
} | ||
|
||
for _, tt := range cases { | ||
t.Run(tt.name, func(t *testing.T) { | ||
p, err := EzTools(tt.tool) | ||
|
||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
if len(p) == 0 { | ||
t.Fatal(tt.tool + " not found") | ||
} | ||
|
||
if _, err := os.Stat(p); os.IsNotExist(err) { | ||
t.Fatal(tt.tool + " not found") | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// Evtx implementation tests. | ||
package evtx |
Oops, something went wrong.