Skip to content

Commit 0b39878

Browse files
committed
Adds fast mode
1 parent 7ca493b commit 0b39878

18 files changed

+46
-38
lines changed

acquisition/acquisition.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ func New() (*Acquisition, error) {
5454

5555
coll, err := adb.Client.GetCollector(acq.TmpDir, acq.Cpu)
5656
if err != nil {
57+
// Collector install failed, will use find instead
5758
log.Debugf("failed to upload collector: %v", err)
58-
return nil, fmt.Errorf("failed to upload collector: %v", err)
5959
}
6060
acq.Collector = coll
6161

adb/packages.go

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ type Package struct {
3939
ThirdParty bool `json:"third_party"`
4040
}
4141

42-
func (a *ADB) getPackageFiles(packageName string) []PackageFile {
42+
func (a *ADB) getPackageFiles(packageName string, fast bool) []PackageFile {
4343
out, err := a.Shell("pm", "path", packageName)
4444
if err != nil {
4545
log.Errorf("Failed to get file paths for package %s: %v: %s", packageName, err, out)
@@ -57,23 +57,25 @@ func (a *ADB) getPackageFiles(packageName string) []PackageFile {
5757
Path: packagePath,
5858
}
5959

60-
// Not sure if this is useful or not considering packages may
61-
// be downloaded later on
62-
md5Out, err := a.Shell("md5sum", packagePath)
63-
if err == nil {
64-
packageFile.MD5 = strings.SplitN(md5Out, " ", 2)[0]
65-
}
66-
sha1Out, err := a.Shell("sha1sum", packagePath)
67-
if err == nil {
68-
packageFile.SHA1 = strings.SplitN(sha1Out, " ", 2)[0]
69-
}
70-
sha256Out, err := a.Shell("sha256sum", packagePath)
71-
if err == nil {
72-
packageFile.SHA256 = strings.SplitN(sha256Out, " ", 2)[0]
73-
}
74-
sha512Out, err := a.Shell("sha512sum", packagePath)
75-
if err == nil {
76-
packageFile.SHA512 = strings.SplitN(sha512Out, " ", 2)[0]
60+
if !fast {
61+
// Not sure if this is useful or not considering packages may
62+
// be downloaded later on
63+
md5Out, err := a.Shell("md5sum", packagePath)
64+
if err == nil {
65+
packageFile.MD5 = strings.SplitN(md5Out, " ", 2)[0]
66+
}
67+
sha1Out, err := a.Shell("sha1sum", packagePath)
68+
if err == nil {
69+
packageFile.SHA1 = strings.SplitN(sha1Out, " ", 2)[0]
70+
}
71+
sha256Out, err := a.Shell("sha256sum", packagePath)
72+
if err == nil {
73+
packageFile.SHA256 = strings.SplitN(sha256Out, " ", 2)[0]
74+
}
75+
sha512Out, err := a.Shell("sha512sum", packagePath)
76+
if err == nil {
77+
packageFile.SHA512 = strings.SplitN(sha512Out, " ", 2)[0]
78+
}
7779
}
7880

7981
packageFiles = append(packageFiles, packageFile)
@@ -83,7 +85,7 @@ func (a *ADB) getPackageFiles(packageName string) []PackageFile {
8385
}
8486

8587
// GetPackages returns the list of installed package names.
86-
func (a *ADB) GetPackages() ([]Package, error) {
88+
func (a *ADB) GetPackages(fast bool) ([]Package, error) {
8789
withInstaller := true
8890
out, err := a.Shell("pm", "list", "packages", "-U", "-u", "-i")
8991
if err != nil {
@@ -121,7 +123,7 @@ func (a *ADB) GetPackages() ([]Package, error) {
121123
Disabled: false,
122124
System: false,
123125
ThirdParty: false,
124-
Files: a.getPackageFiles(packageName),
126+
Files: a.getPackageFiles(packageName, fast),
125127
}
126128

127129
packages = append(packages, newPackage)

main.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,14 @@ func main() {
4040
var err error
4141
var verbose bool
4242
var list_modules bool
43+
var fast bool
4344
var module string
4445

4546
// Command line options
4647
flag.BoolVar(&verbose, "verbose", false, "Verbose mode")
4748
flag.BoolVar(&verbose, "v", false, "Verbose mode")
49+
flag.BoolVar(&fast, "fast", false, "Fast mode")
50+
flag.BoolVar(&verbose, "f", false, "Fast mode")
4851
flag.BoolVar(&list_modules, "list", false, "List modules and exit")
4952
flag.BoolVar(&list_modules, "l", false, "List modules and exit")
5053
flag.StringVar(&module, "module", "", "Only execute a specific module")
@@ -105,7 +108,7 @@ func main() {
105108
continue
106109
}
107110

108-
err = mod.Run(acq)
111+
err = mod.Run(acq, fast)
109112
if err != nil {
110113
log.Infof("ERROR: failed to run module %s: %v", mod.Name(), err)
111114
}

modules/backup.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func (b *Backup) InitStorage(storagePath string) error {
3939
return nil
4040
}
4141

42-
func (b *Backup) Run(acq *acquisition.Acquisition) error {
42+
func (b *Backup) Run(acq *acquisition.Acquisition, fast bool) error {
4343
log.Info("Would you like to take a backup of the device?")
4444
promptBackup := promptui.Select{
4545
Label: "Backup",

modules/dumpsys.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func (d *Dumpsys) InitStorage(storagePath string) error {
3030
return nil
3131
}
3232

33-
func (d *Dumpsys) Run(acq *acquisition.Acquisition) error {
33+
func (d *Dumpsys) Run(acq *acquisition.Acquisition, fast bool) error {
3434
log.Info("Collecting device diagnostic information. This might take a while...")
3535

3636
out, err := adb.Client.Shell("dumpsys")

modules/env.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func (e *Environment) InitStorage(storagePath string) error {
3030
return nil
3131
}
3232

33-
func (e *Environment) Run(acq *acquisition.Acquisition) error {
33+
func (e *Environment) Run(acq *acquisition.Acquisition, fast bool) error {
3434
log.Info("Collecting environment...")
3535

3636
out, err := adb.Client.Shell("env")

modules/files.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func (f *Files) InitStorage(storagePath string) error {
3030
return nil
3131
}
3232

33-
func (f *Files) Run(acq *acquisition.Acquisition) error {
33+
func (f *Files) Run(acq *acquisition.Acquisition, fast bool) error {
3434
log.Info("Collecting list of files... This might take a while...")
3535
var fileFounds []string
3636
var fileDetails []adb.FileInfo

modules/getprop.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func (g *GetProp) InitStorage(storagePath string) error {
3030
return nil
3131
}
3232

33-
func (g *GetProp) Run(acq *acquisition.Acquisition) error {
33+
func (g *GetProp) Run(acq *acquisition.Acquisition, fast bool) error {
3434
log.Info("Collecting device properties...")
3535

3636
out, err := adb.Client.Shell("getprop")

modules/logcat.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func (l *Logcat) InitStorage(storagePath string) error {
3030
return nil
3131
}
3232

33-
func (l *Logcat) Run(acq *acquisition.Acquisition) error {
33+
func (l *Logcat) Run(acq *acquisition.Acquisition, fast bool) error {
3434
log.Info("Collecting logcat...")
3535

3636
out, err := adb.Client.Shell("logcat", "-d", "-b", "all", "\"*:V\"")

modules/logs.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func (l *Logs) InitStorage(storagePath string) error {
4040
return nil
4141
}
4242

43-
func (l *Logs) Run(acq *acquisition.Acquisition) error {
43+
func (l *Logs) Run(acq *acquisition.Acquisition, fast bool) error {
4444
log.Info("Collecting system logs...")
4545

4646
logFiles := []string{
@@ -62,11 +62,14 @@ func (l *Logs) Run(acq *acquisition.Acquisition) error {
6262
}
6363

6464
logFiles = append(logFiles, files...)
65+
log.Debugf("Files in %s: %s", logFolder, files)
6566
}
6667

6768
for _, logFile := range logFiles {
6869
localPath := filepath.Join(l.LogsPath, logFile)
6970
localDir, _ := filepath.Split(localPath)
71+
log.Debugf("From: %s", logFile)
72+
log.Debugf("To: %s", localPath)
7073

7174
err := os.MkdirAll(localDir, 0o755)
7275
if err != nil {

modules/modules.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515
type Module interface {
1616
Name() string
1717
InitStorage(storagePath string) error
18-
Run(acq *acquisition.Acquisition) error
18+
Run(acq *acquisition.Acquisition, fast bool) error
1919
}
2020

2121
func List() []Module {

modules/packages.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,10 @@ func (p *Packages) getPathToLocalCopy(packageName, filePath string) string {
7575
return localPath
7676
}
7777

78-
func (p *Packages) Run(acq *acquisition.Acquisition) error {
78+
func (p *Packages) Run(acq *acquisition.Acquisition, fast bool) error {
7979
log.Info("Collecting information on installed apps. This might take a while...")
8080

81-
packages, err := adb.Client.GetPackages()
81+
packages, err := adb.Client.GetPackages(fast)
8282
if err != nil {
8383
return fmt.Errorf("failed to retrieve list of installed packages: %v", err)
8484
}

modules/processes.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func (p *Processes) InitStorage(storagePath string) error {
3030
return nil
3131
}
3232

33-
func (p *Processes) Run(acq *acquisition.Acquisition) error {
33+
func (p *Processes) Run(acq *acquisition.Acquisition, fast bool) error {
3434
log.Info("Collecting list of running processes...")
3535

3636
if acq.Collector == nil {

modules/root_binaries.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func (r *RootBinaries) InitStorage(storagePath string) error {
3131
return nil
3232
}
3333

34-
func (r *RootBinaries) Run(acq *acquisition.Acquisition) error {
34+
func (r *RootBinaries) Run(acq *acquisition.Acquisition, fast bool) error {
3535
log.Info("Checking for traces of rooting")
3636
root_binaries := []string{
3737
"su",

modules/selinux.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func (s *SELinux) InitStorage(storagePath string) error {
3030
return nil
3131
}
3232

33-
func (s *SELinux) Run(acq *acquisition.Acquisition) error {
33+
func (s *SELinux) Run(acq *acquisition.Acquisition, fast bool) error {
3434
log.Info("Collecting SELinux status...")
3535

3636
out, err := adb.Client.Shell("getenforce")

modules/services.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func (s *Services) InitStorage(storagePath string) error {
3030
return nil
3131
}
3232

33-
func (s *Services) Run(acq *acquisition.Acquisition) error {
33+
func (s *Services) Run(acq *acquisition.Acquisition, fast bool) error {
3434
log.Info("Collecting list of services...")
3535

3636
out, err := adb.Client.Shell("service list")

modules/settings.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func (s *Settings) InitStorage(storagePath string) error {
3030
return nil
3131
}
3232

33-
func (s *Settings) Run(acq *acquisition.Acquisition) error {
33+
func (s *Settings) Run(acq *acquisition.Acquisition, fast bool) error {
3434
log.Info("Collecting device settings...")
3535

3636
for _, namespace := range []string{"system", "secure", "global"} {

modules/temp.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func (t *Temp) InitStorage(storagePath string) error {
3939
return nil
4040
}
4141

42-
func (t *Temp) Run(acq *acquisition.Acquisition) error {
42+
func (t *Temp) Run(acq *acquisition.Acquisition, fast bool) error {
4343
log.Info("Collecting files in tmp folder...")
4444

4545
// TODO: Also check default tmp folders

0 commit comments

Comments
 (0)