Bläddra i källkod

more logging in android-interact

ppwwyyxx 10 år sedan
förälder
incheckning
5ca0e4e90e
1 ändrade filer med 14 tillägg och 8 borttagningar
  1. 14 8
      android-interact.sh

+ 14 - 8
android-interact.sh

@@ -20,7 +20,7 @@ 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-)
 	[[ -n $uin ]] || {
-		echo "Failed to get wechat uin. You can try other methods, or report a bug."
+		>&2 echo "Failed to get wechat uin. You can try other methods, or report a bug."
 		exit 1
 	}
 	rm system_config_prefs.xml
@@ -28,7 +28,7 @@ if [[ $1 == "uin" ]]; then
 elif [[ $1 == "imei" ]]; then
 	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."
+		>&2 echo "Failed to get imei. You can try other methods, or report a bug."
 		exit 1
 	}
 	echo "Got imei: $imei"
@@ -41,7 +41,7 @@ elif [[ $1 == "db" || $1 == "res" ]]; then
 	# choose the first user.
 	chooseUser=$(echo $userList | head -n1)
 	[[ -n $chooseUser ]] || {
-		echo "Could not find user. Please check whether your resource dir is $RES_DIR"
+		>&2 echo "Could not find user. Please check whether your resource dir is $RES_DIR"
 		exit 1
 	}
 	echo "Found $numUser user(s). User chosen: $chooseUser"
@@ -54,7 +54,7 @@ elif [[ $1 == "db" || $1 == "res" ]]; then
 			adb pull $RES_DIR/$chooseUser/$d
 			cd ..
 			[[ -d $d ]] || {
-				echo "Failed to download resource directory: $RES_DIR/$chooseUser/$d"
+				>&2 echo "Failed to download resource directory: $RES_DIR/$chooseUser/$d"
 				exit 1
 			}
 		done
@@ -66,11 +66,11 @@ elif [[ $1 == "db" || $1 == "res" ]]; then
 		adb pull $MM_DIR/MicroMsg/$chooseUser/EnMicroMsg.db
 		[[ -f EnMicroMsg.db ]] && \
 			echo "File successfully downloaded to EnMicroMsg.db" || {
-			echo "Failed to pull database from adb"
+			>&2 echo "Failed to pull database from adb"
 			exit 1
 		}
 	fi
-elif [[ $1 == "db_decrypt" ]]; then
+elif [[ $1 == "db-decrypt" ]]; then
 	echo "Getting uin..."
 	$0 uin | tail -n1 | grep -o '[0-9]*' | tee /tmp/uin
 	echo "Getting imei..."
@@ -78,11 +78,17 @@ elif [[ $1 == "db_decrypt" ]]; then
 	echo "Getting db..."
 	$0 db
 	echo "Decrypting db..."
-	./decrypt-db.sh EnMicroMsg.db $(</tmp/imei) $(</tmp/uin)
+	imei=$(cat /tmp/imei)
+	uin=$(cat /tmp/uin)
+	if [[ -z $imei || -z $uin ]]; then
+		>&2 echo "Failed to get imei or uin. See README for manual methods."
+		exit 1
+	fi
+	./decrypt-db.sh EnMicroMsg.db $imei $uin
 	rm /tmp/{uin,imei}
 	echo "Done. See decoded.db"
 else
-	echo "Usage: $0 <res|db_decrypt>"
+	echo "Usage: $0 <res|db-decrypt>"
 	exit 1
 fi