forked from FuocomanSap/P4wnp1-ALOA-Menu-Reworked
-
Notifications
You must be signed in to change notification settings - Fork 0
/
new.py
1930 lines (1777 loc) · 63.6 KB
/
new.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
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
#!/usr/bin/env python3
import datetime
import os
import time
import subprocess
from subprocess import Popen
import RPi.GPIO as GPIO
import smbus2 as smbus
from luma.core.render import canvas
from PIL import ImageFont
from library import display, ups, system, ui
UPS = 0 # 1 = UPS Lite connected / 0 = No UPS Lite hat
# this is related to the ups bus not the screen
bus = smbus.SMBus(1) # 0 = /dev/i2c-0 (port I2C0), 1 = /dev/i2c-1 (port I2C1)
GPIO.setwarnings(False)
# P4wnP1 essential const
hidpath = "/usr/local/P4wnP1/HIDScripts/"
sshpath = "/usr/local/P4wnP1/scripts/"
# Load default font.
font = ImageFont.load("fonts/Tamsyn6x12r.pil")
SCNTYPE = 1 # 1= OLED #2 = TERMINAL MODE BETA TESTS VERSION
# GPIO define and OLED configuration
RST_PIN = 25 # waveshare settings
CS_PIN = 8 # waveshare settings
DC_PIN = 24 # waveshare settings
KEY_UP_PIN = 6 # stick up
KEY_DOWN_PIN = 19 # stick down
KEY_LEFT_PIN = 5 # 5 #sitck left // go back
KEY_RIGHT_PIN = 26 # stick right // go in // validate
KEY_PRESS_PIN = 13 # stick center button
KEY1_PIN = 21 # key 1 // up
KEY2_PIN = 20 # 20 #key 2 // cancel/goback
KEY3_PIN = 16 # key 3 // down
USER_I2C = 0 # set to 1 if your oled is I2C or 0 if use SPI interface
# todo: replace with tmuxRun
def autoKillCommand(tx1, t):
#tx2 = "timeout " + str(t) + "s" + tx1
cmd = (
"touch touchedcommand.sh && echo '#!/bin/bash\n"
+ tx1
+ " &' > touchedcommand.sh && chmod +x touchedcommand.sh"
)
result = system.execCmd(cmd)
Popen(["nohup", "/bin/bash", "touchedcommand.sh"], preexec_fn=os.setpgrp)
# display.text("","","Executed","","","","")
time.sleep(t)
# print(cmd)
# subprocess.call(["timeout 2s",str(cmd)])
##Popen(['timeout',cmd],preexec_fn=os.setpgrp)
cmd = "rm -f nohup.out && rm -f touchedcommand.sh"
result = system.execCmd(cmd)
if result == -1:
display.error()
return -1
error = 0
while error == 0:
cmd = "ps -aux | grep '" + tx1 + "' | head -n 1 | cut -d ' ' -f7"
result = system.execCmd(cmd)
cmd = "kill " + (str(result).split("'")[1])[:-2]
# print(cmd)
result = system.execCmd(cmd)
if result == -1:
error = 1
return True
def killCommand(cmd):
error = 0
while error == 0:
cmd = "ps -aux | grep '" + cmd + "' | head -n 1 | cut -d ' ' -f7"
result = system.execCmd(cmd)
cmd = "kill " + (str(result).split("'")[1])[:-2]
# print(cmd)
result = system.execCmd(cmd)
if result == -1:
error = 1
error = 0
while error == 0:
cmd = "ps -aux | grep '" + cmd + "' | head -n 1 | cut -d ' ' -f8"
result = system.execCmd(cmd)
cmd = "kill " + (str(result).split("'")[1])[:-2]
result = system.execCmd(cmd)
if result == -1:
error = 1
return ()
def autoKillCommandNoKill(tx1, t):
cmd = (
"touch touchedcommand.sh && echo '#!/bin/bash\n"
+ tx1
+ " &' > touchedcommand.sh && chmod +x touchedcommand.sh"
)
result = system.execCmd(cmd)
Popen(["nohup", "/bin/bash", "touchedcommand.sh"], preexec_fn=os.setpgrp)
cmd = "rm -f nohup.out && rm -f touchedcommand.sh"
result = system.execCmd(cmd)
if result == -1:
return -1
return 1
def waitingLoop(msg):
uscire = 0
while uscire == 0:
if not GPIO.input(KEY_RIGHT_PIN): # button is pressed:
uscire = 1
display.msg("msg", 0.2)
def checklist(_list):
listattack = _list
maximum = len(listattack) # number of records
cur = 0
lastmenu = ""
item = ["", "", "", "", "", "", "", ""]
time.sleep(0.5)
while GPIO.input(KEY_LEFT_PIN):
# on boucle
tok = 0
if maximum < 7:
for n in range(0, 7):
if n < maximum:
if n == cur:
item[n] = ">" + listattack[n]
else:
item[n] = " " + listattack[n]
else:
item[n] = ""
else:
if cur + 7 < maximum:
for n in range(cur, cur + 7):
if n == cur:
item[tok] = ">" + listattack[n]
else:
item[tok] = " " + listattack[n]
tok = tok + 1
else:
for n in range(maximum - 8, maximum - 1):
if n == cur:
item[tok] = ">" + listattack[n]
else:
item[tok] = " " + listattack[n]
tok = tok + 1
if not GPIO.input(KEY_UP_PIN):
cur = cur - 1
if cur < 0:
cur = 0
if not GPIO.input(KEY_DOWN_PIN):
cur = cur + 1
if cur > maximum - 1:
cur = maximum - 1
if not GPIO.input(KEY_LEFT_PIN): # button is released
return ()
if not GPIO.input(KEY_RIGHT_PIN):
lastmenu = listattack[cur]
# print(lastmenu)
return lastmenu
# print(str(cur) + " " + listattack[cur]) #debug
display.text(
item[0], item[1], item[2], item[3], item[4], item[5], item[6]
)
time.sleep(0.1)
return ""
def shell(cmd):
return subprocess.check_output(cmd, shell=True)
def switchMenu(argument):
switcher = {
# main menu
# | |<-- this character isn't visible
0: "_ DELIBOY |",
1: "_SYSTEM SETTINGS",
2: "_HID ATTACKS",
3: "_WIRELESS ATTACKS",
4: "_TRIGGERS",
5: "_TEMPLATES",
6: "_NETWORK ATTACKS",
# SYSTEM SETTINGS
7: "_System Information",
8: "_OLED Brightness",
9: "_HOST OS Detection",
10: "_Display Off",
11: "_Key Test",
12: "_Reboot GUI",
13: "_Reboot System",
# HID Attacks
14: "_Run HIDScript",
15: "_Key Gamepad",
16: "_Emulate Mouse",
17: "_Set Typing Speed",
18: "_Set Key Layout",
19: "_",
20: "_",
# Wireless Attacks
21: "_Scan WIFI AP",
22: "_Hosts Discovery",
23: "_Nmap",
24: "_Vulnerability Scan",
25: "_Deauther-Bcast",
26: "_Deauther-Client",
27: "_",
# triggers
28: "_Send to oled group",
29: "_",
30: "_",
31: "_",
32: "_",
33: "_",
34: "_",
# templates
35: "_FULL SETTINGS",
36: "_BLUETOOTH",
37: "_USB",
38: "_WIFI",
39: "_TRIGGER ACTIONS",
40: "_NETWORK",
41: "_",
# network attacks
42: "_(Broken)ArpSpoofing",
43: "_Responder",
44: "_",
45: "_",
46: "_",
47: "_",
48: "_",
# main menu page 2
49: "_USBETH ATTACKS",
50: "_TEST MENU",
51: "_newsubmenu3",
52: "_newsubmenu4",
53: "_newsubmenu5",
54: "_newsubmenu6",
55: "_UPDATE OLED MENU",
# usbeth attacks
56: "_Nmap USB Device (x.2)",
57: "_",
58: "_",
59: "_",
60: "_",
61: "_",
62: "_",
# tests
63: "_Test (+7)",
64: "_Test (<7)",
65: "_Select Network Interface",
66: "_New Home Menu",
67: "_",
68: "_",
69: "_",
#
70: "_",
71: "_",
72: "_",
73: "_",
74: "_",
75: "_",
76: "_",
}
return switcher.get(argument, "Invalid")
def about():
# simple sub routine to show an About
display.text(
" : P4wnP1 A.L.O.A :",
"P4wnP1 (c) @Mame82",
"V 1.0",
"This GUI is improved by",
"DELIFER, Fuocoman",
"Original Code by",
"BeBoXoS",
)
while GPIO.input(KEY_LEFT_PIN):
# wait
pass
def identifyOS(ips):
# return os name if found ex. Microsoft Windows 7 , Linux 3.X
return shell(
"nmap -p 22,80,445,65123,56123 -O "
+ ips
+ ' | grep Running: | cut -d ":" -f2 | cut -d "|" -f1'
)
def osDetails(ips):
return shell(
"nmap -p 22,80,445,65123,56123 -O "
+ ips
+ ' | grep "OS details:" | cut -d ":" -f2 | cut -d "," -f1'
)
def keyTest():
if SCNTYPE == 1:
while GPIO.input(KEY_LEFT_PIN):
with canvas(display.device) as draw:
if GPIO.input(KEY_UP_PIN): # button is released
draw.polygon(
[(20, 20), (30, 2), (40, 20)], outline=255, fill=0
) # Up
else: # button is pressed:
draw.polygon(
[(20, 20), (30, 2), (40, 20)], outline=255, fill=1
) # Up filled
if GPIO.input(KEY_LEFT_PIN): # button is released
draw.polygon(
[(0, 30), (18, 21), (18, 41)], outline=255, fill=0
) # left
else: # button is pressed:
draw.polygon(
[(0, 30), (18, 21), (18, 41)], outline=255, fill=1
) # left filled
if GPIO.input(KEY_RIGHT_PIN): # button is released
draw.polygon(
[(60, 30), (42, 21), (42, 41)], outline=255, fill=0
) # right
else: # button is pressed:
draw.polygon(
[(60, 30), (42, 21), (42, 41)], outline=255, fill=1
) # right filled
if GPIO.input(KEY_DOWN_PIN): # button is released
draw.polygon(
[(30, 60), (40, 42), (20, 42)], outline=255, fill=0
) # down
else: # button is pressed:
draw.polygon(
[(30, 60), (40, 42), (20, 42)], outline=255, fill=1
) # down filled
if GPIO.input(KEY_PRESS_PIN): # button is released
draw.rectangle((20, 22, 40, 40), outline=255, fill=0) # center
else: # button is pressed:
draw.rectangle(
(20, 22, 40, 40), outline=255, fill=1
) # center filled
if GPIO.input(KEY1_PIN): # button is released
draw.ellipse((70, 0, 90, 20), outline=255, fill=0) # A button
else: # button is pressed:
draw.ellipse(
(70, 0, 90, 20), outline=255, fill=1
) # A button filled
if GPIO.input(KEY2_PIN): # button is released
draw.ellipse((100, 20, 120, 40), outline=255, fill=0) # B button
else: # button is pressed:
draw.ellipse(
(100, 20, 120, 40), outline=255, fill=1
) # B button filled
if GPIO.input(KEY3_PIN): # button is released
draw.ellipse((70, 40, 90, 60), outline=255, fill=0) # A button
else: # button is pressed:
draw.ellipse(
(70, 40, 90, 60), outline=255, fill=1
) # A button filled
def templateSelect(list):
# getTemplateList("BLUETOOTH").split("\n")
file = getTemplateList(list).split("\n")
maximum = len(file)
cur = 1
lastmenu = ""
item = ["", "", "", "", "", "", "", ""]
time.sleep(0.5)
while GPIO.input(KEY_LEFT_PIN):
# on boucle
tok = 1
if maximum < 8:
for n in range(1, 8):
if n < maximum:
if n == cur:
item[n - 1] = ">" + file[n]
else:
item[n - 1] = " " + file[n]
else:
item[n - 1] = ""
else:
if cur + 7 < maximum:
for n in range(cur, cur + 7):
if n == cur:
item[tok - 1] = ">" + file[n]
else:
item[tok - 1] = " " + file[n]
tok = tok + 1
else:
for n in range(maximum - 8, maximum - 1):
if n == cur:
item[tok - 1] = ">" + file[n]
else:
item[tok - 1] = " " + file[n]
tok = tok + 1
if not GPIO.input(KEY_UP_PIN):
cur = cur - 1
if cur < 1:
cur = 1
if not GPIO.input(KEY_DOWN_PIN):
cur = cur + 1
if cur > maximum - 2:
cur = maximum - 2
if not GPIO.input(KEY_RIGHT_PIN):
lastmenu = file[cur]
print(lastmenu)
return lastmenu
# ----------
display.text(
item[0], item[1], item[2], item[3], item[4], item[5], item[6]
)
time.sleep(0.1)
# todo: rewrite this mess
def runHidScript():
# choose and run (or not) a script
file = ui.fileSelect(hidpath, ".js")
time.sleep(0.5)
if file == "":
return ()
while GPIO.input(KEY_LEFT_PIN):
answer = 0
while answer == 0:
display.text(
"YES YES", "", "", file, "", "", "NO NO"
)
if not GPIO.input(KEY_UP_PIN):
answer = 1
if not GPIO.input(KEY_DOWN_PIN):
answer = 2
if not GPIO.input(KEY1_PIN):
answer = 1
if not GPIO.input(KEY3_PIN):
answer = 2
if answer == 2:
return ()
time.sleep(0.5) # pause
answer = 0
while answer == 0:
display.text(
" Run Background job",
"",
"",
"Method ? CANCEL",
"",
"",
" Run direct job",
)
if not GPIO.input(KEY_UP_PIN):
answer = 1
if not GPIO.input(KEY_LEFT_PIN):
answer = 2
if not GPIO.input(KEY_DOWN_PIN):
answer = 3
if not GPIO.input(KEY1_PIN):
answer = 1
if not GPIO.input(KEY2_PIN):
answer = 2
if not GPIO.input(KEY3_PIN):
answer = 3
if answer == 2:
return ()
display.text("", "", "", "HIDScript running...", "", "", "")
if answer == 1:
# run as background job P4wnP1_cli hid job command
cmd = "P4wnP1_cli hid job '" + file + "'"
system.execCmd(cmd)
return ()
if answer == 3:
# run hid script directly
cmd = "P4wnP1_cli hid run '" + file + "'"
system.execCmd(cmd)
return ()
def restart():
display.text("", "", "", "hang on...", "", "", "")
cmd = "python3 /root/DeliMenu/new.py &"
system.execCmd(cmd)
return ()
def reboot():
display.text("","",""," bye bye!","","","")
system.execCmd("reboot")
return ()
def shutdown():
display.text("","",""," bye bye!","","","")
system.execCmd("shutdown now")
return ()
def getTemplateList(type):
# get list of template
# Possible types : FULL_SETTINGS , BLUETOOTH , USB , WIFI , TRIGGER_ACTIONS , NETWORK
cmd = "P4wnP1_cli template list"
result = system.execCmd(cmd)
list = result
list = list.replace("Templates of type ", "") # remove uwanted text
list = list.replace(" :", "")
list = list.replace("------------------------------------\n", "")
list = list.split("\\n")
result = ""
found = 0
for n in range(0, len(list)):
if list[n] == type:
found = 1
if list[n] == "":
found = 0
if found == 1:
result = result + list[n] + "\n"
return result
def applyTemplate(template, section):
print(template)
print(section)
while GPIO.input(KEY_LEFT_PIN):
answer = 0
while answer == 0:
display.text(
"YES YES", "", "", template, "", "", "NO NO"
)
if not GPIO.input(KEY_UP_PIN):
answer = 1
if not GPIO.input(KEY_DOWN_PIN):
answer = 2
if not GPIO.input(KEY1_PIN):
answer = 1
if not GPIO.input(KEY3_PIN):
answer = 2
if answer == 2:
return ()
time.sleep(0.5) # pause
cmd = "P4wnP1_cli template deploy -" + section + " " + template + ""
system.execCmd(cmd)
return ()
def emuGamepad():
if SCNTYPE == 1:
while GPIO.input(KEY_PRESS_PIN):
with canvas(display.device) as draw:
if GPIO.input(KEY_UP_PIN): # button is released
draw.polygon(
[(20, 20), (30, 2), (40, 20)], outline=255, fill=0
) # Up
else: # button is pressed:
draw.polygon(
[(20, 20), (30, 2), (40, 20)], outline=255, fill=1
) # Up filled
subprocess.check_output(
"P4wnP1_cli hid run -c 'press(\"UP\")'", shell=True
)
if GPIO.input(KEY_LEFT_PIN): # button is released
draw.polygon(
[(0, 30), (18, 21), (18, 41)], outline=255, fill=0
) # left
else: # button is pressed:
draw.polygon(
[(0, 30), (18, 21), (18, 41)], outline=255, fill=1
) # left filled
subprocess.check_output(
"P4wnP1_cli hid run -c 'press(\"LEFT\")'", shell=True
)
if GPIO.input(KEY_RIGHT_PIN): # button is released
draw.polygon(
[(60, 30), (42, 21), (42, 41)], outline=255, fill=0
) # right
else: # button is pressed:
draw.polygon(
[(60, 30), (42, 21), (42, 41)], outline=255, fill=1
) # right filled
subprocess.check_output(
"P4wnP1_cli hid run -c 'press(\"RIGHT\")'", shell=True
)
if GPIO.input(KEY_DOWN_PIN): # button is released
draw.polygon(
[(30, 60), (40, 42), (20, 42)], outline=255, fill=0
) # down
else: # button is pressed:
draw.polygon(
[(30, 60), (40, 42), (20, 42)], outline=255, fill=1
) # down filled
subprocess.check_output(
"P4wnP1_cli hid run -c 'press(\"DOWN\")'", shell=True
)
if GPIO.input(KEY1_PIN): # button is released
draw.ellipse((70, 0, 90, 20), outline=255, fill=0) # A button
else: # button is pressed:
draw.ellipse(
(70, 0, 90, 20), outline=255, fill=1
) # A button filled
subprocess.check_output(
"P4wnP1_cli hid run -c 'press(\"Q\")'", shell=True
)
if GPIO.input(KEY2_PIN): # button is released
draw.ellipse((100, 20, 120, 40), outline=255, fill=0) # B button
else: # button is pressed:
draw.ellipse(
(100, 20, 120, 40), outline=255, fill=1
) # B button filled
subprocess.check_output(
"P4wnP1_cli hid run -c 'press(\"W\")'", shell=True
)
if GPIO.input(KEY3_PIN): # button is released
draw.ellipse((70, 40, 90, 60), outline=255, fill=0) # A button
else: # button is pressed:
draw.ellipse(
(70, 40, 90, 60), outline=255, fill=1
) # A button filled
subprocess.check_output(
"P4wnP1_cli hid run -c 'press(\"E\")'", shell=True
)
def emuMouse():
button1 = 0
button2 = 0
step = 10
time.sleep(0.5)
if SCNTYPE == 1:
while GPIO.input(KEY2_PIN):
with canvas(display.device) as draw:
if GPIO.input(KEY_UP_PIN): # button is released
draw.polygon(
[(20, 20), (30, 2), (40, 20)], outline=255, fill=0
) # Up
else: # button is pressed:
draw.polygon(
[(20, 20), (30, 2), (40, 20)], outline=255, fill=1
) # Up filled
subprocess.check_output(
"P4wnP1_cli hid run -c 'moveStepped(0,-" + str(step) + ")'",
shell=True,
)
if GPIO.input(KEY_LEFT_PIN): # button is released
draw.polygon(
[(0, 30), (18, 21), (18, 41)], outline=255, fill=0
) # left
else: # button is pressed:
draw.polygon(
[(0, 30), (18, 21), (18, 41)], outline=255, fill=1
) # left filled
subprocess.check_output(
"P4wnP1_cli hid run -c 'moveStepped(-" + str(step) + ",0)'",
shell=True,
)
if GPIO.input(KEY_RIGHT_PIN): # button is released
draw.polygon(
[(60, 30), (42, 21), (42, 41)], outline=255, fill=0
) # right
else: # button is pressed:
draw.polygon(
[(60, 30), (42, 21), (42, 41)], outline=255, fill=1
) # right filled
subprocess.check_output(
"P4wnP1_cli hid run -c 'moveStepped(" + str(step) + ",0)'",
shell=True,
)
if GPIO.input(KEY_DOWN_PIN): # button is released
draw.polygon(
[(30, 60), (40, 42), (20, 42)], outline=255, fill=0
) # down
else: # button is pressed:
draw.polygon(
[(30, 60), (40, 42), (20, 42)], outline=255, fill=1
) # down filled
subprocess.check_output(
"P4wnP1_cli hid run -c 'moveStepped(0," + str(step) + ")'",
shell=True,
)
if GPIO.input(KEY_PRESS_PIN): # button is released
draw.rectangle((20, 22, 40, 40), outline=255, fill=0) # center
else: # button is pressed:
draw.rectangle(
(20, 22, 40, 40), outline=255, fill=1
) # center filled
if step == 10:
# result = subprocess.check_output("P4wnP1_cli hid run -c 'button(BT1)'", shell = True )
step = 100
time.sleep(0.2)
else:
# result = subprocess.check_output("P4wnP1_cli hid run -c 'button(BTNONE)'", shell = True )
step = 10
time.sleep(0.2)
if GPIO.input(KEY1_PIN): # button is released
draw.ellipse((70, 0, 90, 20), outline=255, fill=0) # A button
# result = subprocess.check_output("P4wnP1_cli hid run -c 'button(BTNONE)'", shell = True )
else: # button is pressed:
draw.ellipse(
(70, 0, 90, 20), outline=255, fill=1
) # A button filled
if button1 == 0:
subprocess.check_output(
"P4wnP1_cli hid run -c 'button(BT1)'", shell=True
)
button1 = 1
time.sleep(0.2)
subprocess.check_output(
"P4wnP1_cli hid run -c 'button(BTNONE)'", shell=True
)
else:
subprocess.check_output(
"P4wnP1_cli hid run -c 'button(BTNONE)'", shell=True
)
button1 = 0
time.sleep(0.2)
draw.text((64, display.line4), "Key2 : Exit", font=font, fill=255)
if GPIO.input(KEY3_PIN): # button is released
draw.ellipse((70, 40, 90, 60), outline=255, fill=0) # A button
# result = subprocess.check_output("P4wnP1_cli hid run -c 'button(BTNONE)'", shell = True )
else: # button is pressed:
draw.ellipse(
(70, 40, 90, 60), outline=255, fill=1
) # A button filled
if button2 == 0:
subprocess.check_output(
"P4wnP1_cli hid run -c 'button(BT2)'", shell=True
)
button2 = 1
time.sleep(0.2)
subprocess.check_output(
"P4wnP1_cli hid run -c 'button(BTNONE)'", shell=True
)
else:
subprocess.check_output(
"P4wnP1_cli hid run -c 'button(BTNONE)'", shell=True
)
button2 = 0
time.sleep(0.2)
# time.sleep(0.1)
def setTypingSpeed():
time.sleep(0.5) # pause
while GPIO.input(KEY_LEFT_PIN):
display.text(
" Natural typing speed",
"",
"",
" CANCEL",
"",
"",
" Fast typing speed",
)
if not GPIO.input(KEY1_PIN):
subprocess.check_output(
"P4wnP1_cli hid run -c 'typingSpeed(100,150)'", shell=True
)
time.sleep(0.5) # pause
return ()
if not GPIO.input(KEY2_PIN):
time.sleep(0.5) # pause
return ()
if not GPIO.input(KEY3_PIN):
subprocess.check_output(
"P4wnP1_cli hid run -c 'typingSpeed(0,0)'", shell=True
)
time.sleep(0.5) # pause
return ()
time.sleep(0.5) # pause
def scanwifi():
# list wifi APs
cmd = "sudo iwlist wlan0 scan | grep ESSID"
result = system.execCmd(cmd)
SSID = result.split("'")[1]
SSID = SSID.replace(" ESSID:", "")
SSID = SSID.replace('"', "")
ssidlist = SSID.split("\\n")
cmd = "sudo iwlist wlan0 scan | grep Encryption"
result = system.execCmd(cmd)
Ekey = result.split("'")[1]
Ekey = Ekey.replace(" Encryption ", "")
Ekeylist = Ekey.split("\\n")
for n in range(0, len(ssidlist)):
if ssidlist[n] == "":
ssidlist[n] = "Hidden"
ssidlist[n] = ssidlist[n] + " [" + Ekeylist[n] + "]"
# ----------------------------------------------------------
listattack = ssidlist
maximum = len(listattack) # number of records
cur = 0
lastmenu = ""
item = ["", "", "", "", "", "", "", ""]
time.sleep(0.5)
while GPIO.input(KEY_LEFT_PIN):
# on boucle
tok = 0
if maximum < 7:
for n in range(0, 7):
if n < maximum:
if n == cur:
item[n] = ">" + listattack[n]
else:
item[n] = " " + listattack[n]
else:
item[n] = ""
else:
if cur + 7 < maximum:
for n in range(cur, cur + 7):
if n == cur:
item[tok] = ">" + listattack[n]
else:
item[tok] = " " + listattack[n]
tok = tok + 1
else:
for n in range(maximum - 8, maximum - 1):
if n == cur:
item[tok] = ">" + listattack[n]
else:
item[tok] = " " + listattack[n]
tok = tok + 1
if not GPIO.input(KEY_UP_PIN):
cur = cur - 1
if cur < 0:
cur = 0
if not GPIO.input(KEY_DOWN_PIN):
cur = cur + 1
if cur > maximum - 2:
cur = maximum - 2
if not GPIO.input(KEY_RIGHT_PIN):
lastmenu = listattack[cur]
display.text(" TOBE IMPLEMENTED (WIFI)", "", "", "", "", "", "")
time.sleep(2)
return lastmenu
# print(str(cur) + " " + listattack[cur]) #debug
display.text(
item[0], item[1], item[2], item[3], item[4], item[5], item[6]
)
time.sleep(0.1)
return ""
def runTriggers():
while GPIO.input(KEY_PRESS_PIN):
with canvas(display.device) as draw:
if GPIO.input(KEY_UP_PIN): # button is released
draw.polygon([(20, 20), (30, 2), (40, 20)], outline=255, fill=0) # Up
draw.text((28, display.line2 + 2), "1", font=font, fill=255)
else: # button is pressed:
draw.polygon(
[(20, 20), (30, 2), (40, 20)], outline=255, fill=1
) # Up filled
shell('P4wnP1_cli trigger send -n "oled" -v 1')
if GPIO.input(KEY_LEFT_PIN): # button is released
draw.polygon([(0, 30), (18, 21), (18, 41)], outline=255, fill=0) # left
draw.text((11, display.line5 - 7), "3", font=font, fill=255)
else: # button is pressed:
draw.polygon(
[(0, 30), (18, 21), (18, 41)], outline=255, fill=1
) # left filled
shell('P4wnP1_cli trigger send -n "oled" -v 3')
if GPIO.input(KEY_RIGHT_PIN): # button is released
draw.polygon(
[(60, 30), (42, 21), (42, 41)], outline=255, fill=0
) # right
draw.text((45, display.line5 - 7), "4", font=font, fill=255)
else: # button is pressed:
draw.polygon(
[(60, 30), (42, 21), (42, 41)], outline=255, fill=1
) # right filled
shell('P4wnP1_cli trigger send -n "oled" -v 4')
if GPIO.input(KEY_DOWN_PIN): # button is released
draw.polygon(
[(30, 60), (40, 42), (20, 42)], outline=255, fill=0
) # down
draw.text((28, display.line6 + 3), "2", font=font, fill=255)
else: # button is pressed:
draw.polygon(
[(30, 60), (40, 42), (20, 42)], outline=255, fill=1
) # down filled
shell('P4wnP1_cli trigger send -n "oled" -v 2')
if GPIO.input(KEY1_PIN): # button is released
draw.ellipse((70, 0, 90, 20), outline=255, fill=0) # A button
draw.text((75, display.line2), "10", font=font, fill=255)
else: # button is pressed:
draw.ellipse((70, 0, 90, 20), outline=255, fill=1) # A button filled
shell('P4wnP1_cli trigger send -n "oled" -v 10')
if GPIO.input(KEY2_PIN): # button is released
draw.ellipse((100, 20, 120, 40), outline=255, fill=0) # B button
draw.text((105, display.line5 - 7), "20", font=font, fill=255)
else: # button is pressed:
draw.ellipse((100, 20, 120, 40), outline=255, fill=1) # B button filled
shell('P4wnP1_cli trigger send -n "oled" -v 20')
if GPIO.input(KEY3_PIN): # button is released
draw.ellipse((70, 40, 90, 60), outline=255, fill=0) # A button
draw.text((75, display.line7 - 5), "30", font=font, fill=255)
else: # button is pressed:
draw.ellipse((70, 40, 90, 60), outline=255, fill=1) # A button filled
shell('P4wnP1_cli trigger send -n "oled" -v 30')
draw.text((25, display.line4 + 2), "Go", font=font, fill=255)
# time.sleep(0.1)
def usbEthOsDetection():
display.text("", "", "", " PLEASE WAIT", "", "", "")
os = identifyOS("172.16.0.2")
if str(os) == "b''":
while GPIO.input(KEY_LEFT_PIN):
display.text(
"Experimental nmap OS",
"detection",
"",
"Too many fingerprints match this host",
" Or Zero ",
"",
"Press LEFT to exit",
)
return
detail = osDetails("172.16.0.2")
while GPIO.input(KEY_LEFT_PIN):
display.text(
"Experimental nmap OS",
"detection",
"",
os.replace("Microsoft", "MS").replace("Windows", "win"),
detail.replace("Microsoft", "MS").replace("Windows", "win"),
"",
"Press LEFT to exit",
)
def hostSelect():
display.text("", "", "", "wait, may take a while ", "", "", "")
cmd = "hostname -I"
result = system.execCmd(cmd)
subnetIp = result.split(" ")[0].split("'")[1]
pos = subnetIp.rfind(".")
cmd = (
"nmap -sL -Pn "
+ str(subnetIp[0:pos])
+ ".0/24 | grep -v 'Nmap scan report for "
+ subnetIp[0:2]
+ "'"
)
result = system.execCmd(cmd)
hosts = result
hostlist = hosts.split("\\n")
del hostlist[-1]
del hostlist[-1]
del hostlist[0]
for i in range(0, len(hostlist)):
hostlist[i] = hostlist[i][21:]
# print(hostlist[i][21:])
file = hostlist
maximum = len(hostlist)
cur = 1
lastmenu = ""
item = ["", "", "", "", "", "", "", ""]
time.sleep(0.5)
while GPIO.input(KEY_LEFT_PIN):
# on boucle
tok = 1
if maximum < 8:
for n in range(1, 8):
if n < maximum:
if n == cur:
item[n - 1] = ">" + file[n]
else:
item[n - 1] = " " + file[n]
else:
item[n - 1] = ""
else:
if cur + 7 < maximum: