31

我一直在尝试使用 adb 从设备中提取整个 sms/mms 收件箱,但遇到了一些麻烦。手机已root,我尝试了以下命令:

输入

./adb pull /data/data/com.android.providers.telephony/databases/mmssms.db

输出

Permission denied

输入

./adb pull su /data/data/com.android.providers.telephony/databases/mmssms.db

输出

The help menu

我是否认为我可以通过类似于我尝试过的命令来拉取短信收件箱?如果可以做到,我的命令有什么问题?

谢谢

4

3 回答 3

45

获取 /data 目录内容的一种方法是首先将 sqlite db 复制到可访问的位置,然后使用 adb pull 从那里复制到主机。

例如,以下命令使用 android bridge 来抓取 sms 数据(假设它包含在 /data/data/com.android.providers.telephony/databases/mmssms.db 中):

adb shell
$ mkdir /mnt/sdcard/tmp
# su
# cat /data/data/com.android.providers.telephony/databases/mmssms.db > /mnt/sdcard/tmp/mmssms.db
# exit
$ exit
adb pull /mnt/sdcard/tmp/mmssms.db .

现在您的主机上有 mms/sms 数据库,探测以查找最受欢迎的收件人,例如:

sqlite3 -header mmssms.db 'select address from sms' | sort -n | uniq -c | sort -n

最后,整理临时区域:

adb shell
$ rm /mnt/sdcard/tmp/mmssms.db
$ rmdir /mnt/sdcard/tmp
$ exit
于 2012-12-16T19:01:26.777 回答
9

在拉取该数据库之前,您必须授予 ADB 根特权

adb root

adb pull /data/data/com.android.providers.telephony/databases/mmssms.db ./
于 2016-04-06T15:08:48.780 回答
4

感谢@Bonlenfum 的回答,我能够想出一个可重用的脚本,用于将有根设备上的任何文件/目录复制到 Windows 路径(本地或 UNC)。


编辑:修复了包含空格的路径的错误。


将以下内容另存为:adbSuPull.bat

@echo off

SetLocal
set RemotePath=%~1
set LocalPath=%~f2

if [%1] == [] goto Usage
if "%~1" == "/?" goto Usage
if not [%3] == [] goto Usage

:: Replace " " with "\ " (escape spaces)
set RemotePath=%RemotePath: =\ %

set TimeStamp=%date:~-4,4%-%date:~-10,2%-%date:~-7,2%_%time:~-11,2%-%time:~-8,2%-%time:~-5,2%

:: Replace spaces with zeros
set TimeStamp=%TimeStamp: =0%

if "%LocalPath%" == "" set LocalPath=adbSuPull_%UserName%_%TimeStamp%
set SdCardPath=/mnt/sdcard
set TempPath=%SdCardPath%/adbSuPull_temp_%TimeStamp%/

echo.
echo Copying to temp location "%TempPath%"
echo.
adb shell "su -c 'mkdir -p %TempPath%; cp -RLv %RemotePath% %TempPath%'"

echo.
echo Copying to destination "%LocalPath%"
echo.
adb pull "%TempPath%" "%LocalPath%"
if ErrorLevel 0 goto Cleanup

:Error
echo.
echo Operation failed. Is USB Storage in use?
echo.
pause
call Cleanup
exit /b 1

:Cleanup
echo.
echo Removing temp location "%TempPath%"
echo.
adb shell "rm -Rf '%TempPath%'"
exit /b ErrorLevel

:Usage
echo.
echo.adbSuPull ^<RemotePath^> [^<LocalPath^>]
echo.
echo Copies files/directories from a rooted Android device to a Windows path.
echo Author: Ben Lemmond benlemmond@codeglue.org
echo.
echo.  RemotePath (required)  Specifies the path to the file or directory on
echo.                         the rooted Android device.
echo.
echo.  LocalPath (optional)   Specifies the destination path. This can be a
echo.                         Windows local path (C:\folder) or a UNC path
echo.                         (\\server\share).
echo.                         Defaults to adbSuPull_%%UserName%%_%%TimeStamp%%
echo.                         in the current working directory.
exit /b 1

用法:

adbSuPull <RemotePath> [<LocalPath>]

Copies files/directories from a rooted Android device to a Windows path.
Author: Ben Lemmond benlemmond@codeglue.org

  RemotePath (required)  Specifies the path to the file or directory on
                         the rooted Android device.

  LocalPath (optional)   Specifies the destination path. This can be a
                         Windows local path (C:\folder) or a UNC path
                         (\\server\share).
                         Defaults to adbSuPull_%UserName%_%TimeStamp%
                         in the current working directory.
于 2014-08-09T23:52:54.927 回答