def verifyPin(): global pin, c if pin == "": retPage = kalipi.get_retPage() kalipi.screensaver(retPage) menuPin() elif pin == "111": pygame.quit() page = os.environ["MENUDIR"] + "menu-9p.py" retPage = kalipi.get_retPage() args = [page, retPage] os.execvp("python", ["python"] + args) sys.exit() elif pin == "110": pygame.quit() kalipi.run_cmd("/usr/bin/sudo /sbin/shutdown -h now") sys.exit() else: file = ".kalipi" pinFile = os.environ["MENUDIR"] + ".kalipi" file_conn = open(pinFile) file_pin = file_conn.readline()[:-1] file_conn.close() hashed_pin = hashlib.sha512(file + pin).hexdigest() if file_pin == hashed_pin: pygame.quit() launch_bg = os.environ["MENUDIR"] + "launch-bg.sh" process = subprocess.call(launch_bg, shell=True) retPage = kalipi.get_retPage() page = os.environ["MENUDIR"] + retPage args = [page] os.execvp("python", ["python"] + args) sys.exit() else: pin = "" c = 0 return
def menuPin(argv): global c # Init screen kalipi.screen() # Outer Border kalipi.border(tron_blu) ############################# ## Buttons ## # Buttons and labels # See variables at the top of the document to adjust the menu # Title titleButton.draw() # First Row # Button 1 button1.disable = 0 # "1" disables button if button1.disable == 1: button1.draw() else: # Add button launch code here button1.draw() # Button 2 button2.disable = 0 # "1" disables button if button2.disable == 1: button2.draw() else: # Add button launch code here button2.draw() # Button 3 button3.disable = 0 # "1" disables button if button3.disable == 1: button3.draw() else: # Add button launch code here button3.draw() # Second Row # Button 4 button4.disable = 0 # "1" disables button if button4.disable == 1: button4.draw() else: # Add button launch code here button4.draw() # Button 5 button5.disable = 0 # "1" disables button if button5.disable == 1: button5.draw() else: # Add button launch code here button5.draw() # Button 6 button6.disable = 0 # "1" disables button if button6.disable == 1: button6.draw() else: # Add button launch code here button6.draw() # Third Row # Button 7 button7.disable = 0 # "1" disables button if button7.disable == 1: button7.draw() else: # Add button launch code here button7.draw() # Button 8 button8.disable = 0 # "1" disables button if button8.disable == 1: button8.draw() else: # Add button launch code here button8.draw() # Button 9 button9.disable = 0 # "1" disables button if button9.disable == 1: button9.draw() else: # Add button launch code here button9.draw() # Button c buttonc.disable = 0 # "1" disables button if buttonc.disable == 1: buttonc.draw() else: # Add button launch code here buttonc.draw() # Button 0 button0.disable = 0 # "1" disables button if button0.disable == 1: button0.draw() else: # Add button launch code here button0.draw() # Button e buttone.disable = 0 # "1" disables button if buttone.disable == 1: buttone.draw() else: # Add button launch code here buttone.draw() ## Buttons ## ############################# ############################# ## Input loop ## if "KPTIMEOUT" in os.environ: timeout = float( os.environ["KPTIMEOUT"]) * 60 / 3 # Convert timeout to seconds #While loop to manage touch screen inputs t = timeout while True: for event in pygame.event.get(): if event.type == pygame.MOUSEBUTTONDOWN: t = timeout pos = (pygame.mouse.get_pos()[0], pygame.mouse.get_pos()[1]) num = local_on_touch() button(num) if c > 0: pygame.draw.rect(screen.canvas, black, (newOriginX, newOriginX, buttonWidth * 3, buttonHeight), 0) new_titleButton = Button(" " + c * "* ", newOriginX, newOriginX, buttonHeight, buttonWidth * 3 + spacing * 2, tron_blu, green, newTitleFont * 2) new_titleButton.draw() if c > 15: c = 0 else: pygame.draw.rect(screen.canvas, black, (newOriginX, newOriginX, buttonWidth * 3, buttonHeight), 0) titleButton.draw() #Debug: #ensure there is always a safe way to end the program if the touch screen fails ##if event.type == KEYDOWN: ## if event.key == K_ESCAPE: ## sys.exit() pygame.display.update() ## Reduce CPU utilisation time.sleep(0.1) t = t - 0.1 if t <= 0: break ## Screensaver retPage = kalipi.get_retPage() kalipi.screensaver(retPage) menuPin() else: #While loop to manage touch screen inputs while True: for event in pygame.event.get(): if event.type == pygame.MOUSEBUTTONDOWN: pos = (pygame.mouse.get_pos()[0], pygame.mouse.get_pos()[1]) num = local_on_touch() button(num) if c > 0: pygame.draw.rect(screen, black, (newOriginX, newOriginX, buttonWidth * 3, buttonHeight), 0) new_titleButton = Button(" " + c * "* ", newOriginX, newOriginX, buttonHeight, buttonWidth * 3 + spacing * 2, green, newTitleFont * 2) make_button(new_titleButton) if c > 15: c = 0 else: pygame.draw.rect(screen, black, (newOriginX, newOriginX, buttonWidth * 3, buttonHeight), 0) make_button(titleButton) #Debug: #ensure there is always a safe way to end the program if the touch screen fails ## if event.type == KEYDOWN: ## if event.key == K_ESCAPE: ## sys.exit() pygame.display.update() ## Reduce CPU utilisation time.sleep(0.1)
def button(number): if number == 1: if button1.disable == 1: return # Exit process = subprocess.call("setterm -term linux -back default -fore white -clear all", shell=True) pygame.quit() sys.exit(37) if number == 2: if button2.disable == 1: return # X TFT pygame.quit() ## Requires "Anybody" in dpkg-reconfigure x11-common if we have scrolled pages previously ## kalipi.run_cmd("/usr/bin/sudo -u pi FRAMEBUFFER=/dev/fb1 startx") kalipi.run_cmd("/usr/bin/sudo FRAMEBUFFER=/dev/fb1 startx") os.execv(__file__, sys.argv) if number == 3: if button3.disable == 1: return # X HDMI pygame.quit() ## Requires "Anybody" in dpkg-reconfigure x11-common if we have scrolled pages previously ## kalipi.run_cmd("/usr/bin/sudo -u pi FRAMEBUFFER=/dev/fb0 startx") kalipi.run_cmd("/usr/bin/sudo FRAMEBUFFER=/dev/fb0 startx") os.execv(__file__, sys.argv) if number == 4: if button4.disable == 1: return # Shutdown pygame.quit() kalipi.run_cmd("/usr/bin/sudo /sbin/shutdown -h now") sys.exit() if number == 5: if button5.disable == 1: return # VNC if check_vnc(): kalipi.run_cmd("/usr/bin/vncserver -kill :1") button5.fntColor = tron_whi button5.draw() pygame.display.update() else: kalipi.run_cmd("/usr/bin/vncserver :1") button5.fntColor = green button5.draw() pygame.display.update() return if number == 6: if button6.disable == 1: return # Terminal process = subprocess.call("setterm -term linux -back default -fore white -clear all", shell=True) pygame.quit() kalipi.run_cmd("/usr/bin/sudo -u pi screen -R -S term") process = subprocess.call("setterm -term linux -back default -fore black -clear all", shell=True) os.execv(__file__, sys.argv) if check_terminal(): button6.fntColor = green button6.draw() pygame.display.update() else: button6.fntColor = tron_whi button6.draw() pygame.display.update() return if number == 7: if button7.disable == 1: return # Reboot pygame.quit() kalipi.run_cmd("/usr/bin/sudo /sbin/shutdown -r now") sys.exit() if number == 8: if button8.disable == 1: return # Lock retPage="menu-1.py" kalipi.screensaver(retPage) menu1() if number == 9: if button9.disable == 1: return # Next page pygame.quit() page=os.environ["MENUDIR"] + "menu-2.py" os.execvp("python", ["python", page]) sys.exit()
def button(number): if number == 1: if button1.disable == 1: return # Metasploit process = subprocess.call( "setterm -term linux -back default -fore white -clear all", shell=True) pygame.quit() kalipi.run_cmd("/usr/bin/sudo -u pi screen -R -S msf msfconsole") process = subprocess.call( "setterm -term linux -back default -fore black -clear all", shell=True) os.execv(__file__, sys.argv) if check_msf(): button1.fntColor = green button1.draw() pygame.display.update() else: button1.fntColor = tron_whi button1.draw() pygame.display.update() return if number == 2: if button2.disable == 1: return # SDR-Scanner pygame.quit() prog = "/bin/bash " + os.environ[ "MENUDIR"] + "/SDR-Scanner/sdr-scanner.sh" kalipi.run_cmd(prog) os.execv(__file__, sys.argv) if number == 3: if button3.disable == 1: return # Kismet process = subprocess.call( "setterm -term linux -back default -fore white -clear all", shell=True) pygame.quit() kalipi.run_cmd( "/usr/bin/sudo -u pi screen -R -S kismet /usr/bin/kismet") process = subprocess.call( "setterm -term linux -back default -fore black -clear all", shell=True) os.execv(__file__, sys.argv) if check_kismet(): button3.fntColor = green button3.draw() pygame.display.update() else: button3.fntColor = tron_whi button3.draw() pygame.display.update() return if number == 4: if button4.disable == 1: return # OpenVAS if toggle_openvas(): button4.fntColor = green button4.draw() pygame.display.update() else: button4.fntColor = tron_whi button4.draw() pygame.display.update() return if number == 5: if button5.disable == 1: return # Snort if toggle_snort(): button5.fntColor = green button5.draw() pygame.display.update() else: button5.fntColor = tron_whi button5.draw() pygame.display.update() return if number == 6: if button6.disable == 1: return # Pulledpork pygame.quit() cmd = "/usr/bin/sudo /bin/bash " + os.environ[ "MENUDIR"] + "pulledpork.sh" call(cmd, shell=True) os.execv(__file__, sys.argv) if number == 7: if button7.disable == 1: return # Previous page pygame.quit() page = os.environ["MENUDIR"] + "menu-2.py" os.execvp("python", ["python", page]) sys.exit() if number == 8: if button8.disable == 1: return # Screen off retPage = "menu-3.py" kalipi.screensaver(retPage) menu3() if number == 9: if button9.disable == 1: return # Next page pygame.quit() page = os.environ["MENUDIR"] + "menu-4.py" os.execvp("python", ["python", page]) sys.exit()
def button(number): if number == 1: if button1.disable == 1: return # WWW if kalipi.toggle_service("apache2"): #Stop Service button1.fntColor = green button1.draw() pygame.display.update() else: #Start Service button1.fntColor = tron_whi button1.draw() pygame.display.update() return if number == 2: if button2.disable == 1: return # FTP if kalipi.toggle_service("pure-ftpd"): #Stop Service button2.fntColor = green button2.draw() pygame.display.update() else: #Start Service button2.fntColor = tron_whi button2.draw() pygame.display.update() if number == 3: if button3.disable == 1: return # SQL if kalipi.toggle_service("mysql"): button3.fntColor = green button3.draw() pygame.display.update() else: button3.fntColor = tron_whi button3.draw() pygame.display.update() return if number == 4: if button4.disable == 1: return # Hostapd RAS-AP script = os.environ["MENUDIR"] + "RAS-AP/ras-ap.sh" if kalipi.toggle_script(script): # Stop Service button4.fntColor = green button4.draw() pygame.display.update() else: #Start Service button4.fntColor = tron_whi button4.draw() pygame.display.update() if number == 5: if button5.disable == 1: return # darkstat if kalipi.toggle_service("darkstat"): button5.fntColor = green button5.draw() pygame.display.update() else: button5.fntColor = tron_whi button5.draw() pygame.display.update() return if number == 6: if button6.disable == 1: return # ntopng if toggle_ntopng(): button6.fntColor = green button6.draw() pygame.display.update() else: button6.fntColor = tron_whi button6.draw() pygame.display.update() return if number == 7: if button7.disable == 1: return # Previous page pygame.quit() page = os.environ["MENUDIR"] + "menu-1.py" os.execvp("python", ["python", page]) sys.exit() if number == 8: if button8.disable == 1: return # Screen off retPage = "menu-2.py" kalipi.screensaver(retPage) menu2() if number == 9: if button9.disable == 1: return # Next page pygame.quit() page = os.environ["MENUDIR"] + "menu-3.py" os.execvp("python", ["python", page]) sys.exit()