Skip to content

Commit

Permalink
ADB Download All Files (adb-haul.sh)
Browse files Browse the repository at this point in the history
  • Loading branch information
sickcodes committed Jun 17, 2021
1 parent 21b060e commit 2a03933
Showing 1 changed file with 78 additions and 0 deletions.
78 changes: 78 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,80 @@
# adb-download-all
ADB Download All Files - A dirty shell script to adb pull all readable files using adb pull & base64

If you are reverse engineering a hardware Android device, and was to see what interesting files you have read or executable permissions over, then this will mirror all touchable files.

# Alternatives:
## [https://github.com/spion/adbfs-rootless](https://github.com/spion/adbfs-rootless)

adbfs-rootless is great, except it shows unreadable files by the adb user.


# Script

This script is the also found in [./adb-haul.sh](adb-haul.sh)

```bash
#!/bin/bash
# Author: sickcodes
# Contact: https://twitter.com/sickcodes
# Copyright: sickcodes (C) 2021
# License: GPLv3+
# Project: https://github.com/sickcodes/adb-download-all

# IGNORE_DIRS=(
# '.'
# './proc'
# './dev'
# './sys'
# )

# OUTPUT_DIR="${PWD}"
OUTPUT_DIR=./output

mkdir -p "${OUTPUT_DIR}"

ROOT_DIRS=($(adb shell find -maxdepth 1))

for ROOT_DIR in "${ROOT_DIRS[@]}"; do {

# skip directories from IGNORE_DIRS
# [[ -n "${IGNORE_DIRS["${ROOT_DIR}"]}" ]] && continue

case "${ROOT_DIR}" in
'.' ) continue
;;
'./proc' ) continue
;;
'./dev' ) continue
;;
'./sys' ) continue
;;
esac

echo "### Pulling directory: ${ROOT_DIR}"

# find all files in the next folder and enter into an array
unset FILES
readarray -t FILES <<< "$(adb shell find "${ROOT_DIR}/" 2>/dev/null)"

echo "${FILES[@]}"

for FILE in "${FILES[@]}"; do {
OUTPUT_FILE="${OUTPUT_DIR}/${FILE}"
# create directories, rather than pull them
# skip symbolic links
case "$(adb shell file "${FILE}")" in
*directory* ) mkdir -p "${OUTPUT_FILE}" && continue
;;
*symbolic* ) continue
;;
* ) touch "${OUTPUT_FILE}"
;;
esac
# base64 encrypt and decrypt the file to the output directory
base64 -d <<< "$(adb shell "base64 < \"${FILE}\"")" > "${OUTPUT_FILE}"
}
done
}
done
```

0 comments on commit 2a03933

Please sign in to comment.