-
Notifications
You must be signed in to change notification settings - Fork 8
/
main.go
149 lines (128 loc) · 3.8 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
// androidqf - Android Quick Forensics
// Copyright (c) 2021-2022 Claudio Guarnieri.
// Use of this software is governed by the MVT License 1.1 that can be found at
// https://license.mvt.re/1.1/
package main
import (
"flag"
"fmt"
"os"
"time"
"github.com/i582/cfmt/cmd/cfmt"
"github.com/mvt-project/androidqf/acquisition"
"github.com/mvt-project/androidqf/adb"
"github.com/mvt-project/androidqf/log"
"github.com/mvt-project/androidqf/modules"
"github.com/mvt-project/androidqf/utils"
)
func init() {
cfmt.Print(`
{{ __ _ __ ____ }}::green
{{ ____ ____ ____/ /________ (_)___/ /___ / __/ }}::yellow
{{ / __ '/ __ \/ __ / ___/ __ \/ / __ / __ '/ /_ }}::red
{{ / /_/ / / / / /_/ / / / /_/ / / /_/ / /_/ / __/ }}::magenta
{{ \__,_/_/ /_/\__,_/_/ \____/_/\__,_/\__, /_/ }}::blue
{{ /_/ }}::cyan
`)
cfmt.Println("\tandroidqf - Android Quick Forensics")
cfmt.Println()
}
func systemPause() {
cfmt.Println("Press {{Enter}}::bold|green to finish ...")
os.Stdin.Read(make([]byte, 1))
}
func main() {
var err error
var verbose bool
var version_flag bool
var list_modules bool
var fast bool
var module string
var output_folder string
var serial string
// Command line options
flag.BoolVar(&verbose, "verbose", false, "Verbose mode")
flag.BoolVar(&verbose, "v", false, "Verbose mode")
flag.BoolVar(&fast, "fast", false, "Fast mode")
flag.BoolVar(&verbose, "f", false, "Fast mode")
flag.BoolVar(&list_modules, "list", false, "List modules and exit")
flag.BoolVar(&list_modules, "l", false, "List modules and exit")
flag.StringVar(&module, "module", "", "Only execute a specific module")
flag.StringVar(&module, "m", "", "Only execute a specific module")
flag.StringVar(&output_folder, "output", "", "Output folder")
flag.StringVar(&output_folder, "o", "", "Output folder")
flag.StringVar(&serial, "serial", "", "Phone serial number")
flag.StringVar(&serial, "s", "", "Phone serial number")
flag.BoolVar(&version_flag, "version", false, "Show version")
flag.Parse()
if verbose {
log.SetLogLevel(log.DEBUG)
}
if version_flag {
log.Infof("AndroidQF version: %s", utils.Version)
os.Exit(0)
}
if list_modules {
mods := modules.List()
log.Info("List of modules:")
for _, mod := range mods {
log.Infof("- %s", mod.Name())
}
os.Exit(0)
}
log.Debug("Starting androidqf")
adb.Client, err = adb.New(serial)
if err != nil {
log.Fatal("Impossible to initialize adb: ", err)
}
// Initialization
for {
_, err = adb.Client.GetState()
if err == nil {
break
}
log.Debug(err)
log.Error("Unable to get device state. Please make sure it is connected and authorized. Trying again in 5 seconds...")
time.Sleep(5 * time.Second)
}
acq, err := acquisition.New(output_folder)
if err != nil {
log.Debug(err)
log.FatalExc("Impossible to initialise the acquisition", err)
}
// Start acquisitions
log.Info(fmt.Sprintf("Started new acquisition in %s", acq.StoragePath))
mods := modules.List()
for _, mod := range mods {
if (module != "") && (module != mod.Name()) {
continue
}
err = mod.InitStorage(acq.StoragePath)
if err != nil {
log.Infof(
"ERROR: failed to initialize storage for module %s: %v",
mod.Name(),
err,
)
continue
}
err = mod.Run(acq, fast)
if err != nil {
log.Infof("ERROR: failed to run module %s: %v", mod.Name(), err)
}
}
err = acq.HashFiles()
if err != nil {
log.ErrorExc("Failed to generate list of file hashes", err)
return
}
acq.Complete()
acq.StoreInfo()
err = acq.StoreSecurely()
if err != nil {
log.ErrorExc("Something failed while encrypting the acquisition", err)
log.Warning("WARNING: The secure storage of the acquisition folder failed! The data is unencrypted!")
}
log.Info("Acquisition completed.")
systemPause()
}