script improvements

This commit is contained in:
Yuxin Wu
2016-06-18 22:24:20 -07:00
parent 76efd3836a
commit 386cfe39b7
2 changed files with 22 additions and 16 deletions
+11 -7
View File
@@ -65,19 +65,22 @@ Note that commands involving `./android-interact.sh` are meant to be run on the
+ Copy the WeChat user resource directory `/mnt/sdcard/tencent/MicroMsg/${userid}/{emoji,image2,sfs,video,voice2}` from the phone's SD card to the `resource` directory:
+ `./android-interact.sh res`
+ You might need to tweak `RES_DIR` in the script if the default doesn't work
+ This can take a __long__ time. Some ways to do this faster:
+ If there's enough free space on the SD card, you can combine all the files via `busybox tar` without compression in the `adb shell`, use `adb pull` to copy the `tar` archive to the computer, and then extract it. BusyBox is needed as the Android system's `tar` may choke on long paths.
+ Alternatively, you can use pipes. This is slower, but doesn't require any free space on the SD card:
+ You might need to change `RES_DIR` in the script if the default is incorrect on your phone.
+ This can take a __very long__ time. Some manual ways to do it faster:
+ If there's enough free space on your phone, you can archive all required files via `busybox tar` with or without compression in `adb shell`,
and use `adb pull` to copy the archive. Note that busyBox is needed as the Android system's `tar` may choke on long paths.
+ Alternatively, you can use pipes. This is slower, but doesn't require any free space on your phone.
```sh
# copy MicroMsg to the current directory
# This will copy the whole 'MicroMsg' to the current directory:
adb shell 'cd /mnt/sdcard/tencent &&
busybox tar czf - MicroMsg 2>/dev/null | busybox base64' |
base64 -di | tar xzf -
```
+ What you'll need in the end is a `resource` directory with the following subdir: `emoji,image2,sfs,video,voice2`.
+ (Optional) Download the emoji cache from [here](https://github.com/ppwwyyxx/wechat-dump/releases/download/0.1/emoji.cache) and put it in 'wechat-dump'. This will avoid downloading lots of emojis.
+ (Optional) Download the emoji cache from [here](https://github.com/ppwwyyxx/wechat-dump/releases/download/0.1/emoji.cache)
and put it under `wechat-dump`. This will avoid downloading lots of emojis in rendering.
#### Run:
+ Parse and dump text messages of __every__ chat (requires `decrypted.db`):
@@ -113,7 +116,8 @@ Screenshots of generated html:
### TODO List
+ Search by uid/username
+ Faster way to copy a directory from android (I don't know..).
+ Attack the emoji encryption problem
+ Use pipes by default to copy a directory from android
+ Fix rare unhandled types: > 10000 and < 0
+ Better user experiences... see `grep 'TODO' wechat -R`
+ more easy-to-use for non-programmers (GUI?)
+11 -9
View File
@@ -18,7 +18,7 @@ adb root
if [[ $1 == "uin" ]]; then
adb pull $MM_DIR/shared_prefs/system_config_prefs.xml 2>/dev/null
uin=$($GREP 'default_uin' system_config_prefs.xml | $GREP -o 'value="\-?[0-9]*' | cut -c 8-)
uin=$($GREP 'default_uin' system_config_prefs.xml | $GREP -o 'value=\"\-?[0-9]*' | cut -c 8-)
[[ -n $uin ]] || {
>&2 echo "Failed to get wechat uin. You can try other methods, or report a bug."
exit 1
@@ -37,12 +37,13 @@ elif [[ $1 == "imei" ]]; then
echo "Got imei: $imei"
elif [[ $1 == "db" || $1 == "res" ]]; then
echo "Looking for user dir name..."
sleep 1 # sometimes adb complains: device not found
userList=$(adb ls $RES_DIR | cut -f 4 -d ' ' \
sleep 1 # sometimes adb complains: device not found
# look for dirname which looks like md5 (32 alpha-numeric chars)
userList=$(adb ls $RES_DIR | cut -f 4 -d ' ' | sed 's/[^0-9a-z]//g' \
| awk '{if (length() == 32) print}')
numUser=$(echo $userList | wc -l)
numUser=$(echo "$userList" | wc -l)
# choose the first user.
chooseUser=$(echo $userList | head -n1)
chooseUser=$(echo "$userList" | head -n1)
[[ -n $chooseUser ]] || {
>&2 echo "Could not find user. Please check whether your resource dir is $RES_DIR"
exit 1
@@ -54,7 +55,7 @@ elif [[ $1 == "db" || $1 == "res" ]]; then
mkdir -p resource; cd resource
for d in image2 voice2 emoji video sfs; do
mkdir -p $d; cd $d
adb pull $RES_DIR/$chooseUser/$d
adb pull "$RES_DIR/$chooseUser/$d"
cd ..
[[ -d $d ]] || {
>&2 echo "Failed to download resource directory: $RES_DIR/$chooseUser/$d"
@@ -75,11 +76,12 @@ elif [[ $1 == "db" || $1 == "res" ]]; then
adb pull $MM_DIR/MicroMsg/$chooseUser/sfs/avatar.index
[[ -f avatar.index ]] && \
echo "Avatar index successfully downloaded to avatar.index" || {
>&2 echo "Failed to pull avatar index by adb, are you using latest version of wechat?"
exit 1
}
>&2 echo "Failed to pull avatar index by adb, are you using latest version of wechat?"
exit 1
}
fi
elif [[ $1 == "db-decrypt" ]]; then
set -e
echo "Getting uin..."
$0 uin | tail -n1 | $GREP -o '\-?[0-9]*' | tee /tmp/uin
echo "Getting imei..."