-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
selenium.cmd
1733 lines (1646 loc) · 81.7 KB
/
selenium.cmd
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
@echo off & setLocal EnableDelayedExpansion
:: Copyright Conor McKnight
:: https://github.com/C0nw0nk/Selenium
:: https://www.facebook.com/C0nw0nk
:: Automatically sets up selenium and webdriver for use to be portable to any folder on your pc no python required pip any of that nonsense needed
:: all you need is the batch script it will download the latest versions from their github pages portable selenium!
:: simple fast efficient easy to move and manage
::One file to rule them all,
::One file to find them,
::One file to bring them all,
::and inside cyberspace bind them.
::~Conor McKnight
:: IF you like my work please consider helping me keep making things like this
:: DONATE! The same as buying me a beer or a cup of tea/coffee :D <3
:: PayPal : https://paypal.me/wimbledonfc
:: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=ZH9PFY62YSD7U&source=url
:: Crypto Currency wallets :
:: BTC BITCOIN : 3A7dMi552o3UBzwzdzqFQ9cTU1tcYazaA1
:: ETH ETHEREUM : 0xeD82e64437D0b706a55c3CeA7d116407E43d7257
:: SHIB SHIBA INU : 0x39443a61368D4208775Fd67913358c031eA86D59
:: Script Settings
:settings_load
::once finished tasks on webpage run quit commands to exit selenium to safely close the selenium browser
:: 1 enabled
:: 0 disabled
set close_selenium=0
::internet explorer selenium browser
::disabled by default not needed to use this obviously microsoft depreciated IE and Edge is their future
::i added it since selenium have a maintained IE web driver and some people might want to use it
:: 1 enabled
:: 0 disabled
set internetexplorer_selenium=0
::the webpage we want to access to perform a remote automated task on for IE
set internetexplorer_selenium_browser_url=https://www.bbc.co.uk/
::microsoft edge selenium browser
:: 1 enabled
:: 0 disabled
set microsoftedge_selenium=0
::the webpage we want to access to perform a remote automated task on for Edge
set microsoftedge_selenium_browser_url=https://www.bbc.co.uk/
::chrome selenium browser
:: 1 enabled
:: 0 disabled
set chrome_selenium=1
::the webpage we want to access to perform a remote automated task on for Chrome
set chrome_selenium_browser_url=https://www.bbc.co.uk/
::firefox selenium browser
:: 1 enabled
:: 0 disabled
set firefox_selenium=1
::the webpage we want to access to perform a remote automated task on for firefox
set firefox_selenium_browser_url=https://www.bbc.co.uk/
::brave selenium browser
:: 1 enabled
:: 0 disabled
set brave_selenium=1
::the webpage we want to access to perform a remote automated task on for brave
set brave_selenium_browser_url=https://www.bbc.co.uk/
::vivaldi selenium browser
:: 1 enabled
:: 0 disabled
set vivaldi_selenium=1
::the webpage we want to access to perform a remote automated task on for vivaldi
set vivaldi_selenium_browser_url=https://www.bbc.co.uk/
::opera selenium browser
:: 1 enabled
:: 0 disabled
set opera_selenium=0
::the webpage we want to access to perform a remote automated task on for opera
set opera_selenium_browser_url=https://www.bbc.co.uk/
::Tor selenium browser
:: 1 enabled
:: 0 disabled
set tor_selenium=0
::Tor Bridge to use for encrypted traffic
::1 obfs4 - obfs4 is a type of built-in bridge that makes your Tor traffic look random. They are also less likely to be blocked than their predecessors, obfs3 bridges.
::2 snowflake - Snowflake is a built-in bridge that defeats censorship by routing your connection through Snowflake proxies, ran by volunteers.
::3 meek-azure - meek-azure is a built-in bridge that makes it look like you are using a Microsoft web site instead of using Tor.
set tor_proxy_bridge=1
::the webpage we want to access to perform a remote automated task on for Tor
set tor_selenium_browser_url=https://www.bbc.co.uk/
::PhantomJS selenium browser
:: 1 enabled
:: 0 disabled
set phantomjs_selenium=1
::the webpage we want to access to perform a remote automated task on for PhantomJS
set phantomjs_selenium_browser_url=https://www.bbc.co.uk/
::this adds in the ability to make the selenium instance hidden like a background task
::you will not see a browser window appear if you enable headless mode
:: 1 enabled
:: 0 disabled
set headlessbrowser=0
::if we should cleanup our portable folder leaving just this batch script after each use
::default is not to cleanup because its most likely we will run our automated task again
:: 1 enabled
:: 0 disabled
set cleanup=0
::instead of just closing the window after our automated web tasking we pause to view and check once your happy you can set this to 0
:: 1 enabled
:: 0 disabled
set pause_window=1
:: Run this task every 60 seconds
set schedule=60
::Debugging for development and error testing on code
:: 1 enabled
:: 0 disabled
set debug=0
::external selenium script
::this will allow you to modify the selenium script externally if you do not want to do it inside this batch file
::example inside the directory with this batch file you will see a file left every run called chrome.ps1 or firefox.ps1 modify this for your needs
::it wont be deleted and each run time of this batch file it will use this file instead of the inline code in this batch file
:: means you do not need to edit the batch file you can focus on your selenium script modifications without needing to escape batch code
:: 1 enabled
:: 0 disabled
set custom_selenium_script=1
::Set custom user-agent to use if you do not want to expose your default selenium browser user-agent
set custom_user_agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36 Edg/107.0.1418.52"
::Patch chromedriver.exe and msedgedriver.exe changing the identifiable cdc_* string that services like cloudflare and such use to identify selenium
:: 1 enabled
:: 0 disabled
set selenium_driver_patches=0
:: End Edit DO NOT TOUCH ANYTHING BELOW THIS POINT UNLESS YOU KNOW WHAT YOUR DOING!
TITLE C0nw0nk - Selenium - github.com/C0nw0nk/Selenium
if defined varpass goto :start_exe
set root_path="%~dp0"
set site=https://chromedriver.storage.googleapis.com/LATEST_RELEASE
::Elevate to admin rights
:start
net session >nul 2>&1
if %errorlevel% == 0 (
goto :admin
) else (
@pushd "%~dp0" & fltmc | find ^".^" && (powershell start '%~f0' ' %*' -verb runas 2>nul && exit /b)
)
goto :start
:admin
:start_loop
if "%~1"=="" (
start /wait /B "" "%~dp0%~nx0" go 2^>Nul
) else (
goto begin
)
goto start_loop
:begin
::End elevation to admin
set varpass=1
if %PROCESSOR_ARCHITECTURE%==x86 (
set programs_path=%ProgramFiles(x86)%
set system_folder=System32
) else (
set programs_path=%ProgramFiles%
set system_folder=SysWOW64
)
goto :next_download
:start_exe
if not defined close_selenium (
goto :settings_load
)
::Internet Explorer
if %internetexplorer_selenium% == 0 goto :skipie
set global_name=ie
set global_drver_type=IE
set global_drver_type_name=InternetExplorer
if %custom_selenium_script% == 0 goto :start_ie
if not exist "%root_path:"=%%~n0-%global_name%.ps1" goto :start_ie
powershell -ExecutionPolicy Unrestricted -File "%root_path:"=%%~n0-%global_name%.ps1" "%*" -Verb runAs
goto :skipie
:start_ie
::start powershell code
(
if %debug% == 1 echo Set-PSDebug -Trace 1;
echo $workingpath = '%root_path:"=%';
echo Import-Module '%root_path:"=%WebDriver.dll';
echo Import-Module '%root_path:"=%WebDriver.Support.dll';
echo Import-Module '%root_path:"=%Selenium.WebDriverBackedSelenium.dll';
echo #InternetExplorer setup
echo New-ItemProperty "hkcu:\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\0" -Name "2500" -Value 0 -PropertyType DWORD -Force ^| Out-Null;
echo New-ItemProperty "hkcu:\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\1" -Name "2500" -Value 0 -PropertyType DWORD -Force ^| Out-Null;
echo New-ItemProperty "hkcu:\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\2" -Name "2500" -Value 0 -PropertyType DWORD -Force ^| Out-Null;
echo New-ItemProperty "hkcu:\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3" -Name "2500" -Value 0 -PropertyType DWORD -Force ^| Out-Null;
echo New-ItemProperty "hkcu:\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\4" -Name "2500" -Value 0 -PropertyType DWORD -Force ^| Out-Null;
echo New-ItemProperty "hkcu:\Software\Microsoft\Internet Explorer\Main" -Name "TabProcGrowth" -Value 0 -PropertyType DWORD -Force ^| Out-Null;
echo New-ItemProperty "hkcu:\Software\Microsoft\Internet Explorer\Zoom" -Name "ZoomFactor" -Value 100000 -PropertyType DWORD -Force ^| Out-Null;
echo $%global_name%Options = New-Object OpenQA.Selenium.%global_drver_type%.%global_drver_type_name%Options;
echo $%global_name%Options.InitialBrowserUrl = "https://www.google.co.uk/";
echo #https://www.selenium.dev/selenium/docs/api/dotnet/html/T_OpenQA_Selenium_IE_InternetExplorerDriverService.htm
echo $%global_name%Service = [OpenQA.Selenium.%global_drver_type%.%global_drver_type_name%DriverService]::CreateDefaultService^('%root_path:"=%','IEDriverServer.exe'^);
echo #$%global_name%Service.HideCommandPromptWindow = $true;
echo #$%global_name%Service.SuppressInitialDiagnosticInformation = $true;
if %headlessbrowser% == 1 echo $%global_name%Options.addArgument^('--headless'^);
echo $%global_name%Options.addArgument^("-inprivate"^);
echo $%global_name%Options.IgnoreZoomLevel = $true;
echo $%global_name%Options.PageLoadStrategy = 'Normal';
echo $%global_name%Options.UnexpectedAlertBehavior = 'ignore';
echo $%global_name%Options.IntroduceInstabilityByIgnoringProtectedModeSettings = $true;
echo $Options = New-Object OpenQA.Selenium.%global_drver_type%.%global_drver_type_name%Driver^($%global_name%Service,$%global_name%Options^);
echo $Options.Navigate^(^).GoToURL^('%internetexplorer_selenium_browser_url%'^);
echo $pageData = $Options.FindElement^([OpenQA.Selenium.By]::xpath^('//^*[@id="bbccookies-continue-button"]/span[1]'^)^);
echo $pageData.Click^(^);
echo $pageData.Url^(^); #this will navigate browser to the clicked element
echo $pageData = $Options.FindElement^([OpenQA.Selenium.By]::xpath^('//^*[@id="header-content"]/nav/div[1]/div/div[2]/ul[2]/li[2]/a'^)^);
echo $pageData.Click^(^);
echo $pageData.Url^(^); #this will navigate browser to the clicked element
echo Start-Sleep -s 2;
echo $pageTitle = $Options.FindElement^([OpenQA.Selenium.By]::tagname^('title'^)^).getAttribute^('innerHTML'^);
echo Write-Output $pageTitle;
echo $%global_name%Service.Dispose^(^);
if %close_selenium% == 1 echo $Options.Close^(^);$Options.Quit^(^);
)>"%root_path:"=%%~n0-%global_name%.ps1"
::end powershell code
powershell -ExecutionPolicy Unrestricted -File "%root_path:"=%%~n0-%global_name%.ps1" "%*" -Verb runAs
if %debug% == 0 if %custom_selenium_script% == 0 del "%root_path:"=%%~n0-%global_name%.ps1"
:skipie
::Microsoft Edge
if %microsoftedge_selenium% == 0 goto :skipedge
set global_name=edge
set global_drver_type=Edge
if %custom_selenium_script% == 0 goto :start_edge
if not exist "%root_path:"=%%~n0-%global_name%.ps1" goto :start_edge
powershell -ExecutionPolicy Unrestricted -File "%root_path:"=%%~n0-%global_name%.ps1" "%*" -Verb runAs
goto :skipedge
:start_edge
::https://www.selenium.dev/selenium/docs/api/dotnet/html/N_OpenQA_Selenium_Edge.htm
::start powershell code
(
if %debug% == 1 echo Set-PSDebug -Trace 1;
echo $workingpath = '%root_path:"=%';
echo Import-Module '%root_path:"=%WebDriver.dll';
echo Import-Module '%root_path:"=%WebDriver.Support.dll';
echo Import-Module '%root_path:"=%Selenium.WebDriverBackedSelenium.dll';
echo $%global_name%Options = New-Object OpenQA.Selenium.%global_drver_type%.%global_drver_type%Options;
echo #https://www.selenium.dev/selenium/docs/api/dotnet/html/T_OpenQA_Selenium_Edge_EdgeDriverService.htm
echo $%global_name%Service = [OpenQA.Selenium.%global_drver_type%.%global_drver_type%DriverService]::CreateDefaultService^('%root_path:"=%','msedgedriver.exe'^);
echo $%global_name%Service.HideCommandPromptWindow = $true;
echo $%global_name%Service.SuppressInitialDiagnosticInformation = $true;
if %headlessbrowser% == 1 echo $%global_name%Options.addArgument^('--headless'^);
echo $%global_name%Options.addArgument^("start-maximized"^);
echo #$%global_name%Options.addArgument^("-inprivate"^);
echo $%global_name%Options.addExperimentalOption^("useAutomationExtension", $false^);
echo $%global_name%Options.AddAdditionalCapability^('w3c', $false^);
echo $UserAgent = %custom_user_agent%;
echo $%global_name%Options.addArgument^("user-agent=$UserAgent"^);
echo #$%global_name%Options.addArgument^("--window-size=1920,1080"^);
echo $%global_name%Options.PageLoadStrategy = 'Normal';
echo $%global_name%Options.LeaveBrowserRunning = $true;
echo $%global_name%Options.AcceptInsecureCertificates = $true;
echo $Options = New-Object OpenQA.Selenium.%global_drver_type%.%global_drver_type%Driver^($%global_name%Service,$%global_name%Options^);
echo $Options.Navigate^(^).GoToURL^('%microsoftedge_selenium_browser_url%'^);
echo $pageData = $Options.FindElement^([OpenQA.Selenium.By]::xpath^('//^*[@id="bbccookies-continue-button"]/span[1]'^)^);
echo $pageData.Click^(^);
echo $pageData.Url^(^); #this will navigate browser to the clicked element
echo $pageData = $Options.FindElement^([OpenQA.Selenium.By]::xpath^('//^*[@id="header-content"]/nav/div[1]/div/div[2]/ul[2]/li[2]/a'^)^);
echo $pageData.Click^(^);
echo $pageData.Url^(^); #this will navigate browser to the clicked element
echo Start-Sleep -s 2;
echo $pageTitle = $Options.FindElement^([OpenQA.Selenium.By]::tagname^('title'^)^).getAttribute^('innerHTML'^);
echo Write-Output $pageTitle;
echo $%global_name%Service.Dispose^(^);
if %close_selenium% == 1 echo $Options.Close^(^);$Options.Quit^(^);
)>"%root_path:"=%%~n0-%global_name%.ps1"
::end powershell code
powershell -ExecutionPolicy Unrestricted -File "%root_path:"=%%~n0-%global_name%.ps1" "%*" -Verb runAs
if %debug% == 0 if %custom_selenium_script% == 0 del "%root_path:"=%%~n0-%global_name%.ps1"
:skipedge
::Chrome
if %chrome_selenium% == 0 goto :skipchrome
set global_name=chrome
set global_drver_type=Chrome
if %custom_selenium_script% == 0 goto :start_chrome
if not exist "%root_path:"=%%~n0-%global_name%.ps1" goto :start_chrome
powershell -ExecutionPolicy Unrestricted -File "%root_path:"=%%~n0-%global_name%.ps1" "%*" -Verb runAs
goto :skipchrome
:start_chrome
::start powershell code
(
if %debug% == 1 echo Set-PSDebug -Trace 1;
echo $workingpath = '%root_path:"=%';
echo Import-Module '%root_path:"=%WebDriver.dll';
echo Import-Module '%root_path:"=%WebDriver.Support.dll';
echo Import-Module '%root_path:"=%Selenium.WebDriverBackedSelenium.dll';
echo $%global_name%Options = New-Object OpenQA.Selenium.%global_drver_type%.%global_drver_type%Options;
echo #https://www.selenium.dev/selenium/docs/api/dotnet/html/T_OpenQA_Selenium_DriverService.htm
echo $%global_name%Service = [OpenQA.Selenium.%global_drver_type%.%global_drver_type%DriverService]::CreateDefaultService^('%root_path:"=%','chromedriver.exe'^);
echo $%global_name%Service.HideCommandPromptWindow = $true;
echo $%global_name%Service.SuppressInitialDiagnosticInformation = $true;
if %headlessbrowser% == 1 echo $%global_name%Options.addArgument^('--headless'^);
echo $%global_name%Options.addArgument^("start-maximized"^);
echo $%global_name%Options.addArgument^("--incognito"^);
echo $%global_name%Options.addArgument^("--disable-blink-features=AutomationControlled"^);
echo $UserAgent = %custom_user_agent%;
echo $%global_name%Options.addArgument^("user-agent=$UserAgent"^);
echo $%global_name%Options.addArgument^("--window-size=1920,1080"^);
echo $%global_name%Options.PageLoadStrategy = 'Normal';
echo $%global_name%Options.LeaveBrowserRunning = $true;
echo $%global_name%Options.AcceptInsecureCertificates = $true;
echo $Options = New-Object OpenQA.Selenium.%global_drver_type%.%global_drver_type%Driver^($%global_name%Service,$%global_name%Options^);
echo $Options.Navigate^(^).GoToURL^('%chrome_selenium_browser_url%'^);
echo $pageData = $Options.FindElement^([OpenQA.Selenium.By]::xpath^('//^*[@id="bbccookies-continue-button"]/span[1]'^)^);
echo $pageData.Click^(^);
echo $pageData.Url^(^); #this will navigate browser to the clicked element
echo $pageData = $Options.FindElement^([OpenQA.Selenium.By]::xpath^('//^*[@id="header-content"]/nav/div[1]/div/div[2]/ul[2]/li[2]/a'^)^);
echo $pageData.Click^(^);
echo $pageData.Url^(^); #this will navigate browser to the clicked element
echo Start-Sleep -s 2;
echo $pageTitle = $Options.FindElement^([OpenQA.Selenium.By]::tagname^('title'^)^).getAttribute^('innerHTML'^);
echo Write-Output $pageTitle;
echo $%global_name%Service.Dispose^(^);
if %close_selenium% == 1 echo $Options.Close^(^);$Options.Quit^(^);
)>"%root_path:"=%%~n0-%global_name%.ps1"
::end powershell code
powershell -ExecutionPolicy Unrestricted -File "%root_path:"=%%~n0-%global_name%.ps1" "%*" -Verb runAs
if %debug% == 0 if %custom_selenium_script% == 0 del "%root_path:"=%%~n0-%global_name%.ps1"
:skipchrome
::Firefox
if %firefox_selenium% == 0 goto :skipfirefox
set global_name=firefox
set global_drver_type=Firefox
if %custom_selenium_script% == 0 goto :start_firefox
if not exist "%root_path:"=%%~n0-%global_name%.ps1" goto :start_firefox
powershell -ExecutionPolicy Unrestricted -File "%root_path:"=%%~n0-%global_name%.ps1" "%*" -Verb runAs
goto :skipfirefox
:start_firefox
::start powershell code
(
if %debug% == 1 echo Set-PSDebug -Trace 1;
echo $workingpath = '%root_path:"=%';
echo Import-Module '%root_path:"=%WebDriver.dll';
echo Import-Module '%root_path:"=%WebDriver.Support.dll';
echo Import-Module '%root_path:"=%Selenium.WebDriverBackedSelenium.dll';
echo $%global_name%Options = New-Object OpenQA.Selenium.%global_drver_type%.%global_drver_type%Options;
echo #https://www.selenium.dev/selenium/docs/api/dotnet/html/T_OpenQA_Selenium_Firefox_FirefoxDriverService.htm
echo $%global_name%Service = [OpenQA.Selenium.%global_drver_type%.%global_drver_type%DriverService]::CreateDefaultService^('%root_path:"=%','geckodriver.exe'^);
echo $%global_name%Service.HideCommandPromptWindow = $true;
echo $%global_name%Service.SuppressInitialDiagnosticInformation = $true;
if %headlessbrowser% == 1 echo $%global_name%Options.addArgument^('--headless'^);
echo #$%global_name%Options.addArgument^("--kiosk"^);
echo $%global_name%Options.addArgument^("--private-window"^);
echo $UserAgent = %custom_user_agent%;
echo #$%global_name%Options.addArgument^("user-agent=$UserAgent"^);
echo #$%global_name%Options.addArgument^("--window-size=1920,1080"^);
echo $%global_name%Options.addArgument^("--height=600"^);
echo $%global_name%Options.addArgument^("--width=600"^);
echo $%global_name%Options.setPreference^("general.useragent.override", "$UserAgent"^);
echo $%global_name%Options.PageLoadStrategy = 'Normal';
echo $%global_name%Options.LeaveBrowserRunning = $true;
echo $%global_name%Options.AcceptInsecureCertificates = $true;
echo $Options = New-Object OpenQA.Selenium.%global_drver_type%.%global_drver_type%Driver^($%global_name%Service,$%global_name%Options^);
echo $Options.Url^('%firefox_selenium_browser_url%'^);
echo $Options.Navigate^(^).GoToURL^('%firefox_selenium_browser_url%'^);
echo $pageData = $Options.FindElement^([OpenQA.Selenium.By]::xpath^('//^*[@id="bbccookies-continue-button"]/span[1]'^)^);
echo $pageData.Click^(^);
echo $pageData.Url^(^); #this will navigate browser to the clicked element
echo $pageData = $Options.FindElement^([OpenQA.Selenium.By]::xpath^('//^*[@id="header-content"]/nav/div[1]/div/div[2]/ul[2]/li[2]/a'^)^);
echo $pageData.Click^(^);
echo $pageData.Url^(^); #this will navigate browser to the clicked element
echo Start-Sleep -s 2;
echo $pageTitle = $Options.FindElement^([OpenQA.Selenium.By]::tagname^('title'^)^).getAttribute^('innerHTML'^);
echo Write-Output $pageTitle;
echo $%global_name%Service.Dispose^(^);
if %close_selenium% == 1 echo $Options.Close^(^);$Options.Quit^(^);
)>"%root_path:"=%%~n0-%global_name%.ps1"
::end powershell code
powershell -ExecutionPolicy Unrestricted -File "%root_path:"=%%~n0-%global_name%.ps1" "%*" -Verb runAs
if %debug% == 0 if %custom_selenium_script% == 0 del "%root_path:"=%%~n0-%global_name%.ps1"
:skipfirefox
::Brave
if %brave_selenium% == 0 goto :skipbrave
set global_name=brave
set global_drver_type=Chrome
if %custom_selenium_script% == 0 goto :start_brave
if not exist "%root_path:"=%%~n0-%global_name%.ps1" goto :start_brave
powershell -ExecutionPolicy Unrestricted -File "%root_path:"=%%~n0-%global_name%.ps1" "%*" -Verb runAs
goto :skipbrave
:start_brave
::start powershell code
(
if %debug% == 1 echo Set-PSDebug -Trace 1;
echo $workingpath = '%root_path:"=%';
echo Import-Module '%root_path:"=%WebDriver.dll';
echo Import-Module '%root_path:"=%WebDriver.Support.dll';
echo Import-Module '%root_path:"=%Selenium.WebDriverBackedSelenium.dll';
echo $%global_name%Options = New-Object OpenQA.Selenium.%global_drver_type%.%global_drver_type%Options;
echo #https://www.selenium.dev/selenium/docs/api/dotnet/html/T_OpenQA_Selenium_DriverService.htm
echo $%global_name%Service = [OpenQA.Selenium.%global_drver_type%.%global_drver_type%DriverService]::CreateDefaultService^('%root_path:"=%','chromedriver.exe'^);
echo $%global_name%Service.HideCommandPromptWindow = $true;
echo $%global_name%Service.SuppressInitialDiagnosticInformation = $true;
if %headlessbrowser% == 1 echo $%global_name%Options.addArgument^('--headless'^);
echo $%global_name%Options.addArgument^("start-maximized"^);
echo $%global_name%Options.addArgument^("--incognito"^);
echo $%global_name%Options.addArgument^("--disable-blink-features=AutomationControlled"^);
echo $UserAgent = %custom_user_agent%;
echo $%global_name%Options.addArgument^("user-agent=$UserAgent"^);
echo $%global_name%Options.addArgument^("--window-size=1920,1080"^);
echo $%global_name%Options.PageLoadStrategy = 'Normal';
echo $%global_name%Options.LeaveBrowserRunning = $true;
echo $%global_name%Options.AcceptInsecureCertificates = $true;
echo $%global_name%Options.BinaryLocation = "%LocalAppData%\BraveSoftware\Brave-Browser\Application\brave.exe";
echo $Options = New-Object OpenQA.Selenium.%global_drver_type%.%global_drver_type%Driver^($%global_name%Service,$%global_name%Options^);
echo #$Options.executeScript^("Object.defineProperty^(navigator, 'webdriver', ^{set: ^(^) => undefined^}^)"^);
echo $Options.Navigate^(^).GoToURL^('%brave_selenium_browser_url%'^);
echo $pageData = $Options.FindElement^([OpenQA.Selenium.By]::xpath^('//^*[@id="bbccookies-continue-button"]/span[1]'^)^);
echo $pageData.Click^(^);
echo $pageData.Url^(^); #this will navigate browser to the clicked element
echo $pageData = $Options.FindElement^([OpenQA.Selenium.By]::xpath^('//^*[@id="header-content"]/nav/div[1]/div/div[2]/ul[2]/li[2]/a'^)^);
echo $pageData.Click^(^);
echo $pageData.Url^(^); #this will navigate browser to the clicked element
echo Start-Sleep -s 2;
echo $pageTitle = $Options.FindElement^([OpenQA.Selenium.By]::tagname^('title'^)^).getAttribute^('innerHTML'^);
echo $driver_script = $Options.executeScript^("return navigator.webdriver"^);
echo Write-Output $driver_script;
echo Write-Output $pageTitle;
echo $%global_name%Service.Dispose^(^);
if %close_selenium% == 1 echo $Options.Close^(^);$Options.Quit^(^);
)>"%root_path:"=%%~n0-%global_name%.ps1"
::end powershell code
powershell -ExecutionPolicy Unrestricted -File "%root_path:"=%%~n0-%global_name%.ps1" "%*" -Verb runAs
if %debug% == 0 if %custom_selenium_script% == 0 del "%root_path:"=%%~n0-%global_name%.ps1"
:skipbrave
::Vivaldi
if %vivaldi_selenium% == 0 goto :skipvivaldi
set global_name=vivaldi
set global_drver_type=Chrome
if %custom_selenium_script% == 0 goto :start_vivaldi
if not exist "%root_path:"=%%~n0-%global_name%.ps1" goto :start_vivaldi
powershell -ExecutionPolicy Unrestricted -File "%root_path:"=%%~n0-%global_name%.ps1" "%*" -Verb runAs
goto :skipvivaldi
:start_vivaldi
::start powershell code
(
if %debug% == 1 echo Set-PSDebug -Trace 1;
echo $workingpath = '%root_path:"=%';
echo Import-Module '%root_path:"=%WebDriver.dll';
echo Import-Module '%root_path:"=%WebDriver.Support.dll';
echo Import-Module '%root_path:"=%Selenium.WebDriverBackedSelenium.dll';
echo $%global_name%Options = New-Object OpenQA.Selenium.%global_drver_type%.%global_drver_type%Options;
echo #https://www.selenium.dev/selenium/docs/api/dotnet/html/T_OpenQA_Selenium_DriverService.htm
echo $%global_name%Service = [OpenQA.Selenium.%global_drver_type%.%global_drver_type%DriverService]::CreateDefaultService^('%root_path:"=%','vivaldichromedriver.exe'^);
echo $%global_name%Service.HideCommandPromptWindow = $true;
echo $%global_name%Service.SuppressInitialDiagnosticInformation = $true;
if %headlessbrowser% == 1 echo $%global_name%Options.addArgument^('--headless'^);
echo $%global_name%Options.addArgument^("start-maximized"^);
echo $%global_name%Options.addArgument^("--incognito"^);
echo $%global_name%Options.addArgument^("--disable-blink-features=AutomationControlled"^);
echo #$%global_name%Options.addArgument^("--user-data-dir='%LocalAppData%\Vivaldi\User Data'"^);
echo $%global_name%Options.PageLoadStrategy = 'Normal';
echo $%global_name%Options.LeaveBrowserRunning = $true;
echo $%global_name%Options.AcceptInsecureCertificates = $true;
echo #$%global_name%Options.BinaryLocation = "%LocalAppData%\Vivaldi\Application\update_notifier.exe";
echo $%global_name%Options.BinaryLocation = "%LocalAppData%\Vivaldi\Application\vivaldi.exe";
echo #$%global_name%Options.BinaryLocation = "%LocalAppData%\Vivaldi\Application\vivaldi_proxy.exe";
echo #$%global_name%Options.Profile = "%LocalAppData%\Vivaldi\User Data\Default";
echo #$%global_name%Options.setPreference^("--user-data-dir=%LocalAppData%\Vivaldi\User Data"^);
echo $Options = New-Object OpenQA.Selenium.%global_drver_type%.%global_drver_type%Driver^($%global_name%Service,$%global_name%Options^);
echo $timeout = 10;
echo [OpenQA.Selenium.Support.UI.WebDriverWait]$wait = new-object OpenQA.Selenium.Support.UI.WebDriverWait ^($Options,[System.TimeSpan]::FromSeconds^($timeout^)^);
echo [OpenQA.Selenium.Interactions.Actions]$actions = new-object OpenQA.Selenium.Interactions.Actions ^($Options^);
echo $Options.Navigate^(^).GoToURL^('%vivaldi_selenium_browser_url%'^);
echo $wait.Until^([OpenQA.Selenium.Support.UI.ExpectedConditions]::ElementExists^([OpenQA.Selenium.By]::tagname^('title'^)^)^);
echo $pageTitle = $Options.FindElement^([OpenQA.Selenium.By]::tagname^('title'^)^).getAttribute^('innerHTML'^);
echo Write-Output $pageTitle;
echo $%global_name%Service.Dispose^(^);
if %close_selenium% == 1 echo $Options.Close^(^);$Options.Quit^(^);
)>"%root_path:"=%%~n0-%global_name%.ps1"
::end powershell code
powershell -ExecutionPolicy Unrestricted -File "%root_path:"=%%~n0-%global_name%.ps1" "%*" -Verb runAs
if %debug% == 0 if %custom_selenium_script% == 0 del "%root_path:"=%%~n0-%global_name%.ps1"
:skipvivaldi
::Opera
if %opera_selenium% == 0 goto :skipopera
::get opera path since version numbered is dynamic
set operapath=%LocalAppData%\Programs\Opera
set operaversion=nil & if exist "%operapath%" for /D %%X in ("%operapath%\*") do echo %%X|find "." >nul && set operaversion=%%X
::end opera path
set global_name=opera
set global_drver_type=Chrome
if %custom_selenium_script% == 0 goto :start_opera
if not exist "%root_path:"=%%~n0-%global_name%.ps1" goto :start_opera
powershell -ExecutionPolicy Unrestricted -File "%root_path:"=%%~n0-%global_name%.ps1" "%*" -Verb runAs
goto :skipopera
:start_opera
::start powershell code
(
if %debug% == 1 echo Set-PSDebug -Trace 1;
echo $workingpath = '%root_path:"=%';
echo Import-Module '%root_path:"=%WebDriver.dll';
echo Import-Module '%root_path:"=%WebDriver.Support.dll';
echo Import-Module '%root_path:"=%Selenium.WebDriverBackedSelenium.dll';
echo $%global_name%Options = New-Object OpenQA.Selenium.%global_drver_type%.%global_drver_type%Options;
echo #https://www.selenium.dev/selenium/docs/api/dotnet/html/T_OpenQA_Selenium_DriverService.htm
echo $%global_name%Service = [OpenQA.Selenium.%global_drver_type%.%global_drver_type%DriverService]::CreateDefaultService^('%root_path:"=%','operadriver.exe'^);
echo $%global_name%Service.HideCommandPromptWindow = $true;
echo $%global_name%Service.SuppressInitialDiagnosticInformation = $true;
if %headlessbrowser% == 1 echo $%global_name%Options.addArgument^('--headless'^);
echo $%global_name%Options.BinaryLocation = "%operaversion%\opera.exe";
echo #$%global_name%Options.BinaryLocation = "%LocalAppData%\Programs\Opera\launcher.exe";
echo $%global_name%Options.addExperimentalOption^('w3c', $true^);
echo $%global_name%Options.AddAdditionalCapability^('w3c', $true^);
echo $Options = New-Object OpenQA.Selenium.%global_drver_type%.%global_drver_type%Driver^($%global_name%Service,$%global_name%Options^);
echo #$webData = Invoke-WebRequest -Uri "http://127.0.0.1:9222/json/version";
echo #$releases = ConvertFrom-Json $webData.content;
echo #write-output $releases.webSocketDebuggerUrl;
echo $Options.Navigate^(^).GoToURL^('%opera_selenium_browser_url%'^);
echo #$pageData = $Options.FindElement^([OpenQA.Selenium.By]::xpath^('//^*[@id="bbccookies-continue-button"]/span[1]'^)^);
echo #$pageData.Click^(^);
echo #$pageData.Url^(^); #this will navigate browser to the clicked element
echo #$pageData = $Options.FindElement^([OpenQA.Selenium.By]::xpath^('//^*[@id="header-content"]/nav/div[1]/div/div[2]/ul[2]/li[2]/a'^)^);
echo #$pageData.Click^(^);
echo $pageData.Url^(^); #this will navigate browser to the clicked element
echo #Start-Sleep -s 2;
echo $pageTitle = $Options.FindElement^([OpenQA.Selenium.By]::tagname^('title'^)^).getAttribute^('innerHTML'^);
echo Write-Output $pageTitle;
echo $%global_name%Service.Dispose^(^);
if %close_selenium% == 1 echo $Options.Close^(^);$Options.Quit^(^);
)>"%root_path:"=%%~n0-%global_name%.ps1"
::end powershell code
powershell -ExecutionPolicy Unrestricted -File "%root_path:"=%%~n0-%global_name%.ps1" "%*" -Verb runAs
if %debug% == 0 if %custom_selenium_script% == 0 del "%root_path:"=%%~n0-%global_name%.ps1"
:skipopera
::TOR Browser
if %tor_selenium% == 0 goto :skiptor
set global_name=tor
set global_drver_type=Firefox
::higher security keeping the tor.exe encryption secure I made it a setting for debugging reasons when i built this
set tor_proxy_password_enabled=1
(
echo function Get-RandomCharacters^($length, $characters^) {
echo $random = 1..$length ^| ForEach-Object { Get-Random -Maximum $characters.length }
echo $private:ofs="" ;
echo return [String]$characters[$random];
echo }
echo $randompass ^+= Get-RandomCharacters -length 20 -characters 'ABCDEFGHKLMNOPRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
echo Write-Output $randompass;
)>"%root_path:"=%%~n0-%global_name%-generate-random-pass.ps1"
for /f "tokens=*" %%a in ('
powershell -ExecutionPolicy Unrestricted -File ^"%root_path:"=%%~n0-%global_name%-generate-random-pass.ps1^" ^"%*^" -Verb runAs
') do set random_password_output=%%a
del "%root_path:"=%%~n0-%global_name%-generate-random-pass.ps1"
set tor_proxy_password="%random_password_output%"
for /f "tokens=*" %%a in ('
taskkill /F /IM tor.exe /T 2^>Nul
') do break
(
echo function Create-Tor-Password-Hash ^{
echo $torBrowser = "%userprofile%\Desktop\Tor Browser";
echo $TOR_Password = %tor_proxy_password%;
echo $TOR_HOST = "127.0.0.1";
echo $TOR_PORT = 9051;
echo $CTRL_PORT = 9151;
echo $tor_location = "$torBrowser\Browser\TorBrowser\Tor";
echo $torrc_defaults = "$torBrowser\Browser\TorBrowser\Data\Tor\torrc-defaults";
echo $torrc = "$torBrowser\Browser\TorBrowser\Data\Tor\torrc";
echo $tordata = "$torBrowser\Browser\TorBrowser\Data\Tor";
echo $geoIP = "$torBrowser\Browser\TorBrowser\Data\Tor\geoip";
echo $geoIPv6 = "$torBrowser\Browser\TorBrowser\Data\Tor\geoip6";
echo $oniondir = "$torBrowser\Browser\TorBrowser\Data\Tor\onion-auth";
echo $torExe = "$tor_location\tor.exe";
echo $controllerProcess = $PID;
echo function Get-OneToLastItem ^{ param ^($arr^) return $arr^[$arr.Length - 2^]^}
echo $TOR_HashPass_RAW = ^& "$torExe" --defaults-torrc $torrc -f $torrc DataDirectory $tordata ClientOnionAuthDir $oniondir GeoIPFile $geoIP GeoIPv6File $geoIPv6 --hash-password $TOR_Password ^| more;
echo $Tor_HashPass = Get-OneToLastItem^($TOR_HashPass_RAW^);
echo Write-Output $TOR^_HashPass^_RAW;
echo ^}
echo Create-Tor-Password-Hash
)>"%root_path:"=%%~n0-%global_name%-hash.ps1"
for /f "tokens=*" %%a in ('
powershell -ExecutionPolicy Unrestricted -File ^"%root_path:"=%%~n0-%global_name%-hash.ps1^" ^"%*^" -Verb runAs
') do set password_hash_output=%%a
del "%root_path:"=%%~n0-%global_name%-hash.ps1"
if %tor_proxy_password_enabled% == 1 echo %password_hash_output%
(
if %tor_proxy_bridge% == 1 echo Bridge obfs4 193.11.166.194:27025 1AE2C08904527FEA90C4C4F8C1083EA59FBC6FAF cert=ItvYZzW5tn6v3G4UnQa6Qz04Npro6e81AP70YujmK/KXwDFPTs3aHXcHp4n8Vt6w/bv8cA iat-mode=0
if %tor_proxy_bridge% == 1 echo Bridge obfs4 193.11.166.194:27015 2D82C2E354D531A68469ADF7F878FA6060C6BACA cert=4TLQPJrTSaDffMK7Nbao6LC7G9OW/NHkUwIdjLSS3KYf0Nv4/nQiiI8dY2TcsQx01NniOg iat-mode=0
if %tor_proxy_bridge% == 1 echo Bridge obfs4 193.11.166.194:27020 86AC7B8D430DAC4117E9F42C9EAED18133863AAF cert=0LDeJH4JzMDtkJJrFphJCiPqKx7loozKN7VNfuukMGfHO0Z8OGdzHVkhVAOfo1mUdv9cMg iat-mode=0
if %tor_proxy_bridge% == 1 echo Bridge obfs4 193.11.166.194:27025 1AE2C08904527FEA90C4C4F8C1083EA59FBC6FAF cert=ItvYZzW5tn6v3G4UnQa6Qz04Npro6e81AP70YujmK/KXwDFPTs3aHXcHp4n8Vt6w/bv8cA iat-mode=0
if %tor_proxy_bridge% == 1 echo Bridge obfs4 5.45.100.58:1337 66002E678B3A3C6968AB1944C233A82A34FCF0B8 cert=cZei7/b4KsHqb0tTn3mnAZ^+LruUAJ1^+yiXKwWxmNFLbpfQycmibCoYjlmX8n1gGskaiQLQ iat-mode=0
if %tor_proxy_bridge% == 1 echo Bridge obfs4 23.94.134.145:8082 1F36B62A1ECED5C884D188330D7291ED6A98827F cert=sCzTCeprtMZ3IyVjJo^+ksd0d/XYbPDT3TrfBM0nQv^+DL1LkFC5eRPmXPpAsfsUNeIxfzJA iat-mode=0
if %tor_proxy_bridge% == 1 echo Bridge obfs4 51.68.156.67:14638 66CDD5C6A077CAE91B497B22A9EAEAF7C55B023D cert=RqjodnFshvL9WvQx0jPN4OxxV0ITbmw1Y8Bsoz3aYXtl1ShWU4VfDTM64SXi9Ngq/MCBFw iat-mode=0
if %tor_proxy_bridge% == 1 echo Bridge obfs4 51.68.86.212:33427 75D8ECC96D0249ABE56E86D1F2325FBFAE02FB57 cert=3En/B81R63^+m1PiiQwhiAXsIMP9YmytOwTGBvckE4VlU8rFeqTkGoQkA8oayQ0f1MrxhMQ iat-mode=0
if %tor_proxy_bridge% == 1 echo Bridge obfs4 185.44.209.160:15045 3176C361647E23B1371E4EB444B05D6841386C11 cert=fgq1fgr8UDsBPUHY1Jbe9u6Ozj^+eF5/zsMk9yqfvpxNC02rtgM8/MKYR/V4P5FO4CDbrBw iat-mode=0
if %tor_proxy_bridge% == 1 echo Bridge obfs4 185.247.226.57:443 C2A28A62022616D17173FBB79EFF8162628EE136 cert=2LUpLXg7zAfYuCYFr3aMlYI2i1LMqj5we^+s06LtVrVrUV1EGcjoxTyj054Ykdyu1G5XTUQ iat-mode=0
if %tor_proxy_bridge% == 1 echo Bridge obfs4 139.162.53.29:9091 27243AB18BEDA83528E87D585DAFF625ABD04CE8 cert=IOcH6JY^+WUTsUh2zj43IRKqoQ8p/3QpZOCYitHLd9N8LbUOexnapA4NEAE/QFfdm3wDECw iat-mode=0
if %tor_proxy_bridge% == 2 echo Bridge snowflake 192.0.2.3:80 2B280B23E1107BB62ABFC40DDCC8824814F80A72 fingerprint=2B280B23E1107BB62ABFC40DDCC8824814F80A72 url=https://snowflake-broker.torproject.net.global.prod.fastly.net/ front=cdn.sstatic.net ice=stun:stun.l.google.com:19302,stun:stun.altar.com.pl:3478,stun:stun.antisip.com:3478,stun:stun.bluesip.net:3478,stun:stun.dus.net:3478,stun:stun.epygi.com:3478,stun:stun.sonetel.com:3478,stun:stun.sonetel.net:3478,stun:stun.stunprotocol.org:3478,stun:stun.uls.co.za:3478,stun:stun.voipgate.com:3478,stun:stun.voys.nl:3478 utls-imitate=hellorandomizedalpn
if %tor_proxy_bridge% == 3 echo Bridge meek_lite 192.0.2.18:80 BE776A53492E1E044A26F17306E1BC46A55A1625 url=https://meek.azureedge.net/ front=ajax.aspnetcdn.com
echo ClientOnionAuthDir %userprofile%\Desktop\Tor Browser\Browser\TorBrowser\Data\Tor\onion-auth
echo DataDirectory %userprofile%\Desktop\Tor Browser\Browser\TorBrowser\Data\Tor
echo GeoIPFile %userprofile%\Desktop\Tor Browser\Browser\TorBrowser\Data\Tor\geoip
echo GeoIPv6File %userprofile%\Desktop\Tor Browser\Browser\TorBrowser\Data\Tor\geoip6
echo UseBridges 1
echo AvoidDiskWrites 1
echo Log notice stdout
echo CookieAuthentication 0
if %tor_proxy_password_enabled% == 1 echo HashedControlPassword %password_hash_output%
echo DormantCanceledByStartup 1
echo ClientTransportPlugin meek_lite,obfs2,obfs3,obfs4,scramblesuit exec %userprofile%\Desktop\Tor Browser\Browser\TorBrowser\Tor\PluggableTransports\obfs4proxy.exe
echo ClientTransportPlugin snowflake exec %userprofile%\Desktop\Tor Browser\Browser\TorBrowser\Tor\PluggableTransports\snowflake-client.exe
)>"%userprofile%\Desktop\Tor Browser\Browser\TorBrowser\Data\Tor\torrc"
(
echo function Start-Tor {
echo $torBrowser = "%userprofile%\Desktop\Tor Browser";
echo $TOR_Password = %tor_proxy_password%;
echo $TOR_HOST = "127.0.0.1";
echo $TOR_PORT = 9051;
echo $CTRL_PORT = 9151;
echo $tor_location = "$torBrowser\Browser\TorBrowser\Tor";
echo $torrc_defaults = "$torBrowser\Browser\TorBrowser\Data\Tor\torrc-defaults";
echo $torrc = "$torBrowser\Browser\TorBrowser\Data\Tor\torrc";
echo $tordata = "$torBrowser\Browser\TorBrowser\Data\Tor";
echo $geoIP = "$torBrowser\Browser\TorBrowser\Data\Tor\geoip";
echo $geoIPv6 = "$torBrowser\Browser\TorBrowser\Data\Tor\geoip6";
echo $oniondir = "$torBrowser\Browser\TorBrowser\Data\Tor\onion-auth";
echo $torExe = "$tor_location\tor.exe";
echo $controllerProcess = $PID;
echo function Get-OneToLastItem { param ^($arr^) return $arr[$arr.Length - 2]}
echo $TOR_HashPass_RAW = ^& "$torExe" --defaults-torrc $torrc -f $torrc DataDirectory $tordata ClientOnionAuthDir $oniondir GeoIPFile $geoIP GeoIPv6File $geoIPv6 --hash-password $TOR_Password ^| more;
echo $Tor_HashPass = Get-OneToLastItem^($TOR_HashPass_RAW^);
echo $TOR_VERSION_RAW = ^& "$torExe" --defaults-torrc $torrc -f $torrc DataDirectory $tordata ClientOnionAuthDir $oniondir GeoIPFile $geoIP GeoIPv6File $geoIPv6 --version ^| more;
echo $Tor_Version = Get-OneToLastItem^($TOR_VERSION_RAW^);
echo Write-Host "Running $Tor_Version" -ForegroundColor DarkGray;
echo Write-Host "Press [Ctrl+C] to stop Tor service.";
if %tor_proxy_password_enabled% == 0 echo ^& "$torExe" --defaults-torrc $torrc -f $torrc DataDirectory $tordata ClientOnionAuthDir $oniondir GeoIPFile $geoIP GeoIPv6File $geoIPv6 ^+__ControlPort $CTRL_PORT ^+__SocksPort "${TOR_HOST}:$TOR_PORT ExtendedErrors IPv6Traffic PreferIPv6 KeepAliveIsolateSOCKSAuth" __OwningControllerProcess $controllerProcess ^| oh ^| more;
if %tor_proxy_password_enabled% == 1 echo ^& "$torExe" --defaults-torrc $torrc -f $torrc DataDirectory $tordata ClientOnionAuthDir $oniondir GeoIPFile $geoIP GeoIPv6File $geoIPv6 HashedControlPassword $TOR_HashPass_RAW ^+__ControlPort $CTRL_PORT ^+__SocksPort "${TOR_HOST}:$TOR_PORT ExtendedErrors IPv6Traffic PreferIPv6 KeepAliveIsolateSOCKSAuth" __OwningControllerProcess $controllerProcess ^| oh ^| more;
echo }
echo Start-Tor
)>"%root_path:"=%%~n0-%global_name%-tor-service.ps1"
start /MIN ^"^" powershell -ExecutionPolicy Unrestricted -File ^"%root_path:"=%%~n0-%global_name%-tor-service.ps1^" ^"%*^" -Verb runAs
if %custom_selenium_script% == 0 goto :start_tor
if not exist "%root_path:"=%%~n0-%global_name%.ps1" goto :start_tor
powershell -ExecutionPolicy Unrestricted -File "%root_path:"=%%~n0-%global_name%.ps1" "%*" -Verb runAs
goto :skiptor
:start_tor
::start powershell code
(
if %debug% == 1 echo Set-PSDebug -Trace 1;
echo $workingpath = '%root_path:"=%';
echo Import-Module '%root_path:"=%WebDriver.dll';
echo Import-Module '%root_path:"=%WebDriver.Support.dll';
echo Import-Module '%root_path:"=%Selenium.WebDriverBackedSelenium.dll';
echo #Start-Process '%userprofile%\Desktop\Tor Browser\Browser\TorBrowser\Tor\tor.exe';
echo #Start-Process '%userprofile%\Desktop\Tor Browser\Browser\firefox.exe';
echo $%global_name%Options = New-Object OpenQA.Selenium.%global_drver_type%.%global_drver_type%Options;
echo #https://www.selenium.dev/selenium/docs/api/dotnet/html/T_OpenQA_Selenium_Firefox_FirefoxDriverService.htm
echo $%global_name%Service = [OpenQA.Selenium.%global_drver_type%.%global_drver_type%DriverService]::CreateDefaultService^('%root_path:"=%','geckodriver.exe'^);
echo #$%global_name%Service.HideCommandPromptWindow = $true;
echo #$%global_name%Service.SuppressInitialDiagnosticInformation = $true;
echo $%global_name%Service.FirefoxBinaryPath = '%userprofile%\Desktop\Tor Browser\Browser\firefox.exe';
if %headlessbrowser% == 1 echo $%global_name%Options.addArgument^('--headless'^);
echo #$%global_name%Options.addArgument^("--kiosk"^);
echo #$%global_name%Options.addArgument^("--private-window"^);
echo $UserAgent = %custom_user_agent%;
echo #$%global_name%Options.addArgument^("--window-size=1920,1080"^);
echo #$%global_name%Options.addArgument^("--height=600"^);
echo #$%global_name%Options.addArgument^("--width=600"^);
echo #$%global_name%Options.addArgument^("--disable-blink-features=AutomationControlled"^);
echo $%global_name%Options.Profile = "%userprofile%\Desktop\Tor Browser\Browser\TorBrowser\Data\Browser\profile.default";
echo $%global_name%Options.setPreference^("general.useragent.override", "$UserAgent"^);
echo $%global_name%Options.setPreference^("webdriver.load.strategy", "unstable"^);
echo $%global_name%Options.setPreference^("network.proxy.type", 1^);
echo $%global_name%Options.setPreference^("network.proxy.socks","127.0.0.1"^);
echo $%global_name%Options.setPreference^("network.proxy.socks_port", 9051^);
echo $%global_name%Options.setPreference^("network.proxy.socks_remote_dns", $true^);
echo $%global_name%Options.setPreference^("network.proxy.socks_version", 5^);
if %tor_proxy_password_enabled% == 1 echo $%global_name%Options.setPreference^("network.proxy.socks_password", %tor_proxy_password%^)
echo $%global_name%Options.setPreference^("places.history.enabled", $false^);
echo $%global_name%Options.setPreference^("privacy.clearOnShutdown.offlineApps", $true^);
echo $%global_name%Options.setPreference^("privacy.clearOnShutdown.passwords", $true^);
echo $%global_name%Options.setPreference^("privacy.clearOnShutdown.siteSettings", $true^);
echo $%global_name%Options.setPreference^("privacy.sanitize.sanitizeOnShutdown", $true^);
echo $%global_name%Options.setPreference^("signon.rememberSignons", $false^);
echo $%global_name%Options.setPreference^("network.cookie.lifetimePolicy", 2^);
echo $%global_name%Options.setPreference^("network.dns.disablePrefetch", $true^);
echo $%global_name%Options.setPreference^("network.http.sendRefererHeader", 0^);
echo $%global_name%Options.setPreference^(^);
echo $%global_name%Options.PageLoadStrategy = 'Normal';
echo $%global_name%Options.LeaveBrowserRunning = $true;
echo $%global_name%Options.AcceptInsecureCertificates = $true;
echo $Options = New-Object OpenQA.Selenium.%global_drver_type%.%global_drver_type%Driver^($%global_name%Service,$%global_name%Options^);
echo #$Options.SwitchTo^(^).Window^($Options.WindowHandles[1]^);
echo $pageData = $Options.FindElement^([OpenQA.Selenium.By]::xpath^('//^*[@id="connectButton"]'^)^);
echo $pageData.Click^(^);
echo Start-Sleep -s 5;
echo #$Options.Url^('%tor_selenium_browser_url%'^);
echo $Options.Navigate^(^).GoToURL^('%tor_selenium_browser_url%'^);
echo $pageData = $Options.FindElement^([OpenQA.Selenium.By]::xpath^('//^*[@id="bbccookies-continue-button"]'^)^);
echo $pageData.Click^(^);
echo $pageData.Url^(^); #this will navigate browser to the clicked element
echo $pageData = $Options.FindElement^([OpenQA.Selenium.By]::xpath^('/html/body/div[6]/header/div/div/nav[2]/ul/li[2]/a'^)^);
echo $pageData.Click^(^);
echo $pageData.Url^(^); #this will navigate browser to the clicked element
echo Start-Sleep -s 2;
echo $pageTitle = $Options.FindElement^([OpenQA.Selenium.By]::tagname^('title'^)^).getAttribute^('innerHTML'^);
echo Write-Output $pageTitle;
echo #$Options.switchTo^(^).newWindow^(WindowType.TAB^);
echo #$Options.SwitchTo^(^).Window^($Options.WindowHandles[1]^);
echo $Options.Navigate^(^).GoToURL^('https://checkip.amazonaws.com/'^);
echo $pageData.Click^(^);
echo $pageData = $Options.FindElement^([OpenQA.Selenium.By]::tagname^('pre'^)^).getAttribute^('innerHTML'^);
echo Write-Output "Tor IP is : $pageData";
echo $%global_name%Service.Dispose^(^);
if %close_selenium% == 1 echo $Options.Close^(^);$Options.Quit^(^);
)>"%root_path:"=%%~n0-%global_name%.ps1"
::end powershell code
powershell -ExecutionPolicy Unrestricted -File "%root_path:"=%%~n0-%global_name%.ps1" "%*" -Verb runAs
if %debug% == 0 if %custom_selenium_script% == 0 del "%root_path:"=%%~n0-%global_name%.ps1"
for /f "tokens=*" %%a in ('
taskkill /F /IM tor.exe /T 2^>Nul
') do break
del "%root_path:"=%%~n0-%global_name%-tor-service.ps1"
:skiptor
::PhantomJS Browser
if %phantomjs_selenium% == 0 goto :skipphantomjs
set global_name=phantomjs
set global_drver_type=PhantomJS
if %custom_selenium_script% == 0 goto :start_phantomjs
if not exist "%root_path:"=%%~n0-%global_name%.ps1" goto :start_phantomjs
powershell -ExecutionPolicy Unrestricted -File "%root_path:"=%%~n0-%global_name%.ps1" "%*" -Verb runAs
goto :skipphantomjs
:start_phantomjs
::start powershell code
(
if %debug% == 1 echo Set-PSDebug -Trace 1;
echo $SeleniumDriverPath = '%root_path:"=%';
echo Import-Module '%root_path:"=%WebDriver3.11.0.dll';
echo Import-Module '%root_path:"=%WebDriver.Support3.11.0.dll';
echo Import-Module '%root_path:"=%Selenium.WebDriverBackedSelenium3.11.0.dll';
echo [OpenQA.Selenium.PhantomJS.PhantomJSOptions]$options = New-Object OpenQA.Selenium.PhantomJS.PhantomJSOptions;
echo $service = [OpenQA.Selenium.PhantomJS.PhantomJSDriverService]::CreateDefaultService^('%root_path:"=%','phantomjs.exe'^);
echo $service.HideCommandPromptWindow = $true;
echo $service.SuppressInitialDiagnosticInformation = $true;
echo $service.IgnoreSslErrors = $true;
echo $service.WebSecurity = $false;
if %headlessbrowser% == 1 echo $options.addArgument^('--headless'^);
echo #$caps = [OpenQA.Selenium.Remote.DesiredCapabilities]::phantomjs^(^);
echo #$caps.SetCapability^('CapabilityType.ACCEPT_SSL_CERTS', $true^);
echo $cli_args = @^(^);
echo $cli_args ^+= "--web-security=no";
echo $cli_args ^+= "--ignore-ssl-errors=yes";
echo $options.AddAdditionalCapability^("phantomjs.cli.args", $cli_args^);
echo $options.AddAdditionalCapability^("phantomjs.page.settings.ignore-ssl-errors", $true^);
echo $options.AddAdditionalCapability^("phantomjs.page.settings.webSecurityEnabled", $false^);
echo $options.AddAdditionalCapability^("phantomjs.page.settings.userAgent", %custom_user_agent%^);
echo $phantomjspath = '%root_path:"=%';
echo $driver = New-Object OpenQA.Selenium.PhantomJS.PhantomJSDriver^($service, $options^);
echo $driver.Navigate^(^).GoToURL^('%phantomjs_selenium_browser_url%'^);
echo $pageTitle = $driver.FindElement^([OpenQA.Selenium.By]::tagname^('title'^)^).getAttribute^('innerHTML'^);
echo Write-Output $pageTitle;
echo $timeout = 10;
echo [OpenQA.Selenium.Support.UI.WebDriverWait]$wait = new-object OpenQA.Selenium.Support.UI.WebDriverWait ^($driver,[System.TimeSpan]::FromSeconds^($timeout^)^);
echo [OpenQA.Selenium.Interactions.Actions]$actions = new-object OpenQA.Selenium.Interactions.Actions ^($driver^);
echo $selector = 'li.ssrcss-t1nvxi-GlobalNavigationProduct:nth-child^(2^) ^> a:nth-child^(1^)';
echo $wait.Until^([OpenQA.Selenium.Support.UI.ExpectedConditions]::ElementExists^([OpenQA.Selenium.By]::CssSelector^($selector^)^)^);
echo $element = $driver.FindElement^([OpenQA.Selenium.By]::CssSelector^($selector^)^);
echo Write-Host $element.getAttribute^('href'^);
echo $driver.Navigate^(^).GoToURL^($element.getAttribute^('href'^)^); #this will navigate browser to the element
echo $wait.Until^([OpenQA.Selenium.Support.UI.ExpectedConditions]::ElementExists^([OpenQA.Selenium.By]::tagname^('title'^)^)^);
echo $pageTitle = $driver.FindElement^([OpenQA.Selenium.By]::tagname^('title'^)^).getAttribute^('innerHTML'^);
echo Write-Output $pageTitle;
echo $driver.Navigate^(^).GoToURL^('https://ifconfig.me/ua'^);
echo $wait.Until^([OpenQA.Selenium.Support.UI.ExpectedConditions]::ElementExists^([OpenQA.Selenium.By]::tagname^('pre'^)^)^);
echo $pageTitle = $driver.FindElement^([OpenQA.Selenium.By]::tagname^('pre'^)^).getAttribute^('innerHTML'^);
echo Write-Output $pageTitle;
echo $driver.Dispose^(^);
if %close_selenium% == 1 echo $driver.Close^(^);$driver.Quit^(^);
)>"%root_path:"=%%~n0-%global_name%.ps1"
::end powershell code
powershell -ExecutionPolicy Unrestricted -File "%root_path:"=%%~n0-%global_name%.ps1" "%*" -Verb runAs
if %debug% == 0 if %custom_selenium_script% == 0 del "%root_path:"=%%~n0-%global_name%.ps1"
:skipphantomjs
goto :end_script
goto :next_download
:start_download
set downloadurl=%downloadurl: =%
FOR /f %%i IN ("%downloadurl:"=%") DO set filename="%%~ni"& set fileextension="%%~xi"
set downloadpath="%root_path:"=%%filename%%fileextension%"
(
echo Dim oXMLHTTP
echo Dim oStream
echo Set fso = CreateObject^("Scripting.FileSystemObject"^)
echo If Not fso.FileExists^("%downloadpath:"=%"^) Then
echo Set oXMLHTTP = CreateObject^("MSXML2.ServerXMLHTTP.6.0"^)
echo oXMLHTTP.Open "GET", "%downloadurl:"=%", False
echo oXMLHTTP.SetRequestHeader "User-Agent", "Mozilla/5.0 ^(Windows NT 10.0; Win64; rv:51.0^) Gecko/20100101 Firefox/51.0"
echo oXMLHTTP.SetRequestHeader "Referer", "https://www.google.co.uk/"
echo oXMLHTTP.SetRequestHeader "DNT", "1"
echo oXMLHTTP.Send
echo If oXMLHTTP.Status = 200 Then
echo Set oStream = CreateObject^("ADODB.Stream"^)
echo oStream.Open
echo oStream.Type = 1
echo oStream.Write oXMLHTTP.responseBody
echo oStream.SaveToFile "%downloadpath:"=%"
echo oStream.Close
echo End If
echo End If
echo ZipFile="%downloadpath:"=%"
echo ExtractTo="%root_path:"=%"
echo ext = LCase^(fso.GetExtensionName^(ZipFile^)^)
echo If NOT fso.FolderExists^(ExtractTo^) Then
echo fso.CreateFolder^(ExtractTo^)
echo End If
echo Set app = CreateObject^("Shell.Application"^)
echo Sub ExtractByExtension^(fldr, ext, dst^)
echo For Each f In fldr.Items
echo If f.Type = "File folder" Then
echo ExtractByExtension f.GetFolder, ext, dst
echo End If
echo If instr^(f.Path, "\%file_name_to_extract%"^) ^> 0 Then
echo If fso.FileExists^(dst ^& f.Name ^& "." ^& LCase^(fso.GetExtensionName^(f.Path^)^) ^) Then
echo Else
echo call app.NameSpace^(dst^).CopyHere^(f.Path^, 4^+16^)
echo End If
echo End If
echo Next
echo End Sub
echo If instr^(ZipFile, "zip"^) ^> 0 Then
echo ExtractByExtension app.NameSpace^(ZipFile^), "exe", ExtractTo
echo End If
if [%file_name_to_extract%]==[*] echo set FilesInZip = app.NameSpace^(ZipFile^).items
if [%file_name_to_extract%]==[*] echo app.NameSpace^(ExtractTo^).CopyHere FilesInZip, 4
if [%delete_download%]==[1] echo fso.DeleteFile ZipFile
echo Set fso = Nothing
echo Set objShell = Nothing
)>"%root_path:"=%%~n0.vbs"
cscript //nologo "%root_path:"=%%~n0.vbs"
if %debug% == 0 del "%root_path:"=%%~n0.vbs"
:next_download
goto :skip_version_grab
:start_version_grab
(
echo var http = WScript.CreateObject^('MSXML2.ServerXMLHTTP.6.0'^);
echo var url = WScript.Arguments.Item^(0^)
echo http.open^("GET", url, false^);
echo http.send^(^);
echo if ^(http.status === 200^) WScript.Echo^(http.responseText^);
echo WScript.Quit^(0^);
)>"%root_path:"=%%~n0-ip.vbs"
for /f "tokens=*" %%a in ('
cscript //nologo ^"%root_path:"=%%~n0-ip.vbs^"^ %site%
') do set "vbs_output=%%a"
del "%root_path:"=%%~n0-ip.vbs"
set site=https://chromedriver.storage.googleapis.com/%vbs_output%/chromedriver_win32.zip
:skip_version_grab
goto :skip_latest_driver_github
:get_latest_driver_github
::Get latest geckodriver
(
echo $repo = "%grab_latest_repo:"=%"
echo $filenamePattern = "*%grab_latest_file:"=%"
echo $preRelease = $%grab_latest_prerelease%
echo if ^($preRelease^) {
echo $releasesUri = "https://api.github.com/repos/$repo/releases"
echo $downloadUri = ^(^(Invoke-RestMethod -Method GET -Uri $releasesUri^)[0].assets ^| Where-Object name -like $filenamePattern ^).browser_download_url
echo } else {
echo $releasesUri = "https://api.github.com/repos/$repo/releases/latest"
echo $downloadUri = ^(^(Invoke-RestMethod -Method GET -Uri $releasesUri^).assets ^| Where-Object name -like $filenamePattern ^).browser_download_url
echo }
echo Write-Output $downloadUri ^| Out-File "%root_path:"=%%~n0-psoutput.txt"
)>"%root_path:"=%%~n0-latest-driver.ps1"
powershell -ExecutionPolicy Unrestricted -File "%root_path:"=%%~n0-latest-driver.ps1" "%*" -Verb runAs
for /f "tokens=*" %%a in ('type "%root_path:"=%%~n0-psoutput.txt"') do set "latest_driver_output=%%a"
del "%root_path:"=%%~n0-latest-driver.ps1"
del "%root_path:"=%%~n0-psoutput.txt"
:skip_latest_driver_github
goto :skip_latest_download_link
:get_latest_download_link
::Get latest download link of a webpage
(
echo $url = "%grab_latest_url:"=%"
echo $html_tag = "%grab_latest_html_tag:"=%"
echo $matching_string = "%grab_latest_matching_string:"=%"
echo foreach^($i in %grab_low_range%..%grab_high_range%^){
echo $downloadUri = ^(^(Invoke-WebRequest $url -UseBasicParsing -MaximumRedirection 10^).Links ^| Where-Object $html_tag -like $matching_string^)[$i].href
echo if ^( -not ^([string]::IsNullOrEmpty^($downloadUri^)^) ^) {
echo $true_variable=%redirect_true_or_false%;
echo if ^($true_variable^) {
echo if ^($downloadUri -match "^^/"^) {
echo $var = [System.Uri]$url
echo $scheme = $var.Scheme
echo $domain = $var.Host
echo $downloadUri = $scheme ^+ "://" ^+ $domain ^+ $downloadUri
echo }
echo $downloadURL = $downloadUri
echo $request = Invoke-WebRequest -UseBasicParsing -Method Head -Uri $downloadURL
echo $redirectedUri = $request.BaseResponse.ResponseUri.AbsoluteUri
echo $downloadUri = $redirectedUri
echo }
echo Write-Output $downloadUri ^| Out-File "%root_path:"=%%~n0-psoutput.txt"
echo break;
echo }
echo }
)>"%root_path:"=%%~n0-latest-download.ps1"
powershell -ExecutionPolicy Unrestricted -File "%root_path:"=%%~n0-latest-download.ps1" "%*" -Verb runAs
for /f "tokens=*" %%a in ('type "%root_path:"=%%~n0-psoutput.txt"') do set "latest_download_output=%%a"
del "%root_path:"=%%~n0-latest-download.ps1"
del "%root_path:"=%%~n0-psoutput.txt"
del "%root_path:"=%%~n0-psfilenameoutput.txt"
:skip_latest_download_link
goto :skip_selenium_driver_patching
:start_selenium_driver_patching
:: https://gist.github.com/C0nw0nk/f3fe5541567bf93998d22dca64eeb185
(
echo $regexA = 'cdc_.{22}';
echo $ThisFile = '%root_path:"=%%driver_file_to_patch%';
echo $new_date="10/10/2000 13:37:02";
echo if ^( ^(Get-ChildItem $ThisFile^).CreationTime -notlike $new_date ^) {
echo Write-Output "%driver_file_to_patch% Patching now";
echo } else {
echo Write-Output "%driver_file_to_patch% is already patched";
echo Exit;
echo }
echo function Get-RandomCharacters^($length, $characters^) {
echo $random = 1..$length ^| ForEach-Object { Get-Random -Maximum $characters.length }
echo $private:ofs="";
echo return [String]$characters[$random];
echo }
echo $random ^+= Get-RandomCharacters -length 3 -characters 'abcdefghijklmnopqrstuvwxyz';
echo $random = 'cdc_' ^+ $random;
echo $randomupper = Get-RandomCharacters -length 1 -characters 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
echo $randomtwo = Get-RandomCharacters -length 12 -characters 'abcdefghijklmnopqrstuvwxyz';
echo $randomuppertwo = Get-RandomCharacters -length 2 -characters 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
echo $randomthree = Get-RandomCharacters -length 4 -characters 'abcdefghijklmnopqrstuvwxyz';
echo $output = $random ^+= $randomupper ^+= $randomtwo ^+= $randomuppertwo ^+= $randomthree;
echo Write-Output "New cdc string is : $output";
echo Get-ChildItem $ThisFile ^| ForEach-Object {
echo $c = ^(Get-Content $_.FullName -Raw^);
echo if ^($c -match $regexA^) {
echo $existing_cdc = $matches[0];
echo Write-Output "Existing cdc to be replaced: $existing_cdc";
echo }
echo }
echo $byteEncParam =
echo if ^($IsCoreCLR^) { @{ AsByteStream = $true } }
echo else { @{ Encoding = 'Byte' } }
echo $data = Get-Content @byteEncParam -ReadCount 0 $ThisFile
echo $dataAsHexString = [BitConverter]::ToString^($data^)
echo $search = $existing_cdc
echo $replacement = $output
echo $searchAsHexString = [BitConverter]::ToString^([Text.Encoding]::UTF8.GetBytes^($search^)^)
echo $replaceAsHexString = [BitConverter]::ToString^([Text.Encoding]::UTF8.GetBytes^($replacement^)^)
echo $dataAsHexString = $dataAsHexString.Replace^($searchAsHexString, $replaceAsHexString^)
echo $modifiedData = [byte[]] ^($dataAsHexString -split '-' -replace '^^', '0x'^)
echo Set-Content @byteEncParam $ThisFile -Value $modifiedData
echo ^(Get-ChildItem $ThisFile^).CreationTime = $new_date;
echo ^(Get-ChildItem $ThisFile^).LastWriteTime = $new_date;
)>"%root_path:"=%%~n0-driver-patch.ps1"