diff --git a/android-interact.sh b/android-interact.sh index ba2d890..3b2ed33 100755 --- a/android-interact.sh +++ b/android-interact.sh @@ -2,7 +2,10 @@ # File: android-interact.sh # Date: Sun Jan 11 23:05:58 2015 +0800 # Author: Yuxin Wu -PROG_NAME=`readlink -f "$0"` + +source compatibility.sh + +PROG_NAME=`$REALPATH "$0"` PROG_DIR=`dirname "$PROG_NAME"` cd "$PROG_DIR" @@ -15,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 ]] || { echo "Failed to get wechat uin. You can try other methods, or report a bug." exit 1 @@ -23,7 +26,7 @@ if [[ $1 == "uin" ]]; then rm system_config_prefs.xml echo "Got wechat uin: $uin" elif [[ $1 == "imei" ]]; then - imei=$(adb shell dumpsys iphonesubinfo | grep 'Device ID' | grep -o '[0-9]*') + imei=$(adb shell dumpsys iphonesubinfo | grep 'Device ID' | $GREP -o '[0-9]+') [[ -n $imei ]] || { echo "Failed to get imei. You can try other methods, or report a bug." exit 1 diff --git a/compatibility.sh b/compatibility.sh new file mode 100755 index 0000000..cf1688a --- /dev/null +++ b/compatibility.sh @@ -0,0 +1,20 @@ +#!/bin/bash -e +# $File: compatibility.sh +# $Date: Mon Jan 19 14:27:25 2015 +0800 +# Author: Vury Leo + +realpath() { + [[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}" +} + +if [ `uname` = 'Darwin' ] +then + REALPATH='realpath' + GREP='grep -E' + MD5SUM='md5' +else + REALPATH='readlink -f' + GREP='grep' + MD5SUM='md5sum' +fi + diff --git a/decrypt_db.sh b/decrypt_db.sh index 9c882e8..ce1af33 100755 --- a/decrypt_db.sh +++ b/decrypt_db.sh @@ -3,6 +3,8 @@ # Date: Sun Jan 11 22:30:50 2015 +0800 # Author: Yuxin Wu +source compatibility.sh + MSGDB=$1 imei=$2 uin=$3 @@ -20,17 +22,18 @@ if [[ -f $output ]]; then fi -KEY=$(echo -n "$imei$uin" | md5sum | cut -b 1-7) +KEY=$(echo -n "$imei$uin" | $MD5SUM | cut -b 1-7) echo "KEY: $KEY" +uname | grep Darwin > /dev/null || os=linux && os=darwin uname -m | grep x86_64 > /dev/null || version=32bit && version=64bit -echo "Use $version sqlcipher." +echo "Use $version sqlcipher of $os." echo "Dump decoded database... " echo "Don't worry about libcrypt.so version warning." -SQLCIPHER=./sqlcipher/$version +SQLCIPHER=./sqlcipher/$os/$version export LD_LIBRARY_PATH=$SQLCIPHER $SQLCIPHER/sqlcipher $MSGDB << EOF PRAGMA key='$KEY';