Quantcast
Channel: Bits, Bytes and my 5 cents » Raspberry Pi
Viewing all articles
Browse latest Browse all 10

Hack-In-A-Box mit PiTFT und Raspberry Pi

$
0
0

Mein Raspberry Pi lag lange Zeit rum und irgendwie wollte ich mal wieder etwas damit spielen und so habe ich mir ein 2.8 Zoll Touchscreen Display mit einer Auflösung von 320×240 geleistet, welches direkt auf den Pi aufgesteckt werden kann. Zusätzlich auch noch eine passende WLAN-Antenne und ein Gehäuse, soll ja auch nach etwas aussehen ;-)

PiTFT

Da das Display bereits zusammengesetzt und funktionstüchtig geliefert wird, muss es nur noch angesteckt werden und los gehts. Dazu gibt es von Adafruit ein Image, welches auch gleich die nötigen Anpassungen mitbringt: Klick

Foto 13.11.14 21 54 41

Doch nachdem das Display nun läuft, kommen wir zur eigentlichen Idee. Das ganze entstand mit dem Gedanken eine kleine Box zu erstellen, welche am Netzwerk angehängt werden kann und einerseits prüfen kann, ob eine Netzwerkverbindung besteht via WLAN oder Ethernet, anderseits aber auch diverse Attacken wie Man-in-the-Middle Angriffe durch ARP Spoofing oder Netzwerk Scans mit NMAP automatisch auf einen einfachen Klick starten. Doch dazu muss zuerst mal ein einfaches GUI her. Und da Python bereits vorhanden ist, bietet sich das direkt an.

Auf meiner Suche bin ich auf FBText gestossen, welches das Display schön und sauber ansteuern kann. Wer sich jetzt hier eine fixfertige Lösung wünscht, muss ich leider enttäuschen, soweit bin ich noch nicht. Zur Zeit gibt es erst das GUI mit den Buttons und ein Check, ob man auch online ist. Mehr folgt später :-)

Foto 13.11.14 21 56 09 Foto 13.11.14 21 56 15


Das GUI selbst besteht aus zwei Teilen: Einem Teil, welches die eigentliche Übersicht mit den Buttons repräsentiert:

import pygame
import os
import pygameui as ui
import subprocess
from display import run as popup

os.putenv('SDL_FBDEV', '/dev/fb1')
os.putenv('SDL_MOUSEDRV', 'TSLIB')
os.putenv('SDL_MOUSEDEV', '/dev/input/touchscreen')

MARGIN = 20
server = "8.8.8.8"

class PiTft(ui.Scene):
	def __init__(self):
		ui.Scene.__init__(self)

		self.status_button = ui.Button(ui.Rect(MARGIN, MARGIN, 130, 90), 'Status')
		self.status_button.on_clicked.connect(self.main_action)
		self.add_child(self.status_button)

		self.discover_button = ui.Button(ui.Rect(170, MARGIN, 130, 90), 'Discover')
		self.discover_button.on_clicked.connect(self.main_action)
		self.add_child(self.discover_button)

		self.mitm_button = ui.Button(ui.Rect(MARGIN, 130, 130, 90), 'MitM')
		self.mitm_button.on_clicked.connect(self.main_action)
		self.add_child(self.mitm_button)

		self.deauth_button = ui.Button(ui.Rect(170, 130, 130, 90), 'OFF')
		self.deauth_button.on_clicked.connect(self.main_action)
		self.add_child(self.deauth_button)

	def main_action(self, btn, mbtn):
		if btn.text == 'Status':
			response = os.system("ping -c 1 " + server)
			if response == 0:
				popup("ONLINE", (0,255,0))
			else:
				popup("OFFLINE", (255,0,0))
		elif btn.text == 'Discover':
			print("4 on")
		elif btn.text == 'MitM':
			print ("17 of:f")
		elif btn.text == 'OFF':
			os.system("sudo poweroff")
ui.init('Raspberry Pi UI', (320, 240))
pygame.mouse.set_visible(False)
ui.scene.push(PiTft())
ui.run()

Und eine Funktion zum Überblenden von Statusinformationen:

import pygame
import os
from time import sleep

def run( str, color ):
	WHITE = (255,255,255)

	os.putenv('SDL_FBDEV', '/dev/fb1')
	pygame.init()

	lcd = pygame.display.set_mode((320, 240))
	pygame.mouse.set_visible(False)

	font_big = pygame.font.Font(None, 50)

	lcd.fill(color)

	text_surface = font_big.render(str, True, WHITE)
	rect = text_surface.get_rect(center=(160,120))
	lcd.blit(text_surface, rect)

	pygame.display.update()
	sleep(5.0)

Alles was nun noch fehlt ist die Funktionalität, doch die muss ich zuerst noch einbinden. Wir werden sehen :-)


Viewing all articles
Browse latest Browse all 10

Latest Images

Pangarap Quotes

Pangarap Quotes

Vimeo 10.7.0 by Vimeo.com, Inc.

Vimeo 10.7.0 by Vimeo.com, Inc.

HANGAD

HANGAD

MAKAKAALAM

MAKAKAALAM

Doodle Jump 3.11.30 by Lima Sky LLC

Doodle Jump 3.11.30 by Lima Sky LLC

Trending Articles


Gwapo Quotes : Babaero Quotes


Dino Rey para colorear


Libros para colorear


Mandalas de flores para colorear


Dibujos para colorear de perros


Renos para colorear


mayabang Quotes, Torpe Quotes, tanga Quotes


Love Quotes Tagalog


Kahit may Toyo ka


Mga Tala sa “Unang Siglo ng Nobela sa Filipinas” (2009) ni Virgilio S. Almario


Pokemon para colorear


Winx Club para colorear


Girasoles para colorear


Sapos para colorear


Vacas para colorear


Dromedario para colorear


Long Distance Relationship Tagalog Love Quotes


Tagalog Long Distance Relationship Love Quotes


RE: Mutton Pies (mely)


Ang Nobela sa “From Darna to ZsaZsa Zaturnnah: Desire and Fantasy, Essays on...





Latest Images

Pangarap Quotes

Pangarap Quotes

Vimeo 10.7.0 by Vimeo.com, Inc.

Vimeo 10.7.0 by Vimeo.com, Inc.

HANGAD

HANGAD

MAKAKAALAM

MAKAKAALAM

Doodle Jump 3.11.30 by Lima Sky LLC

Doodle Jump 3.11.30 by Lima Sky LLC