Skip to content

Commit d71c696

Browse files
besendorfJanik Besendorf
andauthored
add bugreport module (#41)
Co-authored-by: Janik Besendorf <jb@reporter-ohne-grenzen.de>
1 parent 95be608 commit d71c696

File tree

3 files changed

+71
-0
lines changed

3 files changed

+71
-0
lines changed

adb/adb.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,13 @@ func (a *ADB) Backup(arg string) error {
9191
return cmd.Run()
9292
}
9393

94+
// Bugreport generates a bugreport of the the device
95+
func (a *ADB) Bugreport() error {
96+
cmd := exec.Command(a.ExePath, "bugreport", "bugreport.zip")
97+
err := cmd.Run()
98+
return err
99+
}
100+
94101
// check if file exists
95102
func (a *ADB) FileExists(path string) (bool, error) {
96103
out, err := a.Shell("[", "-f", path, "] || echo 1")

modules/bugreport.go

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
// androidqf - Android Quick Forensics
2+
// Copyright (c) 2021-2023 Claudio Guarnieri.
3+
// Use of this software is governed by the MVT License 1.1 that can be found at
4+
// https://license.mvt.re/1.1/
5+
6+
package modules
7+
8+
import (
9+
"os"
10+
"path/filepath"
11+
12+
"github.com/mvt-project/androidqf/acquisition"
13+
"github.com/mvt-project/androidqf/adb"
14+
"github.com/mvt-project/androidqf/log"
15+
)
16+
17+
type Bugreport struct {
18+
StoragePath string
19+
}
20+
21+
func NewBugreport() *Bugreport {
22+
return &Bugreport{}
23+
}
24+
25+
func (b *Bugreport) Name() string {
26+
return "bugreport"
27+
}
28+
29+
func (b *Bugreport) InitStorage(storagePath string) error {
30+
b.StoragePath = storagePath
31+
return nil
32+
}
33+
34+
func (b *Bugreport) Run(acq *acquisition.Acquisition, fast bool) error {
35+
36+
log.Info(
37+
"Generating a bugreport for the device...",
38+
)
39+
40+
err := adb.Client.Bugreport()
41+
if err != nil {
42+
log.Debugf("Impossible to generate bugreport: %w", err)
43+
return err
44+
}
45+
46+
cwd, err := os.Getwd()
47+
if err != nil {
48+
log.Debugf("Impossible to get current directory: %w", err)
49+
return err
50+
}
51+
52+
origBugreportPath := filepath.Join(cwd, "bugreport.zip")
53+
bugreportPath := filepath.Join(b.StoragePath, "bugreport.zip")
54+
55+
err = os.Rename(origBugreportPath, bugreportPath)
56+
if err != nil {
57+
return err
58+
}
59+
60+
log.Info("Bugreport completed!")
61+
62+
return nil
63+
}

modules/modules.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ type Module interface {
2121
func List() []Module {
2222
return []Module{
2323
NewBackup(),
24+
NewBugreport(),
2425
NewPackages(),
2526
NewGetProp(),
2627
NewDumpsys(),

0 commit comments

Comments
 (0)