Skip to content

Commit

Permalink
Consider unusual sdcard path
Browse files Browse the repository at this point in the history
  • Loading branch information
Te-k committed Jan 25, 2024
1 parent b8f2c9e commit 163d761
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 26 deletions.
43 changes: 17 additions & 26 deletions acquisition/acquisition.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ type Acquisition struct {
Completed time.Time `json:"completed"`
Collector *adb.Collector `json:"collector"`
TmpDir string `json:"tmp_dir"`
SdCard string `json:"sdcard"`
Cpu string `json:"cpu"`
}

Expand Down Expand Up @@ -93,24 +94,6 @@ func (a *Acquisition) Complete() {
assets.CleanAssets()
}

/*func (a *Acquisition) initADB() error {
var err error
a.ADB, err = adb.New()
if err != nil {
log.Debugf("failed to initialize adb: %v", err)
return fmt.Errorf("failed to initialize adb: %v", err)
}
_, err = a.ADB.GetState()
if err != nil {
log.Debugf("failed to get adb state: %v", err)
return fmt.Errorf("failed to get adb state (are you sure a device is connected?): %v",
err)
}
return nil
}*/

func (a *Acquisition) GetSystemInformation() error {
// Get architecture information
out, err := adb.Client.Shell("getprop ro.product.cpu.abi")
Expand All @@ -125,18 +108,26 @@ func (a *Acquisition) GetSystemInformation() error {
if err != nil {
return fmt.Errorf("failed to run `adb shell env`: %v", err)
}
tmpFolder := ""
a.TmpDir = "/data/local/tmp/"
a.SdCard = "/sdcard/"
for _, line := range strings.Split(out, "\n") {
line = strings.TrimSpace(line)
if strings.HasPrefix(line, "TMPDIR=") {
tmpFolder = strings.TrimPrefix(line, "TMPDIR=")
a.TmpDir = strings.TrimPrefix(line, "TMPDIR=")
}
}
if tmpFolder == "" {
tmpFolder = "/data/local/tmp"
}
a.TmpDir = tmpFolder
log.Debugf("Found temp folder/ %s", tmpFolder)
if strings.HasPrefix(line, "EXTERNAL_STORAGE=") {
a.SdCard = strings.TrimPrefix(line, "EXTERNAL_STORAGE=")
}
}
if !strings.HasSuffix(a.TmpDir, "/") {
a.TmpDir = a.TmpDir + "/"
}
if !strings.HasSuffix(a.SdCard, "/") {
a.SdCard = a.SdCard + "/"
}

log.Debugf("Found temp folder at %s", a.TmpDir)
log.Debugf("Found sdcard at %s", a.SdCard)
return nil
}

Expand Down
3 changes: 3 additions & 0 deletions modules/files.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ func (f *Files) Run(acq *acquisition.Acquisition, fast bool) error {
if acq.TmpDir != "/data/local/tmp/" {
folders = append(folders, acq.TmpDir)
}
if acq.SdCard != "/sdcard/" {
folders = append(folders, acq.SdCard)
}

for _, folder := range folders {
var out []adb.FileInfo
Expand Down

0 comments on commit 163d761

Please sign in to comment.