- # !/bin/bash
- # Find a given app's appleID/status
- # v1.1.2 - 3rd July 2010 - by Secretss
- # ttwj added some shit here `-`
- ###########################################################################################
- if [ "$#" != "1" ] || [ "$1" = "-h" ]; then
- echo -e "Usage: appstat \"app name\"\n -to find the app's Apple ID or status"
- echo -e "Usage: appstat -a\n -to add an iTunes ID to your database."
- echo -e "Usage: appstat -u\n -to update AppStat"
- echo -e "Usage: appstat -h\n -to display this text\n"
- echo -e "v1.1.1 Written by Secretss\nContact Secretss[C4iD] on Rizon IRC server\nor @Secretss_ on Twitter.\n"
- exit
- fi
- if [ "$1" = "-u" ]; then
- cd /usr/bin
- before=$(md5sum appstat)
- echo -e "Checking for updates."
- wget -N -q http://dl.dropbox.com/u/1838452/appstat
- chmod 755 appstat
- if [ "$before" != "$(md5sum appstat)" ]; then
- echo -e "AppStat has been successfully updated.\n"
- exit
- else
- echo -e "No updates available.\n"
- exit
- fi
- exit
- fi
- #Get the list of iTunes ID
- if [ -e /var/mobile/appstat.info ]; then
- itunesid=$(cat "/var/mobile/appstat.info")
- for i in $itunesid
- do
- if [ ! $itunesid1 ]; then
- itunesid1=$i
- fi
- if [ ! $itunesid2 ]; then
- itunesid2=$i
- fi
- if [ ! $itunesid3 ]; then
- itunesid3=$i
- fi
- if [ ! $itunesid4 ]; then
- itunesid4=$i
- fi
- if [ ! $itunesid5 ]; then
- itunesid5=$i
- fi
- done
- else
- echo "You do not have any iTunes ID added, please enter it below"
- read itunesid
- if [ $itunesid ]; then
- echo $itunesid > /var/mobile/appstat.info
- echo "Added sucessfully :)"
- fi
- fi
- #########################################################################################01#
- ls -d /User/Applications/*/*.app > /tmp/appstat.log
- dir=$(grep -i "/$1.app" /tmp/appstat.log)
- dircount=$(echo "$dir" | wc -l)
- if [ $dircount -gt 1 ]; then
- echo Multiple apps found with name \"$1\".
- rm -f /tmp/appstat.log
- exit
- fi
- #########################################################################################02#
- function appleIDsearch {
- if [ -f "$dir/iTunesMetadata.plist" ]; then
- appleID=$(plutil -key appleId "$dir/iTunesMetadata.plist" 2>&1)
- if [ "${appleID:0:6}" = "Error:" ]; then
- plutil -convert xml1 "$dir/iTunesMetadata.plist" > /dev/null 2>&1
- appleID=$(echo $(grep -A 1 AppleID "$dir/iTunesMetadata.plist" | tr -d '\n') | sed -e "s/.*<string>//" -e "s/<\/string>//")
- fi
- if [ "${appleID:${#appleID}-8:${#appleID}}" = "@***.com" ]; then
- echo This app is pirated.
- elif [ "$appleID" != "$itunesid1" ] && [ "$appleID" != "$itunesid2" ]; then
- echo This app is cracked.
- else
- echo $appleID
- fi
- else
- echo This app is cracked.
- fi
- }
- #########################################################################################03#
- if [ -z "$dir" ]; then
- echo Locating application...
- for appfolder in $(find /User/Applications -iname "*.app"); do
- if [ -d "$appfolder" ]; then
- cd "$appfolder"
- if [ -f info.plist ]; then
- mv info.plist Info.plist
- fi
- plutil -convert xml1 Info.plist > /dev/null 2>&1
- if [ "$(echo $1 | tr A-Z a-z)" = "$(echo $(plutil -key CFBundleDisplayName Info.plist 2>&1) | tr A-Z a-z)" ]; then
- dir="$(pwd)/../"
- appleIDsearch
- rm -f /tmp/appstat.log
- exit
- fi
- fi
- done
- echo Could not find app.
- else
- dir="$dir/../"
- appleIDsearch
- fi
- #########################################################################################04#
- rm -f /tmp/appstat.log
- exit