From b214eedf0d04a9accfd40500403ea981f759e70e Mon Sep 17 00:00:00 2001 From: JohnE Date: Sat, 26 Sep 2015 01:17:56 -0700 Subject: [PATCH] NEW: created script to pull all app files from a phone --- tools/pull_android_data.py | 50 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 tools/pull_android_data.py diff --git a/tools/pull_android_data.py b/tools/pull_android_data.py new file mode 100644 index 0000000..f09f364 --- /dev/null +++ b/tools/pull_android_data.py @@ -0,0 +1,50 @@ +# +# +# +import re +from subprocess import Popen, PIPE, check_call + + +def androidPullData(): + dir_names = [] + # call adb shel command to parse the file system + process = Popen(["adb", "shell", "ls", "-l", "/data/data"], stdout=PIPE, stderr=PIPE) + stdout, stderr = process.communicate() + strings = stdout.split('\n') + for sstr in strings: + results = re.search(r'\s(\w+\.[\w|\.]+)', sstr) + if results: + dir_names.append(results.group(1)) + + for fdir in dir_names: + print "[{}]".format(fdir) + ret = check_call(["mkdir", fdir]) + if (ret > 0): + print "ERROR: problem creating directory {}".format(ret) + else: + print "Pulling data from directory {}".format("/data/data/"+fdir) + process = Popen(["adb", "pull", "/data/data/"+fdir], stdout=PIPE, stderr=PIPE, cwd=fdir) + stdout, stderr = process.communicate() + # if stderr: + # print "ERROR: {}".format(stderr) + # else: + # print "[COMPLETE]" + # print "COMPLETED!!!" + # print "STDERR ==\n {}".format(stderr) + # print "STDOUT == n {}".format(stdout) + + +def adbCheck(): + # check that adb is executable + # check that adb is in root mode + return True + + +def main(): + if adbCheck(): + androidPullData() + return + + +if __name__ == "__main__": + main()