Skip to content

Commit 2a03933

Browse files
committed
ADB Download All Files (adb-haul.sh)
1 parent 21b060e commit 2a03933

File tree

1 file changed

+78
-0
lines changed

1 file changed

+78
-0
lines changed

README.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,80 @@
11
# adb-download-all
22
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

Comments
 (0)