├── Kali-Pi-3.5.jpg
├── README-KALI-PI.md
├── README-ORIGINAL.md
├── README.md
├── launch-bg.sh
├── menu
├── menu_8button.py
├── menu_kali-1.py
├── menu_kali-2.py
├── menu_kali-3.py
├── menu_kali-4.py
├── menu_kali-9.py
├── menu_kali_2.8
└── Kali-Pi-2.8.jpg
├── menu_pause.py
├── menu_pigrrl.py
├── menu_screenoff.py
├── menu_touchpi.py
├── pulledpork.sh
└── sdr-scanner.sh
/Kali-Pi-3.5.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Re4son/pitftmenu/120f22c5e2fe2204e007a84e70f1ead9e06eea93/Kali-Pi-3.5.jpg
--------------------------------------------------------------------------------
/README-KALI-PI.md:
--------------------------------------------------------------------------------
1 | # KALI-PI Launcher
2 |
3 | Simple touch menu for Raspberry Pi projects using the [3.5" Adafruit PiTFT](http://www.adafruit.com/products/2097) 480x320 touch screen based on garthvh's original project.
4 | It's been slightly improved to be more resource friendly, allow to scroll through multiple themes and return after closing an application.
5 |
6 | It runs as a python script in the framebuffer without needing a desktop environment.
7 |
8 | This menu is the default launcher in [Sticky Finger's Kali Pi](http://www.whitedome.com.au/kali-pi)
9 | 
10 |
11 | I was after an easy way to launch X Window on either the TFT screen or through HDMI without the need for massive reconfigurations.
12 | I came accross [garthvh's project featured on Adafruit](https://blog.adafruit.com/2015/05/08/simple-pitft-touchpi-menu-system-piday-raspberrypi-raspberry_pi/) and used it as basis for this project
13 |
14 |
15 | ## Installation
16 |
17 | git clone https://github.com/re4son/pitftmenu
18 | cd pitftmenu
19 | customise the file "menu" to match the path
20 | cusomise the scripts to suit your needs
21 |
22 | **Important: Pygame is broken on on Debian Jessie. I'll explain below how to fix it.**
23 |
24 | ## Usage
25 | sudo ./menu
26 |
27 | ## Layout
28 |
29 | ### Start Screen
30 |
31 | The first menu is menu_kali-1.py, which provides the following options:
32 |
33 | 
34 |
35 | All functions are self explainatory.
36 | After exiting and application, the screen returns back to the last menu.
37 |
38 | The "Screen Off" function launches the python script "menu_screenoff.py", which uses the RPi.GPIO module to turn the screen off.
39 | You can turn it back on by pressing anywhere on the screen.
40 |
41 | Using the ">>>" button, we can scroll to the next screen, namely "menu_kali-2.py"
42 |
43 | ### menu_kali-2.py
44 |
45 | Some more applications to launch:
46 |
47 | 
48 |
49 | Kismet and SDR-Scanner have to be installed for this to work.
50 | If you want to enable the reboot and shutdown commands you will need to make the following updates
51 |
52 | sudo visudo
53 | Add the following line:
54 |
55 | %pi ALL=(ALL:ALL) NOPASSWD: /sbin/poweroff, /sbin/reboot, /sbin/shutdown, /home/pi/pitftmenu/menu
56 |
57 | ### menu_kali-3.py
58 |
59 | This script allows us to stop and start services:
60 |
61 | 
62 |
63 | Press a button to start a service.
64 |
65 | The button changes to green when the service is running:
66 |
67 | 
68 |
69 | Press the button again to stop the service.
70 |
71 | ### menu_kali-4.py
72 |
73 | This script allows us to stop and start MySQL & Snort and allows to update the Snort rules via PulledPork:
74 | 
75 |
76 | ### menu_kali-9.py
77 | The last script displays some health information:
78 |
79 | 
80 |
81 | ### Run menu at startup
82 |
83 | The preferred method to run this script on startup is to add it to the end of ".profile"
84 |
85 | nano ~/home/.profile
86 |
87 | And add the following line to the bottom of the file
88 |
89 | sudo /home/pi/pitftmenu/menu
90 |
91 | ## Fix Pygame on Debian Jessie
92 | The package "libsdl1.2-15-10", which ships with Debian Jessie, breaks pygame.
93 | To make it work we have to revert back to "libsdl1.2-15-5" from Wheezy.
94 |
95 | The quickest way is to comment everything out in your /etc/apt/sources.list and temporarily add:
96 |
97 | ```
98 | deb http://archive.raspbian.org/raspbian wheezy main contrib non-free
99 | ```
100 |
101 |
102 | Import the corresponding keys:
103 | ```
104 | deb http://archive.raspbian.org/raspbian wheezy main contrib non-free
105 | gpg -a --export 9165938D90FDDD2E | sudo apt-key add -
106 | ```
107 |
108 | Remove the offending package and replace it with the working one:
109 | ```
110 | sudo apt-get update
111 | sudo apt-get remove libsdl1.2debian python-pygame
112 | apt-get install libsdl-image1.2 libsdl-mixer1.2 libsdl-ttf2.0-0 libsdl1.2debian libsmpeg0 python-pygame
113 | sudo apt-mark hold libsdl1.2debian
114 | ```
115 |
116 | Restore "/etc/apt/sources.list" to it's original state.
117 |
118 | That's it. Pygame is fixed :-)
119 |
120 | ## References
121 |
122 | This project is a fork of garthvh's work, available here:
123 | [https://github.com/garthvh/pitftmenu](https://github.com/garthvh/pitftmenu)
124 |
--------------------------------------------------------------------------------
/README-ORIGINAL.md:
--------------------------------------------------------------------------------
1 | # Simple PiTFT TouchPi Menu System
2 |
3 | Simple touch menu for Raspberry Pi projects using the [3.5" Adafruit PiTFT](http://www.adafruit.com/products/2097) 480x320 touch screen.
4 |
5 | Runs as a python script in the framebuffer without needing a desktop environment.
6 |
7 | Featured on the adafruit blog for pi day:
8 |
10 |
11 |
12 | I have made a model b+ [Touch Pi](https://learn.adafruit.com/touch-pi-portable-raspberry-pi) 3D printed case for my screen and raspberry pi, and with a battery and [PowerBoost 500c](https://www.adafruit.com/product/1944) charger it makes a great base for raspberry pi projects.
13 |
14 | I wanted a way to do common tasks like going to the desktop, rebooting and shutting down without needing to use a keyboard. I also wanted the screen to display the current IP address to make it easier to ssh into the device.
15 |
16 | Written using python and pygame the 3.5" screen is broken out into 8 large touchable menu areas.
17 |
18 | ## Installation
19 |
20 | git clone https://github.com/garthvh/pitftmenu
21 | cd pitftmenu
22 |
23 | ### 8 Button Menu Template
24 |
25 | The basic 8 Button Template can be run with the following command the buttons in this example simply print out the number of the button pushed and closes the menu:
26 |
27 | 
28 |
29 | sudo python menu_8button.py
30 |
31 | ### Generic Touch Pi Menu
32 |
33 | My basic touch pi menu with a top label with your hostname and IP address, one open button and working buttons for Desktop, Terminal, Configuring Wifi, Reboot and Shutdown.
34 |
35 | WiFi Functionality Requires PiFi and Virtual Keyboard.
36 |
37 | 
38 |
39 | 
40 |
41 | sudo python menu_touchpi.py
42 |
43 | ### Reboot and Shutdown Buttons
44 |
45 | If you want to enable the reboot and shutdown commands you will need to make the following updates
46 |
47 | sudo visudo
48 |
49 | Add the following lines to the end of the file to target the www-data user
50 |
51 | www-data ALL=/sbin/shutdown
52 | www-data ALL=NOPASSWD: /sbin/shutdown
53 |
54 | ### Automatic low battery shutdown
55 |
56 | I have connected the LBO pin on the PowerBoost 500c to GPIO Pin 21, when it returns low the TouchPi shuts down.
57 |
58 | 
59 |
60 | ### Run menu at startup
61 |
62 | If you want the script to run at startup, add a cron job
63 |
64 | sudo crontab -e
65 |
66 | And add the following line to the bottom of the file
67 |
68 | @reboot python /home/pi/pitftmenu/menu_touchpi.py &
69 |
70 | ## References
71 |
72 | The examples here are cobbled together from other code linked to below:
73 |
74 | - https://github.com/5Volt-Junkie/RPi-Tron-Radio/blob/master/tron-radio.py
75 | - http://richardhawthorn.com/?p=128
76 | - http://www.raspberrypi-spy.co.uk/2013/07/running-a-python-script-at-boot-using-cron/
77 | - https://github.com/DoctorBud/raspberrypi-node/tree/176f7536d505de17b0d790855a836e0d2cb7d059/pitft-pygame
78 | - https://learn.adafruit.com/pi-video-output-using-pygame/pygame-drawing-functions
79 | - https://learn.adafruit.com/pi-video-output-using-pygame/pointing-pygame-to-the-framebuffer
80 | - http://home.uktechreviews.com/Raspberry/Pi%20blog/files/pygame-menu.html
81 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # KALI-PI Launcher
2 |
3 | Simple touch menu for Raspberry Pi projects using the [3.5" Adafruit PiTFT](http://www.adafruit.com/products/2097) 480x320 touch screen based on garthvh's original project.
4 | It's been slightly improved to be more resource friendly, allow to scroll through multiple themes and return after closing an application.
5 |
6 | It runs as a python script in the framebuffer without needing a desktop environment.
7 |
8 | This menu is the default launcher in [Sticky Finger's Kali Pi](http://www.whitedome.com.au/kali-pi)
9 | 
10 |
11 | I was after an easy way to launch X Window on either the TFT screen or through HDMI without the need for massive reconfigurations.
12 | I came accross [garthvh's project featured on Adafruit](https://blog.adafruit.com/2015/05/08/simple-pitft-touchpi-menu-system-piday-raspberrypi-raspberry_pi/) and used it as basis for this project
13 |
14 |
15 | ## Installation
16 |
17 | git clone https://github.com/re4son/pitftmenu
18 | cd pitftmenu
19 | For 2.8" screens: git checkout 2.8
20 | customise the file "menu" to match the path
21 | cusomise the scripts to suit your needs
22 |
23 | **Important: Pygame is broken on on Debian Jessie. I'll explain below how to fix it.**
24 |
25 | ## Usage
26 | sudo ./menu
27 |
28 | ## Layout
29 |
30 | ### Start Screen
31 |
32 | The first menu is menu_kali-1.py, which provides the following options:
33 |
34 | 
35 |
36 | All functions are self explainatory.
37 | After exiting and application, the screen returns back to the last menu.
38 |
39 | The "Screen Off" function launches the python script "menu_screenoff.py", which uses the RPi.GPIO module to turn the screen off.
40 | You can turn it back on by pressing anywhere on the screen.
41 |
42 | Using the ">>>" button, we can scroll to the next screen, namely "menu_kali-2.py"
43 |
44 | ### menu_kali-2.py
45 |
46 | Some more applications to launch:
47 |
48 | 
49 |
50 | Kismet and SDR-Scanner have to be installed for this to work.
51 | If you want to enable the reboot and shutdown commands you will need to make the following updates
52 |
53 | sudo visudo
54 | Add the following line:
55 |
56 | %pi ALL=(ALL:ALL) NOPASSWD: /sbin/poweroff, /sbin/reboot, /sbin/shutdown, /home/pi/pitftmenu/menu
57 |
58 | ### menu_kali-3.py
59 |
60 | This script allows us to stop and start services:
61 |
62 | 
63 |
64 | Press a button to start a service.
65 |
66 | The button changes to green when the service is running:
67 |
68 | 
69 |
70 | Press the button again to stop the service.
71 |
72 | ### menu_kali-4.py
73 |
74 | This script allows us to stop and start MySQL & Snort and allows to update the Snort rules via PulledPork:
75 | 
76 |
77 | ### menu_kali-9.py
78 | The last script displays some health information:
79 |
80 | 
81 |
82 | ### Run menu at startup
83 |
84 | The preferred method to run this script on startup is to add it to the end of ".profile"
85 |
86 | nano ~/home/.profile
87 |
88 | And add the following line to the bottom of the file
89 |
90 | sudo /home/pi/pitftmenu/menu
91 |
92 | ## Fix Pygame on Debian Jessie
93 | The package "libsdl1.2-15-10", which ships with Debian Jessie, breaks pygame.
94 | To make it work we have to revert back to "libsdl1.2-15-5" from Wheezy.
95 |
96 | The quickest way is to comment everything out in your /etc/apt/sources.list and temporarily add:
97 |
98 | ```
99 | deb http://archive.raspbian.org/raspbian wheezy main contrib non-free
100 | ```
101 |
102 |
103 | Import the corresponding keys:
104 | ```
105 | deb http://archive.raspbian.org/raspbian wheezy main contrib non-free
106 | gpg -a --export 9165938D90FDDD2E | sudo apt-key add -
107 | ```
108 |
109 | Remove the offending package and replace it with the working one:
110 | ```
111 | sudo apt-get update
112 | sudo apt-get remove libsdl1.2debian python-pygame
113 | apt-get install libsdl-image1.2 libsdl-mixer1.2 libsdl-ttf2.0-0 libsdl1.2debian libsmpeg0 python-pygame
114 | sudo apt-mark hold libsdl1.2debian
115 | ```
116 |
117 | Restore "/etc/apt/sources.list" to it's original state.
118 |
119 | That's it. Pygame is fixed :-)
120 |
121 | ## References
122 |
123 | This project is a fork of garthvh's work, available here:
124 | [https://github.com/garthvh/pitftmenu](https://github.com/garthvh/pitftmenu)
125 |
--------------------------------------------------------------------------------
/launch-bg.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | BACKGROUND="Kali-Pi-3.5.jpg"
3 | setterm -term linux -back default -fore black -clear all
4 | fbi -t 2 -1 -d /dev/fb1 -noverbose -a $MENUDIR$BACKGROUND
5 |
--------------------------------------------------------------------------------
/menu:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | ##############################################
3 | ## ##
4 | ## Menu ##
5 | ## Launches menu_kali-1.py ##
6 | ## Best autostarted through ~/.profile ##
7 | ## ##
8 | ##############################################
9 |
10 |
11 | export FRAMEBUFFER=/dev/fb1
12 | export MENUDIR="/home/pi/pitftmenu/"
13 | startpage="menu_kali-1.py"
14 | /usr/bin/clear
15 |
16 | /usr/bin/env python $MENUDIR$startpage
17 |
--------------------------------------------------------------------------------
/menu_8button.py:
--------------------------------------------------------------------------------
1 | import sys, pygame
2 | from pygame.locals import *
3 | import time
4 | import subprocess
5 | import os
6 | from subprocess import *
7 | os.environ["SDL_FBDEV"] = "/dev/fb1"
8 | os.environ["SDL_MOUSEDEV"] = "/dev/input/touchscreen"
9 | os.environ["SDL_MOUSEDRV"] = "TSLIB"
10 |
11 | # Initialize pygame and hide mouse
12 | pygame.init()
13 | pygame.mouse.set_visible(0)
14 |
15 | # define function for printing text in a specific place with a specific width and height with a specific colour and border
16 | def make_button(text, xpo, ypo, height, width, colour):
17 | font=pygame.font.Font(None,42)
18 | label=font.render(str(text), 1, (colour))
19 | screen.blit(label,(xpo,ypo))
20 | pygame.draw.rect(screen, blue, (xpo-10,ypo-10,width,height),3)
21 |
22 | # define function for printing text in a specific place with a specific colour
23 | def make_label(text, xpo, ypo, fontsize, colour):
24 | font=pygame.font.Font(None,fontsize)
25 | label=font.render(str(text), 1, (colour))
26 | screen.blit(label,(xpo,ypo))
27 |
28 | # define function that checks for touch location
29 | def on_touch():
30 | # get the position that was touched
31 | touch_pos = (pygame.mouse.get_pos() [0], pygame.mouse.get_pos() [1])
32 | # x_min x_max y_min y_max
33 | # button 1 event
34 | if 30 <= touch_pos[0] <= 240 and 30 <= touch_pos[1] <=85:
35 | button(1)
36 | # button 2 event
37 | if 260 <= touch_pos[0] <= 470 and 30 <= touch_pos[1] <=85:
38 | button(2)
39 | # button 3 event
40 | if 30 <= touch_pos[0] <= 240 and 105 <= touch_pos[1] <=160:
41 | button(3)
42 | # button 4 event
43 | if 260 <= touch_pos[0] <= 470 and 105 <= touch_pos[1] <=160:
44 | button(4)
45 | # button 5 event
46 | if 30 <= touch_pos[0] <= 240 and 180 <= touch_pos[1] <=235:
47 | button(5)
48 | # button 6 event
49 | if 260 <= touch_pos[0] <= 470 and 180 <= touch_pos[1] <=235:
50 | button(6)
51 | # button 7 event
52 | if 30 <= touch_pos[0] <= 240 and 255 <= touch_pos[1] <=310:
53 | button(7)
54 | # button 8 event
55 | if 260 <= touch_pos[0] <= 470 and 255 <= touch_pos[1] <=310:
56 | button(8)
57 |
58 | # Define each button press action
59 | def button(number):
60 | print "You pressed button ",number
61 |
62 | if number == 1:
63 | time.sleep(5) #do something interesting here
64 | sys.exit()
65 |
66 | if number == 2:
67 | time.sleep(5) #do something interesting here
68 | sys.exit()
69 |
70 | if number == 3:
71 | time.sleep(5) #do something interesting here
72 | sys.exit()
73 |
74 | if number == 4:
75 | time.sleep(5) #do something interesting here
76 | sys.exit()
77 |
78 | if number == 5:
79 | time.sleep(5) #do something interesting here
80 | sys.exit()
81 |
82 | if number == 6:
83 | time.sleep(5) #do something interesting here
84 | sys.exit()
85 |
86 | if number == 7:
87 | time.sleep(5) #do something interesting here
88 | sys.exit()
89 |
90 | if number == 8:
91 | time.sleep(5) #do something interesting here
92 | sys.exit()
93 |
94 | #colors R G B
95 | white = (255, 255, 255)
96 | red = (255, 0, 0)
97 | green = ( 0, 255, 0)
98 | blue = ( 0, 0, 255)
99 | black = ( 0, 0, 0)
100 | cyan = ( 50, 255, 255)
101 | magenta = (255, 0, 255)
102 | yellow = (255, 255, 0)
103 | orange = (255, 127, 0)
104 |
105 | # Set up the base menu you can customize your menu with the colors above
106 |
107 | #set size of the screen
108 | size = width, height = 480, 320
109 | screen = pygame.display.set_mode(size)
110 |
111 | # Background Color
112 | screen.fill(black)
113 |
114 | # Outer Border
115 | pygame.draw.rect(screen, blue, (0,0,480,320),10)
116 |
117 | # Buttons and labels
118 | # First Row
119 | make_button("Menu Item 1", 30, 30, 55, 210, blue)
120 | make_button("Menu Item 2", 260, 30, 55, 210, blue)
121 | # Second Row
122 | make_button("Menu Item 3", 30, 105, 55, 210, blue)
123 | make_button("Menu item 4", 260, 105, 55, 210, blue)
124 | # Third Row
125 | make_button("Menu item 5", 30, 180, 55, 210, blue)
126 | make_button("Menu item 6", 260, 180, 55, 210, blue)
127 | # Fourth Row
128 | make_button("Menu item 7", 30, 255, 55, 210, blue)
129 | make_button("Menu item 8", 260, 255, 55, 210, blue)
130 |
131 | # While loop to manage touch screen inputs
132 | while 1:
133 | for event in pygame.event.get():
134 | if event.type == pygame.MOUSEBUTTONDOWN:
135 | print "screen pressed" #for debugging purposes
136 | pos = (pygame.mouse.get_pos() [0], pygame.mouse.get_pos() [1])
137 | print pos #for checking
138 | pygame.draw.circle(screen, white, pos, 2, 0) #for debugging purposes - adds a small dot where the screen is pressed
139 | on_click()
140 |
141 | #ensure there is always a safe way to end the program if the touch screen fails
142 |
143 | if event.type == KEYDOWN:
144 | if event.key == K_ESCAPE:
145 | sys.exit()
146 | pygame.display.update()
147 |
--------------------------------------------------------------------------------
/menu_kali-1.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | import sys, os, time, subprocess, commands, pygame
3 | from pygame.locals import *
4 | from subprocess import *
5 | os.environ["SDL_FBDEV"] = "/dev/fb1"
6 | os.environ["SDL_MOUSEDEV"] = "/dev/input/touchscreen"
7 | os.environ["SDL_MOUSEDRV"] = "TSLIB"
8 | launch_bg=os.environ["MENUDIR"] + "launch-bg.sh"
9 | process = subprocess.call(launch_bg, shell=True)
10 |
11 | # Initialize pygame modules individually (to avoid ALSA errors) and hide mouse
12 | pygame.font.init()
13 | pygame.display.init()
14 |
15 | pygame.mouse.set_visible(0)
16 |
17 | # define function for printing text in a specific place with a specific width and height with a specific colour and border
18 | def make_button(text, xpo, ypo, height, width, colour):
19 | pygame.draw.rect(screen, tron_regular, (xpo-10,ypo-10,width,height),3)
20 | pygame.draw.rect(screen, tron_light, (xpo-9,ypo-9,width-1,height-1),1)
21 | pygame.draw.rect(screen, tron_regular, (xpo-8,ypo-8,width-2,height-2),1)
22 | font=pygame.font.Font(None,42)
23 | label=font.render(str(text), 1, (colour))
24 | screen.blit(label,(xpo,ypo))
25 |
26 |
27 | # define function for printing text in a specific place with a specific colour
28 | def make_label(text, xpo, ypo, fontsize, colour):
29 | font=pygame.font.Font(None,fontsize)
30 | label=font.render(str(text), 1, (colour))
31 | screen.blit(label,(xpo,ypo))
32 |
33 | # define function that checks for touch location
34 | def on_touch():
35 | # get the position that was touched
36 | touch_pos = (pygame.mouse.get_pos() [0], pygame.mouse.get_pos() [1])
37 | # x_min x_max y_min y_max
38 | # button 1 event
39 | if 30 <= touch_pos[0] <= 240 and 105 <= touch_pos[1] <=160:
40 | button(1)
41 | # button 2 event
42 | if 260 <= touch_pos[0] <= 470 and 105 <= touch_pos[1] <=160:
43 | button(2)
44 | # button 3 event
45 | if 30 <= touch_pos[0] <= 240 and 180 <= touch_pos[1] <=235:
46 | button(3)
47 | # button 4 event
48 | if 260 <= touch_pos[0] <= 470 and 180 <= touch_pos[1] <=235:
49 | button(4)
50 | # button 5 event
51 | if 30 <= touch_pos[0] <= 240 and 255 <= touch_pos[1] <=310:
52 | button(5)
53 | # button 6 event
54 | if 260 <= touch_pos[0] <= 470 and 255 <= touch_pos[1] <=310:
55 | button(6)
56 |
57 | def run_cmd(cmd):
58 | process = Popen(cmd.split(), stdout=PIPE)
59 | output = process.communicate()[0]
60 | return output
61 |
62 |
63 | # Define each button press action
64 | def button(number):
65 | if number == 1:
66 | # X TFT
67 | pygame.quit()
68 | ## Requires "Anybody" in dpkg-reconfigure x11-common if we have scrolled pages previously
69 | ## run_cmd("/usr/bin/sudo -u pi FRAMEBUFFER=/dev/fb1 startx")
70 | run_cmd("/usr/bin/sudo FRAMEBUFFER=/dev/fb1 startx")
71 | os.execv(__file__, sys.argv)
72 |
73 | if number == 2:
74 | # X HDMI
75 | pygame.quit()
76 | ## Requires "Anybody" in dpkg-reconfigure x11-common if we have scrolled pages previously
77 | ## run_cmd("/usr/bin/sudo -u pi FRAMEBUFFER=/dev/fb0 startx")
78 | run_cmd("/usr/bin/sudo FRAMEBUFFER=/dev/fb0 startx")
79 | os.execv(__file__, sys.argv)
80 |
81 |
82 | if number == 3:
83 | # exit
84 | pygame.quit()
85 | process = subprocess.call("setterm -term linux -back default -fore white -clear all", shell=True)
86 | sys.exit()
87 |
88 | if number == 4:
89 | # htop
90 | pygame.quit()
91 | process = subprocess.call("/usr/bin/htop", shell=True)
92 | os.execv(__file__, sys.argv)
93 |
94 | if number == 5:
95 | # next page
96 | pygame.quit()
97 | ##process = subprocess.call("setterm -term linux -back black -fore black -clear all", shell=True)
98 | ##startx only works when we don't use subprocess here, don't know why
99 | page=os.environ["MENUDIR"] + "menu_screenoff.py"
100 | os.execvp("python", ["python", page])
101 | sys.exit()
102 |
103 | if number == 6:
104 | # next page
105 | pygame.quit()
106 | ##startx only works when we don't use subprocess here, don't know why
107 | page=os.environ["MENUDIR"] + "menu_kali-2.py"
108 | os.execvp("python", ["python", page])
109 | sys.exit()
110 |
111 |
112 |
113 | # colors R G B
114 | white = (255, 255, 255)
115 | tron_whi = (189, 254, 255)
116 | red = (255, 0, 0)
117 | green = ( 0, 255, 0)
118 | blue = ( 0, 0, 255)
119 | tron_blu = ( 0, 219, 232)
120 | black = ( 0, 0, 0)
121 | cyan = ( 50, 255, 255)
122 | magenta = (255, 0, 255)
123 | yellow = (255, 255, 0)
124 | tron_yel = (255, 218, 10)
125 | orange = (255, 127, 0)
126 | tron_ora = (255, 202, 0)
127 |
128 | # Tron theme orange
129 | tron_regular = tron_ora
130 | tron_light = tron_yel
131 | tron_inverse = tron_whi
132 |
133 | # Tron theme blue
134 | ##tron_regular = tron_blu
135 | ##tron_light = tron_whi
136 | ##tron_inverse = tron_yel
137 |
138 | # Set up the base menu you can customize your menu with the colors above
139 |
140 | #set size of the screen
141 | size = width, height = 480, 320
142 | screen = pygame.display.set_mode(size)
143 |
144 | # Background Color
145 | screen.fill(black)
146 |
147 | # Outer Border
148 | pygame.draw.rect(screen, tron_regular, (0,0,479,319),8)
149 | pygame.draw.rect(screen, tron_light, (2,2,479-4,319-4),2)
150 |
151 | pi_hostname = run_cmd("hostname")
152 | pi_hostname = " " + pi_hostname[:-1]
153 | # Buttons and labels
154 | # First Row Label
155 | make_label(pi_hostname, 32, 30, 48, tron_inverse)
156 | # Second Row buttons 3 and 4
157 | make_button(" X on TFT", 30, 105, 55, 210, tron_light)
158 | make_button(" X on HDMI", 260, 105, 55, 210, tron_light)
159 | # Third Row buttons 5 and 6
160 | make_button(" Terminal", 30, 180, 55, 210, tron_light)
161 | make_button(" hTop", 260, 180, 55, 210, tron_light)
162 | # Fourth Row Buttons
163 | make_button(" Screen Off", 30, 255, 55, 210, tron_light)
164 | make_button(" >>>", 260, 255, 55, 210, tron_light)
165 |
166 |
167 | #While loop to manage touch screen inputs
168 | while 1:
169 | for event in pygame.event.get():
170 | if event.type == pygame.MOUSEBUTTONDOWN:
171 | pos = (pygame.mouse.get_pos() [0], pygame.mouse.get_pos() [1])
172 | on_touch()
173 |
174 | #ensure there is always a safe way to end the program if the touch screen fails
175 | if event.type == KEYDOWN:
176 | if event.key == K_ESCAPE:
177 | sys.exit()
178 | pygame.display.update()
179 | ## Reduce CPU utilisation
180 | time.sleep(0.1)
181 |
--------------------------------------------------------------------------------
/menu_kali-2.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | import sys, os, subprocess, time, pygame, socket
3 | from pygame.locals import *
4 | from subprocess import *
5 | os.environ["SDL_FBDEV"] = "/dev/fb1"
6 | os.environ["SDL_MOUSEDEV"] = "/dev/input/touchscreen"
7 | os.environ["SDL_MOUSEDRV"] = "TSLIB"
8 |
9 | # Initialize pygame modules individually (to avoid ALSA errors) and hide mouse
10 | pygame.font.init()
11 | pygame.display.init()
12 | pygame.mouse.set_visible(0)
13 |
14 | # define function for printing text in a specific place with a specific width and height with a specific colour and border
15 | def make_button(text, xpo, ypo, height, width, colour):
16 | pygame.draw.rect(screen, tron_regular, (xpo-10,ypo-10,width,height),3)
17 | pygame.draw.rect(screen, tron_light, (xpo-9,ypo-9,width-1,height-1),1)
18 | pygame.draw.rect(screen, tron_regular, (xpo-8,ypo-8,width-2,height-2),1)
19 | font=pygame.font.Font(None,42)
20 | label=font.render(str(text), 1, (colour))
21 | screen.blit(label,(xpo,ypo))
22 |
23 | # define function for printing text in a specific place with a specific colour
24 | def make_label(text, xpo, ypo, fontsize, colour):
25 | font=pygame.font.Font(None,fontsize)
26 | label=font.render(str(text), 1, (colour))
27 | screen.blit(label,(xpo,ypo))
28 |
29 | # define function that checks for touch location
30 | def on_touch():
31 | # get the position that was touched
32 | touch_pos = (pygame.mouse.get_pos() [0], pygame.mouse.get_pos() [1])
33 | # x_min x_max y_min y_max
34 | # button 1 event
35 | if 30 <= touch_pos[0] <= 240 and 105 <= touch_pos[1] <=160:
36 | button(1)
37 | # button 2 event
38 | if 260 <= touch_pos[0] <= 470 and 105 <= touch_pos[1] <=160:
39 | button(2)
40 | # button 3 event
41 | if 30 <= touch_pos[0] <= 240 and 180 <= touch_pos[1] <=235:
42 | button(3)
43 | # button 4 event
44 | if 260 <= touch_pos[0] <= 470 and 180 <= touch_pos[1] <=235:
45 | button(4)
46 | # button 5 event
47 | if 30 <= touch_pos[0] <= 240 and 255 <= touch_pos[1] <=310:
48 | button(5)
49 | # button 6 event
50 | if 260 <= touch_pos[0] <= 470 and 255 <= touch_pos[1] <=310:
51 | button(6)
52 |
53 | # Get Your External IP Address
54 | def get_ip():
55 | ip_msg = "Not connected"
56 | try:
57 | s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
58 | s.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
59 | s.connect(('', 0))
60 | ip_msg=" IP: " + s.getsockname()[0]
61 | except Exception:
62 | pass
63 | return ip_msg
64 |
65 | # Restart Raspberry Pi
66 | def restart():
67 | command = "/usr/bin/sudo /sbin/shutdown -r now"
68 | process = Popen(command.split(), stdout=PIPE)
69 | output = process.communicate()[0]
70 | return output
71 |
72 | # Shutdown Raspberry Pi
73 | def shutdown():
74 | command = "/usr/bin/sudo /sbin/shutdown -h now"
75 | process = Popen(command.split(), stdout=PIPE)
76 | output = process.communicate()[0]
77 | return output
78 |
79 | def get_temp():
80 | command = "vcgencmd measure_temp"
81 | process = Popen(command.split(), stdout=PIPE)
82 | output = process.communicate()[0]
83 | return output
84 |
85 | def run_cmd(cmd):
86 | process = Popen(cmd.split(), stdout=PIPE)
87 | output = process.communicate()[0]
88 | return output
89 |
90 | # Define each button press action
91 | def button(number):
92 | if number == 1:
93 | # Kismet
94 | pygame.quit()
95 | subprocess.call("/usr/bin/sudo -u pi /usr/bin/kismet", shell=True)
96 | os.execv(__file__, sys.argv)
97 |
98 | if number == 2:
99 | # SDR-Scanner
100 | pygame.quit()
101 | prog="/bin/bash " + os.environ["MENUDIR"] + "sdr-scanner.sh"
102 | run_cmd(prog)
103 | os.execv(__file__, sys.argv)
104 |
105 | if number == 3:
106 | # shutdown
107 | pygame.quit()
108 | shutdown()
109 | sys.exit()
110 |
111 | if number == 4:
112 | # reboot
113 | screen.fill(black)
114 | font=pygame.font.Font(None,72)
115 | label=font.render("Rebooting. .", 1, (white))
116 | screen.blit(label,(40,120))
117 | pygame.display.flip()
118 | pygame.quit()
119 | restart()
120 | sys.exit()
121 |
122 | if number == 5:
123 | # Previous page
124 | pygame.quit()
125 | page=os.environ["MENUDIR"] + "menu_kali-1.py"
126 | os.execvp("python", ["python", page])
127 | sys.exit()
128 |
129 |
130 | if number == 6:
131 | # Next page
132 | pygame.quit()
133 | page=os.environ["MENUDIR"] + "menu_kali-3.py"
134 | os.execvp("python", ["python", page])
135 | sys.exit()
136 |
137 |
138 |
139 | # colors R G B
140 | white = (255, 255, 255)
141 | tron_whi = (189, 254, 255)
142 | red = (255, 0, 0)
143 | green = ( 0, 255, 0)
144 | blue = ( 0, 0, 255)
145 | tron_blu = ( 0, 219, 232)
146 | black = ( 0, 0, 0)
147 | cyan = ( 50, 255, 255)
148 | magenta = (255, 0, 255)
149 | yellow = (255, 255, 0)
150 | tron_yel = (255, 215, 10)
151 | orange = (255, 127, 0)
152 | tron_ora = (255, 202, 0)
153 |
154 | # Tron theme orange
155 | ## tron_regular = tron_ora
156 | ## tron_light = tron_yel
157 | ## tron_inverse = tron_whi
158 |
159 | # Tron theme blue
160 | tron_regular = tron_blu
161 | tron_light = tron_whi
162 | tron_inverse = tron_yel
163 |
164 | # Set up the base menu you can customize your menu with the colors above
165 |
166 | #set size of the screen
167 | size = width, height = 480, 320
168 | screen = pygame.display.set_mode(size)
169 |
170 | # Background Color
171 | screen.fill(black)
172 |
173 | # Outer Border
174 | pygame.draw.rect(screen, tron_regular, (0,0,479,319),8)
175 | pygame.draw.rect(screen, tron_light, (2,2,479-4,319-4),2)
176 |
177 | # Buttons and labels
178 | # First Row Label
179 | make_label(get_ip(), 32, 30, 48, tron_inverse)
180 | # Second Row buttons 1 and 2
181 | make_button(" Kismet", 30, 105, 55, 210, tron_light)
182 | make_button(" SDR-Scanner", 260, 105, 55, 210, tron_light)
183 | # Third Row buttons 3 and 4
184 | make_button(" Shutdown", 30, 180, 55, 210, tron_light)
185 | make_button(" Reboot", 260, 180, 55, 210, tron_light)
186 | # Fourth Row Buttons
187 | make_button(" <<<", 30, 255, 55, 210, tron_light)
188 | make_button(" >>>", 260, 255, 55, 210, tron_light)
189 |
190 |
191 | #While loop to manage touch screen inputs
192 | while 1:
193 | for event in pygame.event.get():
194 | if event.type == pygame.MOUSEBUTTONDOWN:
195 | pos = (pygame.mouse.get_pos() [0], pygame.mouse.get_pos() [1])
196 | on_touch()
197 |
198 | #ensure there is always a safe way to end the program if the touch screen fails
199 | if event.type == KEYDOWN:
200 | if event.key == K_ESCAPE:
201 | sys.exit()
202 | pygame.display.update()
203 | ## Reduce CPU utilisation
204 | time.sleep(0.1)
205 |
--------------------------------------------------------------------------------
/menu_kali-3.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | import sys, os, pygame, subprocess, commands, time, socket
3 | from pygame.locals import *
4 | from subprocess import *
5 | os.environ["SDL_FBDEV"] = "/dev/fb1"
6 | os.environ["SDL_MOUSEDEV"] = "/dev/input/touchscreen"
7 | os.environ["SDL_MOUSEDRV"] = "TSLIB"
8 |
9 | # Initialize pygame modules individually (to avoid ALSA errors) and hide mouse
10 | pygame.font.init()
11 | pygame.display.init()
12 | pygame.mouse.set_visible(0)
13 |
14 | # define function for printing text in a specific place with a specific width and height with a specific colour and border
15 | def make_button(text, xpo, ypo, height, width, colour):
16 | pygame.draw.rect(screen, tron_regular, (xpo-10,ypo-10,width,height),3)
17 | pygame.draw.rect(screen, tron_light, (xpo-9,ypo-9,width-1,height-1),1)
18 | pygame.draw.rect(screen, tron_regular, (xpo-8,ypo-8,width-2,height-2),1)
19 | font=pygame.font.Font(None,42)
20 | label=font.render(str(text), 1, (colour))
21 | screen.blit(label,(xpo,ypo))
22 |
23 | # define function for printing text in a specific place with a specific colour
24 | def make_label(text, xpo, ypo, fontsize, colour):
25 | font=pygame.font.Font(None,fontsize)
26 | label=font.render(str(text), 1, (colour))
27 | screen.blit(label,(xpo,ypo))
28 |
29 | # define function that checks for touch location
30 | def on_touch():
31 | # get the position that was touched
32 | touch_pos = (pygame.mouse.get_pos() [0], pygame.mouse.get_pos() [1])
33 | # x_min x_max y_min y_max
34 | # button 1 event
35 | if 30 <= touch_pos[0] <= 240 and 105 <= touch_pos[1] <=160:
36 | button(1)
37 | # button 2 event
38 | if 260 <= touch_pos[0] <= 470 and 105 <= touch_pos[1] <=160:
39 | button(2)
40 | # button 3 event
41 | if 30 <= touch_pos[0] <= 240 and 180 <= touch_pos[1] <=235:
42 | button(3)
43 | # button 4 event
44 | if 260 <= touch_pos[0] <= 470 and 180 <= touch_pos[1] <=235:
45 | button(4)
46 | # button 5 event
47 | if 30 <= touch_pos[0] <= 240 and 255 <= touch_pos[1] <=310:
48 | button(5)
49 | # button 6 event
50 | if 260 <= touch_pos[0] <= 470 and 255 <= touch_pos[1] <=310:
51 | button(6)
52 |
53 | # Get Your External IP Address
54 | def get_ip():
55 | ip_msg = "Not connected"
56 | try:
57 | s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
58 | s.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
59 | s.connect(('', 0))
60 | ip_msg=" IP: " + s.getsockname()[0]
61 | except Exception:
62 | pass
63 | return ip_msg
64 |
65 | # Restart Raspberry Pi
66 | def restart():
67 | command = "/usr/bin/sudo /sbin/shutdown -r now"
68 | process = Popen(command.split(), stdout=PIPE)
69 | output = process.communicate()[0]
70 | return output
71 |
72 | # Shutdown Raspberry Pi
73 | def shutdown():
74 | command = "/usr/bin/sudo /sbin/shutdown -h now"
75 | process = Popen(command.split(), stdout=PIPE)
76 | output = process.communicate()[0]
77 | return output
78 |
79 | def get_date():
80 | d = time.strftime("%a, %d %b %Y %H:%M:%S", time.localtime())
81 | return d
82 |
83 | def run_cmd(cmd):
84 | process = Popen(cmd.split(), stdout=PIPE)
85 | output = process.communicate()[0]
86 | return output
87 |
88 | def check_service(srvc):
89 | try:
90 | check = "/usr/sbin/service " + srvc + " status"
91 | status = run_cmd(check)
92 | if ("is running" in status) or ("active (running)") in status:
93 | return True
94 | else:
95 | return False
96 | except:
97 | return False
98 |
99 | def toggle_service(srvc):
100 | check = "/usr/sbin/service " + srvc + " status"
101 | start = "/usr/sbin/service " + srvc + " start"
102 | stop = "/usr/sbin/service " + srvc + " stop"
103 | status = run_cmd(check)
104 | if ("is running" in status) or ("active (running)") in status:
105 | run_cmd(stop)
106 | return False
107 | else:
108 | run_cmd(start)
109 | return True
110 |
111 | def check_vnc():
112 | if 'vnc :1' in commands.getoutput('/bin/ps -ef'):
113 | return True
114 | else:
115 | return False
116 |
117 | # Define each button press action
118 | def button(number):
119 | if number == 1:
120 | # Apache
121 | if toggle_service("apache2"):
122 | make_button(" WWW Server", 30, 105, 55, 210, green)
123 | else:
124 | make_button(" WWW Server", 30, 105, 55, 210, tron_light)
125 | return
126 |
127 | if number == 2:
128 | # Pure-ftpd
129 | if toggle_service("pure-ftpd"):
130 | make_button(" FTP Server", 260, 105, 55, 210, green)
131 | else:
132 | make_button(" FTP Server", 260, 105, 55, 210, tron_light)
133 | return
134 |
135 | if number == 3:
136 | # VNC Server
137 | if check_vnc():
138 | ## run_cmd("/usr/bin/sudo -u pi /usr/bin/vncserver -kill :1")
139 | run_cmd("/usr/bin/vncserver -kill :1")
140 | make_button(" VNC-Server", 30, 180, 55, 210, tron_light)
141 | else:
142 | ## run_cmd("/usr/bin/sudo -u pi /usr/bin/vncserver :1")
143 | run_cmd("/usr/bin/vncserver :1")
144 | make_button(" VNC-Server", 30, 180, 55, 210, green)
145 | return
146 |
147 | if number == 4:
148 | # msfconsole
149 | pygame.quit()
150 | process = subprocess.call("setterm -term linux -back default -fore white -clear all", shell=True)
151 | call("/usr/bin/msfconsole", shell=True)
152 | process = subprocess.call("setterm -term linux -back default -fore black -clear all", shell=True)
153 | os.execv(__file__, sys.argv)
154 |
155 | if number == 5:
156 | # Previous page
157 | pygame.quit()
158 | page=os.environ["MENUDIR"] + "menu_kali-2.py"
159 | os.execvp("python", ["python", page])
160 | sys.exit()
161 |
162 |
163 | if number == 6:
164 | # Next page
165 | pygame.quit()
166 | page=os.environ["MENUDIR"] + "menu_kali-4.py"
167 | os.execvp("python", ["python", page])
168 | sys.exit()
169 |
170 |
171 |
172 | # colors R G B
173 | white = (255, 255, 255)
174 | tron_whi = (189, 254, 255)
175 | red = (255, 0, 0)
176 | green = ( 0, 255, 0)
177 | blue = ( 0, 0, 255)
178 | tron_blu = ( 0, 219, 232)
179 | black = ( 0, 0, 0)
180 | cyan = ( 50, 255, 255)
181 | magenta = (255, 0, 255)
182 | yellow = (255, 255, 0)
183 | tron_yel = (255, 215, 10)
184 | orange = (255, 127, 0)
185 | tron_ora = (255, 202, 0)
186 |
187 | # Tron theme orange
188 | tron_regular = tron_ora
189 | tron_light = tron_yel
190 | tron_inverse = tron_whi
191 |
192 | # Tron theme blue
193 | ##tron_regular = tron_blu
194 | ##tron_light = tron_whi
195 | ##tron_inverse = tron_yel
196 |
197 | # Set up the base menu you can customize your menu with the colors above
198 |
199 | #set size of the screen
200 | size = width, height = 480, 320
201 | screen = pygame.display.set_mode(size)
202 |
203 | # Background Color
204 | screen.fill(black)
205 |
206 | # Outer Border
207 | pygame.draw.rect(screen, tron_regular, (0,0,479,319),8)
208 | pygame.draw.rect(screen, tron_light, (2,2,479-4,319-4),2)
209 |
210 | # Buttons and labels
211 | # First Row Label
212 | make_label(get_date(), 32, 30, 48, tron_inverse)
213 | # Second Row buttons 1 and 2
214 | if check_service("apache2"):
215 | make_button(" WWW Server", 30, 105, 55, 210, green)
216 | else:
217 | make_button(" WWW Server", 30, 105, 55, 210, tron_light)
218 | if check_service("pure-ftpd"):
219 | make_button(" FTP Server", 260, 105, 55, 210, green)
220 | else:
221 | make_button(" FTP Server", 260, 105, 55, 210, tron_light)
222 | # Third Row buttons 3 and 4
223 | if check_vnc():
224 | make_button(" VNC-Server", 30, 180, 55, 210, green)
225 | else:
226 | make_button(" VNC-Server", 30, 180, 55, 210, tron_light)
227 | make_button(" Metasploit ", 260, 180, 55, 210, tron_light)
228 | # Fourth Row Buttons
229 | make_button(" <<<", 30, 255, 55, 210, tron_light)
230 | make_button(" >>>", 260, 255, 55, 210, tron_light)
231 |
232 |
233 | #While loop to manage touch screen inputs
234 | while 1:
235 | for event in pygame.event.get():
236 | if event.type == pygame.MOUSEBUTTONDOWN:
237 | pos = (pygame.mouse.get_pos() [0], pygame.mouse.get_pos() [1])
238 | on_touch()
239 |
240 | #ensure there is always a safe way to end the program if the touch screen fails
241 | if event.type == KEYDOWN:
242 | if event.key == K_ESCAPE:
243 | sys.exit()
244 | pygame.display.update()
245 | ## Reduce CPU utilisation
246 | time.sleep(0.1)
247 |
--------------------------------------------------------------------------------
/menu_kali-4.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | import sys, os, pygame, subprocess, commands, time, socket
3 | from pygame.locals import *
4 | from subprocess import *
5 | os.environ["SDL_FBDEV"] = "/dev/fb1"
6 | os.environ["SDL_MOUSEDEV"] = "/dev/input/touchscreen"
7 | os.environ["SDL_MOUSEDRV"] = "TSLIB"
8 |
9 | # Initialize pygame modules individually (to avoid ALSA errors) and hide mouse
10 | pygame.font.init()
11 | pygame.display.init()
12 | pygame.mouse.set_visible(0)
13 |
14 | # define function for printing text in a specific place with a specific width and height with a specific colour and border
15 | def make_button(text, xpo, ypo, height, width, colour):
16 | pygame.draw.rect(screen, tron_regular, (xpo-10,ypo-10,width,height),3)
17 | pygame.draw.rect(screen, tron_light, (xpo-9,ypo-9,width-1,height-1),1)
18 | pygame.draw.rect(screen, tron_regular, (xpo-8,ypo-8,width-2,height-2),1)
19 | font=pygame.font.Font(None,42)
20 | label=font.render(str(text), 1, (colour))
21 | screen.blit(label,(xpo,ypo))
22 |
23 | # define function for printing text in a specific place with a specific colour
24 | def make_label(text, xpo, ypo, fontsize, colour):
25 | font=pygame.font.Font(None,fontsize)
26 | label=font.render(str(text), 1, (colour))
27 | screen.blit(label,(xpo,ypo))
28 |
29 | # define function that checks for touch location
30 | def on_touch():
31 | # get the position that was touched
32 | touch_pos = (pygame.mouse.get_pos() [0], pygame.mouse.get_pos() [1])
33 | # x_min x_max y_min y_max
34 | # button 1 event
35 | if 30 <= touch_pos[0] <= 240 and 105 <= touch_pos[1] <=160:
36 | button(1)
37 | # button 2 event
38 | if 260 <= touch_pos[0] <= 470 and 105 <= touch_pos[1] <=160:
39 | button(2)
40 | # button 3 event
41 | if 30 <= touch_pos[0] <= 240 and 180 <= touch_pos[1] <=235:
42 | button(3)
43 | # button 4 event
44 | if 260 <= touch_pos[0] <= 470 and 180 <= touch_pos[1] <=235:
45 | button(4)
46 | # button 5 event
47 | if 30 <= touch_pos[0] <= 240 and 255 <= touch_pos[1] <=310:
48 | button(5)
49 | # button 6 event
50 | if 260 <= touch_pos[0] <= 470 and 255 <= touch_pos[1] <=310:
51 | button(6)
52 |
53 | # Get Your External IP Address
54 | def get_ip():
55 | ip_msg = "Not connected"
56 | try:
57 | s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
58 | s.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
59 | s.connect(('', 0))
60 | ip_msg=" IP: " + s.getsockname()[0]
61 | except Exception:
62 | pass
63 | return ip_msg
64 |
65 | # Restart Raspberry Pi
66 | def restart():
67 | command = "/usr/bin/sudo /sbin/shutdown -r now"
68 | process = Popen(command.split(), stdout=PIPE)
69 | output = process.communicate()[0]
70 | return output
71 |
72 | # Shutdown Raspberry Pi
73 | def shutdown():
74 | command = "/usr/bin/sudo /sbin/shutdown -h now"
75 | process = Popen(command.split(), stdout=PIPE)
76 | output = process.communicate()[0]
77 | return output
78 |
79 | def get_date():
80 | d = time.strftime("%a, %d %b %Y %H:%M:%S", time.localtime())
81 | return d
82 |
83 | def run_cmd(cmd):
84 | process = Popen(cmd.split(), stdout=PIPE)
85 | output = process.communicate()[0]
86 | return output
87 |
88 | def check_service(srvc):
89 | try:
90 | check = "/usr/sbin/service " + srvc + " status"
91 | status = run_cmd(check)
92 | if ("is running" in status) or ("active (running)") in status:
93 | return True
94 | else:
95 | return False
96 | except:
97 | return False
98 |
99 | def toggle_service(srvc):
100 | check = "/usr/sbin/service " + srvc + " status"
101 | start = "/usr/sbin/service " + srvc + " start"
102 | stop = "/usr/sbin/service " + srvc + " stop"
103 | status = run_cmd(check)
104 | if ("is running" in status) or ("active (running)") in status:
105 | run_cmd(stop)
106 | return False
107 | else:
108 | run_cmd(start)
109 | return True
110 |
111 | def toggle_openvas():
112 | check = "/usr/sbin/service openvas-manager status"
113 | start = "/usr/bin/openvas-start"
114 | stop = "/usr/bin/openvas-stop"
115 | status = run_cmd(check)
116 | if ("is running" in status) or ("active (running)") in status:
117 | run_cmd(stop)
118 | return False
119 | else:
120 | run_cmd(start)
121 | return True
122 |
123 | def check_vnc():
124 | if 'vnc :1' in commands.getoutput('/bin/ps -ef'):
125 | return True
126 | else:
127 | return False
128 |
129 | # Define each button press action
130 | def button(number):
131 | if number == 1:
132 | # MySQL
133 | if toggle_service("mysql"):
134 | make_button(" MySQL", 30, 105, 55, 210, green)
135 | pygame.display.update()
136 | else:
137 | make_button(" MySQL", 30, 105, 55, 210, tron_light)
138 | pygame.display.update()
139 | return
140 |
141 | if number == 2:
142 | # snortbarn
143 | if toggle_service("snortbarn"):
144 | make_button(" Snort", 260, 105, 55, 210, green)
145 | pygame.display.update()
146 | else:
147 | make_button(" Snort", 260, 105, 55, 210, tron_light)
148 | pygame.display.update()
149 | return
150 |
151 | if number == 3:
152 | # Pulledpork
153 | pygame.quit()
154 | cmd="/usr/bin/sudo /bin/bash " + os.environ["MENUDIR"] + "pulledpork.sh"
155 | call(cmd, shell=True)
156 | ##run_cmd(cmd)
157 | os.execv(__file__, sys.argv)
158 |
159 | if number == 4:
160 | # openvas
161 | if toggle_openvas():
162 | make_button(" OpenVAS", 260, 180, 55, 210, green)
163 | pygame.display.update()
164 |
165 | else:
166 | make_button(" OpenVAS", 260, 180, 55, 210, tron_light)
167 | pygame.display.update()
168 | return
169 |
170 | if number == 5:
171 | # Previous page
172 | pygame.quit()
173 | page=os.environ["MENUDIR"] + "menu_kali-3.py"
174 | os.execvp("python", ["python", page])
175 | sys.exit()
176 |
177 |
178 | if number == 6:
179 | # Next page
180 | pygame.quit()
181 | page=os.environ["MENUDIR"] + "menu_kali-9.py"
182 | os.execvp("python", ["python", page])
183 | sys.exit()
184 |
185 |
186 |
187 | # colors R G B
188 | white = (255, 255, 255)
189 | tron_whi = (189, 254, 255)
190 | red = (255, 0, 0)
191 | green = ( 0, 255, 0)
192 | blue = ( 0, 0, 255)
193 | tron_blu = ( 0, 219, 232)
194 | black = ( 0, 0, 0)
195 | cyan = ( 50, 255, 255)
196 | magenta = (255, 0, 255)
197 | yellow = (255, 255, 0)
198 | tron_yel = (255, 215, 10)
199 | orange = (255, 127, 0)
200 | tron_ora = (255, 202, 0)
201 |
202 | # Tron theme orange
203 | ##tron_regular = tron_ora
204 | ##tron_light = tron_yel
205 | ##tron_inverse = tron_whi
206 |
207 | # Tron theme blue
208 | tron_regular = tron_blu
209 | tron_light = tron_whi
210 | tron_inverse = tron_yel
211 |
212 | # Set up the base menu you can customize your menu with the colors above
213 |
214 | #set size of the screen
215 | size = width, height = 480, 320
216 | screen = pygame.display.set_mode(size)
217 |
218 | # Background Color
219 | screen.fill(black)
220 |
221 | # Outer Border
222 | pygame.draw.rect(screen, tron_regular, (0,0,479,319),8)
223 | pygame.draw.rect(screen, tron_light, (2,2,479-4,319-4),2)
224 |
225 | # Buttons and labels
226 | # First Row Label
227 | make_label(get_date(), 32, 30, 48, tron_inverse)
228 | # Second Row buttons 1 and 2
229 | if check_service("mysql"):
230 | make_button(" MySQL", 30, 105, 55, 210, green)
231 | else:
232 | make_button(" MySQL", 30, 105, 55, 210, tron_light)
233 | if check_service("snortbarn"):
234 | make_button(" Snort", 260, 105, 55, 210, green)
235 | else:
236 | make_button(" Snort", 260, 105, 55, 210, tron_light)
237 | # Third Row buttons 3 and 4
238 | make_button(" PulledPork", 30, 180, 55, 210, tron_light)
239 | if check_service("openvas-manager"):
240 | make_button(" OpenVAS", 260, 180, 55, 210, green)
241 | else:
242 | make_button(" OpenVAS", 260, 180, 55, 210, tron_light)
243 | # Fourth Row Buttons
244 | make_button(" <<<", 30, 255, 55, 210, tron_light)
245 | make_button(" >>>", 260, 255, 55, 210, tron_light)
246 |
247 |
248 | #While loop to manage touch screen inputs
249 | while 1:
250 | for event in pygame.event.get():
251 | if event.type == pygame.MOUSEBUTTONDOWN:
252 | pos = (pygame.mouse.get_pos() [0], pygame.mouse.get_pos() [1])
253 | on_touch()
254 |
255 | #ensure there is always a safe way to end the program if the touch screen fails
256 | if event.type == KEYDOWN:
257 | if event.key == K_ESCAPE:
258 | sys.exit()
259 | pygame.display.update()
260 | ## Reduce CPU utilisation
261 | time.sleep(0.1)
262 |
--------------------------------------------------------------------------------
/menu_kali-9.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | import sys, os, subprocess, time, pygame
3 | from pygame.locals import *
4 | from subprocess import *
5 | os.environ["SDL_FBDEV"] = "/dev/fb1"
6 | os.environ["SDL_MOUSEDEV"] = "/dev/input/touchscreen"
7 | os.environ["SDL_MOUSEDRV"] = "TSLIB"
8 |
9 | # Initialize pygame modules individually (to avoid ALSA errors) and hide mouse
10 | pygame.font.init()
11 | pygame.display.init()
12 | pygame.mouse.set_visible(0)
13 |
14 | # define function for printing text in a specific place with a specific width and height with a specific colour and border
15 | def make_button(text, xpo, ypo, height, width, colour):
16 | pygame.draw.rect(screen, tron_regular, (xpo-10,ypo-10,width,height),3)
17 | pygame.draw.rect(screen, tron_light, (xpo-9,ypo-9,width-1,height-1),1)
18 | pygame.draw.rect(screen, tron_regular, (xpo-8,ypo-8,width-2,height-2),1)
19 | font=pygame.font.Font(None,42)
20 | label=font.render(str(text), 1, (colour))
21 | screen.blit(label,(xpo,ypo))
22 |
23 |
24 | # define function for printing text in a specific place with a specific colour
25 | def make_label(text, xpo, ypo, fontsize, colour):
26 | font=pygame.font.Font(None,fontsize)
27 | label=font.render(str(text), 1, (colour))
28 | screen.blit(label,(xpo,ypo))
29 |
30 | # define function that checks for touch location
31 | def on_touch():
32 | # get the position that was touched
33 | touch_pos = (pygame.mouse.get_pos() [0], pygame.mouse.get_pos() [1])
34 | # x_min x_max y_min y_max
35 | # button 1 event
36 | ## if 30 <= touch_pos[0] <= 240 and 105 <= touch_pos[1] <=160:
37 | ## button(1)
38 | # button 2 event
39 | ## if 260 <= touch_pos[0] <= 470 and 105 <= touch_pos[1] <=160:
40 | ## button(2)
41 | # button 3 event
42 | ## if 30 <= touch_pos[0] <= 240 and 180 <= touch_pos[1] <=235:
43 | ## button(3)
44 | # button 4 event
45 | ## if 260 <= touch_pos[0] <= 470 and 180 <= touch_pos[1] <=235:
46 | ## button(4)
47 | # button 5 event
48 | if 30 <= touch_pos[0] <= 240 and 255 <= touch_pos[1] <=310:
49 | button(5)
50 | # button 6 event
51 | if 260 <= touch_pos[0] <= 470 and 255 <= touch_pos[1] <=310:
52 | button(6)
53 |
54 | # Get time and date
55 |
56 | def get_temp():
57 | command = "vcgencmd measure_temp"
58 | process = Popen(command.split(), stdout=PIPE)
59 | output = process.communicate()[0]
60 | temp = 'Temp: ' + output[5:-1]
61 | return temp
62 |
63 | def get_clock():
64 | command = "vcgencmd measure_clock arm"
65 | process = Popen(command.split(), stdout=PIPE)
66 | output = process.communicate()[0]
67 | clock = output.split("=")
68 | clock = int(clock[1][:-1]) / 1024 /1024
69 | clock = 'Clock: ' + str(clock) + "MHz"
70 | return clock
71 |
72 | def get_volts():
73 | command = "vcgencmd measure_volts"
74 | process = Popen(command.split(), stdout=PIPE)
75 | output = process.communicate()[0]
76 | volts = 'Core: ' + output[5:-1]
77 | return volts
78 |
79 | def run_cmd(cmd):
80 | process = Popen(cmd.split(), stdout=PIPE)
81 | output = process.communicate()[0]
82 | return output
83 |
84 | # Define each button press action
85 | def button(number):
86 | if number == 5:
87 | # Previous page
88 | pygame.quit()
89 | page=os.environ["MENUDIR"] + "menu_kali-4.py"
90 | os.execvp("python", ["python", page])
91 | sys.exit()
92 |
93 |
94 | if number == 6:
95 | # Refresh
96 | pygame.quit()
97 | os.execv(__file__, sys.argv)
98 |
99 |
100 | # colors R G B
101 | white = (255, 255, 255)
102 | tron_whi = (189, 254, 255)
103 | red = (255, 0, 0)
104 | green = ( 0, 255, 0)
105 | blue = ( 0, 0, 255)
106 | tron_blu = ( 0, 219, 232)
107 | black = ( 0, 0, 0)
108 | cyan = ( 50, 255, 255)
109 | magenta = (255, 0, 255)
110 | yellow = (255, 255, 0)
111 | tron_yel = (255, 218, 10)
112 | orange = (255, 127, 0)
113 | tron_ora = (255, 202, 0)
114 |
115 | # Tron theme orange
116 | tron_regular = tron_ora
117 | tron_light = tron_yel
118 | tron_inverse = tron_whi
119 |
120 | # Tron theme blue
121 | ##tron_regular = tron_blu
122 | ##tron_light = tron_whi
123 | ##tron_inverse = tron_yel
124 | # Set up the base menu you can customize your menu with the colors above
125 |
126 | #set size of the screen
127 | size = width, height = 480, 320
128 | screen = pygame.display.set_mode(size)
129 |
130 | # Background Color
131 | screen.fill(black)
132 |
133 | # Outer Border
134 | pygame.draw.rect(screen, tron_regular, (0,0,479,319),8)
135 | pygame.draw.rect(screen, tron_light, (2,2,479-4,319-4),2)
136 |
137 | # Buttons and labels
138 | # First Row Label
139 | make_label(get_temp(), 32, 30, 48, tron_inverse)
140 |
141 | # Second Row buttons 1 and 2
142 | make_label(get_clock(), 32, 105, 48, tron_inverse)
143 | ## make_button(" Kismet", 30, 105, 55, 210, tron_light)
144 | ## make_button(" SDR-Scanner", 260, 105, 55, 210, tron_light)
145 | # Third Row buttons 3 and 4
146 | make_label(get_volts(), 32, 180, 48, tron_inverse)
147 | ## make_button(" Shutdown", 30, 180, 55, 210, tron_light)
148 | ## make_button(" Reboot", 260, 180, 55, 210, tron_light)
149 | # Fourth Row Buttons
150 | make_button(" <<<", 30, 255, 55, 210, tron_light)
151 | make_button(" Refresh", 260, 255, 55, 210, tron_light)
152 |
153 |
154 | #While loop to manage touch screen inputs
155 | while 1:
156 | for event in pygame.event.get():
157 | if event.type == pygame.MOUSEBUTTONDOWN:
158 | pos = (pygame.mouse.get_pos() [0], pygame.mouse.get_pos() [1])
159 | on_touch()
160 |
161 | #ensure there is always a safe way to end the program if the touch screen fails
162 | if event.type == KEYDOWN:
163 | if event.key == K_ESCAPE:
164 | sys.exit()
165 | pygame.display.update()
166 | ## Reduce CPU utilisation
167 | time.sleep(0.1)
168 |
--------------------------------------------------------------------------------
/menu_kali_2.8/Kali-Pi-2.8.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Re4son/pitftmenu/120f22c5e2fe2204e007a84e70f1ead9e06eea93/menu_kali_2.8/Kali-Pi-2.8.jpg
--------------------------------------------------------------------------------
/menu_pause.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | import pygame, os, sys, subprocess, time
3 | import RPi.GPIO as GPIO
4 | from pygame.locals import *
5 | from subprocess import *
6 | os.environ["SDL_FBDEV"] = "/dev/fb1"
7 | os.environ["SDL_MOUSEDEV"] = "/dev/input/touchscreen"
8 | os.environ["SDL_MOUSEDRV"] = "TSLIB"
9 |
10 | # Initialize pygame modules individually (to avoid ALSA errors) and hide mouse
11 | pygame.font.init()
12 | pygame.display.init()
13 | pygame.mouse.set_visible(0)
14 |
15 | # Initialise GPIO
16 | GPIO.setwarnings(False)
17 |
18 |
19 | #While loop to manage touch screen inputs
20 | while 1:
21 | for event in pygame.event.get():
22 | if event.type == pygame.MOUSEBUTTONDOWN:
23 | sys.exit()
24 |
25 | #ensure there is always a safe way to end the program if the touch screen fails
26 | if event.type == KEYDOWN:
27 | if event.key == K_ESCAPE:
28 | sys.exit()
29 | time.sleep(0.4)
30 |
--------------------------------------------------------------------------------
/menu_pigrrl.py:
--------------------------------------------------------------------------------
1 | import sys, pygame, socket
2 | from pygame.locals import *
3 | import time
4 | import subprocess
5 | import os
6 | import RPi.GPIO
7 | from subprocess import *
8 | os.environ["SDL_FBDEV"] = "/dev/fb1"
9 | os.environ["SDL_MOUSEDEV"] = "/dev/input/touchscreen"
10 | os.environ["SDL_MOUSEDRV"] = "TSLIB"
11 |
12 | #
13 |
14 | # Initialize pygame and hide mouse
15 | pygame.init()
16 | pygame.mouse.set_visible(0)
17 |
18 | # define function for printing text in a specific place with a specific width and height with a specific colour and border
19 | def make_button(text, xpo, ypo, height, width, colour):
20 | font=pygame.font.Font(None,30)
21 | label=font.render(str(text), 1, (colour))
22 | screen.blit(label,(xpo,ypo+8))
23 | pygame.draw.rect(screen, blue, (xpo-5,ypo-5,width,height),5)
24 |
25 | # define function for printing text in a specific place with a specific colour
26 | def make_label(text, xpo, ypo, fontsize, colour):
27 | font=pygame.font.Font(None,fontsize)
28 | label=font.render(str(text), 1, (colour))
29 | screen.blit(label,(xpo,ypo))
30 |
31 | # define function that checks for touch location
32 | def on_touch():
33 | # get the position that was touched
34 | touch_pos = (pygame.mouse.get_pos() [0], pygame.mouse.get_pos() [1])
35 | # x_min x_max y_min y_max
36 | # button 1 event
37 | if 10 <= touch_pos[0] <= 155 and 65 <= touch_pos[1] <=105:
38 | button(1)
39 | # button 2 event
40 | if 165 <= touch_pos[0] <= 310 and 65 <= touch_pos[1] <=105:
41 | button(2)
42 | # button 3 event
43 | if 10 <= touch_pos[0] <= 155 and 125 <= touch_pos[1] <=165:
44 | button(3)
45 | # button 4 event
46 | if 165 <= touch_pos[0] <= 310 and 125 <= touch_pos[1] <=165:
47 | button(4)
48 | # button 5 event
49 | if 10 <= touch_pos[0] <= 155 and 185 <= touch_pos[1] <=230:
50 | button(5)
51 | # button 6 event
52 | if 165 <= touch_pos[0] <= 310 and 185 <= touch_pos[1] <=230:
53 | button(6)
54 |
55 | # Get Your External IP Address
56 | def get_ip():
57 | ip_msg = "Not connected"
58 | try:
59 | s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
60 | s.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
61 | s.connect(('', 0))
62 | ip_msg="IP:" + s.getsockname()[0]
63 | except Exception:
64 | pass
65 | return ip_msg
66 |
67 | # Restart Raspberry Pi
68 | def restart():
69 | command = "/usr/bin/sudo /sbin/shutdown -r now"
70 | process = Popen(command.split(), stdout=PIPE)
71 | output = process.communicate()[0]
72 | return output
73 |
74 | # Shutdown Raspberry Pi
75 | def shutdown():
76 | command = "/usr/bin/sudo /sbin/shutdown -h now"
77 | process = Popen(command.split(), stdout=PIPE)
78 | output = process.communicate()[0]
79 | return output
80 |
81 | def run_cmd(cmd):
82 | process = Popen(cmd.split(), stdout=PIPE)
83 | output = process.communicate()[0]
84 | return output
85 |
86 | # Define each button press action
87 | def button(number):
88 | print "You pressed button ",number
89 |
90 | if number == 1:
91 | # desktop
92 | screen.fill(black)
93 | font=pygame.font.Font(None,48)
94 | label=font.render("Launching Desktop", 1, (white))
95 | screen.blit(label,(10,110))
96 | pygame.display.flip()
97 | pygame.quit()
98 | subprocess.call("FRAMEBUFFER=/dev/fb1 startx", shell=True)
99 | #run_cmd("FRAMEBUFFER=/dev/fb1 startx")
100 | sys.exit()
101 |
102 | if number == 2:
103 | # exit
104 | screen.fill(black)
105 | font=pygame.font.Font(None,48)
106 | label=font.render("Exiting to Terminal", 1, (white))
107 | screen.blit(label,(10,110))
108 | pygame.display.flip()
109 | pygame.quit()
110 | sys.exit()
111 |
112 | if number == 3:
113 | # Emulation Station
114 | screen.fill(black)
115 | font=pygame.font.Font(None,48)
116 | label=font.render("Emulation Station Loading. .", 1, (white))
117 | screen.blit(label,(20,110))
118 | pygame.display.flip()
119 | pygame.quit()
120 | os.system("emulationstation")
121 | sys.exit()
122 |
123 | if number == 4:
124 | # Wifi Settings
125 | screen.fill(black)
126 | font=pygame.font.Font(None,48)
127 | label=font.render("WiFi Settings. .", 1, (white))
128 | screen.blit(label,(20,120))
129 | pygame.display.flip()
130 | pygame.quit()
131 | os.system("sudo python /home/pi/pifi.py/pifi.py --gui")
132 | sys.exit()
133 |
134 | if number == 5:
135 | # reboot
136 | screen.fill(black)
137 | font=pygame.font.Font(None,48)
138 | label=font.render("Rebooting. .", 1, (white))
139 | screen.blit(label,(40,110))
140 | pygame.display.flip()
141 | pygame.quit()
142 | restart()
143 | sys.exit()
144 |
145 | if number == 6:
146 | # shutdown
147 | screen.fill(black)
148 | font=pygame.font.Font(None,48)
149 | label=font.render("Shutting Down. .", 1, (white))
150 | screen.blit(label,(20,110))
151 | pygame.display.flip()
152 | pygame.quit()
153 | shutdown()
154 | sys.exit()
155 |
156 |
157 |
158 | # colors R G B
159 | white = (255, 255, 255)
160 | red = (255, 0, 0)
161 | green = ( 0, 255, 0)
162 | blue = ( 0, 0, 255)
163 | black = ( 0, 0, 0)
164 | cyan = ( 50, 255, 255)
165 | magenta = (255, 0, 255)
166 | yellow = (255, 255, 0)
167 | orange = (255, 127, 0)
168 |
169 | # Set up the base menu you can customize your menu with the colors above
170 |
171 | #set size of the screen
172 | size = width, height = 320, 240
173 |
174 | screen = pygame.display.set_mode(size)
175 |
176 | # Background Color
177 | screen.fill(black)
178 |
179 | # Outer Border
180 | pygame.draw.rect(screen, blue, (0,0,320,240),5)
181 | pi_hostname = run_cmd("hostname")
182 | pi_hostname = pi_hostname[:-1]
183 | # Buttons and labels
184 | # First Row Label
185 | make_label(pi_hostname + " - " + get_ip(), 20, 20, 36, blue)
186 | # Second Row buttons 3 and 4
187 | make_button(" Desktop", 15, 65, 50, 145, blue)
188 | make_button(" Terminal", 170, 65, 50, 145, blue)
189 | # Third Row buttons 5 and 6
190 | make_button(" Games", 15, 125, 50, 145, blue)
191 | make_button(" WiFi Setup", 170, 125, 50, 145, blue)
192 | # Fourth Row Buttons
193 | make_button(" Reboot", 15, 185, 50, 145, blue)
194 | make_button(" Shutdown", 170, 185, 50, 145, blue)
195 |
196 | # LBO Pin from Powerboost
197 | RPi.GPIO.setmode (RPi.GPIO.BCM)
198 | RPi.GPIO.setup(21, RPi.GPIO.IN, pull_up_down=RPi.GPIO.PUD_UP)
199 |
200 |
201 | #While loop to manage touch screen inputs
202 | while 1:
203 | for event in pygame.event.get():
204 | if event.type == pygame.MOUSEBUTTONDOWN:
205 | pos = (pygame.mouse.get_pos() [0], pygame.mouse.get_pos() [1])
206 | on_touch()
207 |
208 | #ensure there is always a safe way to end the program if the touch screen fails
209 | if event.type == KEYDOWN:
210 | if event.key == K_ESCAPE:
211 | sys.exit()
212 | pygame.display.update()
213 |
214 | if RPi.GPIO.input(21) == RPi.GPIO.LOW:
215 | screen.fill(black)
216 | font=pygame.font.Font(None,48)
217 | label=font.render("Battery Low, Shutting down", 1, (white))
218 | screen.blit(label,(20,120))
219 | pygame.display.flip()
220 | time.sleep(10)
221 | pygame.quit()
222 | shutdown()
223 | sys.exit()
224 |
--------------------------------------------------------------------------------
/menu_screenoff.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | import pygame, os, sys, subprocess, time
3 | import RPi.GPIO as GPIO
4 | from pygame.locals import *
5 | from subprocess import *
6 | os.environ["SDL_FBDEV"] = "/dev/fb1"
7 | os.environ["SDL_MOUSEDEV"] = "/dev/input/touchscreen"
8 | os.environ["SDL_MOUSEDRV"] = "TSLIB"
9 | launch_bg=os.environ["MENUDIR"] + "launch-bg.sh"
10 | process = subprocess.call(launch_bg, shell=True)
11 |
12 | # Initialize pygame modules individually (to avoid ALSA errors) and hide mouse
13 | pygame.font.init()
14 | pygame.display.init()
15 | pygame.mouse.set_visible(0)
16 |
17 | # Initialise GPIO
18 | GPIO.setmode(GPIO.BCM)
19 | GPIO.setup(18, GPIO.OUT)
20 |
21 |
22 | def run_cmd(cmd):
23 | process = Popen(cmd.split(), stdout=PIPE)
24 | output = process.communicate()[0]
25 | return output
26 |
27 | # Turn screen on
28 | def screen_on():
29 | pygame.quit()
30 | backlight = GPIO.PWM(18, 1023)
31 | backlight.start(100)
32 | GPIO.cleanup()
33 | page=os.environ["MENUDIR"] + "menu_kali-1.py"
34 | os.execvp("python", ["python", page])
35 |
36 |
37 | # Turn screen off
38 | def screen_off():
39 | backlight = GPIO.PWM(18, 0.1)
40 | backlight.start(0)
41 | process = subprocess.call("setterm -term linux -back black -fore black -clear all", shell=True)
42 |
43 |
44 | #While loop to manage touch screen inputs
45 | screen_off()
46 | while 1:
47 | for event in pygame.event.get():
48 | if event.type == pygame.MOUSEBUTTONDOWN:
49 | screen_on()
50 |
51 | #ensure there is always a safe way to end the program if the touch screen fails
52 | if event.type == KEYDOWN:
53 | if event.key == K_ESCAPE:
54 | sys.exit()
55 | time.sleep(0.4)
56 |
--------------------------------------------------------------------------------
/menu_touchpi.py:
--------------------------------------------------------------------------------
1 | import sys, pygame, socket
2 | from pygame.locals import *
3 | import time
4 | import subprocess
5 | import os
6 | import RPi.GPIO
7 | from subprocess import *
8 | os.environ["SDL_FBDEV"] = "/dev/fb1"
9 | os.environ["SDL_MOUSEDEV"] = "/dev/input/touchscreen"
10 | os.environ["SDL_MOUSEDRV"] = "TSLIB"
11 |
12 | # Initialize pygame and hide mouse
13 | pygame.init()
14 | pygame.mouse.set_visible(0)
15 |
16 | # define function for printing text in a specific place with a specific width and height with a specific colour and border
17 | def make_button(text, xpo, ypo, height, width, colour):
18 | font=pygame.font.Font(None,42)
19 | label=font.render(str(text), 1, (colour))
20 | screen.blit(label,(xpo,ypo))
21 | pygame.draw.rect(screen, blue, (xpo-10,ypo-10,width,height),5)
22 |
23 | # define function for printing text in a specific place with a specific colour
24 | def make_label(text, xpo, ypo, fontsize, colour):
25 | font=pygame.font.Font(None,fontsize)
26 | label=font.render(str(text), 1, (colour))
27 | screen.blit(label,(xpo,ypo))
28 |
29 | # define function that checks for touch location
30 | def on_touch():
31 | # get the position that was touched
32 | touch_pos = (pygame.mouse.get_pos() [0], pygame.mouse.get_pos() [1])
33 | # x_min x_max y_min y_max
34 | # button 1 event
35 | if 30 <= touch_pos[0] <= 240 and 105 <= touch_pos[1] <=160:
36 | button(1)
37 | # button 2 event
38 | if 260 <= touch_pos[0] <= 470 and 105 <= touch_pos[1] <=160:
39 | button(2)
40 | # button 3 event
41 | if 30 <= touch_pos[0] <= 240 and 180 <= touch_pos[1] <=235:
42 | button(3)
43 | # button 4 event
44 | if 260 <= touch_pos[0] <= 470 and 180 <= touch_pos[1] <=235:
45 | button(4)
46 | # button 5 event
47 | if 30 <= touch_pos[0] <= 240 and 255 <= touch_pos[1] <=310:
48 | button(5)
49 | # button 6 event
50 | if 260 <= touch_pos[0] <= 470 and 255 <= touch_pos[1] <=310:
51 | button(6)
52 |
53 | # Get Your External IP Address
54 | def get_ip():
55 | ip_msg = "Not connected"
56 | try:
57 | s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
58 | s.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
59 | s.connect(('', 0))
60 | ip_msg="IP:" + s.getsockname()[0]
61 | except Exception:
62 | pass
63 | return ip_msg
64 |
65 | # Restart Raspberry Pi
66 | def restart():
67 | command = "/usr/bin/sudo /sbin/shutdown -r now"
68 | process = Popen(command.split(), stdout=PIPE)
69 | output = process.communicate()[0]
70 | return output
71 |
72 | # Shutdown Raspberry Pi
73 | def shutdown():
74 | command = "/usr/bin/sudo /sbin/shutdown -h now"
75 | process = Popen(command.split(), stdout=PIPE)
76 | output = process.communicate()[0]
77 | return output
78 |
79 | def get_temp():
80 | command = "vcgencmd measure_temp"
81 | process = Popen(command.split(), stdout=PIPE)
82 | output = process.communicate()[0]
83 | return output
84 |
85 | def run_cmd(cmd):
86 | process = Popen(cmd.split(), stdout=PIPE)
87 | output = process.communicate()[0]
88 | return output
89 |
90 | # Define each button press action
91 | def button(number):
92 | print "You pressed button ",number
93 |
94 | if number == 1:
95 | # desktop
96 | screen.fill(black)
97 | font=pygame.font.Font(None,72)
98 | label=font.render("Launching Desktop", 1, (white))
99 | screen.blit(label,(10,120))
100 | pygame.display.flip()
101 | pygame.quit()
102 | subprocess.call("FRAMEBUFFER=/dev/fb1 startx", shell=True)
103 | #run_cmd("FRAMEBUFFER=/dev/fb1 startx")
104 | sys.exit()
105 |
106 | if number == 2:
107 | # exit
108 | screen.fill(black)
109 | font=pygame.font.Font(None,72)
110 | label=font.render("Exiting to Terminal", 1, (white))
111 | screen.blit(label,(10,120))
112 | pygame.display.flip()
113 | pygame.quit()
114 | sys.exit()
115 |
116 | if number == 3:
117 | # Pretend Shutdown
118 | screen.fill(black)
119 | font=pygame.font.Font(None,48)
120 | label=font.render("Battery Low, Shutting down", 1, (white))
121 | screen.blit(label,(20,120))
122 | pygame.display.flip()
123 | time.sleep(120)
124 | pygame.quit()
125 | sys.exit()
126 |
127 | if number == 4:
128 | # Wifi Settings
129 | screen.fill(black)
130 | font=pygame.font.Font(None,72)
131 | label=font.render("WiFi Settings. .", 1, (white))
132 | screen.blit(label,(20,120))
133 | pygame.display.flip()
134 | pygame.quit()
135 | os.system("sudo python /home/pi/pifi.py/pifi.py --gui")
136 | sys.exit()
137 |
138 | if number == 5:
139 | # reboot
140 | screen.fill(black)
141 | font=pygame.font.Font(None,72)
142 | label=font.render("Rebooting. .", 1, (white))
143 | screen.blit(label,(40,120))
144 | pygame.display.flip()
145 | pygame.quit()
146 | restart()
147 | sys.exit()
148 |
149 | if number == 6:
150 | # shutdown
151 | screen.fill(black)
152 | font=pygame.font.Font(None,72)
153 | label=font.render("Shutting Down. .", 1, (white))
154 | screen.blit(label,(20,120))
155 | pygame.display.flip()
156 | pygame.quit()
157 | shutdown()
158 | sys.exit()
159 |
160 |
161 |
162 | # colors R G B
163 | white = (255, 255, 255)
164 | red = (255, 0, 0)
165 | green = ( 0, 255, 0)
166 | blue = ( 0, 0, 255)
167 | black = ( 0, 0, 0)
168 | cyan = ( 50, 255, 255)
169 | magenta = (255, 0, 255)
170 | yellow = (255, 255, 0)
171 | orange = (255, 127, 0)
172 |
173 | # Set up the base menu you can customize your menu with the colors above
174 |
175 | #set size of the screen
176 | size = width, height = 480, 320
177 | screen = pygame.display.set_mode(size)
178 |
179 | # Background Color
180 | screen.fill(black)
181 |
182 | # Outer Border
183 | pygame.draw.rect(screen, blue, (0,0,480,320),10)
184 | pi_hostname = run_cmd("hostname")
185 | pi_hostname = pi_hostname[:-1]
186 | # Buttons and labels
187 | # First Row Label
188 | make_label(pi_hostname + " - " + get_ip(), 32, 30, 48, blue)
189 | # Second Row buttons 3 and 4
190 | make_button(" Desktop", 30, 105, 55, 210, blue)
191 | make_button(" Terminal", 260, 105, 55, 210, blue)
192 | # Third Row buttons 5 and 6
193 | make_button(" Empty Button", 30, 180, 55, 210, blue)
194 | make_button(" WiFi Settings", 260, 180, 55, 210, blue)
195 | # Fourth Row Buttons
196 | make_button(" Reboot", 30, 255, 55, 210, blue)
197 | make_button(" Shutdown", 260, 255, 55, 210, blue)
198 |
199 | # LBO Pin from Powerboost
200 | RPi.GPIO.setmode (RPi.GPIO.BCM)
201 | RPi.GPIO.setup(21, RPi.GPIO.IN, pull_up_down=RPi.GPIO.PUD_UP)
202 |
203 |
204 | #While loop to manage touch screen inputs
205 | while 1:
206 | for event in pygame.event.get():
207 | if event.type == pygame.MOUSEBUTTONDOWN:
208 | pos = (pygame.mouse.get_pos() [0], pygame.mouse.get_pos() [1])
209 | on_touch()
210 |
211 | #ensure there is always a safe way to end the program if the touch screen fails
212 | if event.type == KEYDOWN:
213 | if event.key == K_ESCAPE:
214 | sys.exit()
215 | pygame.display.update()
216 |
217 | if RPi.GPIO.input(21) == RPi.GPIO.LOW:
218 | screen.fill(black)
219 | font=pygame.font.Font(None,48)
220 | label=font.render("Battery Low, Shutting down", 1, (white))
221 | screen.blit(label,(20,120))
222 | pygame.display.flip()
223 | time.sleep(10)
224 | pygame.quit()
225 | shutdown()
226 | sys.exit()
227 |
--------------------------------------------------------------------------------
/pulledpork.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | script="/home/pi/pitftmenu/menu_pause.py"
3 | setterm -term linux -back default -fore white -clear all
4 | /usr/bin/env perl /usr/local/bin/pulledpork.pl -c /usr/local/etc/snort/pulledpork.conf -lT
5 | /usr/bin/env python $script
6 | setterm -term linux -back default -fore black -clear all
7 |
--------------------------------------------------------------------------------
/sdr-scanner.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | cd /home/pi/FreqShow/
3 | sudo python freqshow.py
4 |
--------------------------------------------------------------------------------