diff --git a/android-interact.sh b/android-interact.sh index c3cc8ba..6857525 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 6a2d1b6..fd3cd9a 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 decrypted 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'; diff --git a/sqlcipher/darwin/64bit/.libs/sqlite3 b/sqlcipher/darwin/64bit/.libs/sqlite3 new file mode 100755 index 0000000..6edeab1 Binary files /dev/null and b/sqlcipher/darwin/64bit/.libs/sqlite3 differ diff --git a/sqlcipher/darwin/64bit/sqlcipher b/sqlcipher/darwin/64bit/sqlcipher new file mode 100755 index 0000000..8546113 --- /dev/null +++ b/sqlcipher/darwin/64bit/sqlcipher @@ -0,0 +1,130 @@ +#! /bin/sh + +# sqlite3 - temporary wrapper script for .libs/sqlite3 +# Generated by ltmain.sh (GNU libtool) 2.2.6 +# +# The sqlite3 program cannot be directly executed until all the libtool +# libraries that it depends on are installed. +# +# This wrapper script should never be moved out of the build directory. +# If it is, it will not operate correctly. + +# Sed substitution that helps us do robust quoting. It backslashifies +# metacharacters that are still active within double-quoted strings. +Xsed='/opt/local/bin/gsed -e 1s/^X//' +sed_quote_subst='s/\([`"$\\]\)/\\\1/g' + +# Be Bourne compatible +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac +fi +BIN_SH=xpg4; export BIN_SH # for Tru64 +DUALCASE=1; export DUALCASE # for MKS sh + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +relink_command="" + +# This environment variable determines our operation mode. +if test "$libtool_install_magic" = "%%%MAGIC variable%%%"; then + # install mode needs the following variables: + generated_by_libtool_version='2.2.6' + notinst_deplibs=' libsqlite3.la' +else + # When we are sourced in execute mode, $file and $ECHO are already set. + if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then + ECHO="/bin/echo" + file="$0" + # Make sure echo works. + if test "X$1" = X--no-reexec; then + # Discard the --no-reexec flag, and continue. + shift + elif test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t'; then + # Yippee, $ECHO works! + : + else + # Restart under the correct shell, and then maybe $ECHO will work. + exec /bin/sh "$0" --no-reexec ${1+"$@"} + fi + fi + + # Find the directory that this script lives in. + thisdir=`$ECHO "X$file" | $Xsed -e 's%/[^/]*$%%'` + test "x$thisdir" = "x$file" && thisdir=. + + # Follow symbolic links until we get to the real thisdir. + file=`ls -ld "$file" | /opt/local/bin/gsed -n 's/.*-> //p'` + while test -n "$file"; do + destdir=`$ECHO "X$file" | $Xsed -e 's%/[^/]*$%%'` + + # If there was a directory component, then change thisdir. + if test "x$destdir" != "x$file"; then + case "$destdir" in + [\\/]* | [A-Za-z]:[\\/]*) thisdir="$destdir" ;; + *) thisdir="$thisdir/$destdir" ;; + esac + fi + + file=`$ECHO "X$file" | $Xsed -e 's%^.*/%%'` + file=`ls -ld "$thisdir/$file" | /opt/local/bin/gsed -n 's/.*-> //p'` + done + + + # Usually 'no', except on cygwin/mingw when embedded into + # the cwrapper. + WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=no + if test "$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR" = "yes"; then + # special case for '.' + if test "$thisdir" = "."; then + thisdir=`pwd` + fi + # remove .libs from thisdir + case "$thisdir" in + *[\\/].libs ) thisdir=`$ECHO "X$thisdir" | $Xsed -e 's%[\\/][^\\/]*$%%'` ;; + .libs ) thisdir=. ;; + esac + fi + + # Try to get the absolute directory name. + absdir=`cd "$thisdir" && pwd` + test -n "$absdir" && thisdir="$absdir" + + program='sqlite3' + progdir="$thisdir/.libs" + + + if test -f "$progdir/$program"; then + # Add our own library path to DYLD_LIBRARY_PATH + DYLD_LIBRARY_PATH="/Users/vuryleo/Projects/sqlcipher/.libs:$DYLD_LIBRARY_PATH" + + # Some systems cannot cope with colon-terminated DYLD_LIBRARY_PATH + # The second colon is a workaround for a bug in BeOS R4 sed + DYLD_LIBRARY_PATH=`$ECHO "X$DYLD_LIBRARY_PATH" | $Xsed -e 's/::*$//'` + + export DYLD_LIBRARY_PATH + + if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then + # Run the actual program with our arguments. + + exec "$progdir/$program" ${1+"$@"} + + $ECHO "$0: cannot exec $program $*" 1>&2 + exit 1 + fi + else + # The program doesn't exist. + $ECHO "$0: error: \`$progdir/$program' does not exist" 1>&2 + $ECHO "This script is just a wrapper for $program." 1>&2 + /bin/echo "See the libtool documentation for more information." 1>&2 + exit 1 + fi +fi diff --git a/sqlcipher/32bit/libsqlcipher.so.0 b/sqlcipher/linux/32bit/libsqlcipher.so.0 similarity index 100% rename from sqlcipher/32bit/libsqlcipher.so.0 rename to sqlcipher/linux/32bit/libsqlcipher.so.0 diff --git a/sqlcipher/32bit/sqlcipher b/sqlcipher/linux/32bit/sqlcipher similarity index 100% rename from sqlcipher/32bit/sqlcipher rename to sqlcipher/linux/32bit/sqlcipher diff --git a/sqlcipher/64bit/libsqlcipher.so.0 b/sqlcipher/linux/64bit/libsqlcipher.so.0 similarity index 100% rename from sqlcipher/64bit/libsqlcipher.so.0 rename to sqlcipher/linux/64bit/libsqlcipher.so.0 diff --git a/sqlcipher/64bit/sqlcipher b/sqlcipher/linux/64bit/sqlcipher similarity index 100% rename from sqlcipher/64bit/sqlcipher rename to sqlcipher/linux/64bit/sqlcipher