Advertisement
cielavenir

applink (lesser) on PC

Mar 31st, 2012
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.19 KB | None | 0 0
  1. #!/usr/bin/python
  2. #applink (lesser)
  3.  
  4. #scp mobile@192.168.X.X:/var/mobile/Library/Caches/com.apple.mobile.installation.plist ./
  5. #plutil -i com.apple.mobile.installation.plist | applink.py xml.plist > applink.sh
  6. #scp applink.sh mobile@192.168.X.X:~/
  7. #ssh mobile@192.168.X.X
  8. #sh applink.sh
  9.  
  10. PATH="/var/mobile/applink"
  11. applist={}
  12.  
  13. import sys,os,plistlib,codecs
  14.  
  15. # Gets the info from the MobileInstallation cache.
  16. def find_apps():
  17.  #if not os.path.exists(plist):
  18.  # sys.stderr.write("MobileInstallation cache not found. Fallback not available on PC.\n")
  19.   #find_apps_old()
  20.  # return
  21.  try:
  22.   mobileInstallationCache = plistlib.readPlist(sys.stdin)
  23.  except:
  24.   sys.stderr.write("Reading the MobileInstallation cache failed. Fallback not available on PC.\n")
  25.   #find_apps_old()
  26.   return
  27.  if "User" not in mobileInstallationCache:
  28.   sys.stderr.write("MobileInstallation cache doesn't have a User key. Fallback not available on PC.\n")
  29.   #find_apps_old()
  30.   return
  31.  appStoreApps = mobileInstallationCache["User"]
  32.  sys.stderr.write("Here are the app bundles I found:\n")
  33.  for key in appStoreApps:
  34.   i = appStoreApps[key]
  35.   path = "/".join(i["Path"].rstrip("/").split("/")[:-1])
  36.   if "CFBundleDisplayName" in i and i["CFBundleDisplayName"] != "": #os.path.exists(path)
  37.    #dotApp = i["Path"].rstrip("/").split("/")[-1]
  38.    #dotAppFull = path + "/" + dotApp
  39.    if path.startswith("/private"):
  40.     path = path.split("/private", 1)[1]
  41.    guid = path.split("/")[-1]
  42.    sys.stderr.write(guid+"\n")
  43.    if i["CFBundleDisplayName"] in applist:
  44.     sys.stderr.write("Duplicate name\n")
  45.     #sys.stdout.write("rm \""+i["CFBundleDisplayName"]+"_"+guid+"\"\n")
  46.     sys.stdout.write("ln -s \""+path+"\" \""+i["CFBundleDisplayName"]+"_"+guid+"\"\n")
  47.    else:
  48.     applist[i["CFBundleDisplayName"]]=guid
  49.     #sys.stdout.write("rm \""+i["CFBundleDisplayName"]+"\"\n")
  50.     sys.stdout.write("ln -s \""+path+"\" \""+i["CFBundleDisplayName"]+"\"\n")
  51.  
  52. #main
  53. sys.stdout = codecs.getwriter('utf_8')(sys.stdout)
  54. sys.stdout.write("#!/bin/sh\n")
  55. #sys.stdout.write("export LC_ALL=en_US.UTF-8\n")
  56. sys.stdout.write("rm -rf \""+PATH+"\"\n")
  57. sys.stdout.write("mkdir \""+PATH+"\"\n")
  58. sys.stdout.write("cd \""+PATH+"\"\n")
  59. find_apps()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement