|
1 | 1 | # adb-download-all |
2 | 2 | ADB Download All Files - A dirty shell script to adb pull all readable files using adb pull & base64 |
| 3 | + |
| 4 | +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. |
| 5 | + |
| 6 | +# Alternatives: |
| 7 | +## [https://github.com/spion/adbfs-rootless](https://github.com/spion/adbfs-rootless) |
| 8 | + |
| 9 | +adbfs-rootless is great, except it shows unreadable files by the adb user. |
| 10 | + |
| 11 | + |
| 12 | +# Script |
| 13 | + |
| 14 | +This script is the also found in [./adb-haul.sh](adb-haul.sh) |
| 15 | + |
| 16 | +```bash |
| 17 | +#!/bin/bash |
| 18 | +# Author: sickcodes |
| 19 | +# Contact: https://twitter.com/sickcodes |
| 20 | +# Copyright: sickcodes (C) 2021 |
| 21 | +# License: GPLv3+ |
| 22 | +# Project: https://github.com/sickcodes/adb-download-all |
| 23 | + |
| 24 | +# IGNORE_DIRS=( |
| 25 | +# '.' |
| 26 | +# './proc' |
| 27 | +# './dev' |
| 28 | +# './sys' |
| 29 | +# ) |
| 30 | + |
| 31 | +# OUTPUT_DIR="${PWD}" |
| 32 | +OUTPUT_DIR=./output |
| 33 | + |
| 34 | +mkdir -p "${OUTPUT_DIR}" |
| 35 | + |
| 36 | +ROOT_DIRS=($(adb shell find -maxdepth 1)) |
| 37 | + |
| 38 | +for ROOT_DIR in "${ROOT_DIRS[@]}"; do { |
| 39 | + |
| 40 | + # skip directories from IGNORE_DIRS |
| 41 | + # [[ -n "${IGNORE_DIRS["${ROOT_DIR}"]}" ]] && continue |
| 42 | + |
| 43 | + case "${ROOT_DIR}" in |
| 44 | + '.' ) continue |
| 45 | + ;; |
| 46 | + './proc' ) continue |
| 47 | + ;; |
| 48 | + './dev' ) continue |
| 49 | + ;; |
| 50 | + './sys' ) continue |
| 51 | + ;; |
| 52 | + esac |
| 53 | + |
| 54 | + echo "### Pulling directory: ${ROOT_DIR}" |
| 55 | + |
| 56 | + # find all files in the next folder and enter into an array |
| 57 | + unset FILES |
| 58 | + readarray -t FILES <<< "$(adb shell find "${ROOT_DIR}/" 2>/dev/null)" |
| 59 | + |
| 60 | + echo "${FILES[@]}" |
| 61 | + |
| 62 | + for FILE in "${FILES[@]}"; do { |
| 63 | + OUTPUT_FILE="${OUTPUT_DIR}/${FILE}" |
| 64 | + # create directories, rather than pull them |
| 65 | + # skip symbolic links |
| 66 | + case "$(adb shell file "${FILE}")" in |
| 67 | + *directory* ) mkdir -p "${OUTPUT_FILE}" && continue |
| 68 | + ;; |
| 69 | + *symbolic* ) continue |
| 70 | + ;; |
| 71 | + * ) touch "${OUTPUT_FILE}" |
| 72 | + ;; |
| 73 | + esac |
| 74 | + # base64 encrypt and decrypt the file to the output directory |
| 75 | + base64 -d <<< "$(adb shell "base64 < \"${FILE}\"")" > "${OUTPUT_FILE}" |
| 76 | + } |
| 77 | + done |
| 78 | +} |
| 79 | +done |
| 80 | +``` |
0 commit comments