Advertisement
Guest User

Untitled

a guest
Sep 30th, 2012
291
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 68.16 KB | None | 0 0
  1. #!/bin/sh
  2. #
  3. # PoedCrackMod v25L rc12 (july 2012)
  4. #
  5. # Rapid Advanced Secure Thorough Intelligent Gaulish Nuclear Acclaimed Cracker
  6. # Rapide Avance Securise Tout-terrain Intelligent Gaulois Nucleaire Approfondi Craqueur
  7. #
  8. # For all devices, for all iOS versions.
  9. # Pour toutes les iMachines, quelque soit la version de l'iOS.
  10. #
  11. # For every kind of people, to make the world go round.
  12. # Un bon script et une bonne biere belge bien fraiche: que demande le peuple ?
  13. #
  14. # Now includes full working fat binary support, ASLR, and many many more features.
  15. # Il sait tout faire, et bien plus encore.
  16. #
  17. #
  18. # The truth is I never left you. I kept my promise.
  19. #
  20. #
  21. # Based upon poedGirl's ancient poedCrack (December 2009).
  22. # poedGirl's version available at: http://www.roapd.com/uploads/poedCrack.gz
  23. # poedCrack is heavily based on DeCrypt by FloydianSlip
  24. # Many thanks to:
  25. # puy0, SaladFork, Flox, Flawless, FloydianSlip, MadHouse, TDDebug
  26. # and every helping people !
  27.  
  28.  
  29.  
  30. # ======
  31. # Please, customize the script first !
  32. # Choices are:
  33.  
  34. # - Default language (US:english, FR:french, ES:spanish, DE:german, IT:italian).
  35.  PCMlang="US"
  36. #PCMlang="FR1"
  37. #PCMlang="FR2"
  38. #PCMlang="ES1"
  39. #PCMlang="ES2"
  40. #PCMlang="DE1"
  41. #PCMlang="DE2"
  42. #PCMlang="IT1"
  43. #PCMlang="IT2"
  44.  
  45. # - Default CrackerName (or "Anonymous").
  46. PCMcracker="Anonymous"
  47.  
  48. # - Should "extra details" appear in Ipa name (ie: "iPad / 3GS / etc") ? (You can hate them)
  49. PCMextras="YES"
  50.  
  51. # - Display graphical progress bars ? (based on number and/or size of apps) ("by size" is slower)
  52. PCMbarNum="YES"
  53. PCMbarSize="YES"
  54.  
  55. # - Should display be verbose ? (verbose is slower and messier)
  56. PCMverbose="NO"
  57.  
  58. # - Should script talk to you ? (it only speaks english, only with iOS4+, only with "speak" tool from Cydia)
  59. PCMspeak="YES"
  60.  
  61. # - Should artist's name be used in filename ?
  62. PCMartistfrommeta="YES"
  63.  
  64. # - Should menu display 'real name' of apps ? (slower, slower, and strange sort order)
  65. PCMrealnamemenu="NO"
  66.  
  67. # - Default compression level is blank (aka "-6"), and is the best speed/size ratio.
  68. # - Recommended. Upload/download/storage will be good.
  69.  PCMcompression=""
  70. # - Maximum compression ("-9") (also "-8" or "-7") is very very slow, but size is the best.
  71. # - If your iDevice is fast, if you're not in a hurry, if size matters. Best upload/download/storage.
  72. #PCMcompression="-9"
  73. # - Minimum compression ("-2") (also "-3" to "-5") is way faster, but size is way worse.
  74. # - Upload/download/storage will be worse. (CrackTM and Clutch and newest Crackulous use "-2").
  75. # - With "-2", PCM will be as fast as the others.
  76. #PCMcompression="-2"
  77. # - Don't use "-1" (sloppy) or "-0" (store), as size will be horrible, and all will suffer. Avoid.
  78.  
  79. # - Should I generate fake MetaData or not ?
  80. #   (Some people hate them, some love them, some protections check them, you should really keep them)
  81. PCMmetadata="YES"
  82.  
  83. # - Should I try LamestPatchest on the executable ?
  84. #   (It won't work 100%, but sometimes it really helps) (and now it's very very fast) (you should keep it)
  85. PCMlamestpatchest="YES"
  86.  
  87. # - What menu dots do you prefer ?
  88.  PCMdots=".............................."
  89. #PCMdots="------------------------------"
  90. #PCMdots="                              "
  91. #PCMdots="______________________________"
  92.  
  93. # Progress bar display
  94. PCMxxx="====="
  95. PCMsss="-----"
  96.  
  97. # DEBUG ONLY: - Should I try to crack arm6+arm7 on arm6 devices ? (It won't work at all)
  98. PCMarm7onarm6="NEVER"
  99. # DEBUG ONLY: - Force the "this script is running inside a GUI" check ?
  100. PCMinaGUI="NEVER"
  101. # DEBUG ONLY: - Check only (all tested but Ipa not created)
  102. PCMcheck="NEVER"
  103.  
  104. # Thanks you for testing.
  105. # ======
  106.  
  107.  
  108. # ======
  109. function SelectLanguage
  110. {
  111. # Language US
  112. if [ $PCMlang = "US" ]; then
  113.     MsgAltMeth="Using alternative dumping method"
  114.     MsgAnaAppl="Analyzing application"
  115.     MsgAppLoca="Locating"
  116.     MsgBadChoi="Bad choice"
  117.     MsgBldMenu="Building menu..."
  118.     MsgBrzMode="Berzerk mode: cracking ALL"
  119.     MsgCntFind="Cannot find"
  120.     MsgCopExec="and copying executable"
  121.     MsgCreDire="Creating directories"
  122.     MsgDmpUncr="Dumping unencrypted data from application"
  123.     MsgIpaInco="Incomplete .ipa"
  124.     MsgDskFull="Disk full"
  125.     MsgEraMemo="Erasing memory file"
  126.     MsgInsCydi="Install from Cydia"
  127.     MsgIpaDone="Done as"
  128.     MsgMnuEmpt="empty"
  129.     MsgMarDone="Marking all apps done"
  130.     MsgPatCryp="Locating and patching CryptID"
  131.     MsgRemTemp="Removing temporary files"
  132.     MsgRepData="and replacing encrypted data"
  133.     MsgSizUnit="B"
  134.     MsgUnaLoca="Unable to locate"
  135.     MsgVrfDump="Verifying dump"
  136.     MsgWrgChoi="Wrong choice"
  137.     MsgWarning="Warning"
  138.     MsgWrnMeta="iTunesMetadata format changed"
  139.     MsgYouChoi="Your choices"
  140.     MsgZipStep="Compressing the .ipa (step"
  141.     MsgComBoth="Combining both parts into a fat binary"
  142.     MsgSgnAppl="Signing the application"
  143.     MsgCopArtw="Copying Artwork"
  144.     MsgFakMeta="and faking MetaData"
  145.     MsgNotMeta="and no MetaData"
  146.     MsgFoundIt="Found"
  147.     MsgWasAskd="Asked"
  148.     MsgErrrors="Errors"
  149.     MsgBrzNoth="nothing"
  150.     MsgMrkDone="Mark all done                 "
  151.     MskZroDone="Reset done list               "
  152. fi
  153.  
  154. # Language FR1 or FR2
  155. if [ $PCMlang = "FR1" -o $PCMlang = "FR2" ]; then
  156.     MsgAnaAppl="Analyse d'application"
  157.     MsgAppLoca="Recherche"
  158.     MsgBldMenu="Construction du menu..."
  159.     MsgBrzMode="Mode Berzerk: on craque TOUT"
  160.     MsgCntFind="Introuvable:"
  161.     MsgDskFull="Disque plein"
  162.     MsgInsCydi="Installer avec Cydia"
  163.     MsgMnuEmpt="vide"
  164.     MsgRemTemp="Effacement fichiers temporaires"
  165.     MsgSizUnit="o"
  166.     MsgUnaLoca="Impossible de trouver"
  167.     MsgWrgChoi="Mauvais choix"
  168.     MsgWarning="Attention"
  169.     MsgWrnMeta="nouveau format d'iTunesMetadata"
  170.     MsgYouChoi="Votre choix"
  171.     MsgComBoth="Consolidation des deux sections binaires"
  172.     MsgSgnAppl="Signature de l'application"
  173.     MsgCopArtw="Copie de l'Artwork"
  174.     MsgFakMeta="et fausses MetaData"
  175.     MsgNotMeta="et pas de MetaData"
  176.     MsgWasAskd="Voulu"
  177.     MsgErrrors="Erreurs"
  178.     MsgBrzNoth="rien"
  179.     MsgMrkDone="Tout marquer fait             "
  180.     MskZroDone="Effacer liste fait            "
  181. fi
  182. # Language FR1 (ascii)
  183. if [ $PCMlang = "FR1" ]; then
  184.     MsgAltMeth="$( echo -e -n "M\0351thode alternative de dumping" )"
  185.     MsgBadChoi="$( echo -e -n "Choix erron\0351" )"
  186.     MsgCopExec="$( echo -e -n "& copie de l'ex\0351cutable" )"
  187.     MsgCreDire="$( echo -e -n "Cr\0351ation r\0351pertoires" )"
  188.     MsgDmpUncr="$( echo -e -n "Extraction des donn\0351es d\0351crypt\0351es de l'appli" )"
  189.     MsgIpaInco="$( echo -e -n "Ipa incompl\0350te" )"
  190.     MsgEraMemo="$( echo -e -n "Effacement fichier m\0351moire" )"
  191.     MsgIpaDone="$( echo -e -n "R\0351sultat:" )"
  192.     MsgMarDone="$( echo -e -n "Toutes les apps sont marqu\0351es comme trait\0351es" )"
  193.     MsgPatCryp="$( echo -e -n "Localisation et \0351crasement du CryptID" )"
  194.     MsgRepData="$( echo -e -n "et remplacement par d\0351crypt\0351es" )"
  195.     MsgVrfDump="$( echo -e -n "V\0351rif donn\0351es" )"
  196.     MsgZipStep="$( echo -e -n "Compression de l'ipa (\0351tape" )"
  197.     MsgFoundIt="$( echo -e -n "Trouv\0351" )"
  198. fi
  199. # Language FR2 (utf8)
  200. if [ $PCMlang = "FR2" ]; then
  201.     MsgAltMeth="$( echo -e -n "M\0303\0251thode alternative de dumping" )"
  202.     MsgBadChoi="$( echo -e -n "Choix erron\0303\0251" )"
  203.     MsgCopExec="$( echo -e -n "& copie de l'ex\0303\0251cutable" )"
  204.     MsgCreDire="$( echo -e -n "Cr\0303\0251ation r\0303\0251pertoires" )"
  205.     MsgDmpUncr="$( echo -e -n "Extraction des donn\0303\0251es d\0303\0251crypt\0303\0251es de l'appli" )"
  206.     MsgIpaInco="$( echo -e -n "Ipa incompl\0303\0250te" )"
  207.     MsgEraMemo="$( echo -e -n "Effacement fichier m\0303\0251moire" )"
  208.     MsgIpaDone="$( echo -e -n "R\0303\0251sultat:" )"
  209.     MsgMarDone="$( echo -e -n "Toutes les apps sont marqu\0303\0251es comme trait\0303\0251es" )"
  210.     MsgPatCryp="$( echo -e -n "Localisation et \0303\0251crasement du CryptID" )"
  211.     MsgRepData="$( echo -e -n "et remplacement par d\0303\0251crypt\0303\0251es" )"
  212.     MsgVrfDump="$( echo -e -n "V\0303\0251rif donn\0303\0251es" )"
  213.     MsgZipStep="$( echo -e -n "Compression de l'ipa (\0303\0251tape" )"
  214.     MsgFoundIt="$( echo -e -n "Trouv\0303\0251" )"
  215. fi
  216.  
  217.  
  218. # Language ES1 or ES2
  219. if [ $PCMlang = "ES1" -o $PCMlang = "ES2" ]; then
  220.     MsgBrzMode="Modo Berzerk: crackando TODO"
  221.     MsgCntFind="No encontro"
  222.     MsgCopExec="y copiando ejecutable"
  223.     MsgCreDire="Creando directorios"
  224.     MsgEraMemo="Borrado memoria archivo"
  225.     MsgInsCydi="Instalarlo desde Cydia"
  226.     MsgIpaDone="Done as"
  227.     MsgMarDone="Marcando todas aplicaciones como 'hecho'"
  228.     MsgPatCryp="Locating y patching CryptID"
  229.     MsgRemTemp="Borrando archivos temporales"
  230.     MsgRepData="y reemplazando datos cifrados"
  231.     MsgSizUnit="B"
  232.     MsgUnaLoca="Incapaz de ubicar"
  233.     MsgWarning="Warning"
  234.     MsgWrnMeta="iTunesMetadata formato cambiado"
  235.     MsgCopArtw="Copiando Artwork"
  236.     MsgFakMeta="y fingiendo MetaData"
  237.     MsgNotMeta="y no MetaData"
  238.     MsgFoundIt="Found"
  239.     MsgWasAskd="Asked"
  240.     MsgErrrors="Errores"
  241.     MsgBrzNoth="nada"
  242.     MsgMrkDone="Marcar todas hechas           "
  243.     MskZroDone="Vaciar lista hechas           "
  244. fi
  245. # Language ES1 (ascii)
  246. if [ $PCMlang = "ES1" ]; then
  247.     MsgAltMeth="$( echo -e -n "Usando m\0351todo alternativo de dumping" )"
  248.     MsgAnaAppl="$( echo -e -n "Analizando aplicaci\0363n" )"
  249.     MsgAppLoca="$( echo -e -n "Ubicaci\0363n" )"
  250.     MsgBadChoi="$( echo -e -n "Mala elecci\0363n" )"
  251.     MsgBldMenu="$( echo -e -n "Construyendo men\0372..." )"
  252.     MsgDmpUncr="$( echo -e -n "Dumping decifrados datos de la aplicaci\0363n" )"
  253.     MsgIpaInco="$( echo -e -n "\0241 Incompleta .ipa" )"
  254.     MsgDskFull="$( echo -e -n "\0277 Disco lleno" )"
  255.     MsgMnuEmpt="$( echo -e -n "vac\0355o" )"
  256.     MsgVrfDump="$( echo -e -n "Verificaci\0363n" )"
  257.     MsgWrgChoi="$( echo -e -n "Opci\0363n incorrecta" )"
  258.     MsgYouChoi="$( echo -e -n "\0277 Su elecci\0363" )"
  259.     MsgZipStep="$( echo -e -n "Compresi\0363n de .ipa (paso" )"
  260.     MsgComBoth="$( echo -e -n "Combinaci\0363n dos partes en fat binary" )"
  261.     MsgSgnAppl="$( echo -e -n "Firma de la aplicaci\0363n" )"
  262. fi
  263. # Language ES2 (utf8)
  264. if [ $PCMlang = "ES2" ]; then
  265.     MsgAltMeth="$( echo -e -n "Usando m\0303\0251todo alternativo de dumping" )"
  266.     MsgAnaAppl="$( echo -e -n "Analizando aplicaci\0303\0263n" )"
  267.     MsgAppLoca="$( echo -e -n "Ubicaci\0303\0263n" )"
  268.     MsgBadChoi="$( echo -e -n "Mala elecci\0303\0263n" )"
  269.     MsgBldMenu="$( echo -e -n "Construyendo men\0303\0272..." )"
  270.     MsgDmpUncr="$( echo -e -n "Dumping decifrados datos de la aplicaci\0303\0263n" )"
  271.     MsgIpaInco="$( echo -e -n "\0302\0241 Incompleta .ipa" )"
  272.     MsgDskFull="$( echo -e -n "\0302\0277 Disco lleno" )"
  273.     MsgMnuEmpt="$( echo -e -n "vac\0303\0255o" )"
  274.     MsgVrfDump="$( echo -e -n "Verificaci\0303\0263n" )"
  275.     MsgWrgChoi="$( echo -e -n "Opci\0303\0263n incorrecta" )"
  276.     MsgYouChoi="$( echo -e -n "\0302\0277 Su elecci\0303\0263" )"
  277.     MsgZipStep="$( echo -e -n "Compresi\0303\0263n de .ipa (paso" )"
  278.     MsgComBoth="$( echo -e -n "Combinaci\0303\0263n dos partes en fat binary" )"
  279.     MsgSgnAppl="$( echo -e -n "Firma de la aplicaci\0303\0263n" )"
  280. fi
  281.  
  282. # Language DE1 or DE2. Translation by Ushnak.
  283. if [ $PCMlang = "DE1" -o $PCMlang = "DE2" ]; then
  284.     MsgAltMeth="Alternative Methode zum Dumpen"
  285.     MsgAnaAppl="Analyse der App"
  286.     MsgAppLoca="Suche"
  287.     MsgBrzMode="Berzerker Modus: ALLES wird gecrackt"
  288.     MsgCntFind="Nicht aufzufinden:"
  289.     MsgCopExec="Kopieren der Executable"
  290.     MsgCreDire="Erstellen der Ordner"
  291.     MsgDskFull="Kein Speicher mehr"
  292.     MsgInsCydi="Installieren mit Cydia"
  293.     MsgIpaDone="Fertig"
  294.     MsgMnuEmpt="leer"
  295.     MsgMarDone="Alle Apps als gecrackt markieren"
  296.     MsgPatCryp="Aufinden und patchen der CryptID"
  297.     MsgSizUnit="B"
  298.     MsgWrgChoi="Schlechte Wahl"
  299.     MsgWarning="Warnung"
  300.     MsgYouChoi="Ihre Wahl"
  301.     MsgZipStep="Kompression der .ipa (Schritt"
  302.     MsgSgnAppl="Signieren der App"
  303.     MsgCopArtw="Kopieren des Artworks"
  304.     MsgFakMeta="und der falschen MetaData"
  305.     MsgNotMeta="und keine MetaData"
  306.     MsgFoundIt="Gefunden"
  307.     MsgWasAskd="Angefragt"
  308.     MsgErrrors="Fehler"
  309.     MsgBrzNoth="Nichts"
  310. fi
  311. # Language DE1 (ascii). Translation by Ushnak.
  312. if [ $PCMlang = "DE1" ]; then
  313.     MsgBadChoi="$( echo -e -n "Ung\0374ltige Wahl" )"
  314.     MsgBldMenu="$( echo -e -n "Aufbau des Men\0374s..." )"
  315.     MsgDmpUncr="$( echo -e -n "Dumping von unverschl\0374sselten Daten der App" )"
  316.     MsgIpaInco="$( echo -e -n "Unvollst\0344ndige .ipa" )"
  317.     MsgEraMemo="$( echo -e -n "L\0366schen des Zwischenspeichers" )"
  318.     MsgRemTemp="$( echo -e -n "L\0366schen des Speichers" )"
  319.     MsgRepData="$( echo -e -n "und Austausch der verschl\0374sselten Daten" )"
  320.     MsgUnaLoca="$( echo -e -n "Unm\0366glich zu Finden" )"
  321.     MsgVrfDump="$( echo -e -n "\0334perpr\0374fen des Dumps" )"
  322.     MsgWrnMeta="$( echo -e -n "Das Format der iTunesMetaData wurde ge\0344ndert" )"
  323.     MsgComBoth="$( echo -e -n "Zusammensetzung der zwei Bin\0344rdateien" )"
  324.     MsgMrkDone="$( echo -e -n "Alles als angew\0344hlt           " )"
  325.     MskZroDone="$( echo -e -n "Liste der angew\0344hlten l\0366schen " )"
  326. fi
  327. # Language DE2 (utf8). Translation by Ushnak.
  328. if [ $PCMlang = "DE2" ]; then
  329.     MsgBadChoi="$( echo -e -n "Ung\0303\0274ltige Wahl" )"
  330.     MsgBldMenu="$( echo -e -n "Aufbau des Men\0303\0274s..." )"
  331.     MsgDmpUncr="$( echo -e -n "Dumping von unverschl\0303\0274sselten Daten der App" )"
  332.     MsgIpaInco="$( echo -e -n "Unvollst\0303\0244ndige .ipa" )"
  333.     MsgEraMemo="$( echo -e -n "L\0303\0266schen des Zwischenspeichers" )"
  334.     MsgRemTemp="$( echo -e -n "L\0303\0266schen des Speichers" )"
  335.     MsgRepData="$( echo -e -n "und Austausch der verschl\0303\0274sselten Daten" )"
  336.     MsgUnaLoca="$( echo -e -n "Unm\0303\0266glich zu Finden" )"
  337.     MsgVrfDump="$( echo -e -n "\0303\0234perpr\0303\0274fen des Dumps" )"
  338.     MsgWrnMeta="$( echo -e -n "Das Format der iTunesMetaData wurde ge\0303\0244ndert" )"
  339.     MsgComBoth="$( echo -e -n "Zusammensetzung der zwei Bin\0303\0244rdateien" )"
  340.     MsgMrkDone="$( echo -e -n "Alles als angew\0303\0244hlt           " )"
  341.     MskZroDone="$( echo -e -n "Liste der angew\0303\0244hlten l\0303\0266schen " )"
  342. fi
  343.  
  344. # Language IT1 and IT2. Translation by Wfede21.
  345. if [ $PCMlang = "IT1" -o $PCMlang = "IT2" ]; then
  346.     MsgAltMeth="Metodo alternativo di dump"
  347.     MsgAnaAppl="Analisi applicazione"
  348.     MsgAppLoca="Localizzo"
  349.     MsgBadChoi="Scelta sbagliata"
  350.     MsgBldMenu="Costruisco il menu..."
  351.     MsgCntFind="Impossibile trovare"
  352.     MsgCopExec="e copio l'eseguibile"
  353.     MsgCreDire="Creo le cartelle"
  354.     MsgDmpUncr="Dump dei dati non criptati dall'applicazione"
  355.     MsgIpaInco=".ipa non completa"
  356.     MsgDskFull="Memoria piena"
  357.     MsgEraMemo="Cancellando file di memoria"
  358.     MsgInsCydi="Installa da Cydia"
  359.     MsgIpaDone="Fatto come"
  360.     MsgMnuEmpt="vuoto"
  361.     MsgMarDone="Tutte le app craccate"
  362.     MsgPatCryp="Trovo e sistemo il CryptID"
  363.     MsgRemTemp="Rimozione file temporanei"
  364.     MsgRepData="e sostituisco i dati criptati"
  365.     MsgSizUnit="B"
  366.     MsgUnaLoca="Impossibile trovare"
  367.     MsgVrfDump="Controllo dump"
  368.     MsgWrgChoi="Scelta sbagliata"
  369.     MsgWarning="Attenzione"
  370.     MsgWrnMeta="formato iTunesMetadata cambiato"
  371.     MsgYouChoi="La tua scelta"
  372.     MsgZipStep="Compressione .ipa (passo"
  373.     MsgComBoth="Combino le parti in uno"
  374.     MsgSgnAppl="Signing the application"
  375.     MsgCopArtw="Copia di Artwork"
  376.     MsgFakMeta="e falsifico MetaData"
  377.     MsgNotMeta="e niente MetaData"
  378.     MsgFoundIt="Trovato"
  379.     MsgWasAskd="Chiesto"
  380.     MsgErrrors="Errore"
  381.     MsgBrzNoth="niente"
  382.     MsgMrkDone="Segna come tutte craccate     "
  383.     MskZroDone="Azzera lista app craccate     "
  384. fi
  385. # Language IT1 (ascii). Translation by Wfede21.
  386. if [ $PCMlang = "IT1" ]; then
  387.     MsgBrzMode="$( echo -e -n "Modalit\0340 Berzerk: crack di tutte le app" )"
  388. fi
  389. # Language IT2 (utf8). Translation by Wfede21.
  390. if [ $PCMlang = "IT2" ]; then
  391.     MsgBrzMode="$( echo -e -n "Modalit\0303\0240 Berzerk: crack di tutte le app" )"
  392. fi
  393. }
  394.  
  395.  
  396. # ======
  397. function UnicodeToHuman
  398. {
  399. # Convert from unicode to human, and remove unwanted chars
  400. human=$(echo -n "$unicode" | sed -e "s: :_:g" | od -c -A n -v --width=999 | sed \
  401.     -e 's:+:Plus:g' \
  402.     -e 's:302.240:_:g' \
  403.     -e 's:302.251:_:g' \
  404.     -e 's:302.256:_:g' \
  405.     -e 's:302.260:Degree:g' \
  406.     -e "s:302.264:':g" \
  407.     -e 's:303.201:A:g' \
  408.     -e 's:303.207:C:g' \
  409.     -e 's:303.211:E:g' \
  410.     -e 's:303.216:I:g' \
  411.     -e 's:303.224:O:g' \
  412.     -e 's:303.234:U:g' \
  413.     -e 's:303.237:B:g' \
  414.     -e 's:303.240:a:g' \
  415.     -e 's:303.241:a:g' \
  416.     -e 's:303.242:a:g' \
  417.     -e 's:303.245:a:g' \
  418.     -e 's:303.247:c:g' \
  419.     -e 's:303.250:e:g' \
  420.     -e 's:303.251:e:g' \
  421.     -e 's:303.252:e:g' \
  422.     -e 's:303.253:e:g' \
  423.     -e 's:303.255:i:g' \
  424.     -e 's:303.256:i:g' \
  425.     -e 's:303.257:i:g' \
  426.     -e 's:303.263:o:g' \
  427.     -e 's:303.264:o:g' \
  428.     -e 's:303.266:o:g' \
  429.     -e 's:303.270:o:g' \
  430.     -e 's:303.271:u:g' \
  431.     -e 's:303.273:u:g' \
  432.     -e 's:303.274:u:g' \
  433.     -e 's:304.237:g:g' \
  434.     -e 's:304.261:i:g' \
  435.     -e 's:305.223:oe:g' \
  436.     -e 's:312.236:k:g' \
  437.     -e 's:316.251:Omega:g' \
  438.     -e 's:342.200.223:-:g' \
  439.     -e 's:342.200.224:-:g' \
  440.     -e "s:342.200.230:':g" \
  441.     -e "s:342.200.231:':g" \
  442.     -e 's:342.200.242:-:g' \
  443.     -e 's:342.202.254:EUR:g' \
  444.     -e 's:342.204.242:_:g' \
  445.     -e 's:342.210.236:Infinity:g' \
  446.     -e 's:342.213.205:.:g' \
  447.     -e 's:342.226.272:_:g' \
  448.     -e 's:342.227.217:-:g' \
  449.     -e 's:342.230.205:_:g' \
  450.     -e 's:342.231.253:_:g' \
  451.     -e 's:342.235.222:_:g' \
  452.     -e 's:347.246.205:_:g' \
  453.     | tr -cd "[:alnum:][_'.][-]" | sed -e "s:_: :g" | sed -e "s:  : :g" )
  454. # Todo: future enhancements
  455. # Help wanted for unknown or other unicodes
  456. }
  457.  
  458.  
  459. # ======
  460. function DisplayBars
  461. {
  462. ProgressPct=""
  463. if [ $PCMbarNum = "YES" ]; then
  464.     ProgressXXX=$(( $BarCols * $ProgressDone / $ProgressTarget ))
  465.     ProgressSSS=$(( $BarCols - $ProgressXXX ))
  466.     ProgressPct=$(( 100 * $ProgressDone / $ProgressTarget ))
  467.     echo "[${escGreen}${PCMxxx:0:$ProgressXXX}${escBlue}${PCMsss:0:$ProgressSSS}${escReset}] $ProgressPct%"
  468. fi
  469. if [ $PCMbarSize = "YES" ]; then
  470.     ProgressXXX=$(( $BarCols * $ProgressDoneSize / $ProgressTargetSize ))
  471.     ProgressSSS=$(( $BarCols - $ProgressXXX ))
  472.     ProgressPct=$(( 100 * $ProgressDoneSize / $ProgressTargetSize ))
  473.     echo "[${escCyan}${PCMxxx:0:$ProgressXXX}${escBlue}${PCMsss:0:$ProgressSSS}${escReset}] $ProgressPct%"
  474. fi
  475.  
  476. if [ ! -z "$ProgressPct" -a $PCMspeak = "YES" ]; then
  477.     speak "$ProgressPct %" &
  478. fi
  479. }
  480.  
  481.  
  482. # ======
  483. # Begin Crack Function
  484. function CrackFunction
  485. {
  486.     # Get the parameters
  487.     AppExecCur="$1"
  488.     AppExecSrc="$2"
  489. ##  CurOff="$3"
  490.  
  491.     # Getting executable's details
  492.     Peter=$(otool -l "$WorkDir/$AppName/$AppExecCur")
  493.  
  494.     # Check executable's dump address. Rare apps shift it on purpose.
  495.     Pesky=$(echo "$Peter" | tr '\n' '\\' | sed -e 's:Load command:\nLoad command:g' | grep "cmd LC_SEGMENT" | grep "segname __TEXT" | tr '\\' '\n' | grep "vmaddr" | awk --non-decimal-data '{print ($2)+0 }')
  496.     if [ $Pesky != 4096 ]; then
  497.         echo "${Meter33}${escRed}$MsgWarning:${escReset} address shifting ($Pesky)"
  498.     fi
  499.  
  500.     # Finding location of the "cstring" data block to be LamedPatched
  501.     LPoff=$(echo "$Peter" | grep cstring -A4 | grep offset | awk '{print $2}')
  502.     if [ ! "$LPoff" ]; then
  503.         echo "${Meter33}${escYellow}$MsgWarning:${escReset} unable to find LPoff"
  504.         LPoff=0
  505.         LPsize=0
  506.     else
  507.         LPsize=$(echo "$Peter" | grep cstring -A4 | grep size | awk --non-decimal-data '{print ($2)+0 }')
  508.         if [ ! "$LPsize" ]; then
  509.             echo "${Meter33}${escYellow}$MsgWarning:${escReset} unable to find LPsize"
  510.             LPoff=0
  511.             LPsize=0
  512.         fi
  513.     fi
  514.  
  515.     # Finding all Crypt details
  516.     CryptID=$(echo "$Peter" | grep cryptid | awk '{print $2}')
  517.     if [ "$CryptID" != "1" ]; then
  518.         echo "${escRed}Application is not encrypted${escReset}"
  519.         rm -fr "$WorkDir"
  520.         return 1
  521.     fi
  522.     CryptSize=$(echo "$Peter" | grep cryptsize | awk '{print $2}')
  523.     if [ ! "$CryptSize" ]; then
  524.         echo "${escRed}Unable to find CryptSize${escReset}"
  525.         rm -fr "$WorkDir"
  526.         return 1
  527.     fi
  528.     CryptOff=$(echo "$Peter" | grep cryptoff | awk '{print $2}')
  529.     if [ ! "$CryptOff" ]; then
  530.         echo "${escRed}Unable to find CryptOff${escReset}"
  531.         rm -fr "$WorkDir"
  532.         return 1
  533.     fi
  534.  
  535.     # - Take first 4KB of the file (ie: headers), convert to hex on 1 long line
  536.     # - Find the CryptID command block
  537.     # - Compute the offset to patch
  538.     # - Patch 01 --> 00
  539.     if [ $PCMverbose = "YES" ]; then
  540.         echo "${Meter34}$MsgPatCryp"
  541.     fi
  542.     dd bs=4096 count=1 if="$WorkDir/$AppName/$AppExecCur" 2> /dev/null | \
  543.     od -A n -t x1 -v | \
  544.     tr -d ' ','\n' | \
  545.     sed "s/0000002100000014......................01.*/CanYouFillItCanYouFillItMichaelJackson/g" > "$WorkDir/hex.tmp"
  546.     foo=$(echo -ne "\x00" | dd bs=1 seek=$(( $(stat -c%s "$WorkDir/hex.tmp") / 2 )) conv=notrunc status=noxfer of="$WorkDir/$AppName/$AppExecCur" 2>&1> /dev/null)
  547.     rm -f "$WorkDir/hex.tmp"
  548.     cid=$(otool -l "$WorkDir/$AppName/$AppExecCur" | grep cryptid | awk '{print $2}')
  549.  
  550.     if [ "$cid" != "0" ]; then
  551.         echo "${escRed}Unable to patch CryptID${escReset}"
  552.         rm -fr "$WorkDir"
  553.         return 1
  554.     fi
  555.  
  556.     WaspWasp="NO"
  557.  
  558.     # Does it have the ASLR bit flag ?
  559.     AslrBits=$(dd bs=1 count=1 skip=26 if="$WorkDir/$AppName/$AppExecCur" 2> /dev/null | od -A n -t u -v )
  560.     AslrBit=$(( $AslrBits & 32 ))
  561.     if [ $AslrBit -ne 0 ]; then
  562. ##      echo "${Meter37}${escYellow}$MsgWarning:${escReset} ASLR bit detected"
  563.         # Only if the iDevice has an arm7 cpu
  564.         if [ ! $CPUType ]; then
  565.             NotAslrBits=$(( $AslrBits & 223 ))
  566. ##          if [ $PCMverbose = "YES" ]; then
  567. ##              echo "${Meter38}Wasp Wasp Attack ! Sharpz Stingz !"
  568. ##          fi
  569.             WaspWasp="YES"
  570. ##          ExtrasAslr=" ASLR"
  571.         fi
  572.     fi
  573.  
  574.     # Dumping the binary
  575.     if [ $PCMverbose = "YES" ]; then
  576.         echo "${Meter40}$MsgDmpUncr"
  577.     fi
  578.  
  579.     # Creating GDB script
  580.     if [ $AltDump != "YES" -a $WaspWasp != "YES" ]; then
  581.         echo -e "set sharedlibrary load-rules \".*\" \".*\" none\r\n\
  582.         set inferior-auto-start-dyld off\r\n\
  583.         set sharedlibrary preload-libraries off\r\n\
  584.         set sharedlibrary load-dyld-symbols off\r\n\
  585.         handle all nostop\r\n\
  586.         rb doModInitFunctions\r\n
  587.         command 1\r\n\
  588.         dump memory $WorkDir/dump.bin $(($CryptOff + $Pesky)) $(($CryptSize + $CryptOff + $Pesky))\r\n\
  589.         dump memory $WorkDir/LP.bin $(($LPoff + $Pesky)) $(($LPsize + $LPoff + $Pesky))\r\n\
  590.         kill\r\n\
  591.         quit\r\n\
  592.         end\r\n\
  593.         start" > $WorkDir/batch.gdb
  594.     else
  595.         echo -e "set sharedlibrary load-rules \".*\" \".*\" none\r\n\
  596.         set inferior-auto-start-dyld off\r\n\
  597.         set sharedlibrary preload-libraries off\r\n\
  598.         set sharedlibrary load-dyld-symbols off\r\n\
  599.         dump memory $WorkDir/dump.bin $(($CryptOff + $Pesky)) $(($CryptSize + $CryptOff + $Pesky))\r\n\
  600.         dump memory $WorkDir/LP.bin $(($LPoff + $Pesky)) $(($LPsize + $LPoff + $Pesky))\r\n\
  601.         quit\r\n" > $WorkDir/batch.gdb
  602.     fi
  603. #       set disable-aslr on\r\n\
  604.  
  605.     # Cracking the binary
  606.     if [ $AltDump != "YES" -a $WaspWasp != "YES" ]; then
  607.         DumpLog=$(gdb -q -e "$AppExecSrc" -x $WorkDir/batch.gdb -batch 2>&1)
  608.     else
  609.         if [ $AltDump = "YES" ]; then
  610.             echo -n "${Meter41}${escYellow}Alt${escReset} dumping"
  611.         else
  612.             echo -n "${Meter41}Loading ${escYellow}ASLR${escReset}"
  613.         fi
  614.         echo -n "${Meter42} app in background"
  615.         # Running executable, frozen, ASLR disabled, in background, with Pod2G's tool.
  616.         (posix_spawn "$AppExecSrc" & echo $! > /tmp/pid.txt ) > /dev/null  2>&1> /dev/null
  617.  
  618.         # Get PID of this background process
  619.         backback=$(cat /tmp/pid.txt)
  620.         rm /tmp/pid.txt
  621.         echo "${Meter43} ($backback)"
  622.         sleep 1
  623.         # Check if app is still running (not crashed)
  624.         if [ ! "$(ps -p $backback | grep "$backback " | wc -l)" -eq 1 ]; then
  625.             echo "App crashed before dumping !"
  626.             rm -fr "$WorkDir"
  627.             return 1
  628.         fi
  629.         echo -n "${Meter44}Attaching, dumping, "
  630.         DumpLog=$(gdb -q -x $WorkDir/batch.gdb -batch --pid=$backback  >&1  2>&1)
  631.         if [ -e /usr/bin/logger ]; then
  632.             echo "$DumpLog" | logger -t PCMdump
  633.         fi
  634.         # Kill and wait...
  635.         echo -n "${Meter45}killing, "
  636.         kill $backback > /dev/null 2>&1
  637.         sleep 1
  638.         echo "${Meter46}waiting"
  639.         wait $backback > /dev/null 2>&1
  640.     fi
  641.  
  642.     # Not needed anymore
  643.     rm $WorkDir/batch.gdb
  644.  
  645.     # Verifying dump
  646.     if [ $PCMverbose = "YES" ]; then
  647.         echo -n "${Meter50}$MsgVrfDump "
  648.     fi
  649.     if [ ! -e "$WorkDir/dump.bin" ]; then
  650.         echo "${escRed}failed ! Can't dump ?${escReset}"
  651.         if [ -e /usr/bin/logger ]; then
  652.             echo "$DumpLog" | logger -t PCMdump
  653.         fi
  654.         rm -fr "$WorkDir"
  655.         return 1
  656.     fi
  657.     DumpSize=$(stat -c%s "$WorkDir/dump.bin")
  658.     if [ "$DumpSize" != "$CryptSize" ]; then
  659.         echo "${escRed}failed ! Wrong dump size ?${escReset}"
  660.         if [ -e /usr/bin/logger ]; then
  661.             echo "$DumpLog" | logger -t PCMdump
  662.         fi
  663.         rm -fr "$WorkDir"
  664.         return 1
  665.     fi
  666.  
  667.     # Replacing executable's crypted data with dumped clear data
  668.     if [ $PCMverbose = "YES" ]; then
  669.         echo "${Meter54}$MsgRepData"
  670.     fi
  671.     foo=$(dd seek=1 count=1 obs=$CryptOff ibs=$DumpSize conv=notrunc if="$WorkDir/dump.bin" of="$WorkDir/$AppName/$AppExecCur" 2>&1> /dev/null)
  672.     rm "$WorkDir/dump.bin"
  673.  
  674.     # Trying LamestPatchest to remove some ads and some security checks
  675.     if [ $PCMlamestpatchest = "YES" ]; then
  676.         # LamingDineringDashing
  677.         DinerDash=""
  678.         if [ "$AppExec" = "Diner Dash" ]; then
  679.             echo "${Meter57}${escYellow}Note:${escReset} damn lame Diner Dash !"
  680.             DinerDash="-e s=iPhone1,=iPhune1,=g "
  681.         fi
  682.  
  683.         if [ $LPoff = 0 -o $LPsize = 0 ]; then
  684.             patchme="$WorkDir/$AppName/$AppExecCur"
  685.             if [ $PCMverbose = "YES" ]; then
  686.                 echo -n "${Meter58}${escYellow}Trying old LamerPatcher...${escReset} "
  687.             fi
  688.         else
  689.             patchme="$WorkDir/LP.bin"
  690.             if [ $PCMverbose = "YES" ]; then
  691.                 echo -n "${Meter58}Trying LamestPatchest... "
  692.             fi
  693.             # Disk full ?
  694.             if [ $(stat -c%s "$WorkDir/LP.bin") != $LPsize ]; then
  695.                 echo "${escRed}$MsgDskFull ?${escReset}"
  696.                 rm -fr "$WorkDir"
  697.                 return 1
  698.             fi
  699.         fi
  700.  
  701.         # LamingPatching !
  702.         sed --in-place=.BCK \
  703.             -e 's=/Cydia\.app=/Czdjb\.bpp=g' \
  704.             -e 's=ppa\.aidyC=ppb\.bjdzC=g' \
  705.             -e 's=/private/var/lib/apt=/prjvbtf/vbr/ljb/bpt=g' \
  706.             -e 's=/bin/mkdir=/bjn/mkdjr=g' \
  707.             -e 's=/bin/bash=/bjn/bbsh=g' \
  708.             -e 's=/usr/bin/ssh=/vsr/bjn/ssh=g' \
  709.             -e 's=/Applicat\d0\d0\d0ions/dele\d0\d0\d0teme\.txt=/Bppljcbt\d0\d0\d0jpns/dflf\d0\d0\d0tfmf\.txt=g' \
  710.             -e 's=/Appl\d0\d0\d0ications/C\d0\d0ydi\d0a\.app=/Bppl\d0\d0\d0jcbtjpns/C\d0\d0zdj\d0b\.bpp=g' \
  711.             -e 's=ations/Cy\d0\d0\d0/Applic\d0pp\d0\d0dia.a=btjpns/Cz\d0\d0\d0/Bppljc\d0pp\d0\d0djb.b=g' \
  712.             -e 's=ate/va\d0\d0/priv\d0\d0\d0pt/\d0b/a\d0r/li=btf/vb\d0\d0/prjv\d0\d0\d0pt/\d0b/b\d0r/lj=g' \
  713.             -e 's=pinchmedia\.com=pjnchmfdjb\.cpm=g' \
  714.             -e 's=admob\.com=bdmpb\.cpm=g' \
  715.             -e 's=doubleclick\.net=dpvblfcljck\.nft=g' \
  716.             -e 's=googlesyndication\.com=gppglfszndjcbtjpn\.cpm=g' \
  717.             -e 's=flurry\.com=flvrrz\.cpm=g' \
  718.             -e 's=qwapi\.com=qwbpj\.cpm=g' \
  719.             -e 's=mobclix\.com=mpbcljx\.cpm=g' \
  720.             -e 's=http://ad\.=http://bd/=g' \
  721.             -e 's=http://ads\.=http://bds/=g' \
  722.             -e 's=http://ads2\.=http://bds2/=g' \
  723.             -e 's=http://ingameads\.=http://jngbmfbds/=g' \
  724.             -e 's=adwhirl\.com=bdwhjrl\.cpm=g' \
  725.             -e 's=vdopia\.com=vdppjb\.cpm=g' \
  726.             -e 's=tapjoyads\.com=tbpjpzbds\.cpm=g' \
  727.             -e 's=/Library/MobileSubstrate=/Ljbrbrz/MpbjlfSvbstrbtf=g' \
  728.             $DinerDash  "$patchme"
  729.  
  730.         #   "/Applications/mAdvLock.app"
  731.         #   "/Applications/Icy\.app"
  732.         #   "/Applications/SBSettings\.app"
  733.  
  734.         # Disk full ?
  735.         if [ ! -e "$patchme.BCK" ]; then
  736.             echo "${escRed}$MsgDskFull ?${escReset}"
  737.             rm -fr "$WorkDir"
  738.             return 1
  739.         else
  740.             if [ $(stat -c%s "$patchme.BCK") != $(stat -c%s "$patchme") ]; then
  741.                 echo "${escRed}$MsgDskFull ?${escReset}"
  742.                 rm -fr "$WorkDir"
  743.                 return 1
  744.             fi
  745.         fi
  746.  
  747.         # Something patched or not ?
  748.         cmp --silent "$patchme.BCK" "$patchme"
  749.         if [ "$?" != "0" ]; then
  750.             if [ $PCMverbose = "YES" ]; then
  751.                 echo "${Meter59}patched things"
  752.             fi
  753.             Patched=" LP"
  754.             if [ -e "$WorkDir/LP.bin" ]; then
  755.                 foo=$(dd seek=1 count=1 obs=$LPoff ibs=$LPsize conv=notrunc if="$WorkDir/LP.bin" of="$WorkDir/$AppName/$AppExecCur" 2>&1> /dev/null)
  756.             fi
  757.         else
  758.             if [ $PCMverbose = "YES" ]; then
  759.                 echo "${Meter59}found nothing"
  760.             fi
  761.         fi
  762.         rm "$patchme.BCK"
  763.     fi
  764.     if [ -e "$WorkDir/LP.bin" ]; then
  765.         rm "$WorkDir/LP.bin"
  766.     fi
  767. }
  768.  
  769.  
  770. # ======
  771. # Begin Core Function
  772. function CoreFunction
  773. {
  774. AppInput=$1
  775. CrackerName=$2
  776. CreditFile=$3
  777.  
  778. if [ ! "$CrackerName" ]; then
  779.     CrackerName="$PCMcracker"
  780. fi
  781.  
  782. if [ ! "$CreditFile" ]; then
  783.     CreditFile="$CrackerName"
  784. fi
  785.  
  786. # Script has app's full directory path as input (ie: called from GUI)
  787. if [ -d "$AppInput" ]; then
  788.     tempLoc=$AppInput
  789. else
  790.     # Script has app's name as input
  791.     echo "$MsgAppLoca '$AppInput'"
  792.     # Escape the "*" as ".*"
  793.     AppGrep=$(echo "/$AppInput\.app" | sed "s:\*:\.\*:g")
  794.     if [ -e /tmp/lsd.tmp ]; then
  795.         tempLoc=$(grep -i "$AppGrep" /tmp/lsd.tmp)
  796.     else
  797.         tempLoc=""
  798.     fi
  799.     if [ -z "$tempLoc" ]; then
  800.         echo "$MsgUnaLoca '$AppInput'"
  801.         rm -f /tmp/lsd.tmp
  802.         return 1
  803.     fi
  804.     AppCount=$(echo "$tempLoc" | wc -l)
  805.     if [ $AppCount -gt 1 ]; then
  806.         echo "$MsgFoundIt $AppCount installation directories:"
  807.         echo "$tempLoc"
  808.         rm -f /tmp/lsd.tmp
  809.         return 1
  810.     fi
  811. fi
  812.  
  813. # The app has been found
  814. MenuFound=$(($MenuFound + 1))
  815. AppPath=$(dirname "$tempLoc")
  816. AppName=$(basename "$tempLoc")
  817. echo -n "${Meter4}${escCyan}$MsgFoundIt ${escReset}'$(echo $AppName | sed "s:\\.app::")': "
  818.  
  819. if [ ! -d "$AppPath" ]; then
  820.     echo "$MsgUnaLoca original installation directory"
  821.     return 1
  822. fi
  823. if [ ! -d "$AppPath/$AppName" ]; then
  824.     echo "$MsgUnaLoca .app directory"
  825.     return 1
  826. fi
  827. AppExec=$(plutil -key CFBundleExecutable "$tempLoc/Info.plist" 2> /dev/null)
  828. if [ ! -e "$AppPath/$AppName/$AppExec" ]; then
  829.     echo "$MsgUnaLoca executable"
  830.     return 1
  831. fi
  832. # Get the name from MetaData
  833. AppDisplayName=$(plutil -key itemName "$AppPath/iTunesMetadata.plist" 2> /dev/null)
  834. # No alphanum characters at all ?
  835. AppDisplayNameAlpha=$(echo -n "$AppDisplayName" | tr -cd "[:alnum:]")
  836. if [ "$AppDisplayNameAlpha" = "" ]; then
  837.     #echo "${Meter5}$MsgWarning: non-alpha name !"
  838.     AppDisplayName=""
  839. fi
  840. # Get the name from InfoPlist or from executable name
  841. if [ "$AppDisplayName" = "" ]; then
  842.     AppDisplayName=$(plutil -key CFBundleDisplayName "$tempLoc/Info.plist" 2> /dev/null)
  843.     AppDisplayNameAlpha=$(echo -n "$AppDisplayName" | tr -cd "[:alnum:]")
  844.     if [ "$AppDisplayNameAlpha" = "" ]; then
  845.         AppDisplayName=$(plutil -key CFBundleName "$tempLoc/Info.plist" 2> /dev/null)
  846.         AppDisplayNameAlpha=$(echo -n "$AppDisplayName" | tr -cd "[:alnum:]")
  847.         if [ "$AppDisplayNameAlpha" = "" ]; then
  848.             AppDisplayName=$AppExec
  849.             #AppDisplayNameAlpha=$(echo -n "$AppDisplayName" | tr -cd "[:alnum:]")
  850.             #if [ "$AppDisplayNameAlpha" = "" ]; then
  851.             #   echo "${Meter6}$MsgWarning: too exotic name !"
  852.             #fi
  853.         fi
  854.     fi
  855. fi
  856.  
  857. # Convert AppName from unicode to human
  858. unicode=$AppDisplayName
  859. UnicodeToHuman
  860. AppDisplayName=$human
  861.  
  862. # Get the artist name from MetaData
  863. if [ $PCMartistfrommeta = "YES" ]; then
  864.     artistName=$(plutil -key artistName "$AppPath/iTunesMetadata.plist" 2> /dev/null)
  865.     artistNameAlpha=$(echo -n "$artistName" | tr -cd "[:alnum:]")
  866.     # At least some alphanum inside ?
  867.     if [ "$artistNameAlpha" != "" ]; then
  868.         # Convert from unicode to human
  869.         unicode=$artistName
  870.         UnicodeToHuman
  871.         AppDisplayName="$AppDisplayName [$human]"
  872.     fi
  873. fi
  874.  
  875. # Show the real human name of the app
  876. echo "${Meter5}$AppDisplayName"
  877.  
  878. # Dealing with version numbers
  879. AppVer=$(plutil -key CFBundleVersion "$tempLoc/Info.plist" 2> /dev/null | tr -d "\n\r")
  880. AppShortVer=$(plutil -key CFBundleShortVersionString "$tempLoc/Info.plist" 2> /dev/null | tr -d "\n\r")
  881. if [ ! "$AppShortVer" = "" ]; then
  882.     if [ ! "$AppShortVer" = "$AppVer" ]; then
  883.         AppVer="$AppShortVer v$AppVer"
  884.     fi
  885. fi
  886. MinOS=$(plutil -key MinimumOSVersion "$tempLoc/Info.plist" 2> /dev/null | tr -d ".")
  887. if [ "$MinOS" = "" ]; then
  888.     echo "${Meter7}${escYellow}$MsgWarning:${escReset} unable to get MinOS"
  889.     MinOS="000"
  890. fi
  891.  
  892. Patched=""
  893. Fixed=""
  894. Extras=""
  895. ExtrasMatos=""
  896. ExtrasAslr=""
  897.  
  898. # Does it need at least an iPhone3GS ?
  899. Required=$(plutil -key 'UIRequiredDeviceCapabilities' "$tempLoc/Info.plist" 2> /dev/null)
  900. if [ ! -z "$(echo "$Required" | grep -e "armv7" -e "opengles-2")" ]; then
  901.     ExtrasMatos=" 3GS"
  902. fi
  903. # Does it need at least an iPhone4 ?
  904. if [ ! -z "$(echo "$Required" | grep -e "front-facing-camera" -e "gyroscope")" ]; then
  905.     ExtrasMatos=" iPhone4"
  906. fi
  907.  
  908. # Is it iPad compatible only ? Or universal ?
  909. iPad=$(plutil -key 'UIDeviceFamily' "$tempLoc/Info.plist" 2> /dev/null)
  910. if [ ! -z "$iPad" ]; then
  911.     if [ -z "$(echo "$iPad" | grep -e "1")" ]; then
  912.         ExtrasMatos=" iPad"
  913.     else
  914.         if [ ! -z "$(echo "$iPad" | grep -e "2")" ]; then
  915.             ExtrasMatos="$ExtrasMatos Univ"
  916.         fi
  917.     fi
  918. fi
  919.  
  920. # Creating temporary directory
  921. if [ $PCMverbose = "YES" ]; then
  922.     echo -n "${Meter10}$MsgCreDire "
  923. fi
  924. WorkDir="/tmp/PCM-$(date +%Y%m%d-%H%M%S)"
  925. NewAppDir="$HOME/Documents/Cracked"
  926. if [ -e "$WorkDir" ]; then
  927.     rm -rf "$WorkDir"
  928. fi
  929. mkdir -p "$WorkDir"
  930. if [ ! -e "$NewAppDir" ]; then
  931.     mkdir -p "$NewAppDir"
  932. fi
  933. mkdir -p "$WorkDir/$AppName"
  934. if [ ! -d "$WorkDir" -o ! -d "$NewAppDir" -o ! -d "$WorkDir/$AppName" ]; then
  935.     echo "failed ! Directories not created"
  936.     return 1
  937. fi
  938.  
  939. # Copying executable to temporary space
  940. if [ $PCMverbose = "YES" ]; then
  941.     echo "${Meter15}$MsgCopExec"
  942. fi
  943.  
  944. foo=$( cp -a "$AppPath/$AppName/$AppExec" "$WorkDir/$AppName/" 2>&1> /dev/null )
  945. if [ ! -e "$WorkDir/$AppName/$AppExec" ]; then
  946.     echo "Unable to copy application files"
  947.     rm -fr "$WorkDir"
  948.     return 1
  949. else
  950.     # Disk full ?
  951.     if [ $(stat -c%s "$WorkDir/$AppName/$AppExec") != $(stat -c%s "$AppPath/$AppName/$AppExec") ]; then
  952.         echo "${escRed}$MsgDskFull ?${escReset}"
  953.         rm -fr "$WorkDir"
  954.         return 1
  955.     fi
  956. fi
  957.  
  958. if [ $PCMverbose = "YES" ]; then
  959.     echo -n "${Meter20}$MsgAnaAppl: "
  960. fi
  961.  
  962. # Looking for fat's magic numbers (CafeBabe)
  963. CafeBabeIsFat=$(dd bs=4 count=1 skip=0 if="$WorkDir/$AppName/$AppExec" 2> /dev/null | od -A n -t x1 -v | grep "ca fe ba be")
  964. if [ ! "$CafeBabeIsFat" ]; then
  965.     if [ $PCMverbose = "YES" ]; then
  966.         echo "${Meter25}Thin Binary found"
  967.     fi
  968. else
  969.     if [ $PCMverbose = "YES" ]; then
  970.         echo "${Meter25}Fat Binary found"
  971.     fi
  972.  
  973.     # Get the fat's full headers, then extract the infos
  974.     foo=$(dd bs=4096 count=1 skip=0 if="$WorkDir/$AppName/$AppExec" of="$WorkDir/$AppName/CafeBabe.is.Fat" 2>&1> /dev/null)
  975.     FullCafeBabe=$(cat "$WorkDir/$AppName/CafeBabe.is.Fat" | od -A n -t x1 -v | tr -d ' ','\n')
  976.     SixOrNine=${FullCafeBabe:30:2}
  977.     NineOrSix=${FullCafeBabe:70:2}
  978.     if [ "$SixOrNine" = "06" ]; then
  979.         SixSix=${FullCafeBabe:32:16}
  980.     fi
  981.     if [ "$SixOrNine" = "09" ]; then
  982.         NineNine=${FullCafeBabe:32:16}
  983.     fi
  984.     if [ "$NineOrSix" = "06" ]; then
  985.         SixSix=${FullCafeBabe:72:16}
  986.     fi
  987.     if [ "$NineOrSix" = "09" ]; then
  988.         NineNine=${FullCafeBabe:72:16}
  989.     fi
  990.     SixOff=$(echo "0x${SixSix:0:8}" | awk --non-decimal-data '{print ($1)+1 }')
  991.     SixSize=$(echo "0x${SixSix:8:8}" | awk --non-decimal-data '{print ($1)+0 }')
  992.     NineOff=$(echo "0x${NineNine:0:8}" | awk --non-decimal-data '{print ($1)+1 }')
  993.     NineSize=$(echo "0x${NineNine:8:8}" | awk --non-decimal-data '{print ($1)+0 }')
  994.  
  995.     # Cut the arm6 part from the fat binary
  996.     if [ $PCMverbose = "YES" ]; then
  997.         echo "${Meter26}Dumping armv6 section"
  998.     fi
  999.     foo=$( cat "$WorkDir/$AppName/$AppExec" | tail --bytes=+$SixOff | head --bytes=$SixSize > "$WorkDir/$AppName/IWantYourSix" 2> /dev/null )
  1000.  
  1001.     # Disk full ?
  1002.     if [ ! -e "$WorkDir/$AppName/IWantYourSix" ]; then
  1003.         echo "${escRed}$MsgDskFull ?${escReset}"
  1004.         rm -fr "$WorkDir"
  1005.         return 1
  1006.     else
  1007.         if [ $(stat -c%s "$WorkDir/$AppName/IWantYourSix") != $SixSize ]; then
  1008.             echo "${escRed}$MsgDskFull ?${escReset}"
  1009.             rm -fr "$WorkDir"
  1010.             return 1
  1011.         fi
  1012.     fi
  1013.  
  1014.     chmod 777 "$WorkDir/$AppName/IWantYourSix"
  1015.  
  1016.     # Force armv7 processing on armv6 devices. (It won't work at all; for debug only !)
  1017.     if [ $PCMarm7onarm6 = "YES" ]; then
  1018.         echo "${Meter27}${escYellow}$MsgWarning:${escReset} forcing armv7 is stupid !"
  1019.         CPUType=""
  1020.     else
  1021.         CPUType=$(sysctl hw.cpusubtype | grep 6 | awk '{print $2}')
  1022.     fi
  1023.  
  1024.     # The iDevice has an arm7 cpu
  1025.     if [ ! $CPUType ]; then
  1026.         if [ $PCMverbose = "YES" ]; then
  1027.             echo "${Meter28}Dumping armv7 section"
  1028.         fi
  1029.  
  1030.         # Swapping armv6 and armv7 headers (for later SwapSwapAttack)
  1031.         SixOrNine=$(dd bs=1 count=1 skip=15 if="$WorkDir/$AppName/$AppExec" 2> /dev/null)
  1032.         NineOrSix=$(dd bs=1 count=1 skip=35 if="$WorkDir/$AppName/$AppExec" 2> /dev/null)
  1033.         foo=$(echo -n "$NineOrSix" | dd bs=1 seek=15 conv=notrunc status=noxfer of="$WorkDir/$AppName/$AppExec" 2>&1> /dev/null)
  1034.         foo=$(echo -n "$SixOrNine" | dd bs=1 seek=35 conv=notrunc status=noxfer of="$WorkDir/$AppName/$AppExec" 2>&1> /dev/null)
  1035.  
  1036.         # Dumping swapped armv7 part
  1037.         foo=$( cat "$WorkDir/$AppName/$AppExec" | tail --bytes=+$NineOff | head --bytes=$NineSize > "$WorkDir/$AppName/SevenTrumpets" 2> /dev/null )
  1038.  
  1039.         # Disk full ?
  1040.         if [ ! -e "$WorkDir/$AppName/SevenTrumpets" ]; then
  1041.             echo "${escRed}$MsgDskFull ?${escReset}"
  1042.             rm -fr "$WorkDir"
  1043.             return 1
  1044.         else
  1045.             if [ $(stat -c%s "$WorkDir/$AppName/SevenTrumpets") != $NineSize ]; then
  1046.                 echo "${escRed}$MsgDskFull ?${escReset}"
  1047.                 rm -fr "$WorkDir"
  1048.                 return 1
  1049.             fi
  1050.         fi
  1051.  
  1052.         chmod 777 "$WorkDir/$AppName/SevenTrumpets"
  1053.     else
  1054.         if [ $PCMverbose = "YES" ]; then
  1055.             echo "${Meter28}Non armv7 compatible CPU: not dumping armv7"
  1056.         fi
  1057.     fi
  1058.     # (Deleting the swapped fat binary: later. We still need it)
  1059. fi
  1060.  
  1061.  
  1062. # Cracking the parts
  1063. if [ ! "$CafeBabeIsFat" ]; then
  1064.     # Thin binary: only one part to crack
  1065.     CrackFunction "$AppExec" "$AppPath/$AppName/$AppExec" 0
  1066. else
  1067.     # Fat binary: two parts to crack
  1068.     if [ $PCMverbose = "YES" ]; then
  1069.         echo "${Meter30}--- Cracking armv6 section ---"
  1070.     fi
  1071.     # If arm7 device, two parts are cracked.
  1072.     if [ ! $CPUType ]; then
  1073.         # Cracking the previously swapped fat binary in WorkDir
  1074. ##      if [ $PCMverbose = "YES" ]; then
  1075. ##          echo "${Meter31}Swap Swap Attack !"
  1076. ##      fi
  1077.  
  1078.         # Copying some files
  1079.         mkdir "$WorkDir/$AppName/SC_Info"
  1080.         chmod 777 "$WorkDir/$AppName/SC_Info"
  1081.         cp "$AppPath/$AppName/SC_Info/$AppExec.sinf" "$WorkDir/$AppName/SC_Info/$AppExec.sinf"
  1082.         chmod 777 "$WorkDir/$AppName/SC_Info/$AppExec.sinf"
  1083.         cp "$AppPath/$AppName/SC_Info/$AppExec.supp" "$WorkDir/$AppName/SC_Info/$AppExec.supp"
  1084.         chmod 777 "$WorkDir/$AppName/SC_Info/$AppExec.supp"
  1085.  
  1086.         # If first part (arm6) of a fat binary and running an arm7 iDevice, swap trick !
  1087.         # (The arm7 iDevice always load the arm7 part, but it's swapped with the arm6 part: tricked).
  1088.         CrackFunction "IWantYourSix" "$WorkDir/$AppName/$AppExec" $(($SixOff - 1))
  1089.         RetRet=$?
  1090.         if [ $RetRet != 0 ]; then
  1091.             echo "${Meter32}${escRed}Error:${escReset} problem encountered in CrackFunction"
  1092.             rm -fr "$WorkDir"
  1093.             return $RetRet
  1094.         fi
  1095.  
  1096.         # Removing temp files
  1097.         rm "$WorkDir/$AppName/$AppExec"
  1098.         rm "$WorkDir/$AppName/SC_Info/$AppExec.sinf"
  1099.         rm "$WorkDir/$AppName/SC_Info/$AppExec.supp"
  1100.         rmdir "$WorkDir/$AppName/SC_Info"
  1101.  
  1102.         if [ $PCMverbose = "YES" ]; then
  1103.             echo "${Meter30}--- Cracking armv7 section ---"
  1104.         fi
  1105.         CrackFunction "SevenTrumpets" "$AppPath/$AppName/$AppExec" $(($NineOff - 1))
  1106.     else
  1107.         # Only arm6 part is cracked on arm6 devices.
  1108.         CrackFunction "IWantYourSix" "$AppPath/$AppName/$AppExec" $(($SixOff - 1))
  1109.     fi
  1110. fi
  1111. RetRet=$?
  1112. if [ $RetRet != 0 ]; then
  1113.     echo "${Meter60}${escRed}Error:${escReset} problem encountered in CrackFunction"
  1114.     rm -fr "$WorkDir"
  1115.     return $RetRet
  1116. fi
  1117.  
  1118.  
  1119. # Unsplitting fat binary
  1120. if [ "$CafeBabeIsFat" ]; then
  1121.     # Removing old swapped fat binary
  1122.     rm -f "$WorkDir/$AppName/$AppExec"
  1123.     if [ $PCMverbose = "YES" ]; then
  1124.         echo "${Meter61}---"
  1125.     fi
  1126.     # If there are two parts to paste
  1127.     if [ -e "$WorkDir/$AppName/SevenTrumpets" ]; then
  1128.         if [ $PCMverbose = "YES" ]; then
  1129.             echo "${Meter62}$MsgComBoth"
  1130.         fi
  1131.  
  1132.         if [ $NineOff -gt $SixOff ]; then
  1133.             foo=$( cat "$WorkDir/$AppName/CafeBabe.is.Fat" "$WorkDir/$AppName/IWantYourSix" /dev/zero | head --bytes=$(($NineOff - 1)) > "$WorkDir/$AppName/TaSoeurEstGrosse"  2> /dev/null )
  1134.             foo=$( cat "$WorkDir/$AppName/TaSoeurEstGrosse" "$WorkDir/$AppName/SevenTrumpets" > "$WorkDir/$AppName/$AppExec"  2> /dev/null )
  1135.             rm -f "$WorkDir/$AppName/TaSoeurEstGrosse"
  1136.         else
  1137.             #echo "${Meter64}$MsgWarning: Six ($SixOff) is bigger ($NineOff)"
  1138.             foo=$( cat "$WorkDir/$AppName/CafeBabe.is.Fat" "$WorkDir/$AppName/SevenTrumpets" /dev/zero | head --bytes=$(($SixOff - 1)) > "$WorkDir/$AppName/TaSoeurEstGrosse"  2> /dev/null )
  1139.             foo=$( cat "$WorkDir/$AppName/TaSoeurEstGrosse" "$WorkDir/$AppName/IWantYourSix" > "$WorkDir/$AppName/$AppExec"  2> /dev/null )
  1140.             rm -f "$WorkDir/$AppName/TaSoeurEstGrosse"
  1141.         fi
  1142.         rm "$WorkDir/$AppName/IWantYourSix"
  1143.         rm "$WorkDir/$AppName/SevenTrumpets"
  1144.         # Disk full ?
  1145.         if [ $(stat -c%s "$WorkDir/$AppName/$AppExec") != $(stat -c%s "$AppPath/$AppName/$AppExec") ]; then
  1146.             echo "${escRed}$MsgDskFull ?${escReset}"
  1147.             rm -fr "$WorkDir"
  1148.             return 1
  1149.         fi
  1150.     else
  1151.         # Only arm6 part is done
  1152.         mv "$WorkDir/$AppName/IWantYourSix" "$WorkDir/$AppName/$AppExec"
  1153.     fi
  1154.  
  1155.     # Disk full ?
  1156.     if [ ! -e "$WorkDir/$AppName/$AppExec" ]; then
  1157.         echo "${escRed}$MsgDskFull ?${escReset}"
  1158.         rm -fr "$WorkDir"
  1159.         return 1
  1160.     fi
  1161.  
  1162.     chmod 777 "$WorkDir/$AppName/$AppExec"
  1163.  
  1164.     # Dropping my girlfriend
  1165.     if [ -e "$WorkDir/$AppName/CafeBabe.is.Fat" ]; then
  1166.         rm -f "$WorkDir/$AppName/CafeBabe.is.Fat"
  1167.     fi
  1168. fi
  1169.  
  1170. # Signing the application with 'ldone' (better than 'ldid').
  1171. if [ $PCMverbose = "YES" ]; then
  1172.     echo "${Meter64}$MsgSgnAppl"
  1173. fi
  1174. foo=$(ldone "$WorkDir/$AppName/$AppExec" -s 2>&1> /dev/null)
  1175.  
  1176. # Timestamp-back executable to defeat checks
  1177. touch -r "$AppPath/$AppName/$AppExec" "$WorkDir/$AppName/$AppExec"
  1178.  
  1179. # Adding date
  1180. DayToday="$( date +%Y-%m-%d )"
  1181.  
  1182. # Adding credits file
  1183. if [ ! "$CrackerName" = "Anonymous" ]; then
  1184.     if [ $PCMverbose = "YES" ]; then
  1185.         echo "${Meter65}Adding Credits"
  1186.     fi
  1187.     echo "Cracked by $CrackerName ($DayToday)" > "$WorkDir/$AppName/$CreditFile"
  1188.     if [ ! -e "$AppPath/$AppName/$AppExec.crc" ]; then
  1189.         echo "CheckSum=$(echo -n "$CrackerName" | od -A n -t x1 -v | tr -d ' ','\n')" > "$WorkDir/$AppName/$AppExec.crc"
  1190.         touch -r "$AppPath/$AppName/$AppExec" "$WorkDir/$AppName/$AppExec.crc"
  1191.     fi
  1192. fi
  1193.  
  1194. # Building .ipa (step 1)
  1195. mkdir -p "$WorkDir/Payload"
  1196. if [ ! -e "$WorkDir/Payload" ]; then
  1197.     echo "Failed to create Payload directory"
  1198.     rm -fr "$WorkDir"
  1199.     return 1
  1200. fi
  1201. mv "$WorkDir/$AppName" "$WorkDir/Payload/"
  1202.  
  1203. if [ $PCMverbose = "YES" ]; then
  1204.     echo -n "${Meter66}$MsgCopArtw "
  1205. fi
  1206. if [ -e "$AppPath/iTunesArtwork" ]; then
  1207.     cp -a "$AppPath/iTunesArtwork" "$WorkDir/"
  1208.     # Timestamp ArtWork to protect cracker
  1209.     touch -r "$AppPath/$AppName/Info.plist" "$WorkDir/iTunesArtwork"
  1210. else
  1211.     echo "${Meter66}failed !"
  1212. fi
  1213.  
  1214. # Handling of CodeResources and friends. Timestamp them to protect cracker
  1215. cp -a "$AppPath/$AppName/Info.plist" "$WorkDir/Payload/$AppName/Info.plist"
  1216. mkdir "$WorkDir/Payload/$AppName/_CodeSignature"
  1217. cp "$AppPath/$AppName/_CodeSignature/CodeResources" "$WorkDir/Payload/$AppName/_CodeSignature/CodeResources"
  1218. touch -r "$AppPath/$AppName/Info.plist" "$WorkDir/Payload/$AppName/_CodeSignature/CodeResources"
  1219. if [ -e "$AppPath/$AppName/CodeResources" ]; then
  1220.     ln -s "_CodeSignature/CodeResources" "$WorkDir/Payload/$AppName/CodeResources"
  1221.     touch -h -r "$AppPath/$AppName/Info.plist" "$WorkDir/Payload/$AppName/CodeResources"
  1222. fi
  1223. if [ -e "$AppPath/$AppName/ResourceRules.plist" ]; then
  1224.     cp "$AppPath/$AppName/ResourceRules.plist" "$WorkDir/Payload/$AppName/ResourceRules.plist"
  1225.     touch -r "$AppPath/$AppName/Info.plist" "$WorkDir/Payload/$AppName/ResourceRules.plist"
  1226. fi
  1227.  
  1228. # Faking MetaData
  1229. if [ $PCMverbose = "YES" ]; then
  1230.     if [ $PCMmetadata = "YES" ]; then
  1231.         echo "${Meter69}$MsgFakMeta"
  1232.     else
  1233.         echo "${Meter69}$MsgNotMeta"
  1234.     fi
  1235. fi
  1236. if [ "$CrackerName" = "Anonymous" ]; then
  1237.     CrackedBy="Timothy.D.Cook@apple.com"
  1238. else
  1239.     CrackedBy="$CrackerName@cracked.by"
  1240.     echo "${Patched}PCM$CrackerName" | tr -cd "[:alnum:]" | tr "[A-Z][a-z][1-9]" "[1-9][a-z][A-Z]" > "$WorkDir/Payload/$AppName/_CodeSignature/ResourceRules"
  1241.     touch -r "$AppPath/$AppName/Info.plist" "$WorkDir/Payload/$AppName/_CodeSignature/ResourceRules"
  1242. fi
  1243.  
  1244. touch -r "$AppPath/$AppName/Info.plist" "$WorkDir/Payload/$AppName/_CodeSignature"
  1245.  
  1246. if [ -e "$AppPath/iTunesMetadata.plist" ]; then
  1247.     cp "$AppPath/iTunesMetadata.plist" "$WorkDir/iTunesMetadataSource.plist"
  1248. else
  1249.     echo "${Meter69}${escRed}Error:${escReset} problem with MetaData !"
  1250.     plutil -create "$WorkDir/iTunesMetadataSource.plist" 2>&1> /dev/null
  1251. fi
  1252.  
  1253. # Convert to pure text (if binary plist)
  1254. plutil -xml "$WorkDir/iTunesMetadataSource.plist" 2>&1> /dev/null
  1255. # Remove unwanted keys and subkeys
  1256. plutil -remove -key 'com.apple.iTunesStore.downloadInfo' "$WorkDir/iTunesMetadataSource.plist" 2>&1> /dev/null
  1257. plutil -remove -key 'asset-info' "$WorkDir/iTunesMetadataSource.plist" 2>&1> /dev/null
  1258. plutil -remove -key 'is-purchased-redownload' "$WorkDir/iTunesMetadataSource.plist" 2>&1> /dev/null
  1259. # Building lines
  1260. echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" > "$WorkDir/iTunesMetadata.plist"
  1261. echo "<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">" >> "$WorkDir/iTunesMetadata.plist"
  1262. echo "<plist version=\"1.0\">" >> "$WorkDir/iTunesMetadata.plist"
  1263. echo "<dict>" >> "$WorkDir/iTunesMetadata.plist"
  1264. grep -A99 "<key>UIRequiredDeviceCapabilities</key>" "$WorkDir/iTunesMetadataSource.plist" | grep -m1 -B99 "</dict>" >> "$WorkDir/iTunesMetadata.plist"
  1265. echo -e "\t<key>appleId</key>" >> "$WorkDir/iTunesMetadata.plist"
  1266. echo -e "\t<string>$CrackedBy</string>" >> "$WorkDir/iTunesMetadata.plist"
  1267. echo -e "\t<key>purchaseDate</key>" >> "$WorkDir/iTunesMetadata.plist"
  1268. echo -e "\t<date>2012-07-07T07:07:07Z</date>" >> "$WorkDir/iTunesMetadata.plist"
  1269. grep -A1 "<key>artistId</key>" "$WorkDir/iTunesMetadataSource.plist" >> "$WorkDir/iTunesMetadata.plist"
  1270. grep -A1 "<key>artistName</key>" "$WorkDir/iTunesMetadataSource.plist" >> "$WorkDir/iTunesMetadata.plist"
  1271. grep -A1 "<key>bundleShortVersionString</key>" "$WorkDir/iTunesMetadataSource.plist" >> "$WorkDir/iTunesMetadata.plist"
  1272. grep -A1 "<key>bundleVersion</key>" "$WorkDir/iTunesMetadataSource.plist" >> "$WorkDir/iTunesMetadata.plist"
  1273. grep -A1 "<key>buy-only</key>" "$WorkDir/iTunesMetadataSource.plist" >> "$WorkDir/iTunesMetadata.plist"
  1274. grep -A1 "<key>buyParams</key>" "$WorkDir/iTunesMetadataSource.plist" >> "$WorkDir/iTunesMetadata.plist"
  1275. grep -A1 "<key>copyright</key>" "$WorkDir/iTunesMetadataSource.plist" >> "$WorkDir/iTunesMetadata.plist"
  1276. grep -A1 "<key>drmVersionNumber</key>" "$WorkDir/iTunesMetadataSource.plist" >> "$WorkDir/iTunesMetadata.plist"
  1277. grep -A1 "<key>fileExtension</key>" "$WorkDir/iTunesMetadataSource.plist" >> "$WorkDir/iTunesMetadata.plist"
  1278. grep -A1 "<key>gameCenterEnabled</key>" "$WorkDir/iTunesMetadataSource.plist" >> "$WorkDir/iTunesMetadata.plist"
  1279. grep -A1 "<key>gameCenterEverEnabled</key>" "$WorkDir/iTunesMetadataSource.plist" >> "$WorkDir/iTunesMetadata.plist"
  1280. grep -A1 -m1 "<key>genre</key>" "$WorkDir/iTunesMetadataSource.plist" >> "$WorkDir/iTunesMetadata.plist"
  1281. grep -A1 -m1 "<key>genreId</key>" "$WorkDir/iTunesMetadataSource.plist" >> "$WorkDir/iTunesMetadata.plist"
  1282. grep -A1 "<key>itemId</key>" "$WorkDir/iTunesMetadataSource.plist" >> "$WorkDir/iTunesMetadata.plist"
  1283. grep -A1 "<key>itemName</key>" "$WorkDir/iTunesMetadataSource.plist" >> "$WorkDir/iTunesMetadata.plist"
  1284. grep -A1 "<key>kind</key>" "$WorkDir/iTunesMetadataSource.plist" >> "$WorkDir/iTunesMetadata.plist"
  1285. grep -A1 "<key>playlistArtistName</key>" "$WorkDir/iTunesMetadataSource.plist" >> "$WorkDir/iTunesMetadata.plist"
  1286. grep -A1 "<key>playlistName</key>" "$WorkDir/iTunesMetadataSource.plist" >> "$WorkDir/iTunesMetadata.plist"
  1287. grep -A1 "<key>price</key>" "$WorkDir/iTunesMetadataSource.plist" >> "$WorkDir/iTunesMetadata.plist"
  1288. grep -A1 "<key>priceDisplay</key>" "$WorkDir/iTunesMetadataSource.plist" >> "$WorkDir/iTunesMetadata.plist"
  1289. grep -A1 "<key>product-type</key>" "$WorkDir/iTunesMetadataSource.plist" >> "$WorkDir/iTunesMetadata.plist"
  1290. grep -A99 "<key>rating</key>" "$WorkDir/iTunesMetadataSource.plist" | grep -m1 -B99 "</dict>" >> "$WorkDir/iTunesMetadata.plist"
  1291. grep -A1 "<key>releaseDate</key>" "$WorkDir/iTunesMetadataSource.plist" >> "$WorkDir/iTunesMetadata.plist"
  1292. grep -A1 "<key>s</key>" "$WorkDir/iTunesMetadataSource.plist" >> "$WorkDir/iTunesMetadata.plist"
  1293. grep -A1 "<key>software-type</key>" "$WorkDir/iTunesMetadataSource.plist" >> "$WorkDir/iTunesMetadata.plist"
  1294. grep -A1 "<key>softwareIcon57x57URL</key>" "$WorkDir/iTunesMetadataSource.plist" >> "$WorkDir/iTunesMetadata.plist"
  1295. grep -A1 "<key>softwareIconNeedsShine</key>" "$WorkDir/iTunesMetadataSource.plist" >> "$WorkDir/iTunesMetadata.plist"
  1296. grep -A99 "<key>softwareSupportedDeviceIds</key>" "$WorkDir/iTunesMetadataSource.plist" | grep -m1 -B99 "</array>" >> "$WorkDir/iTunesMetadata.plist"
  1297. grep -A1 "<key>softwareVersionBundleId</key>" "$WorkDir/iTunesMetadataSource.plist" >> "$WorkDir/iTunesMetadata.plist"
  1298. grep -A1 "<key>softwareVersionExternalIdentifier</key>" "$WorkDir/iTunesMetadataSource.plist" >> "$WorkDir/iTunesMetadata.plist"
  1299. grep -A99 "<key>softwareVersionExternalIdentifiers</key>" "$WorkDir/iTunesMetadataSource.plist" | grep -m1 -B99 "</array>" >> "$WorkDir/iTunesMetadata.plist"
  1300. grep -A99 "<key>subgenres</key>" "$WorkDir/iTunesMetadataSource.plist" | grep -m1 -B99 "</array>" >> "$WorkDir/iTunesMetadata.plist"
  1301. grep -A1 "<key>vendorId</key>" "$WorkDir/iTunesMetadataSource.plist" >> "$WorkDir/iTunesMetadata.plist"
  1302. grep -A1 "<key>versionRestrictions</key>" "$WorkDir/iTunesMetadataSource.plist" >> "$WorkDir/iTunesMetadata.plist"
  1303. echo "</dict>" >> "$WorkDir/iTunesMetadata.plist"
  1304. echo -e "</plist>\n" >> "$WorkDir/iTunesMetadata.plist"
  1305. # Timestamp Metadata to protect cracker
  1306. touch -r "$AppPath/$AppName/Info.plist" "$WorkDir/iTunesMetadata.plist"
  1307.  
  1308. # Check for possible iTunesMetadata format changes
  1309. rm -f /tmp/diff.txt
  1310. diff "$WorkDir/iTunesMetadataSource.plist" "$WorkDir/iTunesMetadata.plist" > /tmp/diff.txt
  1311. rm -f "$WorkDir/iTunesMetadataSource.plist"
  1312. NewFields=$(wc -l /tmp/diff.txt | cut -f 1 -d " ")
  1313. if [ $NewFields -ne "11" -a $NewFields -ne "7" ]; then
  1314.     echo "${Meter70}${escYellow}$MsgWarning: $MsgWrnMeta ?${escReset}"
  1315.     #BEGIN DEBUG
  1316.     #echo "( $NewFields )"
  1317.     #cat /tmp/diff.txt
  1318.     #END DEBUG
  1319. fi
  1320. rm -f /tmp/diff.txt
  1321.  
  1322. # Don't want MetaData ? Keeping a backup
  1323. if [ ! $PCMmetadata = "YES" ]; then
  1324.     mv "$WorkDir/iTunesMetadata.plist" "$WorkDir/iTunesMetadata$PCMmetadatafilename.plist"
  1325. fi
  1326.  
  1327. # Want Extras in filename ?
  1328. if [ $PCMextras = "YES" ]; then
  1329.     Extras="$ExtrasMatos$ExtrasAslr"
  1330. fi
  1331.  
  1332. # Building IPA name, adding AppVersion and MinOsVersion, adding CrackerName
  1333. if [ "$CrackerName" = "Anonymous" ]; then
  1334.     CrackedBy=""
  1335.     ZipComment="25Lr12 ($DayToday)"
  1336. else
  1337.     CrackedBy="-$CrackerName"
  1338.     ZipComment="From $CrackerName with 25Lr12 ($DayToday)"
  1339. fi
  1340.  
  1341. # Cutting too long app name
  1342. AppDisplayName=${AppDisplayName:0:200}
  1343.  
  1344.  IPAName="$NewAppDir/$AppDisplayName (v$AppVer$Extras$Patched$Fixed os$MinOS)$CrackedBy.Lr12.ipa"
  1345. #IPAName="$NewAppDir/$(echo -n "$AppDisplayName" | tr " " ".")-v$AppVer$CrackedBy.ipa"
  1346.  
  1347. # If debug-check-only, don't create Ipa
  1348. if [ $PCMcheck = "YES" ]; then
  1349.     touch "$IPAName.checked"
  1350.     echo "${Meter100}${escGreen}Check:${escReset} $AppDisplayName (v$AppVer$Extras$Patched os$MinOS)."
  1351.     rm -fr "$WorkDir"
  1352.     echo "$tempLoc" >> /var/mobile/.cracked.log
  1353.     MenuOK=$(($MenuOK + 1))
  1354.     return 0
  1355. fi
  1356.  
  1357. #DEBUG
  1358. #FreeSize=$(df -m "$NewAppDir/" | grep disk | awk '{print $4}')
  1359. #echo "${Meter74}Debug: free size on device    [$FreeSize M$MsgSizUnit]"
  1360. #DEBUG
  1361.  
  1362. # Size of first data to compress
  1363. FirstSize=$(du -m -s "$WorkDir" | cut -f 1)
  1364. echo "${Meter75}$MsgZipStep 1) [$FirstSize M$MsgSizUnit]"
  1365.  
  1366. # Timestamping
  1367. touch -r "$AppPath/$AppName/Info.plist" "$WorkDir/Payload/$AppName"
  1368. touch -r "$AppPath/$AppName/Info.plist" "$WorkDir/Payload"
  1369.  
  1370. cd "$WorkDir"
  1371. rm -f "$IPAName"
  1372. # Script version number in zip's comment
  1373. # Faster ipa thanks to smart files order (?)
  1374. ZipError=$( echo "$ZipComment" | zip $PCMcompression -z -y -m -r "$IPAName" "Payload/$AppName/Info.plist" iTunesMetadata$PCMmetadatafilename.plist iTunesArtwork Payload  2>&1> /dev/null )
  1375. #DEBUG: unzip -l "$IPAName"
  1376. cd "$PwdPwd" 2>&1> /dev/null
  1377.  
  1378. if [ ! -z "$ZipError" ]; then
  1379.     echo "${Meter76}${escRed}ZipError${escReset}: \"$( echo "$ZipError" | tr -d "\t\n" )\""
  1380. fi
  1381.  
  1382. if [ ! -e "$IPAName" ]; then
  1383.     echo "${escRed}Failed to compress the .ipa${escReset}"
  1384.     rm -fr "$WorkDir"
  1385.     return 1
  1386. fi
  1387.  
  1388. # Remember size of .ipa after step 1
  1389. ZipSize=$(stat -c%s "$IPAName")
  1390.  
  1391. # Building .ipa (step 2)
  1392. # Using a SymbolicLink pointing to App Directory
  1393. ln -s "$AppPath/" "$WorkDir/Payload"
  1394.  
  1395. #DEBUG
  1396. #FreeSize=$(df -m "$NewAppDir/" | grep disk | awk '{print $4}')
  1397. #echo "${Meter74}Debug: free size on device    [$FreeSize M$MsgSizUnit]"
  1398. #DEBUG
  1399.  
  1400. # Size of other data to compress
  1401. SecondSize=$(du -m -s "$AppPath" | cut -f 1)
  1402. echo "${Meter80}$MsgZipStep 2) [$(( $SecondSize - $FirstSize )) M$MsgSizUnit]"
  1403.  
  1404. cd "$WorkDir"
  1405. # Zip doesn't move/delete source, and excludes some unwanted files. Smart "-n" flag excludes already compact files.
  1406. ZipError=$( zip $PCMcompression -u -y -r -n .jpg:.JPG:.jpeg:.png:.PNG:.gif:.GIF:.Z:.gz:.zip:.zoo:.arc:.lzh:.rar:.arj:.mp3:.mp4:.m4a:.m4v:.ogg:.ogv:.avi:.flac:.aac \
  1407.     "$IPAName" Payload/* -x Payload/iTunesArtwork Payload/iTunesMetadata.plist "Payload/Documents/*" "Payload/Library/*" "Payload/tmp/*" "Payload/$AppName/$AppExec" "Payload/$AppName/SC_Info/*" "Payload/$AppName/_CodeSignature/*" "Payload/$AppName/CodeResources" "Payload/$AppName/ResourceRules.plist" "Payload/$AppName/Info.plist" 2>&1> /dev/null )
  1408. ## */
  1409.  
  1410. if [ ! -z "$ZipError" ]; then
  1411.     echo "${Meter81}${escRed}ZipError${escReset}: \"$( echo "$ZipError" | tr -d "\t\n" )\""
  1412. fi
  1413.  
  1414. # It failed because disk is full (zip size after part2 is still the same)
  1415. if [ $(stat -c%s "$IPAName") -eq $ZipSize ]; then
  1416.     echo "${escRed}$MsgIpaInco ! $MsgDskFull ?${escReset}"
  1417.     rm -f "$IPAName"
  1418.     rm -fr "$WorkDir"
  1419.     return 1
  1420. fi
  1421.  
  1422. # Removing SymbolicLink
  1423. rm "$WorkDir/Payload"
  1424. cd "$PwdPwd" 2>&1> /dev/null
  1425.  
  1426. # Removing temporary directory
  1427. if [ $PCMverbose = "YES" ]; then
  1428.     echo "${Meter98}$MsgRemTemp"
  1429. fi
  1430. rm -rf "$WorkDir"
  1431.  
  1432. # Cracked app is added into the already-cracked apps list
  1433. echo "$tempLoc" >> /var/mobile/.cracked.log
  1434.  
  1435. # Cracked app is added into Crackulous' cracked-apps-ready-to-upload list
  1436. p="/private/var/root/Documents/IPAStore.plist"
  1437. if [ -e "$p" ]; then
  1438.     #If Crackulous is running, we must close it first
  1439.     Killous=$(ps -e | grep "/Applications/Crackulous" | grep -v "grep" | awk '{print $1}')
  1440.     if [ "$Killous" ]; then
  1441.         echo "${Meter99}$MsgWarning: killing Crackulous softly"
  1442.         kill $Killous
  1443.         sleep 1
  1444.     fi
  1445.     plutil -key "$IPAName" -type int -value "$(plutil -key 'itemId' "$AppPath/iTunesMetadata.plist" 2> /dev/null)" "$p" 2>&1> /dev/null
  1446. fi
  1447.  
  1448. # Displaying finished Ipa details
  1449. ZipSize=$(du -m -s "$IPAName" | cut -f 1)
  1450. echo "${Meter100}${escGreen}$MsgIpaDone${escReset} \"$IPAName\" [$ZipSize M$MsgSizUnit]"
  1451.  
  1452. MenuOK=$(($MenuOK + 1))
  1453. }
  1454.  
  1455. # End Core Function
  1456. # ======
  1457.  
  1458.  
  1459.  
  1460.  
  1461. # ======
  1462. # Begin script main part
  1463.  
  1464. # Origin's directory
  1465. PwdPwd="$PWD"
  1466.  
  1467. # Select texts' language
  1468. SelectLanguage
  1469.  
  1470. # Votez Martine !
  1471. if [ ! -e /bin/ps ]; then
  1472.     echo "$MsgCntFind 'ps'. $MsgInsCydi: 'adv-cmds'"
  1473.     exit 1
  1474. fi
  1475.  
  1476. # Is this script running inside a GUI ?
  1477. # (ie: parent process runs from "/Applications/xxx.app")
  1478. if [ ! "$(ps -e | grep "$PPID" | grep "/Applications/.*\.app/")" = "" ]; then
  1479.     PCMinaGUI="YES"
  1480. fi
  1481.  
  1482. # Initialize progress meter labels (for GUI)
  1483. if [ $PCMinaGUI = "YES" ]; then
  1484.     export TERM="xterm"
  1485.     for ((i=0;i<=100;i++)); do
  1486.         export Meter$i="$i% "
  1487.     done
  1488. else
  1489.     # Not in a GUI
  1490. #   clear
  1491.     echo ""
  1492.  
  1493.     # Escape codes
  1494.     esc="$( echo -e -n "\033" )"
  1495.     escReset="${esc}[0m"
  1496.     escUnder="${esc}[4m"
  1497.     escBlue="${esc}[34m"
  1498.     escGreen="${esc}[32m"
  1499.     escRed="${esc}[31m"
  1500.     escYellow="${esc}[33m"
  1501.     escPurple="${esc}[35m"
  1502.     escCyan="${esc}[36m"
  1503.  
  1504.     # Terminal misconfigured
  1505.     if [ -z "$TERM" ]; then
  1506.         echo "${escYellow}$MsgWarning:${escReset} your \$TERM is not set"
  1507.         export TERM="xterm"
  1508.     fi
  1509.  
  1510.     # Screen width
  1511.     if [ ! -e /usr/bin/tput ]; then
  1512.         echo "$MsgCntFind 'tput'"
  1513.         exit 1
  1514.     fi
  1515.     Cols=$(tput cols)
  1516.  
  1517.     # Progress bars full width
  1518.     BarCols=$(( $Cols - 8 ))
  1519.     while [ ${#PCMxxx} -lt $BarCols ]
  1520.     do
  1521.         PCMxxx="$PCMxxx$PCMxxx"
  1522.         PCMsss="$PCMsss$PCMsss"
  1523.     done
  1524. fi
  1525.  
  1526. echo "${Meter0}       *** ${escUnder}PoedCrackMod v2.5.Lr12${escReset} ***"
  1527.  
  1528. if [ ! -e /usr/bin/plutil ]; then
  1529.     echo "$MsgCntFind 'plutil'. $MsgInsCydi: 'Erica Utils'"
  1530.     exit 1
  1531. fi
  1532.  
  1533. if [ ! -e /usr/bin/gdb ]; then
  1534.     echo "$MsgCntFind 'gdb'. $MsgInsCydi: 'GNU Debugger'"
  1535.     exit 1
  1536. fi
  1537. if [ ! -x /usr/bin/gdb ]; then
  1538.     echo "Please chmod 'gdb'"
  1539.     exit 1
  1540. fi
  1541.  
  1542. if [ ! -e /usr/bin/otool ]; then
  1543.     echo "$MsgCntFind 'otool'. $MsgInsCydi: 'Darwin CC Tools'"
  1544.     exit 1
  1545. fi
  1546.  
  1547. if [ ! -e /usr/bin/ldone ]; then
  1548.     echo "$MsgCntFind 'ldone'. $MsgInsCydi"
  1549.     exit 1
  1550. fi
  1551.  
  1552. if [ ! -e /bin/touch ]; then
  1553.     echo "$MsgCntFind 'touch'"
  1554.     exit 1
  1555. fi
  1556.  
  1557. if [ ! -e /usr/bin/zip ]; then
  1558.     echo "$MsgCntFind 'zip'"
  1559.     exit 1
  1560. fi
  1561.  
  1562. if [ ! -e /usr/sbin/sysctl ]; then
  1563.     echo "$MsgCntFind 'sysctl'"
  1564.     exit 1
  1565. fi
  1566.  
  1567. if [ ! -e /usr/bin/basename ]; then
  1568.     echo "$MsgCntFind 'basename'"
  1569.     exit 1
  1570. fi
  1571.  
  1572. if [ ! -e /usr/bin/cut ]; then
  1573.     echo "$MsgCntFind 'cut'"
  1574.     exit 1
  1575. fi
  1576.  
  1577. if [ ! -e /usr/bin/awk ]; then
  1578.     echo "$MsgCntFind 'awk'. $MsgInsCydi: 'Gawk'"
  1579.     exit 1
  1580. fi
  1581.  
  1582. iOSver=$(plutil -key ProductVersion /System/Library/CoreServices/SystemVersion.plist 2> /dev/null | tr -d ".")
  1583. echo "${Meter1}${escYellow}Note:${escReset} running iOS$iOSver"
  1584. if [ ${iOSver:0:1} -gt 4 ]; then
  1585.     if [ ! -z "$(ls -l /usr/bin/gdb | grep -e 'May 20  2011' -e 'Aug  3  2011')" ]; then
  1586.         echo "${escRed}STOP:${escReset} 'gdb for iOS5+' needed !"
  1587.         exit 1
  1588.     fi
  1589. fi
  1590. if [ ! -x /usr/bin/gdb ]; then
  1591.     echo "Please chmod 'gdb'"
  1592.     exit 1
  1593. fi
  1594.  
  1595. # Cydia's "Speak" tool is needed for speech support
  1596. if [ ${iOSver:0:1} -lt 4 ]; then
  1597.     PCMspeak="NO"
  1598. fi
  1599. if [ $PCMspeak = "YES" ]; then
  1600.     if [ ! -e /usr/bin/speak ]; then
  1601.         echo "${Meter3}${escYellow}Note:${escReset} install 'Speak' from Cydia for speech"
  1602.         PCMspeak="NO"
  1603.     fi
  1604. fi
  1605.  
  1606. if [ ! -e /usr/bin/head ]; then
  1607.     echo "$MsgCntFind 'head'"
  1608.     exit 1
  1609. fi
  1610.  
  1611. if [ ! -e /usr/bin/tail ]; then
  1612.     echo "$MsgCntFind 'tail'"
  1613.     exit 1
  1614. fi
  1615.  
  1616. if [ ! -e /usr/bin/posix_spawn ]; then
  1617.     echo "$MsgCntFind 'posix_spawn'"
  1618.     exit 1
  1619. fi
  1620. if [ ! -x /usr/bin/posix_spawn ]; then
  1621.     echo "Please chmod 'posix_spawn'"
  1622.     exit 1
  1623. fi
  1624.  
  1625. # Create an empty public memory file
  1626. if [ ! -e /var/mobile/.cracked.log ]; then
  1627.     touch /var/mobile/.cracked.log
  1628.     chmod 666 /var/mobile/.cracked.log
  1629. fi
  1630.  
  1631. AltDump="NO"
  1632.  
  1633. # Don't want MetaData ? It sucks !
  1634. if [ ! $PCMmetadata = "YES" ]; then
  1635.     echo "${Meter2}${escYellow}Note:${escReset} MetaData='NO' is not recommended"
  1636.     PCMmetadatafilename=".backup"
  1637. fi
  1638.  
  1639. # Is syslog available ?
  1640. if [ ! -e /usr/sbin/syslogd ]; then
  1641.     echo "${Meter3}${escYellow}Note:${escReset} should install 'syslogd' from Cydia"
  1642. fi
  1643. if [ ! -e /usr/bin/logger ]; then
  1644.     echo "${Meter4}${escYellow}Note:${escReset} should install 'logger' from Cydia (inetutils)"
  1645. fi
  1646.  
  1647. if [ ! $PCMinaGUI = "YES" ]; then
  1648.     # Get and store the encrypted apps list
  1649.     rm -f /tmp/lsd.tmp
  1650.  
  1651.     # Why is that slower than next code ???
  1652.     #ls -d /var/mobile/Applications/*/*.app/SC_Info 2> /dev/null | sort -f -t \/ -k 6 | while read OneApp
  1653.     ## */
  1654.     #do
  1655.     #   echo "$(dirname "$OneApp")" >> /tmp/lsd.tmp
  1656.     #done
  1657.  
  1658.     # Why is that faster than previous code ???
  1659.     ls -d /var/mobile/Applications/*/*.app 2> /dev/null | sort -f -t \/ -k 6 | while read OneApp
  1660.     ## */
  1661.     do
  1662.         if [ -d "$OneApp/SC_Info" ]; then
  1663.             echo "$OneApp" >> /tmp/lsd.tmp
  1664.         fi
  1665.     done
  1666.  
  1667.     # Secret "alternative dumping" flag
  1668.     if [ "$1" = "-a" ]; then
  1669.         shift
  1670.         echo "$MsgAltMeth"
  1671. #       if [ ! -e /usr/bin/nice ]; then
  1672. #           echo "$MsgCntFind 'nice'"
  1673. #           rm -f /tmp/lsd.tmp
  1674. #           exit 1
  1675. #       fi
  1676.         AltDump="YES"
  1677.     fi
  1678.  
  1679.     if [ "$1" = "-v" ]; then
  1680.         shift
  1681.         PCMverbose="YES"
  1682.     fi
  1683.  
  1684.     # Secret "check only" flag
  1685.     if [ "$1" = "-chk" ]; then
  1686.         shift
  1687.         PCMcheck="YES"
  1688.     fi
  1689.  
  1690.     # No more argument: display help
  1691.     if [ $# -lt 1 ]; then
  1692.         # The "-a" flag is not displayed in the help, but it does exist.
  1693.         scr=$(basename $0)
  1694.         echo "List/Help: $scr"
  1695.         echo "     Menu: $scr [-v] -m [CN [CFN]]"
  1696.         echo " CrackAll: $scr [-v] -all [CN [CFN]]"
  1697.         echo " CrackOne: $scr [-v] AN [CN [CFN]]"
  1698.         echo " MarkDone: $scr -mark"
  1699.         echo "ResetDone: $scr -zero"
  1700.         echo
  1701.         echo "AN=AppName CN=CrackerName CFN=CreditFileName"
  1702.         echo
  1703.         if [ -e /tmp/lsd.tmp ]; then
  1704.             cat /tmp/lsd.tmp | cut -f 6 -d '/' | sed "s:\\.app:,:" | tr "\n" " "
  1705.             echo -e "\010\010."
  1706.             rm -f /tmp/lsd.tmp
  1707.         fi
  1708.         exit 1
  1709.     fi
  1710.  
  1711.     # Erasing memory file
  1712.     if [ "$1" = "-zero" ]; then
  1713.         echo "$MsgEraMemo"
  1714.         # Don't use rm
  1715.         cp /dev/null /var/mobile/.cracked.log 2>&1> /dev/null
  1716.         rm -f /tmp/lsd.tmp
  1717.         exit 1
  1718.     fi
  1719.  
  1720.     # Marking all apps as done in memory file
  1721.     if [ "$1" = "-mark" ]; then
  1722.         echo "$MsgMarDone"
  1723.         if [ -e /tmp/lsd.tmp ]; then
  1724.             cp /tmp/lsd.tmp /var/mobile/.cracked.log 2>&1> /dev/null
  1725.             rm -f /tmp/lsd.tmp
  1726.         else
  1727.             cp /dev/null /var/mobile/.cracked.log 2>&1> /dev/null
  1728.         fi
  1729.         exit 1
  1730.     fi
  1731.  
  1732.     MenuAsked=0
  1733.     MenuFound=0
  1734.     MenuOK=0
  1735.     MenuError=0
  1736.     MenuErrorList=""
  1737.  
  1738.     # Berzerk mode: cracking all apps
  1739.     if [ "$1" = "-all" ]; then
  1740.         echo -n "$MsgBrzMode !"
  1741.         if [ -e /tmp/lsd.tmp ]; then
  1742.             # ("grep -vf" is sloooow. Use "-Fvf")
  1743.             # Removing already-done from full apps list
  1744.             tempgrep=$(mktemp)
  1745.             grep -Fvf /var/mobile/.cracked.log /tmp/lsd.tmp > $tempgrep
  1746.             MenuAsked=$(cat $tempgrep | wc -l)
  1747.             ProgressTarget=$MenuAsked
  1748.             ProgressDone=0
  1749.             echo " ($MenuAsked)"
  1750.             echo
  1751.  
  1752.             if [ $PCMbarSize = "YES" -a $MenuAsked != 0 ]; then
  1753.                 ProgressTargetSize=0
  1754.                 ProgressDoneSize=0
  1755.                 echo -n "Computing total size"
  1756.                 # (Don't use a pipe for the while loop)
  1757.                 while read OneApp
  1758.                 do
  1759.                     # Size of the app, till dawn.
  1760.                     AppSize=$( du -s -k "$OneApp" | cut -f 1 )
  1761.                     ProgressTargetSize=$(($ProgressTargetSize + $AppSize))
  1762.                     echo -n "."
  1763.                 done < $tempgrep
  1764.                 echo
  1765.                 echo
  1766.             fi
  1767.  
  1768.             # (Don't use a pipe for the while loop)
  1769.             while read OneApp
  1770.             do
  1771.                 ProgressDone=$(($ProgressDone + 1))
  1772.                 echo -n "${escPurple}($ProgressDone/$ProgressTarget)${escReset} "
  1773.  
  1774.                 if [ $PCMbarSize = "YES" ]; then
  1775.                     # Size of the app, till dawn.
  1776.                     AppSize=$( du -s -k "$OneApp" | cut -f 1 )
  1777.                     ProgressDoneSize=$(($ProgressDoneSize + $AppSize))
  1778.                 fi
  1779.  
  1780.                 CoreFunction "$OneApp" "$2" "$3"
  1781.                 if [ $? = 1 ]; then
  1782.                     if [ $PCMspeak = "YES" ]; then
  1783.                         speak "Error !" &
  1784.                     fi
  1785.                     MenuError=$(($MenuError + 1))
  1786.                     if [ -z "$MenuErrorList" ]; then
  1787.                         MenuErrorList="${OneApp:62:$(( ${#OneApp} - 66 ))}"
  1788.                     else
  1789.                         MenuErrorList="$MenuErrorList, ${OneApp:62:$(( ${#OneApp} - 66 ))}"
  1790.                     fi
  1791.                 fi
  1792.  
  1793.                 DisplayBars
  1794.                 echo
  1795.             done < $tempgrep
  1796.             rm -f $tempgrep
  1797.             rm -f /tmp/lsd.tmp
  1798.         else
  1799.             echo " ($MsgBrzNoth)"
  1800.         fi
  1801.  
  1802.         echo "$MsgWasAskd:all ($MenuAsked)  $MsgFoundIt:$MenuFound  $MsgErrrors:$MenuError  OK:$MenuOK."
  1803.         if [ ! -z "$MenuErrorList" ]; then
  1804.             echo "$MsgErrrors: $MenuErrorList."
  1805.         fi
  1806.  
  1807.         if [ $PCMspeak = "YES" ]; then
  1808.             speak "Terminated." &
  1809.         fi
  1810.  
  1811.         exit 1
  1812.     else
  1813.         # Menu mode: displaying menu and processing user choices
  1814.         if [ "$1" = "-m" ]; then
  1815.             if [ -e /tmp/lsd.tmp ]; then
  1816.                 echo -n "$MsgBldMenu"
  1817.                 rm -f /tmp/lsdmenu.tmp
  1818.                 touch /tmp/lsdmenu.tmp
  1819.                 rm -f /tmp/lsddisp.tmp
  1820.                 # Array with all the letters
  1821.                 Letters=( $( echo {a..z} {a..z}{a..z} ) )
  1822.                 # Search for best columns size
  1823.                 BestFiller=666
  1824.                 BestFound=666
  1825.                 for (( i=18;i<=30;i++)); do
  1826.                     FillerFound=$(( $Cols % $i ))
  1827.                     if [ $FillerFound -lt $BestFiller ]; then
  1828.                         BestFiller=$FillerFound
  1829.                         BestFound=$i
  1830.                         if [ $FillerFound = 0 ]; then
  1831.                             break
  1832.                         fi
  1833.                     fi
  1834.                 done
  1835.                 LongNames=$(( $BestFound - 3 ))
  1836.                 ShortNames=$(( $LongNames - 1 ))
  1837.  
  1838.                 # Using 'real name' in menu ?
  1839.                 if [ $PCMrealnamemenu = "YES" ]; then
  1840.                     tempfile=$(mktemp)
  1841.                     templist=$(mktemp)
  1842.                     # Using 'list of installed apps' from SpringBoard as source for real names
  1843.                     cp /var/mobile/Library/Caches/com.apple.mobile.installation.plist $tempfile
  1844.                     plutil -xml $tempfile 2>&1> /dev/null
  1845.                     cat $tempfile | grep -F -e "<key>CFBundleDisplayName</key>" -e "<key>Container</key>"  -A1 | tr -d "\t" > $templist
  1846.                     rm $tempfile
  1847.                 fi
  1848.  
  1849.                 Letter=0
  1850.                 LineLength=$Cols
  1851.                 # ("grep -vf" is sloooow. Use "-Fvf")
  1852.                 # Removing already-done from full apps list
  1853.                 grep -Fvf /var/mobile/.cracked.log /tmp/lsd.tmp | while read OneApp
  1854.                 do
  1855.                     GoodLetter=${Letters[$Letter]}
  1856.  
  1857.                     # Using 'real name' in menu ?
  1858.                     if [ $PCMrealnamemenu = "YES" ]; then
  1859.                         unicode="$( cat $templist | grep "${OneApp:0:61}" -B3 | grep -m1 "<string>" | sed -e 's:<string>::g' -e 's:</string>::g' )"
  1860.                         # If name is too exotic, use 'internal name'
  1861.                         if [ "$(echo -n "$unicode" | tr -cd "[:alnum:]")" = "" ]; then
  1862.                             unicode="${OneApp:62:$(( ${#OneApp} - 66 ))}"
  1863.                         fi
  1864.                         UnicodeToHuman
  1865.                         OneOneApp="$human$PCMdots"
  1866.                     else
  1867.                         OneOneApp="${OneApp:62:$(( ${#OneApp} - 66 ))}$PCMdots"
  1868.                     fi
  1869.  
  1870.                     if [ $Letter -lt 26 ]; then
  1871.                         echo -n "${escPurple}$GoodLetter:${escReset}${OneOneApp:0:$LongNames} " >> /tmp/lsddisp.tmp
  1872.                         echo "\"$GoodLetter\"$OneApp" >> /tmp/lsdmenu.tmp
  1873.                         LineLength=$(( $LineLength - $LongNames - 3 ))
  1874.                     else
  1875.                         echo -n "${escPurple}$GoodLetter:${escReset}${OneOneApp:0:$ShortNames} " >> /tmp/lsddisp.tmp
  1876.                         echo "\"$GoodLetter\"$OneApp" >> /tmp/lsdmenu.tmp
  1877.                         LineLength=$(( $LineLength - $ShortNames - 4 ))
  1878.                     fi
  1879.  
  1880.                     # End of line
  1881.                     if [ $LineLength = $BestFiller ]; then
  1882.                         echo "" >> /tmp/lsddisp.tmp
  1883.                         LineLength=$Cols
  1884.                     fi
  1885.  
  1886.                     Letter=$(($Letter + 1))
  1887.                     # Too much apps (max is 27*26 = 702)
  1888.                     if [ $Letter = 702 ]; then
  1889.                         break
  1890.                     fi
  1891.                 done
  1892.  
  1893.                 if [ $PCMrealnamemenu = "YES" ]; then
  1894.                     rm $templist
  1895.                 fi
  1896.  
  1897.                 # Other options
  1898.                 echo -n "${escPurple}0:${escReset}${MskZroDone:0:$LongNames} " >> /tmp/lsddisp.tmp
  1899.                 echo -n "${escPurple}9:${escReset}${MsgMrkDone:0:$LongNames} " >> /tmp/lsddisp.tmp
  1900.  
  1901.                 # Displaying menu
  1902.                 if [ -e /tmp/lsddisp.tmp ]; then
  1903.                     echo
  1904.                     clear
  1905.                     echo "     *** ${escUnder}PoedCrackMod v2.5.Lr12 menu${escReset} ***"
  1906.                     cat /tmp/lsddisp.tmp
  1907.                     rm -f /tmp/lsddisp.tmp
  1908.                     echo
  1909.                     read -p "$MsgYouChoi ? " YourChoices
  1910.                     echo
  1911.                     ProgressTarget=$( echo $YourChoices | wc -w )
  1912.                     ProgressDone=0
  1913.  
  1914.                     if [ $PCMbarSize = "YES" -a $ProgressTarget != 0 ]; then
  1915.                         ProgressTargetSize=0
  1916.                         ProgressDoneSize=0
  1917.                         echo -n "Computing total size"
  1918.  
  1919.                         # Do all these choices
  1920.                         for OneChoice in $YourChoices
  1921.                         do
  1922.                             if [ ! "$OneChoice" = "0" ]; then
  1923.                                 if [ ! "$OneChoice" = "9" ]; then
  1924.                                     tempLoc=$(grep -i "\"$OneChoice\"" /tmp/lsdmenu.tmp | cut -f 3 -d "\"")
  1925.                                     if [ ! -z "$tempLoc" ]; then
  1926.                                         AppCount=$(echo "$tempLoc" | wc -l)
  1927.                                         if [ $AppCount = 1 ]; then
  1928.                                             # Size of the app, till dawn.
  1929.                                             AppSize=$( du -s -k "$tempLoc" | cut -f 1 )
  1930.                                             ProgressTargetSize=$(($ProgressTargetSize + $AppSize))
  1931.                                             echo -n "."
  1932.                                         fi
  1933.                                     fi
  1934.                                 fi
  1935.                             fi
  1936.                         done
  1937.                         echo
  1938.                         echo
  1939.  
  1940.                         # Nothing to do; no need for progress
  1941.                         if [ $ProgressTargetSize = 0 ]; then
  1942.                             PCMbarSize="ZERO"
  1943.                         fi
  1944.                     fi
  1945.  
  1946.                     # Do all these choices
  1947.                     for OneChoice in $YourChoices
  1948.                     do
  1949.                         ProgressDone=$(($ProgressDone + 1))
  1950.                         echo -n "${escPurple}($ProgressDone/$ProgressTarget)${escReset} "
  1951.                         MenuAsked=$(($MenuAsked + 1))
  1952.                         if [ "$OneChoice" = "0" ]; then
  1953.                             echo "$MsgEraMemo"
  1954.                             # Don't use rm
  1955.                             cp /dev/null /var/mobile/.cracked.log 2>&1> /dev/null
  1956.                             MenuAsked=$(($MenuAsked - 1))
  1957.                         else
  1958.                             if [ "$OneChoice" = "9" ]; then
  1959.                                 echo "$MsgMarDone"
  1960.                                 cp /tmp/lsd.tmp /var/mobile/.cracked.log 2>&1> /dev/null
  1961.                                 MenuAsked=$(($MenuAsked - 1))
  1962.                             else
  1963.                                 tempLoc=$(grep -i "\"$OneChoice\"" /tmp/lsdmenu.tmp | cut -f 3 -d "\"")
  1964.                                 if [ -z "$tempLoc" ]; then
  1965.                                     echo "$MsgWrgChoi ($OneChoice)"
  1966.                                 else
  1967.                                     AppCount=$(echo "$tempLoc" | wc -l)
  1968.                                     if [ $AppCount = 1 ]; then
  1969.  
  1970.                                         if [ $PCMbarSize = "YES" ]; then
  1971.                                             # Size of the app, till dawn.
  1972.                                             AppSize=$( du -s -k "$tempLoc" | cut -f 1 )
  1973.                                             ProgressDoneSize=$(($ProgressDoneSize + $AppSize))
  1974.                                         fi
  1975.  
  1976.                                         CoreFunction "$tempLoc" "$2" "$3"
  1977.                                         if [ $? = 1 ]; then
  1978.                                             if [ $PCMspeak = "YES" ]; then
  1979.                                                 speak "Error !" &
  1980.                                             fi
  1981.                                             MenuError=$(($MenuError + 1))
  1982.                                             if [ -z "$MenuErrorList" ]; then
  1983.                                                 MenuErrorList="${tempLoc:62:$(( ${#tempLoc} - 66 ))}"
  1984.                                             else
  1985.                                                 MenuErrorList="$MenuErrorList, ${tempLoc:62:$(( ${#tempLoc} - 66 ))}"
  1986.                                             fi
  1987.                                         fi
  1988.                                     else
  1989.                                         echo "$MsgBadChoi ($OneChoice = $AppCount)"
  1990.                                     fi
  1991.                                 fi
  1992.                             fi
  1993.                         fi
  1994.  
  1995.                         DisplayBars
  1996.                         echo
  1997.  
  1998.                     done
  1999.                     rm -f /tmp/lsdmenu.tmp
  2000.  
  2001.                     if [ $PCMspeak = "YES" ]; then
  2002.                         speak "Finished." &
  2003.                     fi
  2004.  
  2005.                     echo
  2006.                     echo "$MsgWasAskd:$MenuAsked  $MsgFoundIt:$MenuFound  $MsgErrrors:$MenuError  OK:$MenuOK."
  2007.                     if [ ! -z "$MenuErrorList" ]; then
  2008.                         echo "${escRed}$MsgErrrors:${escReset} $MenuErrorList."
  2009.                     fi
  2010.                 else
  2011.                     echo " $MsgMnuEmpt !"
  2012.                 fi
  2013.                 rm -f /tmp/lsd.tmp
  2014.             else
  2015.                 echo " $MsgMnuEmpt !"
  2016.             fi
  2017.             exit 1
  2018.         fi
  2019.     fi
  2020. fi
  2021.  
  2022. # Just one app to do
  2023. CoreFunction "$1" "$2" "$3"
  2024. #if [ $? = 1 ]; then
  2025. #   echo "Error: problem encountered."
  2026. #   exit 1
  2027. #fi
  2028.  
  2029. # Not needed anymore
  2030. rm -f /tmp/lsd.tmp
  2031.  
  2032.  
  2033. #
  2034. # The truth is I never left you. I kept my promise.
  2035. #
  2036. # Never gonna give you up, never gonna let you down, never gonna run around and desert you.
  2037. # Never gonna make you cry, never gonna say goodbye, never gonna tell a lie and hurt you.
  2038. #
  2039.  
  2040.  
  2041. #
  2042. # Thanks.
  2043. # Merci.
  2044. # Hontoni arigato.
  2045. #
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement