SeeWhyAnEyeSee

rootShell's source code.

Jan 10th, 2015
282
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 29.88 KB | None | 0 0
  1. # Go back github.com/cyniclimbu/rootShell
  2. require 'colored'
  3. require 'highline'
  4. require 'win32ole'
  5. require 'benchmark'
  6. require 'digest' # DO I NEED DIGEST/MD5 DIGEST/SHA1 ETC INDIVIDUALLY?
  7. include HighLine::SystemExtensions
  8.  
  9. # Remove drive file from installation
  10. # It's no longer needed.
  11.  
  12.  
  13. =begin
  14. methods of option 1 and option 2 should sleep from within the method because this method does not provide sleep
  15. for them
  16.  
  17. I still don't know how to thread a ruby program so the animation on methods are
  18. kind of useless but hey...it works! lol :p
  19.  
  20. windows dir - c:\windows\seewhyaneyesee
  21. path file - path
  22.  
  23. default install:
  24. main_dir = $install_path + '\rootshell'
  25. $install_path = ENV['home'] + '/desktop'
  26.  
  27.  
  28. custom install:
  29. main_dir = $install_path + '\rootshell'
  30. $install_path = custom_dir
  31.  
  32. rootshell:
  33. rootshell\user\settings
  34. =end
  35.  
  36. exit if defined?(Ocra)
  37.  
  38.  
  39. RootShell = "rootShell"
  40. ERRORMSG = " An unknown error occured.\n Please send an email to [email protected]\n Describing what caused it.".bold.cyan
  41. SHELLERROR = "An unknown error occurred, please check your input.\nMaybe a bug!"
  42. OUTTAATTEMPTS = "OUT OF ATTEMPTS\n   Restart the shell to try again.".bold.white
  43. TIMER = [0.00001,0.00001,0.01,0.001,0,0.0001,0.1,0.1,0.0001,0.0001,0.01,0.0000001]
  44. PERCENTAGE = (1..100)
  45. drive_regex = /^[(a-z)]:/i
  46. windows = drive_regex.match(Dir.pwd).to_s + '\windows'
  47.  
  48.  
  49.  
  50. #--------------------METHOD--------------------# 001
  51. def admin? #ADMIN? D01
  52. #--------------------------------------------------------
  53. #DEFINE VARIABLES BEFOREHAND!
  54. reg_key  = 'reg query "HKU\S-1-5-19"'
  55. $is_admin = system(reg_key)
  56.  
  57. self_name = File.basename $0,".rb"
  58. self_exe  = self_name + ".exe"
  59. self_rb   = self_name  + ".rb"
  60. #--------------------------------------------------------
  61. if $is_admin == true # IF D02
  62. system("cls")
  63. installer # M E T H O D
  64. #--------------------------------------------------------
  65. elsif $is_admin == false # ELSIF D02
  66. system("cls")
  67.  
  68. if File.exists?(self_exe) and File.exists?(self_rb) # IF D03
  69. puts " A file with a same name was found on this directory.".bold.cyan
  70. puts " Please move the copy somewhere else and restart this shell.".bold.red
  71. puts " ERROR - POSSIBLE CONFLICT CAN OCCUR.".bold.yellow
  72. sleep 4; exit
  73. #--------------------------------------------------------
  74. elsif File.exists?(self_rb) # ELSIF D03
  75.                             # IF FILE EXTENSION IS IN .rb OR .RB
  76. puts " Shell must run as administrator to begin.\n"
  77. puts "\n Message from my creator :D".bold.cyan
  78. puts " I can create a batch file for you to run it as administrator.".bold.cyan
  79. puts " And save it to desktop, if you want?".bold.cyan
  80. puts " Press 'Y' is yes :) and 'N' if you don't like me. :(".bold.cyan
  81.  
  82. loop = 0; while loop < 7 # WHILE LOOP D031
  83. print " > "
  84. choice = get_character.chr
  85.  
  86. if choice == 'y' or choice == 'Y' # IF D0312
  87. #------------------------------------------------
  88.  
  89. batch_file_to_admin # M E T H O D
  90.  
  91. #------------------------------------------------
  92. elsif choice == 'n' or choice == 'N' # ELSIF D0312
  93. sad_array = ["O","k","a","y"," ",":","("]
  94. sad_array.each do |sad|
  95. print sad.bold.cyan
  96. sleep 0.1
  97. end
  98. sleep 1; exit
  99. #------------------------------------------------
  100. elsif loop == 6 # ELSIF D0312
  101. puts OUTTAATTEMPTS
  102. sleep 4; exit
  103. #------------------------------------------------
  104. else  # ELSE D0312
  105. puts "Given character is out of option.".bold.red
  106. #------------------------------------------------
  107. end  # END D0312
  108. #------------------------------------------------
  109. loop += 1
  110. end # END D031
  111. #------------------------------------------------
  112. elsif File.exists?(self_exe) # ELSIF D03
  113.                              # IF FILE EXTENSION IS IN .exe OR .EXE
  114. exe_not_admin = %w(S h e l l \ i s \ n o t \ r u n n i n g \ a s \ a d m i n .)
  115. exe_not_admin.each do |x|
  116. print x.bold.red
  117. sleep 0.02
  118. end
  119. puts "\n"
  120. exe_not_admin = %w(P l e a s e \ s t a r t \ t h i s \ s h e l l \ a s \ a d m i n i s t r a t o r .)
  121.  
  122. exe_not_admin.each do |x|
  123. print x.bold.white
  124. sleep 0.03
  125. end
  126. sleep 4; exit
  127. #------------------------------------------------
  128. else # ELSE D03
  129. puts " ERROR, NO FILE WITH '#{self_name}' NAME WAS FOUND.".bold.red
  130. puts " ERROR CODE - A0".bold.red
  131. puts " Try restarting.\n".bold.white
  132. puts " Press 'M' to see more detail information.".bold.white
  133. puts " Press 'E' to exit shell.".bold.white
  134. #------------------------------------------------
  135. loop = 0; while loop < 7 #WHILE LOOP D04
  136. print " > "
  137. choice = get_character.chr
  138. if choice == 'm' or choice == 'M' # IF D04
  139. puts "\n CODE - A0".bold.red #--# ERROR CODE A0 #--#
  140. puts " A CODE WAS SUPPOSED TO CHECK IF SELF-RUNNING FILE WAS .exe or .rb".bold.green
  141. puts " Possible reason for this error: ".bold.green
  142. puts " 1.The original name of this file was changed!"
  143. puts "    Revert the name if you changed it before."
  144. puts " 2.The extension was changed from .rb to .RB or from .exe to .EXE"
  145. puts "    Revert the extension name if you changed it before."
  146. sleep 4; exit
  147. #------------------------------------------------
  148. elsif choice == 'e' or choice == 'E' # ELSIF D04
  149.  
  150. bye = %w(B y e \ B y e !)
  151. bye.each do |exitmsg|
  152. print exitmsg.bold.magenta
  153. sleep 0.1
  154. end
  155. sleep 1; exit
  156. #------------------------------------------------
  157. elsif loop == 6 # ELSIF D04
  158. puts OUTTAATTEMPTS
  159. sleep 4; exit
  160. #------------------------------------------------
  161. else #END OF D04
  162. puts "Given character is out of option.".bold.red
  163. end # END D04
  164. #------------------------------------------------
  165. loop += 1
  166. end # END D04
  167. #------------------------------------------------
  168. end # END D03
  169. #--------------------------------------------------------
  170. else # ELSE D02
  171. puts ERRORMSG
  172. end # END D02
  173. end  #END D01
  174. #--------------------METHOD--------------------# 001
  175. =begin
  176.  
  177. ########################################## B O R D E R ##########################################
  178.  
  179. =end
  180.  
  181. #--------------------METHOD--------------------# 002 COMPLETED! batch_file_to_admin
  182. def batch_file_to_admin
  183. puts "Making a shell for you :]".bold.green
  184.  
  185. Dir.chdir ENV['HOME'] + '/desktop'
  186. dir = File.dirname $0
  187. shell = File.basename $0
  188.  
  189. batch = File.new("rootShell.bat","w")
  190. batch.puts "@echo OFF"
  191. batch.puts "cd #{dir}"
  192. batch.puts "NET SESSION >nul 2>&1"
  193. batch.puts "IF %ERRORLEVEL% EQU 0 ("
  194. batch.puts "    ECHO Starting rootShell as admin!"
  195. batch.puts "    ruby #{shell}"
  196. batch.puts "    PAUSE"
  197. batch.puts ") ELSE ("
  198. batch.puts "   echo ######## ########  ########   #######  ########  "
  199. batch.puts "   echo ##       ##     ## ##     ## ##     ## ##     ## "
  200. batch.puts "   echo ##       ##     ## ##     ## ##     ## ##     ## "
  201. batch.puts "   echo ######   ########  ########  ##     ## ########  "
  202. batch.puts "   echo ##       ##   ##   ##   ##   ##     ## ##   ##   "
  203. batch.puts "   echo ##       ##    ##  ##    ##  ##     ## ##    ##  "
  204. batch.puts "   echo ######## ##     ## ##     ##  #######  ##     ## "
  205. batch.puts "   echo."
  206. batch.puts "   echo."
  207. batch.puts "   echo ####### ERROR: ADMINISTRATOR PRIVILEGES REQUIRED #########"
  208. batch.puts "   echo This script must be run as administrator to work   "
  209. batch.puts '   echo Right click on my file icon and select "Run As Administrator".'
  210. batch.puts "   echo ##########################################################"
  211. batch.puts "   echo Original version by : https://stackoverflow.com/users/67268/blak3r"
  212. batch.puts "   echo."
  213. batch.puts "   PAUSE"
  214. batch.puts "   EXIT /B 1"
  215. batch.puts ")"
  216. batch.puts "@echo ON"
  217. batch.close
  218.  
  219. puts " Done!"; puts " Go to desktop, right-click on the batch file "
  220. puts '                and click "Run as administrator"'
  221.  
  222. sleep 4; exit
  223.  
  224. end
  225. #--------------------METHOD--------------------# 002 END batch_file_to_admin
  226.  
  227. =begin
  228.  
  229. ########################################## B O R D E R ##########################################
  230.  
  231. =end
  232.  
  233. #--------------------METHOD--------------------# 003 COMPLETED! default_install
  234. def default_install #DEFAULT_INSTALL C01
  235. time_taken = Benchmark.realtime do #C03
  236. puts " Installing.\n".bold.green
  237. #-------------------------------------------------------------
  238. puts "  Setting variables.".bold.white
  239. $install_path = ENV['home'] + '\desktop'
  240. main_dir = $install_path + '\rootshell'
  241. str_path = "Desktop"
  242.  
  243. PERCENTAGE.each do |x| #ANIM01
  244. print "\r  #{x}%".bold.white
  245. sleep TIMER[0]
  246. end #END ANIM01
  247. puts "\n  Done!".bold.white
  248. #-------------------------------------------------------------
  249. Dir.chdir $install_path
  250. puts "   Checking for previous installation on this directory.".bold.yellow
  251. if Dir.exists?(RootShell) #C02
  252. rmvdir = system("rmdir /Q /S rootShell")
  253. sleep 0.5
  254. if rmvdir != true or Dir.exists?(RootShell) #IF C0201
  255. puts " Sorry an error occurred.".bold.red
  256. puts " Detected that rootShell system directory exists.".bold.white
  257. puts "          but unfortunately an error occurred when".bold.white
  258. puts "          it tried to delete the directory.".bold.white
  259. puts " MORE TO IT.".bold.green
  260. puts " To fix the problem, please delete the folder manually.".bold.yellow
  261. puts " Maybe it's a bug? If it is send me an email : [email protected]".bold.yellow
  262. puts "\n Installation failed and was aborted.".bold.cyan
  263. sleep 4; exit
  264. end #END C0201
  265. end #END C02
  266.  
  267. PERCENTAGE.each do |x| #ANIM02
  268. print "\r   #{x}%".bold.yellow
  269. sleep TIMER[10]
  270. end #END ANIM02
  271. puts "\n   Done!".bold.yellow
  272. #-------------------------------------------------------------
  273. puts "    Checking drive".bold.blue
  274. path = Dir.pwd
  275. drive_regex = /^[(a-z)]:/i #REGEX TO GET FRIST LETTER WITH COLON ':'
  276.                            #IGNOREs CASE
  277. $drive = drive_regex.match(path).to_s #SAVE REGEX MATCH AS STRING
  278. windows = $drive + '\windows'
  279.  
  280. PERCENTAGE.each do |x| #ANIM03
  281. print "\r    #{x}%".bold.blue
  282. sleep TIMER.shuffle.pop
  283. end #END ANIM03
  284.  
  285. puts "\n    Done!".bold.blue
  286. #-------------------------------------------------------------
  287. puts "     Creating directories on #{str_path} and c:\\windows".bold.cyan
  288. Dir.mkdir(RootShell)
  289. Dir.chdir RootShell
  290.  
  291. readme = File.new("readme.txt","w")
  292. readme.puts("This folder contains setting configurations.")
  293. readme.puts("Do not edit the setting values unless you know what you're doing.\n\n")
  294. readme.puts("Thanks for downloading rootShell!")
  295. readme.puts("My email - [email protected]")
  296. readme.close
  297.  
  298. Dir.mkdir("user")
  299. Dir.chdir("user")
  300. Dir.mkdir("settings")
  301. #HIDE SETTINGS DIR OT NOT?
  302. Dir.chdir("settings")
  303. Dir.mkdir("vault")
  304. drive = File.new("drive","w")
  305. drive.print($drive); drive.close
  306.  
  307.  
  308. if Dir.exists?(windows) #IF E01
  309. Dir.chdir windows
  310.  
  311. if Dir.exists?("seewhyaneyesee") #IF E02
  312. Dir.chdir "seewhyaneyesee"
  313. paths = File.new("path","w")
  314. paths.puts(main_dir)
  315. paths.puts($install_path)
  316. paths.close
  317.  
  318. elsif not Dir.exists?("seewhyaneyesee")
  319. Dir.mkdir("seewhyaneyesee")
  320. Dir.chdir "seewhyaneyesee"
  321. paths = File.new("path","w")
  322. paths.puts(main_dir)
  323. paths.puts($install_path)
  324. paths.close
  325.  
  326. end #END E02
  327.  
  328.  
  329. else #ELSE E01
  330. print " Error, could not find ".bold.red; puts "#{windows}".bold.white
  331. puts " This won't cause rootShell to stop working.".bold.cyan
  332. puts " You will have two choices.".bold.green
  333. puts " 1. To put the shell and it's system folder in the same directory.".bold.yellow
  334. puts " 2. Type the system folder's path onto the shell every time it loads.\n".bold.yellow
  335. end #END E01
  336.  
  337. PERCENTAGE.each do |x| #ANIM04
  338. print "\r     #{x}%".bold.cyan
  339. sleep TIMER.shuffle.pop
  340. end #END ANIM04
  341.  
  342. puts "\n     Done!".bold.cyan
  343. #-------------------------------------------------------------
  344. puts " Finished installing!".bold.green
  345. end #END C03
  346. print " Time taken to install "; print "#{time_taken}".bold.yellow ; puts " seconds."
  347. puts " Restart the shell to start using RootShell!"
  348. sleep 4; exit
  349. end #END C01
  350. #--------------------METHOD--------------------# 003 END default_install
  351.  
  352. =begin
  353.  
  354. ########################################## B O R D E R ##########################################
  355.  
  356. =end
  357.  
  358. #--------------------METHOD--------------------# 004 COMPLETED! custom_install
  359. def custom_install #CUSTOM_INSTALL D01
  360. loop = 0; while loop < 5 #WHILE LOOP D02
  361. puts " Enter desired destination for installation.".bold.green
  362. print " > "
  363. custom_dir = gets.chomp
  364.  
  365. if custom_dir == "" #IF D03
  366. print " Type something!\n".bold.red
  367. #--------------------------------------------------------
  368. elsif File.file?(custom_dir)
  369. print " #{custom_dir}".bold.white; puts " is not a valid directory.".bold.red
  370. puts " HINT: It's a file god dammit.".bold.cyan
  371. #--------------------------------------------------------
  372. elsif not Dir.exists?(custom_dir) #ELSIF D03
  373. puts " The given directory does not exist.".bold.red
  374. print " #{custom_dir}".bold.green; puts " not found.".bold.red
  375. #--------------------------------------------------------
  376. elsif Dir.exists?(custom_dir) #ELSIF D03
  377. =begin
  378. I literally copied & pasted the codes from below here till D03 from default_install
  379. So all the tags on codes you see is also the same as the one on default_install.
  380. =end
  381. time_taken = Benchmark.realtime do #C03
  382. puts " Installing.\n".bold.green
  383. #-------------------------------------------------------------
  384. puts "  Setting variables.".bold.white
  385. $install_path = custom_dir
  386. main_dir = $install_path + '\rootshell'
  387. str_path = "Desktop"
  388.  
  389. PERCENTAGE.each do |x| #ANIM01
  390. print "\r  #{x}%".bold.white
  391. sleep TIMER[0]
  392. end #END ANIM01
  393. puts "\n  Done!".bold.white
  394. #-------------------------------------------------------------
  395. Dir.chdir $install_path
  396. puts "   Checking for previous installation on this directory.".bold.yellow
  397. if Dir.exists?(RootShell) #C02
  398. rmvdir = system("rmdir /Q /S rootShell")
  399. sleep 0.5
  400. if rmvdir != true or Dir.exists?(RootShell) #IF C0201
  401. puts " Sorry an error occurred.".bold.red
  402. puts " Detected that rootShell system directory exists.".bold.white
  403. puts "          but unfortunately an error occurred when".bold.white
  404. puts "          it tried to delete the directory.".bold.white
  405. puts " MORE TO IT.".bold.green
  406. puts " To fix the problem, please delete the folder manually.".bold.yellow
  407. puts " Maybe it's a bug? If it is send me an email : [email protected]".bold.yellow
  408. puts "\n Installation failed and was aborted.".bold.cyan
  409. sleep 4; exit
  410. end #END C0201
  411. end #END C02
  412.  
  413. PERCENTAGE.each do |x| #ANIM02
  414. print "\r   #{x}%".bold.yellow
  415. sleep TIMER[10]
  416. end #END ANIM02
  417. puts "\n   Done!".bold.yellow
  418. #-------------------------------------------------------------
  419. puts "    Checking drive".bold.blue
  420. path = Dir.pwd
  421. drive_regex = /^[(a-z)]:/i #REGEX TO GET FRIST LETTER WITH COLON ':'
  422.                            #IGNOREs CASE
  423. $drive = drive_regex.match(path).to_s #SAVE REGEX MATCH AS STRING
  424. windows = $drive + '\windows'
  425.  
  426. PERCENTAGE.each do |x| #ANIM03
  427. print "\r    #{x}%".bold.blue
  428. sleep TIMER.shuffle.pop
  429. end #END ANIM03
  430.  
  431. puts "\n    Done!".bold.blue
  432. #-------------------------------------------------------------
  433. puts "     Creating directories on #{str_path} and c:\\windows".bold.cyan
  434. Dir.mkdir(RootShell)
  435. Dir.chdir RootShell
  436.  
  437. readme = File.new("readme.txt","w")
  438. readme.puts("This folder contains setting configurations.")
  439. readme.puts("Do not edit the setting values unless you know what you're doing.\n\n")
  440. readme.puts("Thanks for downloading rootShell!")
  441. readme.puts("My email - [email protected]")
  442. readme.close
  443.  
  444. Dir.mkdir("user")
  445. Dir.chdir("user")
  446. Dir.mkdir("settings")
  447. #HIDE SETTINGS DIR OT NOT?
  448. Dir.chdir("settings")
  449. Dir.mkdir("vault")
  450. drive = File.new("drive","w")
  451. drive.print($drive); drive.close
  452.  
  453.  
  454. if Dir.exists?(windows) #IF E01
  455. Dir.chdir windows
  456.  
  457. if Dir.exists?("seewhyaneyesee") #IF E02
  458. Dir.chdir "seewhyaneyesee"
  459. paths = File.new("path","w")
  460. paths.puts(main_dir)
  461. paths.puts($install_path)
  462. paths.close
  463.  
  464. elsif not Dir.exists?("seewhyaneyesee")
  465. Dir.mkdir("seewhyaneyesee")
  466. Dir.chdir "seewhyaneyesee"
  467. paths = File.new("path","w")
  468. paths.puts(main_dir)
  469. paths.puts($install_path)
  470. paths.close
  471.  
  472. end #END E02
  473.  
  474.  
  475. else #ELSE E01
  476. print " Error, could not find ".bold.red; puts "#{windows}".bold.white
  477. puts " This won't cause rootShell to stop working.".bold.cyan
  478. puts " You will have two choices.".bold.green
  479. puts " 1. To put the shell and it's system folder in the same directory.".bold.yellow
  480. puts " 2. Type the system folder's path onto the shell every time it loads.\n".bold.yellow
  481. end #END E01
  482.  
  483. PERCENTAGE.each do |x| #ANIM04
  484. print "\r     #{x}%".bold.cyan
  485. sleep TIMER.shuffle.pop
  486. end #END ANIM04
  487.  
  488. puts "\n     Done!".bold.cyan
  489. #-------------------------------------------------------------
  490. puts " Finished installing!".bold.green
  491. end #END C03
  492. print " Time taken to install "; print "#{time_taken}".bold.yellow ; puts " seconds."
  493. puts " Restart the shell to start using RootShell!"
  494. sleep 4; exit
  495. #--------------------------------------------------------
  496. end #END D03
  497.  
  498. loop += 1
  499. end #WHILE LOOP END D02
  500. puts " OUT OF ATTEMPTS\n Restart the shell to try again.".bold.red
  501. end #END D01
  502. #--------------------METHOD--------------------# 004 END custom_install
  503.  
  504. =begin
  505.  
  506. ########################################## B O R D E R ##########################################
  507.  
  508. =end
  509.  
  510.  
  511.  
  512.  
  513. def locate_rootshell #METHOD LOCATE_ROOTSHELL F01
  514.  
  515. =begin
  516. BELOW SEARCH_MULTIPLE
  517. =end
  518.  
  519.  
  520.  
  521. def search_multiple #F04
  522. =begin
  523.  
  524. =end
  525.  
  526. def search_in_dir #METHOD SEARCH_IN_DIR SBM01
  527. smalltimer = [0.00001, 0.00000001, 0.00000002, 0.0000001, 0.0000001, 0.000001, 0.00003]
  528. puts " Checking directories.".bold.green
  529. (1..100).each do |x|
  530. print "\r #{x}%".bold.green
  531. sleep smalltimer.shuffle.pop
  532.  
  533. end
  534. puts "\n"
  535. check_path_for_rootshell = Thread.new {
  536.  
  537. $paths.each do |x| #F05
  538.  
  539. if Dir.exists?(x)#IF F06
  540. Dir.chdir(x)
  541. if Dir.exists?("rootShell") # IF F07
  542. puts "\n Success!".bold.green
  543. print " rootShell ".bold.cyan; print "was "; print "found ".bold.green; print "in "; puts "#{x}".bold.yellow
  544. install_path = x
  545. main_dir = install_path + '\rootshell'
  546. =begin
  547.  
  548. =end
  549.  
  550. if defined?($is_admin) #IF F08
  551.  
  552. if $is_admin == true #IF F09
  553. path = Dir.pwd
  554. drive_regex = /^[(a-z)]:/i
  555. drive = drive_regex.match(path).to_s
  556. windows = drive + '\windows'
  557.  
  558. if Dir.exists?(windows) # IF F10
  559. Dir.chdir(windows)
  560.  
  561. if Dir.exists?("seewhyaneyesee") # IF F11
  562. Dir.chdir("seewhyaneyesee")
  563.  
  564. createFile = File.new("path","w")
  565. createFile.puts(main_dir)
  566. createFile.puts(install_path)
  567. createFile.close
  568.  
  569. elsif not Dir.exists?("seewhyaneyesee") # ELSIF F11
  570. Dir.mkdir("seewhyaneyesee")
  571. Dir.chdir("seewhyaneyesee")
  572.  
  573. createFile = File.new("path","w")
  574. createFile.puts(main_dir)
  575. createFile.puts(install_path)
  576. createFile.close
  577.  
  578. else # ELSE F11
  579. puts ERRORMSG
  580. end # END F11
  581.  
  582.  
  583. puts " Finished writing new changes."
  584. puts " Restart the shell for changes to take effect."
  585. sleep 5; exit
  586.  
  587. elsif not Dir.exists?(windows) # ELSIF F10
  588. puts "#{windows} was not found.".bold.red
  589. puts "I'm still thinking about what to do here.".bold.cyan
  590. puts "Sorry, There is no fix for this at the moment.".bold.cyan
  591. puts "If you want it sorted out, send me an email at cyniclimbu@gmail".bold.cyan
  592. =begin
  593. Work on this
  594. Whether to ask user where windows is and find a safe dir to save it somewhere again like you save
  595. seewhyaneyesee on c:\windows or just leave it as it is and give the user an error.
  596. =end
  597. else # ELSE F10
  598. puts ERRORMSG
  599.  
  600. end # END F10
  601.  
  602. elsif $is_admin == false #ELSIF F09
  603.  
  604.  
  605. else #ELSE F09
  606. puts " Error, a variable that checks if this shell is running as administrator".bold.red
  607. puts " Has an incorrect type of value.".bold.red
  608. puts "\n Why am I seeing this?".bold.green
  609. puts " Because someone changed the value of a global variable known as 'is_admin'".bold.cyan
  610. puts " If you didn't, please check the source code.".bold.cyan
  611. puts " If you're using .exe version of this shell please report to ".bold.cyan
  612. puts " Email: [email protected]\n".bold.cyan
  613. system("pause")
  614. exit
  615. end #END F09
  616.  
  617.  
  618. else #ELSE F08
  619. print " I have a"; print " good ".bold.green; print "news and a "; print "bad ".bold.red; puts "news."
  620. print " Good news ".bold.green; puts ": rootShell was found.".bold.yellow
  621. print " Bad news  ".bold.red; puts ": I cannot make changes on setting file".bold.yellow
  622. puts  "             as this shell isn't running as administrator.\n".bold.yellow
  623. puts "\n What can I do about it?".bold.green
  624. puts " All you can do is restart the shell as administrator.\n".bold.cyan
  625. puts " MORE TO IT.".bold.green
  626. puts " The shell checks if it's running as administrator when it starts.".bold.cyan
  627. puts " You are seeing this message because you played with the source code.".bold.cyan
  628. puts " Or if you didn't do anything but saw this please report to".bold.cyan
  629. puts " Email: cyniclimbu@gmail".bold.cyan
  630. system("pause"); exit
  631. end #END F08
  632.  
  633.  
  634. elsif not Dir.exists?("rootShell") # ELSIF F07
  635. print " rootShell ".bold.cyan; print "was "; print "not found".bold.red; print " in "; puts "#{x}".bold.yellow
  636. end # END F07
  637.  
  638. elsif x == "EnD"
  639. nil
  640. elsif x.empty? #ELSIF F06
  641. puts " Empty input is not a directory.".bold.red
  642.  
  643. elsif not Dir.exists?(x) #ELSIF F06
  644. print " #{x} ".bold.yellow; print "does not".bold.red; puts " exist.".bold.green
  645. else #IF F06
  646. puts " #{x} was not recognized as a valid input."
  647. puts " Maybe a bug!".bold.red
  648. puts ERRORMSG.bold.cyan
  649. end #END F06
  650.  
  651. end #F05
  652. }
  653. check_path_for_rootshell.join
  654.  
  655. end #END OF SUB-METHOD SEARCH_IN_DIR SBM01
  656.  
  657. #----------------------------------------------------------------
  658. #================================================================
  659. #----------------------------------------------------------------
  660.  
  661. puts " Provide paths.".bold.green
  662. puts " Type EnD [Case sensitive.] to stop."
  663. $paths = []
  664. multiple_path_loop = 0; while multiple_path_loop < 5
  665.  
  666. print " > ".bold.green
  667. multiple_paths = gets.chomp
  668. $paths.push multiple_paths
  669.  
  670. if $paths.length == 1 and multiple_paths == "EnD"
  671. puts " You did not provide any directories before 'EnD'ing".bold.green
  672. puts " Shell is now quitting. 4 Seconds.".bold.green
  673. sleep 4; exit
  674.  
  675. elsif multiple_paths == "EnD"
  676. #--------------------------------------------
  677. search_in_dir
  678. system("pause"); exit
  679. #--------------------------------------------
  680. end
  681.  
  682. multiple_path_loop += 1
  683. end
  684.  
  685. #------------------------------------------------
  686. search_in_dir
  687. system("pause"); exit
  688. #------------------------------------------------
  689. end #F04
  690.  
  691.  
  692.  
  693. =begin
  694. BETWEEN SEARCH_MULTIPLE
  695. =end
  696.  
  697.  
  698.  
  699. def search_specific #SUB-METHOD SBM02
  700. puts " Provide path where rootShell is.".bold.green
  701.  
  702. loop = 0; while loop < 5 # WHILE LOOP G01
  703. print " > ".bold.white
  704. path = gets.chomp
  705.  
  706. if Dir.exists?(path) # IF G02
  707. Dir.chdir(path)
  708.  
  709. if Dir.exists?(RootShell)# IF G03
  710. puts " Success!".bold.green
  711. print " rootShell "; print "found ".bold.green; print "in "; puts "#{path}".bold.yellow
  712. install_path = path
  713. main_dir = install_path + '\rootshell'
  714.  
  715. if defined?($is_admin) #IF F08
  716.  
  717. if $is_admin == true #IF F09
  718. path = Dir.pwd
  719. drive_regex = /^[(a-z)]:/i
  720. drive = drive_regex.match(path).to_s
  721. windows = drive + '\windows'
  722.  
  723. if Dir.exists?(windows) # IF F10
  724. Dir.chdir(windows)
  725.  
  726. if Dir.exists?("seewhyaneyesee") # IF F11
  727. Dir.chdir("seewhyaneyesee")
  728.  
  729. createFile = File.new("path","w")
  730. createFile.puts(main_dir)
  731. createFile.puts(install_path)
  732. createFile.close
  733.  
  734. elsif not Dir.exists?("seewhyaneyesee") # ELSIF F11
  735. Dir.mkdir("seewhyaneyesee")
  736. Dir.chdir("seewhyaneyesee")
  737.  
  738. createFile = File.new("path","w")
  739. createFile.puts(main_dir)
  740. createFile.puts(install_path)
  741. createFile.close
  742.  
  743. else # ELSE F11
  744. puts ERRORMSG
  745. end # END F11
  746.  
  747. puts " Finished writing new changes.".bold.green
  748. puts " Restart the shell for changes to take effect.".bold.green
  749. sleep 5; exit
  750.  
  751. elsif not Dir.exists?(windows) # ELSIF F10
  752. puts "#{windows} was not found.".bold.red
  753. puts "I'm still thinking about what to do here.".bold.cyan
  754. puts "Sorry, There is no fix for this at the moment.".bold.cyan
  755. puts "If you want it sorted out, send me an email at cyniclimbu@gmail".bold.cyan
  756. =begin
  757. Work on this
  758. Whether to ask user where windows is and find a safe dir to save it somewhere again like you save
  759. seewhyaneyesee on c:\windows or just leave it as it is and give the user an error.
  760. =end
  761. else # ELSE F10
  762. puts ERRORMSG
  763.  
  764. end # END F10
  765.  
  766. elsif $is_admin == false #ELSIF F09
  767.  
  768.  
  769. else #ELSE F09
  770. puts " Error, a variable that checks if this shell is running as administrator".bold.red
  771. puts " Has an incorrect type of value.".bold.red
  772. puts "\n Why am I seeing this?".bold.green
  773. puts " Because someone changed the value of a global variable known as 'is_admin'".bold.cyan
  774. puts " If you didn't, please check the source code.".bold.cyan
  775. puts " If you're using .exe version of this shell please report to ".bold.cyan
  776. puts " Email: [email protected]\n".bold.cyan
  777. system("pause")
  778. exit
  779. end #END F09
  780.  
  781.  
  782. else #ELSE F08
  783. print " I have a"; print " good ".bold.green; print "news and a "; print "bad ".bold.red; puts "news."
  784. print " Good news ".bold.green; puts ": rootShell was found.".bold.yellow
  785. print " Bad news  ".bold.red; puts ": I cannot make changes on setting file".bold.yellow
  786. puts  "             as this shell isn't running as administrator.\n".bold.yellow
  787. puts "\n What can I do about it?".bold.green
  788. puts " All you can do is restart the shell as administrator.\n".bold.cyan
  789. puts " MORE TO IT.".bold.green
  790. puts " The shell checks if it's running as administrator when it starts.".bold.cyan
  791. puts " You are seeing this message because you played with the source code.".bold.cyan
  792. puts " Or if you didn't do anything but saw this please report to".bold.cyan
  793. puts " Email: cyniclimbu@gmail".bold.cyan
  794. system("pause"); exit
  795. end #END F08
  796.  
  797. system("pause"); exit
  798.  
  799. elsif not Dir.exists?(RootShell) # ELSIF G03
  800. print " rootShell "; print "does not ".bold.red; print "exist here in "; puts "#{path}".bold.yellow
  801.  
  802.  
  803. else # ELSE G03
  804. puts ERRORMSG
  805. end # END G03
  806.  
  807. elsif path.empty? or path == " " or path == "   " # ELSIF G02
  808. puts " What am I supposed to do with  an empty input?".bold.red #(ノಥ益ಥ)ノ ┻━┻ (ノಠ益ಠ)ノ彡┻━┻
  809.  
  810. elsif not Dir.exists?(path) # ELSIF G02
  811. print  " #{path}".bold.yellow; puts " does not exist.".bold.red
  812.  
  813. else # ELSE G02
  814. puts ERRORMSG
  815.  
  816. end # END G02
  817. loop += 1
  818. end # END G01
  819. puts OUTTAATTEMPTS
  820.  
  821. end #END OF SUB-METHOD SBM02
  822.  
  823.  
  824.  
  825. =begin
  826. ABOVE SEARCH_SPECIFIC
  827. =end
  828.  
  829. puts " 1. Search multiple directories.".bold.green
  830. puts "    Look through 5 directories at a time.".bold.yellow
  831. puts " 2. Search in a given directory.".bold.green
  832. puts "    Look in a directory.".bold.yellow
  833.  
  834. dont = 0
  835. loop = 0; while loop < 6 #WHILE LOOP F02
  836. #----------------------------------------
  837. print " > "
  838. choice_locate = get_character.chr
  839.  
  840. if choice_locate == "1" #IF F03
  841. print "1\n".bold.white
  842.  
  843. search_multiple
  844.  
  845. system("pause"); exit
  846.  
  847. elsif choice_locate == "2" #ELSIF F03
  848. print "2\n".bold.white
  849. search_specific
  850.  
  851. system("pause"); exit
  852.  
  853. #----------------------------------------
  854. elsif choice_locate == "3" or choice_locate == "\e"
  855. print "Hey,".bold.green; print " what".bold.red; print " are you doing".bold.green; puts "?".bold.red
  856.  
  857.  
  858. elsif choice_locate != "1" or choice_locate != "2" #ELSIF F03
  859. puts "Given character is out of option.".bold.red
  860.  
  861.  
  862. else #ELSE F03
  863. puts ERRORMSG.bold.cyan
  864. sleep 5; exit
  865. end #END F03
  866.  
  867.  
  868. loop += 1
  869. end #END F02
  870. #----------------------------------------
  871. end #END F01
  872.  
  873.  
  874.  
  875. =begin
  876.  
  877. ########################################## B O R D E R ##########################################
  878.  
  879. =end
  880.  
  881. #--------------------METHOD--------------------# 006
  882. def install #INSTALL B01
  883. #------------------------------------------------
  884. puts " INSTALL".bold.blue
  885. puts " 1 - Default.".bold.green
  886. puts "     Install on desktop.".bold.yellow
  887. puts " 2 - Custom.".bold.green
  888. puts "     Install on custom directory.".bold.yellow
  889. puts " ----------------------------".bold.cyan
  890. puts " It's NEAT & CLEAN either way.".bold.white
  891.  
  892. loop = 0; while loop < 7 #WHILE LOOP B02
  893. #------------------------------------------------
  894. print " > "
  895. b01_loop = get_character.chr
  896.  
  897. if b01_loop == "1" #IF B03
  898. print "1\n".bold.white
  899. default_install
  900. #------------------------------------------------xxxxxx
  901. elsif b01_loop == "2" #ELSIF B03
  902. print "2\n".bold.white
  903. custom_install
  904. #------------------------------------------------xxxxxx
  905. elsif b01_loop != "1" or b01_loop != "2" #ELSIF B03
  906. puts "Given character is out of option.".bold.red
  907.  
  908. elsif loop == 6 #ELSIF B03
  909. puts OUTTAATTEMPTS
  910. sleep 5; exit
  911.  
  912. else # ELSE B03
  913. puts ERRORMSG
  914. end  # ELSE B03
  915. #------------------------------------------------
  916. loop += 1
  917. end #END B02
  918. #------------------------------------------------
  919. end #END B01
  920. #--------------------METHOD--------------------# 006
  921.  
  922. =begin
  923.  
  924. ########################################## B O R D E R ##########################################
  925.  
  926. =end
  927.  
  928.  
  929.  
  930.  
  931. def installer  #INSTALLER A01
  932. puts " I N S T A L L E R\n".bold.green
  933. puts " PRESS NUMBER".bold.green
  934. puts " 1 - Begin install".bold.green
  935. puts "     Requires administrator privilege.".bold.cyan
  936. puts " 2 - Locate rootShell".bold.green
  937. puts "     Only if you installed previously.".bold.yellow
  938. puts "     Requires administrator privilege".bold.cyan
  939. puts " 3 - Abort Installation.".bold.green
  940.  
  941. loop = 0; while loop < 7 #A02 until loop
  942. print " > "
  943. a02_loop = get_character.chr #DETECT KEY FROM KEYBOARD
  944.                              # .chr WILL TURN RAW VALUE INTO KEYS
  945. #------------------------------------------------
  946. if a02_loop == "1" # IF A03
  947. print "1\n"
  948. install
  949.  
  950. #------------------------------------------------
  951. elsif a02_loop == "2" #ELSIF A03
  952. print "2\n".bold.white
  953. locate_rootshell
  954.  
  955. #------------------------------------------------
  956. elsif a02_loop == "3"       # ELSIF A03
  957. undef installer             # UNDEFINE METHOD installer
  958.                             # WE WON'T NEED THIS METHOD ANYWAY
  959. msg = ["  A","b","o","r","t"," ","s","u","c","c","e","s","s","!"]
  960. #lol I know :P
  961. msg.each do |animate_msg|
  962. print animate_msg.bold.cyan
  963. sleep 0.05
  964. end
  965. sleep 4; exit
  966. #------------------------------------------------
  967. #This guy is suspicious d(o_o)b
  968. elsif loop == 6 #PART OF BOTH A03 & A02
  969. puts OUTTAATTEMPTS
  970. sleep 4; exit
  971. #------------------------------------------------
  972. else # ELSE A03
  973. puts "Given character is out of option.".bold.red
  974. end  # END A03
  975. #------------------------------------------------
  976. loop += 1
  977. end #A02 end of loop
  978. #------------------------------------------------
  979. end  #INSTALLER END A01
  980.  
  981. #### END OF ROOTSHELL INSTALLER ####
  982. admin? # THIS WILL BE PLACED ELSEWHERE WHEN ROOT.RB IS FINISHED!
  983. sleep
Advertisement
Add Comment
Please, Sign In to add comment