Guest User

Untitled

a guest
Jun 21st, 2018
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.88 KB | None | 0 0
  1. /********************************************************************************************/
  2. /*Installer for iPhoneOS 2/3.x Copyright (c) 2012 Ethan Laur (phyrrus9) <phyrrus9@gmail.com>*/
  3. /*This application is open source, meaning that you may do whatever the hell you want with */
  4. /* it. I do this mainly because I am too goddamn lazy to ACTUALLY enforce copyright on any */
  5. /* of this shit ... so have at it, but please leave my original copyright in any and all of */
  6. /* the files included with the package you recieved either by web or package from cydia stor*/
  7. /*Project created February 6th 2012 at 12:28 PM. what a lonely monday morning bored as hell */
  8. /********************************************************************************************/
  9. /*Additional copyrights and special thanks to: the private dev team, @iAmJake648 */
  10. /********************************************************************************************/
  11. #include <iostream>
  12. #include <stdlib.h>
  13. #include <fstream>
  14. #include <sstream>
  15. #include <string.h>
  16. #define BUILD "0.1-1.1"
  17.  
  18. using namespace std;
  19.  
  20. string trash = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz";
  21.  
  22. string HOST = "abcdefghijklmnopqrstuvwxyz";
  23. string CACHE = "abcdefghijklmnopqrstuvwxyz";
  24. string IOS_VER = "abcdefghijklmnopqrstuvwxyz";
  25. string FILT = "abcdefghijklmnopqrstuvwxyz";
  26.  
  27. void output(string type, string out) //this allows me to make it look neater
  28. {
  29. cout << "<" << type << ">[" << out << "]" << endl;
  30. }
  31.  
  32. int init()
  33. {
  34. cout << "Welcome to commander!" << endl << "Copyright 2012 phyrrus9/private dev team" << endl;
  35. ifstream infile("/var/db/installer.conf");
  36. if (infile.good())
  37. {
  38. output("sys", "LOADING CONFIG");
  39. infile >> HOST;
  40. infile >> CACHE;
  41. infile >> IOS_VER;
  42. infile >> FILT;
  43. output("host", HOST);
  44. output("cache", CACHE);
  45. output("iOS", IOS_VER);
  46. output("filter", FILT);
  47. infile.close(); //oops! I can see LOTS of corruption nightmares again
  48. return 0;
  49. }
  50. else
  51. return 1;
  52.  
  53. }
  54. void search(string package)
  55. {
  56. trash = "cat /var/db/installer.cache | grep ";
  57. trash+=package + " ::" + FILT + "::";
  58. system(trash.c_str());
  59. }
  60. void download(string package)
  61. {
  62. trash = "wget " + HOST + "/" + IOS_VER + "/" + package + ".zip -O /var/tmp/installer.zip -o /var/tmp/installer.log";
  63. string URL = HOST + package + ".zip";
  64. system(trash.c_str());
  65. }
  66. void install(string package)
  67. {
  68. output("install", "BEGIN EXTRACT");
  69. system("unzip -o /var/tmp/installer.zip -d /");
  70. output("install", "RUN EXTRACT SCRIPT");
  71. trash = "sh /var/scripts/installer/" + package + "-extract.sh";
  72. system(trash.c_str());
  73. output("install", "CLEANING UP");
  74. system("rm /var/tmp/installer.zip");
  75. }
  76. void remove(string package)
  77. {
  78. trash = "sh /var/scripts/installer/" + package + "-remove.sh";
  79. system(trash.c_str());
  80. }
  81. void usage()
  82. {
  83. /*I am not using output() here because it would overflow the screen*/
  84. cout << "Installer.bin build " << BUILD << endl;
  85. cout << "Usage:" << endl;
  86. cout << ".. search xxx :search for a package" << endl;
  87. cout << ".. install xxx :install a package" << endl;
  88. cout << ".. remove xxx :remove a package" << endl;
  89. cout << ".. config xxx :rerun config script" << endl;
  90. cout << ".. upgrade :upgrade commander" << endl;
  91. cout << ".. update :updates the caches" << endl;
  92. cout << ".. *broken* :Ignore me .. just a placeholder" << endl;
  93. cout << ".. yyy :shows this dialog" << endl;
  94. }
  95.  
  96.  
  97. int main(int argc, char* argv[])
  98. {
  99. int init_err = 0;
  100. string parameter, filter = "empty";
  101. if (argc == 0)
  102. return -1;
  103. if (argc > 1)
  104. parameter = argv[1];
  105. if (argc > 2)
  106. filter = argv[3];
  107. string package_in;
  108. if (argc > 2)
  109. package_in = argv[2];
  110. init_err = init();
  111. ofstream write("/var/tmp/installer.conf");
  112. if (init_err == 1)
  113. {
  114. output("ERR", "UNABLE TO LOAD CONFIG");
  115. return -1;
  116. }
  117. if (init_err == 0)
  118. {
  119. if (parameter == "search")
  120. {
  121. trash = "Searching database for " + package_in;
  122. output("main", trash);
  123. search(package_in);
  124. output("main", "Search complete");
  125. }
  126. else if (parameter == "install")
  127. {
  128. trash = "Attempting to install " + package_in;
  129. output("main", trash);
  130. download(package_in);
  131. install(package_in);
  132. output("main", "Install complete");
  133. }
  134. else if (parameter == "remove")
  135. {
  136. trash = "Removing package " + package_in;
  137. output("main", trash);
  138. remove(package_in);
  139. output("main", "Package removal compelte");
  140. }
  141. else if (parameter == "config")
  142. {
  143. output("install", "Running config");
  144. trash = "sh /var/scripts/installer/" + package_in + "-extract.sh";
  145. system(trash.c_str());
  146. }
  147. else if (parameter == "upgrade")
  148. {
  149. output("main", "Downloading");
  150. download("phyrrus9.installer");
  151. output("main", "Transferring to install");
  152. install("phyrrus9.installer");
  153. return 9001;
  154. }
  155. else if (parameter == "update")
  156. {
  157. output("sys", "DOWNLOADING CACHE");
  158. trash = "wget " + CACHE + " -O /var/tmp/installer.zip -o /var/tmp/installer.log";
  159. system(trash.c_str());
  160. output("sys", "EXTRACT CACHE");
  161. system("unzip -o /var/tmp/installer.zip -d /var/db");
  162. output("sys", "cLEANING UP");
  163. system("rm /var/tmp/installer.zip");
  164. output("sys", "COMPLETED!");
  165. }
  166. else if (filter != "empty")
  167. {
  168. trash = "Setting the filter to " + filter;
  169. output("filter", trash);
  170. FILT = filter;
  171. output("filter", "Writing to temporary file");
  172. write << HOST << endl << CACHE << endl << IOS_VER << endl << FILT;
  173. output("filter", "Transferring file");
  174. system("mv /var/tmp/installer.cache /var/db/installer.cache");
  175. output("filter", "Settings applied!\nTo change back just set filter to all");
  176. return 0;
  177. }
  178. else
  179. {
  180. output("ERR", "NO PARAMETERS");
  181. usage();
  182. }
  183. }
  184. else
  185. {
  186. output("ERR", "UNKNOWN!");
  187. return -1;
  188. }
  189. return 0;
  190. }
Add Comment
Please, Sign In to add comment