Merge pull request #1 from vuryleo/master

Add some bsd compatibility & darwin version of sqlcipher
This commit is contained in:
Yuxin Wu
2015-01-20 14:58:30 +08:00
9 changed files with 162 additions and 6 deletions
+6 -3
View File
@@ -2,7 +2,10 @@
# File: android-interact.sh
# Date: Sun Jan 11 23:05:58 2015 +0800
# Author: Yuxin Wu <[email protected]>
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
+20
View File
@@ -0,0 +1,20 @@
#!/bin/bash -e
# $File: compatibility.sh
# $Date: Mon Jan 19 14:27:25 2015 +0800
# Author: Vury Leo <i[at]vuryleo[dot]com>
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
+6 -3
View File
@@ -3,6 +3,8 @@
# Date: Sun Jan 11 22:30:50 2015 +0800
# Author: Yuxin Wu <[email protected]>
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';
Binary file not shown.
+130
View File
@@ -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