/
ThunderboltTool.bat
2059 lines (2021 loc) · 67.6 KB
/
ThunderboltTool.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
:: This program is free software: you can redistribute it and/or modify
:: it under the terms of the GNU General Public License as published by
:: the Free Software Foundation, either version 3 of the License, or
:: (at your option) any later version.
::
:: This program is distributed in the hope that it will be useful,
:: but WITHOUT ANY WARRANTY; without even the implied warranty of
:: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
:: GNU General Public License for more details.
::
:: You should have received a copy of the GNU General Public License
:: along with this program. If not, see <http://www.gnu.org/licenses/>.
:: HINT: License is in README.txt.
::
@echo off
SETLOCAL
cls REM in case called by cmd
set verno=v1.0.1
set buildtime=November 24 2012, 2:13 AM EST
title HTC Thunderbolt Tool %verno%
color 0b
IF "%1" == "INFO" (
echo Verno - %verno% >info.log
echo Buildtime - %buildtime% >>info.log
exit
)
::
::Setting up logging
::Special thanks to Alex K. here http://tinyw.in/nh4r
::He solved a tricky log file naming issue for us.
::Because God knows I couldn't have solved it. :P
echo Starting up...
set hr=%time:~0,2%
if "%hr:~0,1%" equ " " set hr=0%hr:~1,1%
set log=logs\%date:~-4,4%%date:~-10,2%%date:~-7,2%_%hr%%time:~3,2%%time:~6,2%_%verno%.log
IF NOT EXIST logs (MKDIR logs)
echo Starting Thunderbolt Tool %verno% build %buildtime% at %date% %time% >%log%
::Making sure that we extracted correctly
echo Setting path >>%log%
set PATH=C:\WINDOWS\SYSTEM32
set uze=no
set sf=here
set rm=here
set dv=here
set modver=
IF NOT EXIST Driver.exe (
set dv=missing
set uze=yes
)
IF NOT EXIST README.txt (
set rm=missing
set uze=yes
)
IF NOT EXIST support_files (
set sf=missing
set uze=yes
)
IF "%uze%" == "yes" (GOTO UNZIP-ERR)
::Other necessary actions
IF NOT EXIST support_files\RAN1 (start README.txt)
echo Program ran for first time. >support_files\RAN1
IF NOT EXIST support_files\download (mkdir support_files\download)
IF EXIST ThunderboltTool.exe (del ThunderboltTool.exe)
::Removing unneeded files
IF EXIST back.bat (del back.bat)
IF EXIST adbwinapi.dll (del adbwinapi.dll)
IF EXIST adbwinusbapi.dll (del adbwinusbapi.dll)
IF EXIST fastboot.exe (del fastboot.exe)
IF EXIST adb.exe (del adb.exe)
::*********************************SKIPPING UPDATES, REMOVE THIS PRIOR TO RELEASE******************************
::GOTO PROGRAM rem ADD :: FOR RELEASE VERSIONS
:: * Script update engine *
::In case of freshly updated script...
IF EXIST support_files\Script-MD5.txt (del support_files\Script-MD5.txt)
IF EXIST OTA.bat (MOVE OTA.bat support_files\OTA.bat) >NUL
IF EXIST support_files\Script-server-MD5.txt (del support_files\Script-server-MD5.txt)
::Building MD5 of current script
:: Downloading latest MD5 Definitions
support_files\wget --quiet -O support_files\Script-server-MD5.txt http://www.androidfilehost.com/main/Thunderbolt_Developers/trter10/Script-server-MD5.txt?param=test
::Checking to see if there's a new version...
FOR /F "tokens=1 delims=" %%a in ( 'support_files\md5sums ThunderboltTool.bat' ) do ( set script-md5=%%a )
set /p script-new-md5=<support_files\Script-server-MD5.txt >>%log%
echo Server MD5 is: "%script-new-md5% ">>%log%
echo Our MD5: "%script-md5%">>%log%
IF "%script-new-md5% " NEQ "%script-md5%" (
Echo Updating >>%log%
GOTO OTA
)
del support_files\Script-new-MD5.txt >>%log% 2>&1
echo No updates availible. >>%log%
echo -- >>%log%
GOTO PROGRAM
:OTA
echo Updating >>%log%
MOVE support_files\OTA.bat OTA.bat >>%log% 2>&1
OTA.bat
exit
:PROGRAM
::Rooter fix
IF EXIST support_files\root\cp (GOTO skipmv)
IF EXIST support_files\root (
echo Running rooter hotfix >>%log%
copy support_files\AdbWinApi.dll support_files\root\AdbWinApi.dll >NUL
copy support_files\AdbWinUsbApi.dll support_files\root\AdbWinUsbApi.dll >NUL
echo copied >support_files\root\cp
)
:skipmv
::Getting SED and its .dll's if the need exists
:REGETSED
IF NOT EXIST support_files\download\sed.zip (goto skipsedmd5)
FOR /F "tokens=1 delims=" %%a in ( 'support_files\md5sums support_files\download\sed.zip' ) do ( set sedmd5=%%a )
echo Our checksum is %sedmd5% >>%log%
echo The correct checksum is 5F4BA3E44B33934E80257F3948970868 support_files\download\sed.zip >>%log%
IF "%sedmd5%" NEQ "5F4BA3E44B33934E80257F3948970868 support_files\download\sed.zip " (
del support_files\download\sed.zip
GOTO REGETSED
)
GOTO regetzip
:skipsedmd5
echo Getting sed >>%log%
support_files\wget -O support_files\download\sed.zip http://www.androidfilehost.com/main/Thunderbolt_Developers/trter10/SED.zip?param=test >>%log% 2>&1
title HTC Thunderbolt Tool %verno%
FOR /F "tokens=1 delims=" %%a in ( 'support_files\md5sums support_files\download\sed.zip' ) do ( set sedmd5=%%a )
echo Our checksum is %sedmd5% >>%log%
echo The correct checksum is 5F4BA3E44B33934E80257F3948970868 support_files\download\sed.zip >>%log%
IF "%sedmd5%" NEQ "5F4BA3E44B33934E80257F3948970868 support_files\download\sed.zip " (
del support_files\download\sed.zip
GOTO REGETSED
)
)
IF NOT EXIST support_files\sed.exe (support_files\unzip support_files\download\sed.zip -d support_files\ >>%log%)
:regetzip
IF NOT EXIST support_files\zip.exe (GOTO skipzipmd5)
FOR /F "tokens=1 delims=" %%a in ( 'support_files\md5sums support_files\zip.exe' ) do ( set zipmd5=%%a )
IF "%zipmd5%" == "83AF340778E7C353B9A2D2A788C3A13A support_files\zip.exe " (GOTO donezip)
:skipzipmd5
echo Getting zip >>%log%
support_files\wget --quiet -O support_files\zip.exe http://www.androidfilehost.com/main/Thunderbolt_Developers/trter10/zip.exe?param=test
FOR /F "tokens=1 delims=" %%a in ( 'support_files\md5sums support_files\zip.exe' ) do ( set zipmd5=%%a )
IF "%zipmd5%" NEQ "83AF340778E7C353B9A2D2A788C3A13A support_files\zip.exe " (
del support_files\zip.exe
goto regetzip
)
:donezip
IF NOT EXIST logs\RUN_ME_FOR_EMAIL.bat (
echo Getting necessary files..
echo Getting log .bat >>%log%
support_files\wget --quiet -O logs\RUN_ME_FOR_EMAIL.bat http://www.androidfilehost.com/main/Thunderbolt_Developers/trter10/RUN_ME_FOR_EMAIL.bat?param=test
)
::
IF EXIST support_files\Script-MD5.txt (del support_files\Script-MD5.txt)
IF EXIST support_files\Script-server-MD5.txt (del support_files\Script-server-MD5.txt)
:SKIPOTAEDIT
::Would direct output to log, but it links
::adb to the log so I cannot echo to it afterwards...
support_files\adb kill-server >NUL 2>&1
support_files\adb start-server >NUL 2>&1
:MAIN
::Just in case...
IF EXIST support_files\adbroot (del support_files\adbroot)
IF EXIST support_files\bl (del support_files\bl)
IF EXIST support_files\romver (del support_files\romver)
IF EXIST support_files\here (del support_files\here)
::In case of any odd errors
set romver=Unknown
set romver1=Unknown
set bootloader=Unknown
set adbrt=Unknown
set andver=Unknown
set here=NULL
set su=Unknown
set sutest=Unknown
::Seeing if phone is online
IF EXIST support_files\here (del support_files\here)
support_files\adb shell echo a>support_files\here 2>&1
set here=NULL
set /p here=<support_files\here
del support_files\here
if "%here%" == "a" (GOTO MAIN2)
::If the script is still going at this point,
::and has not went to :MAIN2, we will set a
::variable that tells the program that the
::phone is not connected.
support_files\fastboot devices >support_files\fbd 2>&1
FOR /F "tokens=1 delims= " %%a in ( 'support_files\md5sums support_files\fbd' ) do ( set fbd=%%a )
del support_files\fbd
IF "%fbd%" NEQ "D41D8CD98F00B204E9800998ECF8427E " (GOTO FASTBOOTONTOOLBOOT)
echo Phone not connected! >>%log%
set warn=nc
::Skipping unneccessary commands...
GOTO skip
:MAIN2
set warn=
echo Getting phone info >>%log%
echo -- >>%log%
::My workaround to get this to work in recovery mode (Just in case)
::Any addidtional /system/bin's before getprop are for this reason also.
FOR /F "tokens=1 delims=" %%a in ( 'support_files\adb shell mount system' ) do ( set bv=%%a )
IF "%bv%" == "Usage: mount [-r] [-w] [-o options] [-t type] device directory " (
echo Phone is normally booted >>%log%
set recovery=No
goto normboot
)
IF "%bv%" == "mount: can't read '/etc/fstab': No such file or directory " (
echo Phone is normally booted >>%log%
set recovery=No
goto normboot
)
echo Phone is in recovery mode >>%log%
support_files\adb shell mount /sdcard >>%log% 2>&1
support_files\adb shell mount /data >>%log% 2>&1
support_files\adb shell mount /cache >>%log% 2>&1
set recovery=yes
:normboot
IF "%waitforboot%" == "1" (
cls
echo Waiting for full boot...
)
::Checking Radio version
for /f "tokens=1 delims=" %%a in ( 'support_files\adb shell getprop gsm.version.baseband' ) do ( set radiover=%%a )
IF "%radiover%" == "" (
set waitforboot=1
goto normboot
)
IF "%radiover%" == " " (
set waitforboot=1
goto normboot
)
IF "%radiover%" == "1.49.00.0406w_1, 0.02.00.0312r " (set icsradios=yes)
IF "%radiover%" == "2.00.00.0308r, 0.02.00.0312r " (set icsradios=yes)
IF "%radiover%" == "2.00.00.0308r, 0.01.79.0331w_1 " (set icsradios=yes)
::Checking ROM Version
::Android ver
for /f "tokens=2 delims==" %%a in ( 'support_files\adb shell cat /system/build.prop ^| find "ro.build.version.release"' ) do ( set andver=%%a )
::Workaround for recovery mode so that we can still get romver
::
::Now looing back on this code (It is now 8/4/2012) I have no idea how this adds recovery compatibility.
::But I'm not gonna screw with it.
::Edit 11/11/12 - I know how it works now. k.
::
for /f "tokens=2 delims==" %%a in ( 'support_files\adb shell cat /system/build.prop ^| find "ro.product.version"' ) do ( set romver1=%%a )
IF "%romver1%" == "Unknown" (for /f "tokens=2 delims==" %%a in ( 'support_files\adb shell cat /system/build.prop ^| find "ro.build.display.id"' ) do ( set romver1=%%a ))
::In case of CM7
IF "%romver1%" == "GRJ22 " (
set romver2=CM7
for /f "tokens=2 delims==" %%a in ( 'support_files\adb shell cat /system/build.prop ^| find "ro.modversion"' ) do ( set modver=%%a )
)
IF "%romver2%" == "CM7" (set romver1=CyanogenMod 7 -)
set romver=%romver1% %modver%
::Checking bootloader
for /f "tokens=1 delims=" %%a in ( 'support_files\adb shell /system/bin/getprop ro.bootloader' ) do ( set bl=%%a )
IF "%bl%" == "6.04.1002 " (set bootloader=Revolutionary S-OFF)
IF "%bl%" == "1.04.2000 " (set bootloader=ENG S-OFF)
IF "%bl%" == "1.04.0000 " (set bootloader=Stock S-ON)
IF "%bl%" == "1.05.0000 " (set bootloader=Stock S-ON)
::Seeing if ADB-Rooted so we can determine
::how to carry out certain actions.
for /f "tokens=1 delims=" %%a in ( 'support_files\adb shell /system/bin/getprop ro.secure' ) do ( set adbroot=%%a )
IF "%adbroot%" == "0 " (set adbrt=Yes) ELSE (set adbrt=No)
IF "%recovery%" == "yes" (Set adbrt=Yes)
::Seeing if su is updated/installed
::Our assumptions, may change later in script
set suhere=1
set oldsu=- Outdated, please update in app
::Just in case phone is removed in process we echo out these
set su1=Unknown
set suver=Unknown
::For the real work
:check
FOR /F "tokens=2 delims=:" %%a in ( 'support_files\adb shell /system/xbin/su -v') do ( set su1=%%a )
FOR /F "tokens=1 delims=:" %%a in ( 'support_files\adb shell /system/xbin/su -v') do ( set suver=%%a )
FOR /F "tokens=1 delims=" %%a in ( 'support_files\adb shell /system/xbin/busybox a') do ( set bbhere=%%a )
echo RAW BBHERE "%bbhere%">>%log%
IF "%bbhere%" == "a: applet not found " (set hasbb=yes)
FOR /F "tokens=1 delims=" %%a in ( 'support_files\adb shell /system/bin/busybox a') do ( set bbhere=%%a )
IF "%bbhere%" == "a: applet not found " (set hasbb=yes)
IF "%hasbb%" NEQ "yes" (
set hasbb=no
goto skipperms
)
FOR /F "tokens=1 delims=" %%a in ( 'support_files\adb shell "ls -l /system/xbin/su ^|awk ' { print $1 }'"') do ( set perms=%%a )
FOR /F "tokens=1 delims=" %%a in ( 'support_files\adb shell "ls -l /system/xbin/su ^|awk ' { print $2 }'"') do ( set user=%%a )
FOR /F "tokens=1 delims=" %%a in ( 'support_files\adb shell "ls -l /system/xbin/su ^|awk ' { print $3 }'"') do ( set group=%%a )
:skipperms
echo RAW HASBB "%hasbb%">>%log%
::Seeing if they do have su in the first place
IF "%su1%" == " /system/xbin/su: not found " (
set suhere=0
goto skipsu
)
IF "%su1%" == " not found " (
set suhere=0
goto skipsu
)
IF "%su1%" == " permission denied " (
set suhere=0
goto skipsu
)
IF "%su1%" == " /system/xbin/su " (
set suhere=0
goto skipsu
)
IF "%su1%" == "SUPERSU " (set sukind=SuperSU)
IF "%su1%" == "Unknown" (set sukind=Superuser)
::Be sure to replace these with the current version when updated
IF "%suver%" GEQ "0.96 " (set oldsu=- Up to date)
IF "%suver%" GEQ "3.1.1 " (set oldsu=- Up to date)
:skipsu
::In case of any errors
cls
::Now to echo the output
echo.
echo Bootloader: %bl% %bootloader% >>%log%
echo ADB rooted: %adbrt% >>%log%
echo ROM Version: %romver% - Android %andver% >>%log%
echo Superuser: %sukind% binary v%suver% >>%log%
echo -- >>%log%
:skip
title HTC Thunderbolt Tool %verno%
set m=NULL
cls
IF "%bl%" == "1.04.2000 " (set rooted=yes)
IF "%bl%" == "6.04.1002 " (set rooted=yes)
IF "%bl%" == "1.04.0000 " (set rooted=no)
IF "%bl%" == "1.05.0000 " (set rooted=no)
::Determining what menu to show
IF "%warn%" == "nc" (GOTO nophonemain)
IF "%rooted%" == "no" (GOTO stockmain)
IF "%suhere%" == "0" (GOTO nosumain)
IF "%rooted%" == "yes" (GOTO rootmain)
:errormain
cls
echo Bootloader info error! >>%log%
echo Welcome to the HTC Thunderbolt tool, by trter10.
echo.
echo There was an error getting bootloader information.
echo If this persists, please contact me.
echo.
echo Press enter to exit.
pause >NUL
GOTO EXIT
:nosumain
cls
echo Loading no su main >>%log%
echo Welcome to the HTC Thunderbolt tool, by trter10.
echo.
echo ------------------------------
echo Install Superuser
echo ------------------------------
echo.
echo The SU binary is missing from your phone.
echo.
echo If you are just here to unroot, press 1.
echo If you are unrooting to try to fix your
echo root, just install the SU binary here.
echo Otherwise, it is a good idea to install.
echo.
echo Press 1 to unroot or 2 to install SU.
echo.
set /p m=Choose what you want to do or hit enter to exit.
IF "%M%" == "1" (GOTO UNROOT)
IF "%M%" == "2" (GOTO SOFFNOROOT2)
IF "%M%" == "NULL" (GOTO EXIT)
goto nosumain
:FASTBOOTONTOOLBOOT
cls
echo Device in fastboot >>%log%
support_files\fastboot getvar version-baseband >support_files\bb 2>&1
set /p baseband1=<support_files\bb
del support_files\bb
FOR /F "tokens=2 delims=:" %%a in ( 'echo %baseband1%' ) do ( set baseband=%%a )
support_files\fastboot getvar security >support_files\sec 2>&1
set /p security1=<support_files\sec
del support_files\sec
FOR /F "tokens=2 delims= " %%a in ( 'echo %security1%' ) do ( set security=%%a )
support_files\fastboot getvar version-bootloader >support_files\bl 2>&1
set /p hbootver1=<support_files\bl
del support_files\bl
FOR /F "tokens=2 delims= " %%a in ( 'echo %hbootver1%' ) do ( set hbootver=%%a )
:fbsoff
cls
echo Loading fastboot menu for s-off>>%log%
echo -- >>%log%
echo Welcome to the HTC Thunderbolt tool, by trter10.
set m=NULL
echo.
echo Phone information:
echo.
echo You are S-%security%
echo Hboot: %hbootver%
echo Radio:%baseband%
echo.
echo FASTBOOT MENU
echo --------------------------------------------------------
echo 1 - Boot menu
echo 2 - About
echo R - Reload info
echo * Security warning fix coming soon!
echo --------------------------------------------------------
set /p m=Choose what you want to do or hit enter to exit.
IF "%M%" == "1" (GOTO SECWAR)
IF "%M%" == "2" (GOTO FBBOOT)
IF "%M%" == "3" (GOTO ABOUT)
IF "%M%" == "r" (GOTO SKIPOTAEDIT)
IF "%M%" == "R" (GOTO SKIPOTAEDIT)
IF "%M%" == "NULL" (
echo -- >>%log%
GOTO EXIT
)
GOTO fbsoff
:fbson
cls
echo Loading fastboot menu for s-on>>%log%
echo -- >>%log%
echo Welcome to the HTC Thunderbolt tool, by trter10.
set m=NULL
echo.
echo Phone information:
echo.
echo S-%security%
echo Hboot %hbootver%
echo Radio%baseband%
echo.
echo FASTBOOT MENU
echo --------------------------------------------------------
echo 1 - Recovery menu
echo 2 - Boot menu
echo 3 - Extras menu
echo 4 - Unroot
echo 5 - About
echo R - Reload info
echo --------------------------------------------------------
set /p m=Choose what you want to do or hit enter to exit.
IF "%M%" == "1" (GOTO RECOVERY)
IF "%M%" == "2" (GOTO BOOT)
IF "%M%" == "3" (GOTO EXTRAS)
IF "%M%" == "4" (GOTO UNROOT)
IF "%M%" == "5" (GOTO ABOUT)
IF "%M%" == "r" (GOTO SKIPOTAEDIT)
IF "%M%" == "R" (GOTO SKIPOTAEDIT)
IF "%M%" == "NULL" (
echo -- >>%log%
GOTO EXIT
)
GOTO fbsoff
:SECWAR
:FBBOOT
:stockmain
cls
echo Loading stock main >>%log%
echo -- >>%log%
echo Welcome to the HTC Thunderbolt tool, by trter10.
echo.
echo Your phone is not S-OFF.
echo.
echo Press enter to S-OFF, install Superuser, and block OTA updates.
echo (This will NOT wipe data, but will void your warranty!)
pause >NUL
GOTO ROOT1
::Old stock main menu, I may decide to re-incorporate it later.
echo Welcome to the HTC Thunderbolt tool, by trter10.
set m=NULL
echo.
echo Phone information:
echo.
echo * WARNING: Phone is stock! You must use
echo option 1 before more functions are availible!
echo.
echo ROM Version: %romver% - Android %andver%
echo.
echo MAIN MENU
echo --------------------------------------------------------
echo 1 - S-OFF and root
echo 2 - About
echo R - Reload info
echo --------------------------------------------------------
set /p m=Choose what you want to do.
IF "%M%" == "1" (GOTO ROOT1)
IF "%M%" == "2" (GOTO ABOUT)
IF "%M%" == "r" (GOTO SKIPOTAEDIT)
IF "%M%" == "R" (GOTO SKIPOTAEDIT)
IF "%M%" == "NULL" (
echo -- >>%log%
GOTO EXIT
)
GOTO stockmain
:rootmain
::prereq's
IF "%recovery%" == "yes" (echo Boot mode: Recovery) ELSE (echo Boot mode: Normal)
IF "%perms%%user:~0,-1%.%group:~0,-1%" NEQ "-rwsr-sr-x root.root" (set po=INCORRECT PERMISSIONS)
set po=
:: ---------------
cls
echo Loading root main menu >>%log%
echo -- >>%log%
echo Welcome to the HTC Thunderbolt tool, by trter10.
set m=NULL
echo.
echo Phone information:
echo.
echo ROM Version: %romver:~0,-1%- Android %andver%
echo.
:: %oldsu% BETA~~
IF "%hasbb%" == "yes" (
echo %sukind% binary v%suver%^(%perms%%user:~0,-1%.%group:~0,-1%^) %po%
)
IF "%hasbb%" NEQ "yes" (
echo %sukind% binary v%suver%
)
echo.
echo MAIN MENU
echo --------------------------------------------------------
echo 1 - Recovery menu
echo 2 - Boot menu
echo 3 - Extras menu
echo 4 - Unroot
echo 5 - About
echo R - Reload info
echo --------------------------------------------------------
set /p m=Choose what you want to do or hit enter to exit.
IF "%M%" == "1" (GOTO RECOVERY)
IF "%M%" == "2" (GOTO BOOT)
IF "%M%" == "3" (GOTO EXTRAS)
IF "%M%" == "4" (GOTO UNROOT)
IF "%M%" == "5" (GOTO ABOUT)
IF "%M%" == "r" (GOTO SKIPOTAEDIT)
IF "%M%" == "R" (GOTO SKIPOTAEDIT)
IF "%M%" == "NULL" (
echo -- >>%log%
GOTO EXIT
)
GOTO ROOTMAIN
:nophonemain
echo Loading phone not connected prompt >>%log%
echo -- >>%log%
cls
set m=NULL
echo Welcome to the HTC Thunderbolt tool, by trter10.
echo.
echo Device not connected!
echo.
echo If you are having issues, please read the README.txt.
echo.
echo Waiting for device connection...
echo.
:nophonemain2
::I can't use a FOR /F here, because if I do it prints "error: device not found" repeatedly
::So we will do it manually
set here=NULL
support_files\adb shell echo a>support_files\here 2>&1
set /p here=<support_files\here
del support_files\here
if "%here%" NEQ "a" (
GOTO nophonemain2
)
GOTO MAIN
::
:: -----------------------------------------------------------------------
::
:ROOT1
echo Starting rooter >>%log%
:ROOT
cls
echo ------------------------------
echo Rooter
echo ------------------------------
echo.
echo Preparing rooter...
IF NOT EXIST support_files\download\DowngradeBypass.zip (GOTO getDB)
IF EXIST support_files\download\downgradebypass.zip.md5 (del support_files\download\downgradebypass.zip.md5)
support_files\wget --quiet -O support_files\download\DowngradeBypass.zip.md5 http://www.androidfilehost.com/main/Thunderbolt_Developers/trter10/S-O-DowngradeBypass.zip.md5?param=test
for /f "tokens=1 delims=" %%a in ( 'support_files\md5sums support_files\download\DowngradeBypass.zip' ) do ( set rootmd5=%%a )
set /p DBzipMD5=<support_files\download\DowngradeBypass.zip.md5
del support_files\download\DowngradeBypass.zip.md5
echo Our checksum is %rootmd5% >>%log%
echo Correct checksum is %DBzipMD5% >>%log%
IF "%rootmd5%" NEQ "%DBzipMD5% " (
:GetDB
cls
echo ------------------------------
echo Rooter
echo ------------------------------
echo.
echo You don't yet have the rooter files, or there is an update.
echo Downloading now...
echo.
echo Downloading Rooter Files >>%log%
IF EXIST support_files\root\ (RMDIR "support_files\root" /S /Q)
support_files\wget -O support_files\download\DowngradeBypass.zip http://www.androidfilehost.com/main/Thunderbolt_Developers/trter10/S-O-DowngradeBypass.zip?param=test >>%log% 2>&1
GOTO ROOT
)
title HTC Thunderbolt Tool %verno%
IF NOT EXIST support_files\root (
echo Unzipping rooter files... >>%log%
support_files\unzip support_files\download\DowngradeBypass.zip -d support_files\root >>%log% 2>&1
)
IF EXIST support_files\root\cp (GOTO skipmv2)
IF EXIST support_files\root (
echo Running rooter hotfix >>%log%
copy support_files\AdbWinApi.dll support_files\root\AdbWinApi.dll >NUL
copy support_files\AdbWinUsbApi.dll support_files\root\AdbWinUsbApi.dll >NUL
echo copied >support_files\root\cp
)
:skipmv2
echo Launching Rooter... >>%log%
echo -- >>%log%
color 0a
cls
set m=NULL
echo ------------------------------ INFO:
echo Rooter -For this to work, you must have an
echo ------------------------------ SDCard, the phone in charge only mode,
echo stay awake enabled, and the phone
echo Press enter when ready. screen on and unlocked the entire time.
pause >NUL
cls
echo ------------------------------
echo Rooter
echo ------------------------------
echo.
for /f "tokens=1 delims=" %%a in ( 'support_files\adb root' ) do ( set rooted=%%a )
IF "%rooted%"=="adbd is already running as root " (GOTO SUCCESSFUL)
set newver=no
IF "%romver%" == "2.11.605.9 " (set newver=yes)
IF "%romver%" == "Unknown " (set newver=yes)
IF "%romver%" == "2.11.605.19 710RD " (set newver=yes)
IF "%romver%" == "2.11.605.9 " (set newver=yes)
IF "%romver%" == "2.11.605.19 710RD " (set newver=yes)
IF "%newver%" NEQ "yes" (
echo Phone is on ROM Version "%romver%"so we will use ZergRush. >>%log%
echo Temp rooting >>%log%
support_files\wget --quiet -O support_files\root\ZergRush http://www.androidfilehost.com/main/Thunderbolt_Developers/trter10/ZergRush?param=test
IF "%retry%" == "yes" (
echo --ROM version is unknown
echo --and fre3vo failed, so we
echo --will try ZergRush.
echo.
)
echo Preparing for S-OFF with
echo ZergRush. Thanks Revolutionary
echo team!
support_files\adb push support_files\root\ZergRush /data/local/ >>%log% 2>&1
support_files\adb shell chmod 777 /data/local/ZergRush
support_files\adb shell /data/local/ZergRush >>%log% 2>&1
support_files\adb wait-for-device
support_files\adb kill-server >NUL 2>&1
support_files\adb start-server >NUL 2>&1
GOTO SKIPFRE3VO
)
echo Preparing for S-OFF with fre3vo, thanks
echo TeamWin! You will see some static across
echo the top of your phone screen.
echo Phone is on ROM Version "%romver%" so we will use fre3vo. >>%log%
echo Temp rooting >>%log%
support_files\adb push support_files\root\fre3vo /data/local/fre3vo >>%log% 2>&1
support_files\adb shell chmod 777 /data/local/fre3vo
support_files\adb shell /data/local/fre3vo -debug -start F0000000 -end FFFFFFFF >>%log% 2>&1
support_files\adb wait-for-device
support_files\adb shell rm /data/local/fre3vo
:SKIPFRE3VO
support_files\adb kill-server >NUL 2>&1
support_files\adb start-server >NUL 2>&1
::Ensuring root was successful...
for /f "tokens=1 delims=" %%a in ( 'support_files\adb root' ) do ( set rooted=%%a )
IF "%rooted%"=="adbd is already running as root " (GOTO SUCCESSFUL) ELSE (
IF "%romver%" == "Unknown " (
set newver=no
set retry=yes
goto mroot
)
GOTO UNSUCCESSFUL
:SUCCESSFUL
cls
echo ------------------------------
echo Rooter
echo ------------------------------
echo.
echo Root successful >>%log%
color 0c
echo Success! Finishing preparations...
echo.
echo Just in case of PG05IMG >>%log%
support_files\adb shell rm /sdcard/PG05IMG.zip >>%log% 2>&1
support_files\adb kill-server >NUL 2>&1
support_files\adb start-server >NUL 2>&1
echo.
for /f "tokens=1 delims=" %%a in ( 'support_files\adb shell getprop ro.serialno' ) do ( set serialno=%%a )
echo X = MsgBox("On the revolutionary website, please scroll down to Download for Windows. Click that button, then cancel the download. Enter your phone's information in the prompts that pop up. The info you need is: Seiral Number: %serialno% Hboot version: %bl% Once you do that, copy your beta key from the website, then paste it into the Revolutionary window. To paste it, right click the title bar of the Revolutionary window then click edit then click paste. If there are two revolutionary windows, you can close one. Please note that for Revolutionary to work you need to uninstall Droid Explorer if you have it. Thanks!",0+64+4096, "PLEASE READ - Message from trter10")>support_files\root\rev.vbs
echo X = MsgBox("Please note that you need to enter Y to download and flash CWM recovery at the end of Revolutionary (If it sticks at waiting for fastboot or rebooting to fastboot once moar make sure you have ran the driver and try unplugging and replugging in the phone.) After Revolutionary completes and CWM is flashed, using the volume buttons to navigate and power to select, you will need to exit fastboot by selecting bootloader, waiting a few seconds, then selecting recovery. Then, CWM will automatically install superuser and reboot.",0+64+4096, "PLEASE READ - Message from trter10")>>support_files\root\rev.vbs
:su-no-ota
echo Putting files on phone >>%log%
echo.
:repushSu
support_files\adb wait-for-device
echo -SU >>%log%
support_files\adb push support_files\root\su.zip /sdcard/su.zip >support_files\pushSu 2>&1
support_files\cat support_files/pushSu >>%log% 2>&1
for /f "tokens=2 delims=(" %%a in ( 'support_files\cat support_files/pushSu' ) do ( set pushSu1=%%a )
echo %pushSu1% >support_files\pushSu
for /f "tokens=1 delims=i" %%a in ( 'support_files\cat support_files/pushSu' ) do ( set pushSu2=%%a )
echo pushSu1 is "%pushSu1%" >>%log%
echo pushSu2 is "%pushSu2%" >>%log%
del support_files\pushSu
IF "%pushSu2%" == "1324669 bytes " (goto sugood)
cls
echo ------------------------------
echo Rooter
echo ------------------------------
echo.
echo It appears there was an error
echo pushing some files to the phone.
echo.
echo Please make sure Stay Awake and
echo Charge Only are enabled. The phone
echo screen must stay on the entire time.
echo.
echo Press enter to repush...
pause >NUL
goto repushSu
:sugood
echo -OTABlock >>%log%
support_files\adb push support_files\root\OTABlock.zip /sdcard/OTABlock.zip >>%log% 2>&1
echo -Extendedcommand >>%log%
support_files\adb push support_files\root\extendedcommand /cache/recovery/extendedcommand >>%log% 2>&1
echo Starting Revolutionary and the Website >>%log%
START /MAX http://www.Revolutionary.io
START support_files\root\Revolutionary.exe
START support_files\root\Revolutionary.exe
START support_files\root\rev.vbs
echo -- >>%log%
::Had to do this because :EXIT runs
::adb kill-server, which messes up rev.
echo Exiting... >>%log%
IF EXIST support_files\adbroot (del support_files\adbroot)
IF EXIST support_files\bl (del support_files\bl)
IF EXIST support_files\romver (del support_files\romver)
IF EXIST support_files\here (del support_files\here)
IF EXIST support_files\Script-new-MD5.txt (del support_files\Script-new-MD5.txt)
exit
:UNSUCCESSFUL
cls
echo Root unsuccessful >>%log%
echo -- >>%log%
echo ------------------------------
echo Rooter
echo ------------------------------
echo.
echo Root unsuccessful! :(
echo.
echo Try pulling your battery and running again.
echo.
pause
GOTO EXIT
::
:: -----------------------------------------------------------------------
::
:UNROOT
echo Starting unrooter >>%log%
:UNROOT2
cls
echo ------------------------------
echo Unrooter
echo ------------------------------
echo.
echo Preparing unrooter...
IF NOT EXIST support_files\download\unroot.zip (GOTO getunroot)
for /f "tokens=1 delims=" %%a in ( 'support_files\md5sums support_files\download\unroot.zip' ) do ( set unroothere=%%a )
echo Our checksum is %unroothere% >>%log%
echo Correct checksum is 770CF07D8DF125E145A4EABF3E7F95B1 support_files\download\unroot.zip >>%log%
IF "%unroothere%" == "770CF07D8DF125E145A4EABF3E7F95B1 support_files\download\unroot.zip " (GOTO rununroot)
cls
echo ------------------------------
echo Unrooter
echo ------------------------------
echo.
echo Re-getting unroot files due to bad checksum >>%log%
echo Bad download! Sorry!
echo Redownloading...
GOTO Justgetunroot
:getunroot
cls
echo ------------------------------
echo Unrooter
echo ------------------------------
echo.
echo Getting unroot files >>%log%
echo You don't yet have the unroot files.
echo Downloading now... This will take awhile...
echo.
:Justgetunroot
IF EXIST support_files\unroot\ (RMDIR "support_files\unroot" /S /Q)
support_files\wget -O support_files\download\unroot.zip http://www.androidfilehost.com/main/Thunderbolt_Developers/trter10/S-O-Unroot.zip?param=test >>%log% 2>&1
title HTC Thunderbolt Tool %verno%
GOTO UNROOT2
:rununroot
IF NOT EXIST support_files\unroot (
echo Unzipping unrooter files... >>%log%
support_files\unzip support_files\download\unroot.zip -d support_files\unroot >>%log% 2>&1
)
for /f "tokens=1 delims=" %%a in ( 'support_files\md5sums support_files\unroot\Stock-ROM.zip' ) do ( set stockromhere=%%a )
echo Our Stock ROM checksum is %stockromhere% >>%log%
echo The correct checksum is 013CBDD3A9B28BC894631008FA2148E2 support_files\unroot\Stock-ROM.zip >>%log%
IF "%stockromhere%" NEQ "013CBDD3A9B28BC894631008FA2148E2 support_files\unroot\Stock-ROM.zip " (
echo Re-unzipping unroot.zip due to bad Stock-ROM.zip checksum >>%log%
RMDIR "support_files\unroot" /S /Q
GOTO rununroot
)
cls
color 0a
echo Launching Unrooter >>%log%
echo ------------------------------ INFO:
echo Unrooter -This will restore COMPLETELY to
echo ------------------------------ stock. (ROM, splash screen, etc)
echo.
echo Press enter when ready. -THIS WILL WIPE DATA!! (Contacts, apps...)
echo.
echo -You MUST have an SDCard with at
echo least 455 MB of free space.
echo.
echo -You must have a full battery charge.
echo.
pause >NUL
:radtest
::debugging purposes only
::set icsradios=yes
IF "%icsradios%" NEQ "yes" (GOTO REPUSH)
cls
echo ------------------------------
echo Unrooter
echo ------------------------------
echo.
echo It appears that you are on the
echo leaked ICS radios. You are on
echo "%radiover:~0,-1%".
echo To unroot, we must first flash
echo back down to Gingerbread radios.
echo.
echo Press enter when ready.
pause >NUL
:radmd5
set flashrad=yes
IF NOT EXIST support_files\download\latestradio.zip (GOTO getradio)
cls
echo ------------------------------
echo Unrooter
echo ------------------------------
echo.
echo Preparing radio >>%log%
echo Preparing radio...
for /f "tokens=1 delims=" %%a in ( 'support_files\md5sums -l support_files\download\latestradio.zip' ) do ( set radiohere=%%a )
echo Our checksum is "%radiohere%" >>%log%
echo Correct checksum is "1964f4062039e27f29a49af63004217f support_files\download\latestradio.zip" >>%log%
IF "%radiohere%" == "1964f4062039e27f29a49af63004217f support_files\download\latestradio.zip " (GOTO flashradio)
cls
echo ------------------------------
echo Unrooter
echo ------------------------------
echo.
echo Redownloading radio due to bad checksum >>%log%
echo Bad download! Sorry!
echo Redownloading...
goto justdownloadradio
:getradio
cls
echo ------------------------------
echo Unrooter
echo ------------------------------
echo.
echo Downloading radio >>%log%
echo Downloading radio, thanks xredjokerx!
:justdownloadradio
support_files\wget -O support_files\download\latestradio.zip http://www.androidfilehost.com/main/Thunderbolt_Developers/trter10/latestradio.zip?param=test >>%log% 2>&1
title HTC Thunderbolt Tool %verno%
goto radmd5
:flashradio
cls
echo ------------------------------
echo Unrooter
echo ------------------------------
echo.
echo Pushing radio to SDCard, please wait...
echo Pushing radio >>%log%
support_files\adb push support_files\download\latestradio.zip /sdcard/PG05IMG.zip >support_files\pushRadio 2>&1
support_files\cat support_files/pushRadio >>%log% 2>&1
for /f "tokens=2 delims=(" %%a in ( 'support_files\cat support_files/pushRadio' ) do ( set pushRadio1=%%a )
echo %pushRadio1% >support_files\pushRadio
for /f "tokens=1 delims=i" %%a in ( 'support_files\cat support_files/pushRadio' ) do ( set pushRadio2=%%a )
echo pushRadio1 is "%pushRadio1%" >>%log%
echo pushRadio2 is "%pushRadio2%" >>%log%
del support_files\pushRadio
IF "%pushRadio2%" == "26687391 bytes " (goto goodradio)
cls
echo ------------------------------
echo Unrooter
echo ------------------------------
echo.
echo It appears there was an error
echo pushing the radio.
echo.
echo Please make sure Stay Awake and
echo Charge Only are enabled. The phone
echo screen must stay on for the push.
echo.
echo Press enter to repush...
pause >NUL
goto flashradio
:goodradio
cls
echo ------------------------------
echo Unrooter
echo ------------------------------
echo.
echo Rebooting to fastboot...
support_files\adb reboot-bootloader
cls
echo ------------------------------
echo Unrooter
echo ------------------------------
echo.
echo Switching to HBOOT >>%log%
echo Switching to HBOOT...
echo.
echo If it gets stuck here for more than
echo 15 seconds, you should either try
echo running Driver.exe, or use a
echo different, non-USB3.0 port.
echo.
support_files\fastboot oem gotohboot >>%log% 2>&1
cls
cls
echo ------------------------------
echo Unrooter
echo ------------------------------
echo.
echo ------------------------------------------------------------------------------
echo Wait a few seconds, and your phone will load a file.
echo Then, press VOLUME UP to confirm that you want to flash the file.
echo During the flash, DO NOT I repeat DO NOT power off the phone!!
echo.
echo Please make sure that the flash completed successfully.
echo If it did not flash successfully, DO NOT TURN OFF YOUR PHONE, and send me an email with info on what happened.
echo.
echo If it flashed correctly, and your phone says "Update Complete...", press POWER.
echo If your phone sits there turned off for a minute or more with the orange light on, just hold the power button for a second or two and let go.
echo Once the phone boots up, unlock the screen, press enter, and I will take control again.
echo ------------------------------------------------------------------------------
support_files\adb kill-server >NUL 2>&1
support_files\adb start-server >NUL 2>&1
support_files\adb wait-for-device
pause >NUL
:rmrad
echo Removing radio >>%log%
cls
echo ------------------------------
echo Unrooter
echo ------------------------------
echo.
echo Please wait...
set tries=0
set triestwo=0
:rerm
echo Attempt "%triestwo%" >>%log%
set rm=NULL
IF %triestwo% GEQ 1 (
PING 1.1.1.1 -n 1 -w 5000 >NUL
echo rm is "%rm%" >>%log%
)
IF %triestwo% GEQ 5 (
set tries=0
set triestwo=0
cls
echo ------------------------------
echo Unrooter
echo ------------------------------
echo.
echo I'm having issues removing the radio
echo from the SD Card. Make sure the screen
echo is on and unlocked!
echo.
echo Press enter to retry.
pause >NUL
goto rmrad
)
set /a triestwo= %tries%+1
set tries=%triestwo%