-
Notifications
You must be signed in to change notification settings - Fork 137
/
EasyInstall.py
590 lines (571 loc) · 23.3 KB
/
EasyInstall.py
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
#!/bin/python3
import os
import platform
from git import Repo
import glob
import time
import shutil
import serial.tools.list_ports
import requests
import json
import esptool
from colorama import Fore, Back, Style
from pathlib import Path
import git
import argparse
parser=argparse.ArgumentParser()
parser.add_argument('-s', '--serialport', type=str, help="Define serial port", default='')
parser.add_argument('-ps', '--preselect', type=int, help="Preselect flashing option", default=None)
args=parser.parse_args()
serialport=args.serialport
fwchoice=args.preselect
OPENASCII=Fore.GREEN+r'''
#################################################################################
# ESP32 FZEasyFlasher #
# by Lord SkeletonMan #
# NOW INCLUDING EVIL PORTAL! #
# Originally Based off of a Windows Batch script #
# by Frog, UberGuidoz, and ImprovingRigamarole #
# #
# Thanks to everyone who has done testing on various chips for me #
# Thanks to Scorp for compiling needed bins for the ESP32-WROOM #
# Thanks to AWOK for pointing out bugs, adding his boards, and testing #
# #
# As of Marauder Update 0.13.7, there is no more serial bin, it is unified, but #
# the latest Marauder Companion App (7.0) is required to use it on your Flipper #
#################################################################################
'''+Style.RESET_ALL
print(OPENASCII)
print("Make sure your ESP32 or WiFi devboard is plugged in!")
BR=str("115200")
def checkforserialport():
global serialport
if serialport!='':
print("Will not check for serial port or possible chip type since it is specified as", serialport)
return
else:
serialport=''
print("Checking for serial port...")
vids=['303A','10C4','1A86', '0483']
com_port=None
ports=list(serial.tools.list_ports.comports())
for vid in vids:
for port in ports:
if vid in port.hwid:
serialport=port.device
device=vid
if serialport=='':
print(Fore.RED+"No ESP32 device was detected!"+Style.RESET_ALL)
print(Fore.RED+"Please plug in a Flipper WiFi devboard or an ESP32 chip and try again"+Style.RESET_ALL)
if fwchoicepreselect==False:
choose_fw()
elif fwchoicepreselect==True:
exit()
if device=='':
return
elif device=='303A':
print(Fore.BLUE+"You are most likely using a Flipper Zero WiFi Devboard or an ESP32-S2"+Style.RESET_ALL)
elif device=='10C4':
print(Fore.BLUE+"You are most likely using an ESP32-WROOM, an ESP32-S2-WROVER, or an ESP32-S3-WROOM"+Style.RESET_ALL)
elif device=='1A86':
print(Fore.MAGENTA+"You are most likely using a knock-off ESP32 chip! Success is not guaranteed!"+Style.RESET_ALL)
elif device== '0483':
print(Fore.BLUE+"You are most likely using an DrB0rk S3 Multiboard"+Style.RESET_ALL)
return
def checkforextrabins():
extraesp32binsrepo="https://github.com/UberGuidoZ/Marauder_BINs.git"
global extraesp32bins
extraesp32bins=("Extra_ESP32_Bins")
global scorpbins
scorpbins=(extraesp32bins+"/Marauder/WROOM")
if os.path.exists(extraesp32bins):
print("The extra ESP32 bins folder exists!")
else:
print("The extra ESP32 bins folder does not exist!")
print("That's okay, downloading them now...")
Repo.clone_from(extraesp32binsrepo, extraesp32bins)
return
def choose_fw():
choices=r'''
//==================================================================\\
|| Options: ||
|| 1) Flash Marauder on WiFi Devboard or ESP32-S2 ||
|| 2) Save Flipper Blackmagic WiFi settings ||
|| 3) Flash Flipper Blackmagic ||
|| 4) Flash Marauder on ESP32-WROOM ||
|| 5) Flash Marauder on ESP32 Marauder Mini ||
|| 6) Flash v6 Marauder on ESP32-WROOM (RabbitLabs Minion Marauder)||
|| 7) Flash Marauder on ESP32-S3 (There is no current S3 bin) ||
|| 8) Flash Marauder on AWOK v1-3 or Duoboard ||
|| 9) Flash Marauder on AWOK v4 Chungus Board ||
|| 10) Flash Marauder on AWOK v5 ESP32 ||
|| 11) Flash Marauder on AWOK Dual ESP32 (Orange Port) ||
|| 12) Flash Marauder on AWOK Dual ESP32 Touch Screen (White Port) ||
|| 13) Flash Marauder on AWOK Dual ESP32 Mini (White Port) ||
|| 14) Flash Evil Portal on ESP32-WROOM ||
|| 15) Flash Evil Portal on ESP32-S2 or WiFi Devboard ||
|| 16) Just Erase ESP32 - Try this if you think you bricked it ||
|| 17) Update all files ||
|| 18) Exit ||
\\==================================================================//
'''
#Still not perfect, but better
global selectedfw
global selectedboard
global fwchoice
global fwchoicepreselect
hardresetlist=[5, 6, 8, 9, 10, 11, 12, 13]
if fwchoice!=None:
fwchoicepreselect=True
print(Fore.BLUE+"You have preselected option", fwchoice,Style.RESET_ALL)
print("If you didn't mean to do this, CTRL-C now!")
print("Waiting 5 seconds before continuing...")
time.sleep(5)
else:
fwchoicepreselect=False
print(choices)
fwchoice=int(input("Please enter the number of your choice: "))
if fwchoice in hardresetlist:
reset='hard_reset'
else:
reset='no_reset'
if fwchoice==1:
print("You have chosen to flash Marauder on a WiFi devboard or ESP32-S2")
chip="esp32s2"
selectedfw="Marauder"
selectedboard="ESP32-S2"
flashsize='4MB'
offset_one='0x1000'
bootloader_bin=extraesp32bins+'/Marauder/bootloader.bin'
offset_two='0x8000'
partitions_bin=extraesp32bins+'/Marauder/partitions.bin'
offset_three='0x10000'
fwbin=esp32marauderfw
checkforserialport()
eraseparams=['-p', serialport, '-b', BR, '-a', 'no_reset', 'erase_flash']
flashparams=['-p', serialport, '-b', BR, '-c', chip, '--before', 'default_reset', '-a', reset, 'write_flash', '--flash_mode', 'dio', '--flash_freq', '80m', '--flash_size', flashsize, offset_one, bootloader_bin, offset_two, partitions_bin, offset_three, fwbin]
flashtheboard(eraseparams, flashparams)
elif fwchoice==2:
print("You have chosen to save Flipper Blackmagic WiFi settings")
chip="esp32s2"
checkforserialport()
eraseparams=['-p', serialport, '-b', BR, 'erase_flash']
savebmset=['-p', serialport, '-b', BR, '-c', chip, '-a', 'no_reset', 'read_flash', '0x9000', '0x6000', extraesp32bins+'/Blackmagic/nvs.bin']
save_flipperbmsettings(savebmset)
elif fwchoice==3:
print("You have chosen to flash Flipper Blackmagic")
chip="esp32s2"
selectedfw="Blackmagic"
selectedboard="ESP32-S2"
flashsize='4MB'
offset_one='0x1000'
bootloader_bin=extraesp32bins+'/Blackmagic/bootloader.bin'
offset_two='0x8000'
partitions_bin=extraesp32bins+'/Blackmagic/partition-table.bin'
fwbin=extraesp32bins+'/Blackmagic/blackmagic.bin'
checkforserialport()
eraseparams=['-p', serialport, '-b', BR, 'erase_flash']
if os.path.exists(extraesp32bins+"/Blackmagic/nvs.bin"):
offset_three='0x9000'
wifisettings=extraesp32bins+'/Blackmagic/nvs.bin'
offset_four='0x10000'
flashparams=['-p', serialport, '-b', BR, '-c', chip, '--before', 'default_reset', '-a', 'no_reset', 'write_flash', '--flash_mode', 'dio', '--flash_freq', '80m', '--flash_size', flashsize, offset_one, bootloader_bin, offset_two, partitions_bin, offset_three, wifisettings, offset_four, fwbin]
else:
offset_three='0x10000'
flashparams=esptool.main['-p', serialport, '-b', BR, '-c', chip, '--before', 'default_reset', '-a', 'no_reset', 'write_flash', '--flash_mode', 'dio', '--flash_freq', '80m', '--flash_size', flashsize, offset_one, bootloader_bin, offset_two, partitions_bin, offset_three, fwbin]
flashtheboard(eraseparams, flashparams)
elif fwchoice==4:
print("You have chosen to flash Marauder onto an ESP32-WROOM")
chip="esp32"
selectedfw="Marauder"
selectedboard="ESP32-WROOM"
flashsize='4MB'
offset_one='0x1000'
bootloader_bin=scorpbins+'/bootloader.bin'
offset_two='0x8000'
partitions_bin=scorpbins+'/partitions.bin'
offset_three='0x10000'
fwbin=espoldhardwarefw
checkforserialport()
eraseparams=['-p', serialport, '-b', BR, 'erase_flash']
flashparams=['-p', serialport, '-b', BR, '-c', chip, '--before', 'default_reset', '-a', reset, 'write_flash', '--flash_mode', 'dio', '--flash_freq', '80m', '--flash_size', flashsize, offset_one, bootloader_bin, offset_two, partitions_bin, offset_three, fwbin]
flashtheboard(eraseparams, flashparams)
elif fwchoice==5:
print("You have chosen to flash Marauder onto an ESP32 Marauder Mini")
chip="esp32"
selectedfw="Marauder"
selectedboard="ESP32 Marauder Mini"
flashsize='4MB'
offset_one='0x1000'
bootloader_bin=scorpbins+'/bootloader.bin'
offset_two='0x8000'
partitions_bin=scorpbins+'/partitions.bin'
offset_three='0x10000'
fwbin=esp32minifw
checkforserialport()
eraseparams=['-p', serialport, '-b', BR, 'erase_flash']
flashparams=['-p', serialport, '-b', BR, '-c', chip, '--before', 'default_reset', '-a', reset, 'write_flash', '--flash_mode', 'dio', '--flash_freq', '80m', '--flash_size', flashsize, offset_one, bootloader_bin, offset_two, partitions_bin, offset_three, fwbin]
flashtheboard(eraseparams, flashparams)
elif fwchoice==6:
print("You have chosen to flash Marauder v6 onto an ESP32-WROOM")
chip="esp32"
selectedfw="Marauder v6"
selectedboard="ESP32-WROOM"
flashsize='4MB'
offset_one='0x1000'
bootloader_bin=scorpbins+'/bootloader.bin'
offset_two='0x8000'
partitions_bin=scorpbins+'/partitions.bin'
offset_three='0x10000'
fwbin=espnewhardwarefw
checkforserialport()
eraseparams=['-p', serialport, '-b', BR, 'erase_flash']
flashparams=['-p', serialport, '-b', BR, '-c', chip, '--before', 'default_reset', '-a', reset, 'write_flash', '--flash_mode', 'dio', '--flash_freq', '80m', '--flash_size', flashsize, offset_one, bootloader_bin, offset_two, partitions_bin, offset_three, fwbin]
flashtheboard(eraseparams, flashparams)
elif fwchoice==7:
print("You have chosen to flash Marauder onto an ESP32-S3")
try:
os.path.exists(esp32s3fw) # Since 1.0.0 update didn't include the S3 bin
except:
print("You don't have the S3 firmware downloaded. It's likely missing from the latest release.")
print("If you put a previous multiboard bin in the ESP32Marauder/releases/ folder, it should be able to flash that.")
exit()
chip="esp32s3"
selectedfw="Marauder"
selectedboard="ESP32-S3"
flashsize='8MB'
offset_one='0x0'
bootloader_bin=extraesp32bins+'/S3/bootloader.bin'
offset_two='0x8000'
partitions_bin=extraesp32bins+'/S3/partitions.bin'
offset_three='0xE000'
boot_app=extraesp32bins+'/S3/boot_app0.bin'
offset_four='0x10000'
fwbin=esp32s3fw
checkforserialport()
eraseparams=['-p', serialport, '-b', BR, 'erase_flash']
flashparams=['-p', serialport, '-b', BR, '-c', chip, '--before', 'default_reset', '-a', 'no_reset', 'write_flash', '--flash_mode', 'dio', '--flash_freq', '80m', '--flash_size', flashsize, offset_one, bootloader_bin, offset_two, partitions_bin, offset_three, boot_app, offset_four, fwbin]
flashtheboard(eraseparams, flashparams)
elif fwchoice==8:
print("You have chosen to flash Marauder onto an AWOK v1-3 or Duoboard")
chip="esp32"
selectedfw="Marauder"
selectedboard="AWOK v1-3 or Duoboard"
flashsize='4MB'
offset_one='0x1000'
bootloader_bin=scorpbins+'/bootloader.bin'
offset_two='0x8000'
partitions_bin=scorpbins+'/partitions.bin'
offset_three='0x10000'
fwbin=espoldhardwarefw
checkforserialport()
eraseparams=['-p', serialport, '-b', BR, 'erase_flash']
flashparams=['-p', serialport, '-b', BR, '-c', chip, '--before', 'default_reset', '-a', reset, 'write_flash', '--flash_mode', 'dio', '--flash_freq', '80m', '--flash_size', flashsize, offset_one, bootloader_bin, offset_two, partitions_bin, offset_three, fwbin]
flashtheboard(eraseparams, flashparams)
elif fwchoice==9:
print("You have chosen to flash Marauder on an AWOK v4 Chungus Board")
chip="esp32s2"
selectedfw="Marauder"
selectedboard="AWOK v4 Chungus Board"
flashsize='4MB'
offset_one='0x1000'
bootloader_bin=extraesp32bins+'/Marauder/bootloader.bin'
offset_two='0x8000'
partitions_bin=extraesp32bins+'/Marauder/partitions.bin'
offset_three='0x10000'
fwbin=esp32marauderfw
checkforserialport()
eraseparams=['-p', serialport, '-b', BR, 'erase_flash']
flashparams=['-p', serialport, '-b', BR, '-c', chip, '--before', 'default_reset', '-a', reset, 'write_flash', '--flash_mode', 'dio', '--flash_freq', '80m', '--flash_size', flashsize, offset_one, bootloader_bin, offset_two, partitions_bin, offset_three, fwbin]
flashtheboard(eraseparams, flashparams)
elif fwchoice==10:
print("You have chosen to flash Marauder on an AWOK v5 ESP32")
chip="esp32s2"
selectedfw="Marauder"
selectedboard="AWOK v5 ESP32"
flashsize='4MB'
offset_one='0x1000'
bootloader_bin=extraesp32bins+'/Marauder/bootloader.bin'
offset_two='0x8000'
partitions_bin=extraesp32bins+'/Marauder/partitions.bin'
offset_three='0x10000'
fwbin=esp32marauderfw
checkforserialport()
eraseparams=['-p', serialport, '-b', BR, 'erase_flash']
flashparams=['-p', serialport, '-b', BR, '-c', chip, '--before', 'default_reset', '-a', reset, 'write_flash', '--flash_mode', 'dio', '--flash_freq', '80m', '--flash_size', flashsize, offset_one, bootloader_bin, offset_two, partitions_bin, offset_three, fwbin]
flashtheboard(eraseparams, flashparams)
elif fwchoice==11:
print("You have chosen to flash Marauder on an AWOK Dual ESP32 (Orange Port)")
chip="esp32s2"
selectedfw="Marauder"
selectedboard="AWOK Dual ESP32 (Orange Port)"
flashsize='4MB'
offset_one='0x1000'
bootloader_bin=extraesp32bins+'/Marauder/bootloader.bin'
offset_two='0x8000'
partitions_bin=extraesp32bins+'/Marauder/partitions.bin'
offset_three='0x10000'
fwbin=esp32marauderfw
checkforserialport()
eraseparams=['-p', serialport, '-b', BR, 'erase_flash']
flashparams=['-p', serialport, '-b', BR, '-c', chip, '--before', 'default_reset', '-a', reset, 'write_flash', '--flash_mode', 'dio', '--flash_freq', '80m', '--flash_size', flashsize, offset_one, bootloader_bin, offset_two, partitions_bin, offset_three, fwbin]
flashtheboard(eraseparams, flashparams)
elif fwchoice==12:
print("You have chosen to flash Marauder onto an AWOK Dual ESP32 Touch Screen (White Port)")
chip="esp32"
selectedfw="Marauder"
selectedboard="AWOK Dual ESP32 Touch Screen (White Port)"
flashsize='4MB'
offset_one='0x1000'
bootloader_bin=scorpbins+'/bootloader.bin'
offset_two='0x8000'
partitions_bin=scorpbins+'/partitions.bin'
offset_three='0x10000'
fwbin=espnewhardwarefw
checkforserialport()
eraseparams=['-p', serialport, '-b', BR, 'erase_flash']
flashparams=['-p', serialport, '-b', BR, '-c', chip, '--before', 'default_reset', '-a', reset, 'write_flash', '--flash_mode', 'dio', '--flash_freq', '80m', '--flash_size', flashsize, offset_one, bootloader_bin, offset_two, partitions_bin, offset_three, fwbin]
flashtheboard(eraseparams, flashparams)
elif fwchoice==13:
print("You have chosen to flash Marauder onto an AWOK Dual ESP32 Mini (White Port)")
chip="esp32"
selectedfw="Marauder Mini"
selectedboard="AWOK Dual ESP32 Mini (White Port)"
flashsize='4MB'
offset_one='0x1000'
bootloader_bin=scorpbins+'/bootloader.bin'
offset_two='0x8000'
partitions_bin=scorpbins+'/partitions.bin'
offset_three='0x10000'
fwbin=esp32minifw
checkforserialport()
eraseparams=['-p', serialport, '-b', BR, 'erase_flash']
flashparams=['-p', serialport, '-b', BR, '-c', chip, '--before', 'default_reset', '-a', reset, 'write_flash', '--flash_mode', 'dio', '--flash_freq', '80m', '--flash_size', flashsize, offset_one, bootloader_bin, offset_two, partitions_bin, offset_three, fwbin]
flashtheboard(eraseparams, flashparams)
elif fwchoice==14:
print("You have chosen to flash Evil Portal on an ESP32-WROOM")
chip="esp32"
selectedfw="Evil Portal"
selectedboard="ESP32-WROOM"
flashsize='4MB'
offset_one='0x1000'
fwbin=evilportalfwwroom
checkforserialport()
eraseparams=['-p', serialport, '-b', BR, 'erase_flash']
flashparams=['-p', serialport, '-b', BR, '-c', chip, '--before', 'default_reset', '-a', 'hard_reset', 'write_flash', '--flash_mode', 'dio', '--flash_freq', '80m', '--flash_size', flashsize, offset_one, fwbin]
flashtheboard(eraseparams, flashparams)
elif fwchoice==15:
print("You have chosen to flash Evil Portal on an ESP32-S2 or WiFi Devboard")
chip="esp32s2"
selectedfw="Evil Portal"
selectedboard="ESP32-S2"
flashsize='4MB'
offset_one='0x1000'
fwbin=evilportalfws2
checkforserialport()
eraseparams=['-p', serialport, '-b', BR, '-a', 'no_reset', 'erase_flash']
flashparams=['-p', serialport, '-b', BR, '-c', chip, '--before', 'default_reset', '-a', 'hard_reset', 'write_flash', '--flash_mode', 'dio', '--flash_freq', '80m', '--flash_size', flashsize, offset_one, fwbin]
flashtheboard(eraseparams, flashparams)
elif fwchoice==16:
print("You have chosen to just erase the ESP32")
checkforserialport()
eraseparams=['-p', serialport, '-b', BR, 'erase_flash']
erase_esp32(eraseparams)
elif fwchoice==17:
print("You have chosen to update all of the files")
fwchoicepreselect=False
fwchoice=None
update_option()
elif fwchoice==18:
print("You have chosen to exit")
print("Exiting!")
exit()
else:
print(Fore.RED+"Invalid option!"+Style.RESET_ALL)
exit()
return
def erase_esp32(eraseparams):
tries=3
attempts=0
for i in range(tries):
try:
attempts+=1
print("Erasing firmware...")
esptool.main(eraseparams)
except Exception as err:
print(err)
if attempts==3:
print("Unable to erase the firmware")
exit()
print("Waiting 5 seconds and trying again...")
time.sleep(5)
continue
print("Successfully erased!")
break
print("Waiting 5 seconds...")
time.sleep(5)
return
def checkforesp32marauder():
print("Checking for Marauder releases")
if os.path.exists("ESP32Marauder/releases"):
print("Great, you have the Marauder releases folder!")
else:
print("Marauder releases folder does not exist, but that's okay, downloading them now...")
os.makedirs('ESP32Marauder/releases')
marauderapi="https://api.github.com/repos/justcallmekoko/ESP32Marauder/releases/latest"
response=requests.get(marauderapi)
jsondata=response.json()
for assetdl in jsondata['assets']:
marauderasset=assetdl['browser_download_url']
if marauderasset.find('/'):
filename=(marauderasset.rsplit('/', 1)[1])
downloadfile=requests.get(marauderasset, allow_redirects=True)
open('ESP32Marauder/releases/'+filename, 'wb').write(downloadfile.content)
esp32marauderfwc=('ESP32Marauder/releases/esp32_marauder_v*_flipper.bin')
if not glob.glob(esp32marauderfwc):
print("No ESP32 Marauder Flipper firmware exists somehow!")
global esp32marauderfw
for esp32marauderfw in glob.glob(esp32marauderfwc):
if os.path.exists(esp32marauderfw):
print("ESP32 Marauder firmware exists at", esp32marauderfw)
return
def checkforevilportal():
print("Checking for Evil portal")
if os.path.exists('EvilPortal'):
print("Great, you have the Evil Portal folder!")
else:
print("Evil Portal folder not found, but that's okay, downloading it now")
os.makedirs('EvilPortal')
evilportalwroomurl="https://github.com/bigbrodude6119/flipper-zero-evil-portal/raw/main/Single%20File%20Bins/Evil%20Portal%20WROOM.bin"
downloadfile=requests.get(evilportalwroomurl)
open("EvilPortal/EvilPortalWROOM.bin", 'wb').write(downloadfile.content)
evilportals2url="https://github.com/bigbrodude6119/flipper-zero-evil-portal/raw/main/Single%20File%20Bins/Evil%20Portal%20WiFi%20Board%20or%20S2.bin"
downloadfile=requests.get(evilportals2url)
open("EvilPortal/EvilPortalS2.bin", 'wb').write(downloadfile.content)
global evilportalfwwroom
global evilportalfws2
evilportalfwwroom="EvilPortal/EvilPortalWROOM.bin"
evilportalfws2="EvilPortal/EvilPortalS2.bin"
if os.path.exists(evilportalfwwroom):
print("WROOM Evil Portal FW exists at", evilportalfwwroom)
else:
print("Somehow, the Evil Portal WROOM bin does not exist!")
if os.path.exists(evilportalfws2):
print("S2 Evil Portal FW exists at", evilportalfws2)
else:
print("Somehow, the Evil Portal S2 bin does not exist!")
return
def checkfors3bin():
esp32s3fwc=('ESP32Marauder/releases/esp32_marauder_v*ultiboardS3.bin')
if not glob.glob(esp32s3fwc):
print("multiboards3 bin does not exist!")
global esp32s3fw
for esp32s3fw in glob.glob(esp32s3fwc):
if os.path.exists(esp32s3fw):
print("ESP32-S3 firmware bin exists at", esp32s3fw)
else:
print("Somehow, the multiboardS3.bin file does not exist!")
esp32s3fw=None
return
def checkforoldhardwarebin():
espoldhardwarefwc=('ESP32Marauder/releases/esp32_marauder_v*_old_hardware.bin')
if not glob.glob(espoldhardwarefwc):
print("old_hardware bin does not exist!")
global espoldhardwarefw
for espoldhardwarefw in glob.glob(espoldhardwarefwc):
if os.path.exists(espoldhardwarefw):
print("Old Hardware bin exists at", espoldhardwarefw)
else:
print("Somehow, the old_hardware.bin file does not exist!")
return
def checkforminibin():
esp32minifwc=('ESP32Marauder/releases/esp32_marauder_v*_mini.bin')
if not glob.glob(esp32minifwc):
print("mini bin does not exist!")
global esp32minifw
for esp32minifw in glob.glob(esp32minifwc):
if os.path.exists(esp32minifw):
print("Mini bin exists at", esp32minifw)
else:
print("Somehow, the mini bin does not exist!")
return
def checkfornewhardwarebin():
espnewhardwarefwc=('ESP32Marauder/releases/esp32_marauder_v*_v6.bin')
if not glob.glob(espnewhardwarefwc):
print("new_hardware bin does not exist!")
global espnewhardwarefw
for espnewhardwarefw in glob.glob(espnewhardwarefwc):
if os.path.exists(espnewhardwarefw):
print("New Hardware bin exists at", espnewhardwarefw)
else:
print("Somehow, the new_hardware.bin file does not exist!")
return
def prereqcheck():
print("Checking for prerequisites...")
checkforextrabins()
checkforesp32marauder()
checkfors3bin()
checkforoldhardwarebin()
checkforminibin()
checkfornewhardwarebin()
checkforevilportal()
return
def flashtheboard(eraseparams, flashparams):
erase_esp32(eraseparams)
tries=3
attempts=0
for i in range(tries):
try:
attempts+=1
print("Flashing", selectedfw, "on", selectedboard)
esptool.main(flashparams)
except Exception as err:
print(err)
if attempts==3:
print("Could not flash", selectedfw, "on", selectedboard)
exit()
print("Waiting 5 seconds and trying again...")
time.sleep(5)
continue
print(Fore.GREEN+selectedboard, "has been flashed with", selectedfw+Style.RESET_ALL)
break
return
def save_flipperbmsettings(savebmset):
tries=3
attempts=0
for i in range(tries):
try:
attempts +=1
print("Saving Flipper Blackmagic WiFi Settings to Extra_ESP32_Bins/Blackmagic/nvs.bin")
esptool.main(savebmset)
except Exception as err:
print(err)
if attempts==3:
print("Could not save Flipper Blackmagic WiFi Settings")
exit()
print("Waiting 5 seconds and trying again...")
time.sleep(5)
continue
print(Fore.GREEN+"Flipper Blackmagic Wifi Settings have been saved to ", extraesp32bins+"/Blackmagic/nvs.bin!"+Style.RESET_ALL)
break
return
def update_option():
print("Checking for and deleting the files before replacing them...")
cwd = os.getcwd()
for paths in Path(cwd).rglob('ESP32Marauder/*/*'):
os.remove(paths)
for paths in Path(cwd).rglob('EvilPortal/*'):
os.remove(paths)
os.rmdir('ESP32Marauder/releases')
os.rmdir('ESP32Marauder')
os.rmdir('EvilPortal')
extrarepo = os.path.join(cwd, "Extra_ESP32_Bins")
repo = Repo(extrarepo)
repo.git.reset('--hard')
repo.git.clean('-xdf')
repo.remotes.origin.pull()
prereqcheck()
choose_fw()
return
prereqcheck()
choose_fw()