Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 4th, 2012  |  syntax: None  |  size: 3.57 KB  |  hits: 9  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. # !/bin/bash
  2. # Find a given app's appleID/status
  3. # v1.1.2 - 3rd July 2010 - by Secretss
  4. # ttwj added some shit here `-`
  5.  
  6. ###########################################################################################
  7. if [ "$#" != "1" ] || [ "$1" = "-h" ]; then
  8.         echo -e "Usage: appstat \"app name\"\n       -to find the app's Apple ID or status"
  9. echo -e "Usage: appstat -a\n               -to add an iTunes ID to your database."
  10.         echo -e "Usage: appstat -u\n       -to update AppStat"
  11.         echo -e "Usage: appstat -h\n       -to display this text\n"
  12.         echo -e "v1.1.1 Written by Secretss\nContact Secretss[C4iD] on Rizon IRC server\nor @Secretss_ on Twitter.\n"
  13.         exit
  14. fi
  15.  
  16. if [ "$1" = "-u" ]; then
  17.         cd /usr/bin
  18.         before=$(md5sum appstat)
  19.         echo -e "Checking for updates."
  20.         wget -N -q http://dl.dropbox.com/u/1838452/appstat
  21.         chmod 755 appstat
  22.         if [ "$before" != "$(md5sum appstat)" ]; then
  23.                 echo -e "AppStat has been successfully updated.\n"
  24.                 exit
  25.         else
  26.                 echo -e "No updates available.\n"
  27.                 exit
  28.         fi
  29.         exit
  30. fi
  31. #Get the list of iTunes ID
  32. if [ -e /var/mobile/appstat.info ]; then
  33.         itunesid=$(cat "/var/mobile/appstat.info")
  34.         for i in $itunesid
  35.         do
  36.                 if [ ! $itunesid1 ]; then
  37.                         itunesid1=$i
  38.                 fi
  39.                 if [ ! $itunesid2 ]; then
  40.                         itunesid2=$i
  41.                 fi
  42.                 if [ ! $itunesid3 ]; then
  43.                         itunesid3=$i
  44.                 fi
  45.                 if [ ! $itunesid4 ]; then
  46.                         itunesid4=$i
  47.                 fi
  48.                 if [ ! $itunesid5 ]; then
  49.                         itunesid5=$i
  50.                 fi
  51.         done
  52. else
  53.         echo "You do not have any iTunes ID added, please enter it below"
  54.         read itunesid
  55.         if [ $itunesid ]; then
  56.                 echo $itunesid > /var/mobile/appstat.info
  57.                 echo "Added sucessfully :)"
  58.         fi
  59. fi
  60. #########################################################################################01#
  61. ls -d /User/Applications/*/*.app > /tmp/appstat.log
  62. dir=$(grep -i "/$1.app" /tmp/appstat.log)
  63. dircount=$(echo "$dir" | wc -l)
  64. if [ $dircount -gt 1 ]; then
  65.         echo Multiple apps found with name \"$1\".
  66.         rm -f /tmp/appstat.log
  67.         exit
  68. fi
  69.  
  70. #########################################################################################02#
  71. function appleIDsearch {
  72.      if [ -f "$dir/iTunesMetadata.plist" ]; then
  73.           appleID=$(plutil -key appleId "$dir/iTunesMetadata.plist" 2>&1)
  74.           if [ "${appleID:0:6}" = "Error:" ]; then
  75.                plutil -convert xml1 "$dir/iTunesMetadata.plist" > /dev/null 2>&1
  76.                appleID=$(echo $(grep -A 1 AppleID "$dir/iTunesMetadata.plist" | tr -d '\n') | sed -e "s/.*<string>//" -e "s/<\/string>//")
  77.           fi
  78.           if [ "${appleID:${#appleID}-8:${#appleID}}" = "@***.com" ]; then
  79.                echo This app is pirated.
  80.  
  81.           elif [ "$appleID" != "$itunesid1" ] && [ "$appleID" != "$itunesid2" ]; then
  82.                echo This app is cracked.
  83.           else
  84.                echo $appleID
  85.           fi
  86.      else
  87.           echo This app is cracked.
  88.      fi
  89. }
  90.  
  91. #########################################################################################03#
  92. if [ -z "$dir" ]; then
  93.      echo Locating application...
  94.      for appfolder in $(find /User/Applications -iname "*.app"); do
  95.           if [ -d "$appfolder" ]; then
  96.                cd "$appfolder"
  97.                if [ -f info.plist ]; then
  98.                     mv info.plist Info.plist
  99.                fi
  100.                plutil -convert xml1 Info.plist > /dev/null 2>&1
  101.                if [ "$(echo $1 | tr A-Z a-z)" = "$(echo $(plutil -key CFBundleDisplayName Info.plist 2>&1) | tr A-Z a-z)" ]; then
  102.                     dir="$(pwd)/../"
  103.                     appleIDsearch
  104.                     rm -f /tmp/appstat.log
  105.                     exit
  106.                fi
  107.           fi
  108.      done
  109.      echo Could not find app.
  110. else
  111.      dir="$dir/../"
  112.      appleIDsearch
  113. fi
  114.  
  115. #########################################################################################04#
  116. rm -f /tmp/appstat.log
  117. exit