#!/usr/bin/python # *-* coding:utf-8 *-* #*************************************************************************** # This file is part of the CRYPTO BONE # File : cryptobone installed in /usr/bin # Version : 1.1.0 (ALL-IN-ONE) # License : BSD # Date : Tuesday, 8 November 2016 # Contact : Please send enquiries and bug-reports to innovation@senderek.ie # # # Copyright (c) 2015-2017 # Ralf Senderek, Ireland. All rights reserved. (https://senderek.ie) # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. All advertising materials mentioning features or use of this software # must display the following acknowledgement: # This product includes software developed by Ralf Senderek. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. #**************************************************************************** import os import base64 import time # debugging off DEBUG_DISPLAY = False DEBUG = False # debugging on #DEBUG = True #DEBUG_DISPLAY = True OS = os.name # find out askpass path ASKPASSS = "/usr/bin/systemd-ask-password" if os.path.isfile ("/usr/libexec/openssh/gnome-ssh-askpass"): ASKPASS="/usr/libexec/openssh/gnome-ssh-askpass" else: if os.path.isfile ("/usr/lib64/seahorse/seahorse-ssh-askpass"): ASKPASS="/usr/lib64/seahorse/seahorse-ssh-askpass" else: if os.path.isfile("/usr/lib/openssh/gnome-ssh-askpass"): ASKPASS = "/usr/lib/openssh/gnome-ssh-askpass" GUI = False try: from Tkinter import * from tkMessageBox import * import tkFont GUI = True except: pass RAMDISK = "/dev/shm" Name="none" StatusCount=3 MaxCount=0 Masterkey = False MODE = "read" Allinone = True MessageID = "None" Recipient = "None" # GUI constants BACKGROUND = "#ddd" GRAY = "#ccc" LABEL = "#eee" ############################################################### def unix (command) : if OS == "posix": Pipe = os.popen(command, "r") Result = Pipe.read() Pipe.close() return Result ############################################################### def clean (): Text.delete("0.0","end") ############################################################### def is_active(): Result = send_command("STATUS") if Result[:6] == "active": return True return False ############################################################### def check_status(): global Allinone, Name, StatusCount, MaxCount if StatusCount > MaxCount: StatusCount = 0 Result = send_command("STATUS") else: Result = "none" StatusCount += 1 if "waiting" in Result: StatusLabel.configure(text="waiting") StatusLabel.configure(bg="orange") if "offline" in Result: StatusLabel.configure(text="cut off") StatusLabel.configure(bg="yellow") showinfo("EXTERNAL Crypto Bone is inactive","Your EXTERNAL Crypto Bone is offline.\nPlease switch it on or check its network connection.\n") if "active" in Result: MaxCount=10 StatusLabel.configure(text="active") StatusLabel.configure(bg="lightgreen") if Name == "none": Result = send_command("SETUP ID") if not "failed" in Result: ID.configure(text=Result[:-1]) Name=Result[:-1] else: MaxCount = 0 if "master key not available" in Result: StatusLabel.configure(text="inactive") StatusLabel.configure(bg="yellow") showinfo("EXTERNAL Crypto Bone is inactive","You need to reboot your computer while the EXTERNAL Crypto Bone is running to transfer the master key.\n") if "boneless" in Result: StatusLabel.configure(text="cut off") StatusLabel.configure(bg="yellow") showinfo("EXTERNAL Crypto Bone is inactive","The IP address of your EXTERNAL Crypto Bone is unknown.\n") if "ssh key not available" in Result: StatusLabel.configure(text="cut off") StatusLabel.configure(bg="yellow") showinfo("EXTERNAL Crypto Bone is inactive","You need to store your EXTERNAL keys in your computer first. Please use setup to copy these keys.\n") Linkstatus = send_command("GETALLINONE") if "ALLINONE" in Linkstatus : Allinone = True IPLabel.configure(text="ALL-IN-ONE") else: Allinone = False IPLabel.configure(text=Linkstatus) ############################################################### def contact(): import subprocess Content = InputField.get().split(" ") args = ["sudo", "-A", "/usr/lib/cryptobone/cbcontrol"] for Word in Content: args.append(Word) ENV = os.environ.copy() ENV['SUDO_ASKPASS'] = ASKPASS p = subprocess.Popen(args, bufsize=-1, stdin=subprocess.PIPE, stdout=subprocess.PIPE, shell=False, env=ENV) if DEBUG_DISPLAY: print InputField.get() (out,err) = p.communicate() if err != None: print "error:",str(err) if DEBUG_DISPLAY: Text.insert("end",str(out)) Text.insert("end", "\n") ############################################################### def send_command(Command): import subprocess # sanitize input Input = "" for C in Command: if (ord(C) > 0) and (ord(C) < 128): Input += C Content = Input.split(" ") args = ["sudo", "-A", "/usr/lib/cryptobone/cbcontrol"] for Word in Content: args.append(Word) ENV = os.environ.copy() ENV['SUDO_ASKPASS'] = ASKPASS p = subprocess.Popen(args, bufsize=-1, stdin=subprocess.PIPE, stdout=subprocess.PIPE, shell=False, env=ENV) if DEBUG_DISPLAY: print Input (out,err) = p.communicate() if err != None: print "error:",str(err) if DEBUG_DISPLAY: Text.insert("end",str(out)) Text.insert("end", "\n") return str(out) ############################################################### def set_select_box(): List = [] if MODE == "write": List = send_command("KEY RECIPIENTLIST").split("\n") if MODE == "read": List = send_command("READ MESSAGELIST").split("\n") Box.delete(0,20) Count = 0 for Item in List: if Item : Box.insert(Count, str(Item)) Count += 1 ############################################################### def set_read(): global MODE, MessageID MODE = "read" Mode.configure(text="READ") L.configure(text="Messages") ControlFrame.pack_forget() Key1.pack_forget() Key2.pack_forget() Key3.pack_forget() Setup1.pack_forget() clean() TextFrame.pack() ControlFrame.pack() Button1.configure(text="Reply") Button2.configure(text="Check for new") Button3.configure(text="Destroy") Button2.pack(padx=8, side=LEFT) Button3.pack(padx=8, side=RIGHT) set_select_box() SelectBox.pack() MessageID = "None" L1.configure(text=MessageID) L2.configure(text="NEW") check_status() ############################################################### def set_write(): global MODE, Recipient MODE = "write" Mode.configure(text="WRITE") L.configure(text="Recipients") ControlFrame.pack_forget() Key1.pack_forget() Key2.pack_forget() Key3.pack_forget() Setup1.pack_forget() clean() TextFrame.pack() ControlFrame.pack() Button1.configure(text="Send Message") Button2.configure(text="Forget") Button2.pack(padx=8, side=LEFT) Button3.pack_forget() set_select_box() SelectBox.pack() Recipient = "None" L1.configure(text=Recipient) L2.configure(text="NEW") check_status() ############################################################### def set_reply(): global MODE MODE = "write" Mode.configure(text="WRITE") ControlFrame.pack_forget() Key1.pack_forget() Key2.pack_forget() Key3.pack_forget() Setup1.pack_forget() clean() TextFrame.pack() ControlFrame.pack() Button1.configure(text="Send Message") Button2.configure(text="Forget") Button3.pack_forget() SelectBox.pack_forget() L1.configure(text="Recipient") L2.configure(text="REPLY") ############################################################### def set_key(): global MODE MODE = "key" Mode.configure(text="KEYS") SelectBox.pack_forget() TextFrame.pack_forget() ControlFrame.pack_forget() Setup1.pack_forget() Key1.pack() Key2.pack() Key3.pack() L1.configure(text="") L2.configure(text="") check_status() ############################################################### def set_setup(): global MODE, Allinone MODE = "setup" Mode.configure(text="SETUP") SelectBox.pack_forget() TextFrame.pack_forget() ControlFrame.pack_forget() Key1.pack_forget() Key2.pack_forget() Key3.pack_forget() Setup1.pack() ControlFrame.pack() Linkstatus = send_command("GETALLINONE") if "ALLINONE" in Linkstatus : Button1.configure(text="Use EXTERNAL") Button2.pack_forget() Button3.pack_forget() else: Button1.configure(text="Use ALL-IN-ONE") Button2.configure(text="Set EXTERNAL Keys") Button3.configure(text="Forget IP Addr") Button2.pack(side=LEFT, padx=8) Button3.pack(side=LEFT, padx=8) L1.configure(text="") L2.configure(text="") ############################################################### def action1(): global Recipient, MessageID, Allinone, PoweroffButton, Fill2, Name, StatusCount if MODE == "read": # reply to the selected message MESSAGE = Text.get("0.0","end").split("\n") set_reply() Text.insert("end","\n\n\n") for Line in MESSAGE: if Line: Text.insert("end", "> "+Line+"\n") if len(MessageID) > 4 : while MessageID[len(MessageID)-1] != '.': MessageID = MessageID[:-1] Recipient = MessageID[:-1] L1.configure(text=Recipient) L2.configure(text="REPLY") elif MODE == "write": MESSAGE = Text.get("0.0","end") # sanitize message NEWMESSAGE = "" for C in MESSAGE: if ord(C) <= 128: NEWMESSAGE += C MESSAGE = base64.b64encode(NEWMESSAGE) if Recipient != "None": Result = send_command("WRITE "+Recipient+" "+MESSAGE) if ("MAIL SENT" in Result) or ("sending message" in Result) : Text.insert("end", "\n\n"+Result) showinfo("Sending Message Out","Message is sent out successfully") else: showinfo("Sending Message Out","Message is not sent out!") else: showinfo("Missing Information","Please select a recipient from the menu before sending the message") elif MODE == "key": print "action one key" elif MODE == "setup": FillRight.pack_forget() if not Allinone: Allinone = True Button1.configure(text="Use EXTERNAL") IPLabel.configure(text="ALL-IN-ONE") send_command("USEALLINONE") Fill2.pack(pady=11) PoweroffButton.pack_forget() else: Allinone = False Button1.configure(text="Use ALL-IN-ONE") IPLabel.configure(text="EXTERNAL CRYPTO BONE") send_command("USECRYPTOBONE") Fill2.pack_forget() PoweroffButton.pack(pady=5) FillRight.pack() StatusCount = 100 Name = "none" ID.configure(text="") set_setup() check_status() ############################################################### def action2(): global Recipient, MessageID if MODE == "read": # check for new messages set_select_box() elif MODE == "write": # forget message MessageID = "none" Recipient = "Recipient" L1.configure(text=Recipient) L2.configure(text="NEW") clean() set_select_box() SelectBox.pack() elif MODE == "key": print "action two key" elif MODE == "setup": List = unix("df 2> /dev/null | cut -f1 -d' '| grep /dev").split() BootDev = "" SD = False for Device in List: BootDir = unix("df -a 2> /dev/null | grep "+Device+" | grep media | grep BOOT | cut -f2 -d%") if BootDir: if BootDir[0] == " ": BootDir = BootDir[1:] if BootDir[-1:] == "\n": BootDir = BootDir[:-1] RES=unix("ls "+BootDir+"/master.key 2>/dev/null") if BootDir and RES: # this device holds a master key BootDev = unix("df -a 2> /dev/null | grep "+Device+" | grep media | grep BOOT | cut -f1 -d' '") if BootDev[-1:] == "\n": BootDev = BootDev[:-1] SD = True print "Using ",BootDev," to copy external keys to this machine." if SD: print "Copying keys from "+BootDev+" to this computer's hard disk" if askyesno("Moving Keys From SD/USB","Copying keys from "+BootDev+" to this computer's hard disk\n\nProceed?"): if askyesno("Moving Keys From SD/USB","You will now replace the keys that are used to access your EXTERNAL Crypto Bone.\n\nIf your EXTERNAL Crypto Bone is already working, you will DESTROY the keys used to access this working EXTERNAL Crypto Bone by replacing the old keys with new keys from the SD card or USB stick.\n\nOnce you have replaced the external keys, this action cannot be undone. You will continue with a new EXTERNAL Crypto Bone, if you proceed here.\n\nDo your really want to do that?\n\nThink twice."): RES = send_command("COPYSDCARD "+BootDev) if "success" in RES : showinfo("Moving Keys From SD/USB","Your Crypto Bone keys have been moved successfully to your computer.\n\nNow you can insert the SD card (or USB stick) into your Beagle Bone or Raspberry Pi (or Linux computer) again and reboot it.\n\nYou need to reboot this main computer as well in order to activate the new keys.") elif "failed" in RES : showinfo("Moving Keys From SD/USB","The secrets on your SDCARD or USB stick have not been transferred completely.\n\nPlease try again.") elif "nokeys" in RES : showinfo("Moving Keys From SD/USB","There are no keys on your SD card or USB stick!\n\nPleas check your SD card image and insert it for a first boot into your Beagle Bone or Raspberry Pi to create the master key.\n\nIf you use a USB stick, make sure that it contains a file system labelled BOOT.") else: showinfo("Moving Keys From SD/USB","There is no SD card with a valid Crypto Bone image or a valid USB stick.") ############################################################### def action3(): if MODE == "read": # destroy selected message if askyesno("Destroy Message", "Do you really want to destroy this message: "+MessageID): send_command("READ DESTROY "+MessageID) clean() set_select_box() elif MODE == "setup": # destroy selected message if askyesno("Delete IP Address", "Do you really want to delete the stored IP address for your EXTERNAL Crypto Bone? "): send_command("DELETE CONFIG") IPLabel.configure(text="unknown") ############################################################### def select(): global MessageID, Recipient index = 0 if len(Box.curselection()) > 0: index = Box.curselection()[0] Selection = Box.get(index) L1.configure(text=Selection) if MODE == "read": MessageID = Selection MESSAGE = send_command("READ MESSAGE "+MessageID) if MESSAGE: clean() Plaintext = base64.b64decode(MESSAGE) NewPlaintext = Plaintext.replace("\r","") Text.insert("end",NewPlaintext) elif MODE == "write": Recipient = Selection ############################################################### def is_message_key(NewKey): if NewKey == "none": return False if len(NewKey) > 19: return True return False ############################################################### def register(): if not is_active(): return "failed" K = InitKey.get() E = Email.get().lower() if is_message_key(K): # todo: check if email address is stored already RES = send_command("KEY USE "+E+" "+K) if "failed" in RES : showerror('Contact Registration', RES[8:]) if "success" in RES : showinfo('Contact Registration', E + "\n\nis now registered and can be used.") else: showerror('Contact Registration', "The message key is too short.") ############################################################### def change_email(): if not is_active(): return "failed" Name = OldName.get() Email = OldEmail.get() Email = Email.lower() New = NewEmail.get() New = New.lower() if not (Name == "Contact Email Address"): Email = Name if (Email != "" ) and (New != "") : RES = send_command("KEY CHANGEEMAIL "+Email+" "+New) print RES if "success" in RES : showinfo('Email Address Change', 'The new email address is now active.') else: if "failed" in RES : showinfo('Email Address Change', RES[8:]) else: if (len(Email) < 6): if (Name == "Contact Email Address"): showerror('Email Address Change', "The email address is invalid.") else: if (len(New) < 6): showerror('Email Address Change', "The new email address is invalid.") ############################################################### def print_secrets(): if is_active(): RES = send_command("KEY NEWSECRETS") Message = "These are three keys that can be used by your contacts\n\n" Keys = RES.split() for Line in Keys: List = Line.split(":") if len(List) > 1: Message += "________________________________\n\n" Message += "Initial key for " +List[0][4:-4] + " :\n" Message += List[1] + "\n" Message += "________________________________\n\n" Message += "\n\nPlease handle this information with extreme care!" askokcancel("New Secrets for Contacts", Message) ############################################################### def show_mailserver_setup(): Result = send_command("SETUP SHOW") if Result: List = Result.split("\n") for Line in List: Secretvalue = Line.split(":") if Secretvalue[0] == "mailserver": Hostname.delete(0,END) Hostname.insert(0,Secretvalue[1]) if Secretvalue[0] == "mailuser": Username.delete(0,END) Username.insert(0,Secretvalue[1]) if Secretvalue[0] == "mailpassword": Password.delete(0,END) Password.insert(0,Secretvalue[1]) ############################################################### def mailserver_setup(): H = Hostname.get() U = Username.get() P = Password.get() if H : send_command("SETUP SERVER "+H) if U : send_command("SETUP USER "+U) if P : send_command("SETUP PASSWORD "+P) ############################################################### def terminate_GUI(): Window.destroy() ############################################################### def do_poweroff(): if not "ALLINONE" in send_command("GETALLINONE"): X=send_command("POWEROFF") print X check_status() ############################################################### def readuser(): USER = InputField.get() # check if this is a valid user if USER and (USER in unix("grep \"^"+USER+":\" /etc/passwd")): RET=unix("beesu -c " +"/usr/lib/cryptobone/activate-cryptobone "+USER ) if RET == "success": showinfo( "SUCCESS","Your Crypto Bone can now be used.\nPlease reboot your computer to create the secrets that are missing.") sys.exit(0) if RET == "initialised": showinfo( "ERROR","This Crypto Bone is already set up.\n\nYour Crypto Bone Daemon is not enabled.\n\nTry: systemctl enable cryptoboned") sys.exit(1) if RET == "nosuchuser": showinfo( "ERROR","No such user. Please try again.") if RET == "noparameter": showinfo( "ERROR","You must specify a user name.") else: showinfo( "ERROR","No such user. Please try again.") ############################################################### # Main ############################################################### if GUI: Window = Tk() Window.title("Crypto Bone Control") if DEBUG: Window.geometry('960x660') else: Window.geometry('960x630') MainFrame = Frame(Window, bg=BACKGROUND) LeftFrame = Frame(MainFrame, bg=BACKGROUND, pady=2) StatusFrame = Frame(LeftFrame, bg=BACKGROUND, pady=5) ModeFrame = Frame(LeftFrame, bg=BACKGROUND, pady=5) TopFrame = Frame(LeftFrame, bg=BACKGROUND, pady=10) TextFrame = Frame(LeftFrame, bg=BACKGROUND) ControlFrame = Frame(LeftFrame,bg=BACKGROUND, pady=5) RightFrame = Frame(MainFrame, bg=BACKGROUND, pady=2) Big = tkFont.Font(family="utopia", size=16) Title = tkFont.Font(family="utopia", size=12) Info = tkFont.Font(family="arial", size=10, slant="italic") Bold = tkFont.Font(family="arial", size=11, weight="bold") BFont = tkFont.Font(family="utopia", size=12, weight="normal") TextFont = tkFont.Font(family="arial", size=11, weight="normal") # DEBUG frame if DEBUG: ButtonFrame = Frame(Window) CleanButton = Button(master=ButtonFrame, text="Clean", command=clean) InputField = Entry(master=ButtonFrame, width=40) ExecButton = Button(master=ButtonFrame, text="do it!", command=contact) CleanButton.pack(side=LEFT) InputField.pack(padx=20,side=LEFT) ExecButton.pack(side=LEFT) ButtonFrame.pack() def OpenHelpUrl(): import webbrowser webbrowser.open_new("https://crypto-bone.com/help") # Left Frame # Status BoneLabel = Label(StatusFrame, text="CRYPTO BONE 1.1", font=Big, width=22, bg=BACKGROUND) BoneLabel.bind("",lambda e: OpenHelpUrl()) IPLabel = Label(StatusFrame, text="", width=26, height=1, font=Bold, bg="#eeffee") StatusLabel = Label(StatusFrame, text="cut off", font=Bold, width=12, height=1, bg="yellow") ID = Label(RightFrame, text="", font=Bold, width=30, height=1, bg="#eeffee") BoneLabel.pack(side=LEFT) IPLabel.pack(side=LEFT) StatusLabel.pack(side=LEFT) ID.pack(pady=10) # Labels Mode = Label(TopFrame, text="READ", font=Bold, bg="yellow", width=10) L1 = Label(TopFrame, text="None", font=Bold, width=58, bg=LABEL) L2 = Label(TopFrame, text="None", font=Bold, width=10, bg=LABEL) Mode.pack(side=LEFT) L1.pack(side=LEFT) L2.pack(side=LEFT) Scroll = Scrollbar(TextFrame) Text = Text(TextFrame, width=75, height=25, font=TextFont, borderwidth=8, relief=FLAT, yscrollcommand = Scroll.set) Scroll.pack( side = RIGHT, fill=Y ) Text.pack() Scroll.config( command = Text.yview ) ReadButton = Button(master=ModeFrame, text="READ", bg=GRAY, font=BFont, command=set_read) WriteButton = Button(master=ModeFrame, text="WRITE", bg=GRAY, font=BFont, command=set_write) KeyButton = Button(master=ModeFrame, text="KEYS", bg=GRAY, font=BFont, command=set_key) SetupButton = Button(master=ModeFrame, text="SETUP", bg=GRAY, font=BFont, command=set_setup) ReadButton.pack(padx=20, side=LEFT, pady=5) WriteButton.pack(padx=20, side=LEFT, pady=5) KeyButton.pack(padx=20, side=LEFT, pady=5) SetupButton.pack(padx=20, side=LEFT, pady=5) # control buttons Button1 = Button(master=ControlFrame, text="", bg=GRAY, font=BFont, width=16, command=action1) Button2 = Button(master=ControlFrame, text="", bg=GRAY, font=BFont, width=16, command=action2) Button3 = Button(master=ControlFrame, text="", bg=GRAY, font=BFont, width=16, command=action3) Button1.pack(padx=8, side=LEFT) Button2.pack(padx=8, side=LEFT) Button3.pack(padx=8, side=LEFT) # Right frame PoweroffButton = Button(master=RightFrame, text=" POWER OFF ", bg=GRAY,font=BFont, command=do_poweroff, width=14) Fill2 = Label(RightFrame, text=" ", height=1, bg=BACKGROUND) if os.path.islink("/etc/systemd/system/multi-user.target.wants/cryptoboned.service"): if "ALLINONE" in send_command("GETALLINONE"): Fill2.pack(pady=11) else: PoweroffButton.pack(pady=5) # FillRight enables an empty RightFrame FillRight = Label(RightFrame, height=1, width=35, bg=BACKGROUND) FillRight.pack(pady=0) SelectBox = Frame(RightFrame, bg=BACKGROUND) L = Label(SelectBox, text="", bg="yellow",font=Bold, width=30) L.pack() BoxFrame = Frame(master=SelectBox) XScroll = Scrollbar(BoxFrame, orient=HORIZONTAL) Box = Listbox(BoxFrame, height=20, width=29, font=TextFont, borderwidth=5, relief=FLAT, xscrollcommand = XScroll.set) XScroll.config(command=Box.xview) XScroll.pack(side=BOTTOM, fill=X ) Box.pack() BoxFrame.pack() SelectButton = Button(master=SelectBox, text="Select", bg=GRAY, font=BFont, command=select) Box.bind('', lambda e: SelectButton.invoke()) SelectButton.pack(pady=5) SelectBox.pack() # Key Management Key1 = Frame(LeftFrame, height=110, pady=10, bg=BACKGROUND) Key2 = Frame(LeftFrame, height=110, pady=10, bg=BACKGROUND) Key3 = Frame(LeftFrame, height=110, pady=10, bg=BACKGROUND) KL1 = Label(Key1, text="Register a New Contact", font=Title, bg="yellow", width=30) KL2 = Label(Key2, text="Change Email Address", font=Title, bg="yellow", width=30) KL3 = Label(Key3, text="Print New Keys",font=Title, bg="yellow", width=30) # first Key frame SubKL1 = Label(Key1, text="Email Address", font=Bold, bg="white", width=27) SubKL2 = Label(Key1, text="Initial Secret", font=Bold, bg="white", width=27) KL1Info = Label(Key1, text=" Enter an initial secret for a new contact email address that is not yet registered ", font=Info, bg=BACKGROUND) Email = Entry(Key1, font=Bold, width=40) InitKey = Entry(Key1, font=Bold, width=40) K1Button = Button(master=Key1, text="Register", bg=GRAY, font=BFont, command=register) KL1.grid(row=0, column=0, columnspan=2) KL1Info.grid(row=1, column=0, columnspan=2, padx=3, pady=8) SubKL1.grid(row=2, column=0, padx=3, pady=2) Email.grid(row=2, column=1, padx=3, pady=2) SubKL2.grid(row=3,column=0, padx=3, pady=2) InitKey.grid(row=3, column=1, padx=3, pady=2) K1Button.grid(row=4, column=0, columnspan=2, padx=3, pady=15) # second Key frame OldName = StringVar(Key2) OldName.set("Contact Email Address") # initial value SubKL3 = OptionMenu(Key2, OldName, "Contact Email Address", " NN 1 ", " NN 2 ", " NN 3 ") SubKL4 = Label(Key2, text="New Contact Email Address", font=Bold, bg="white", width=27) KL2Info = Label(Key2, text=" Change the email address for NN1 , NN2 and NN3 or any registered contact ", font=Info, bg=BACKGROUND) OldEmail = Entry(Key2, font=Bold, width=40) NewEmail = Entry(Key2, font=Bold, width=40) K2Button = Button(master=Key2, text="Change", bg=GRAY, font=BFont, command=change_email) KL2.grid(row=0, column=0, columnspan=2) KL2Info.grid(row=1, column=0, columnspan=2, padx=3, pady=8) SubKL3.grid(row=2, column=0, padx=3, pady=2) OldEmail.grid(row=2, column=1, padx=3, pady=2) SubKL4.grid(row=3,column=0, padx=3, pady=2) NewEmail.grid(row=3, column=1, padx=3, pady=2) K2Button.grid(row=4, column=0, columnspan=2, pady=15) # third Key frame KL3.grid(row=0, column=0) K3Button = Button(master=Key3, text="Generate new secrets", bg=GRAY, font=BFont, command=print_secrets) K3Button.grid(row=1, column=0, pady=5) # Setup frame Setup1 = Frame(LeftFrame, height=100, pady=10, bg=BACKGROUND) SL1 = Label(Setup1, text="Setup the Mail Server for Incoming Email", font=Title, bg="yellow", width=40) InfoPanel = Label(Setup1, text="" , height=15, bg=BACKGROUND, pady=4) SubSL1 = Label(Setup1, text="Mail Server Name", font=Bold, bg="white", width=27) SubSL2 = Label(Setup1, text="User Name", font=Bold, bg="white", width=27) SubSL3 = Label(Setup1, text="Password", font=Bold, bg="white", width=27) SL1Info = Label(Setup1, text=" In order to receive emails you must use an existing mail server account. ", font=Info) Hostname = Entry(Setup1, width=40, font=Bold) Username = Entry(Setup1, width=40, font=Bold) Password = Entry(Setup1, width=40, show="*", font=Bold) S1Button = Button(master=Setup1, text="Update Mail Server Setup", bg=GRAY, font=BFont, command=mailserver_setup) ShowButton = Button(master=Setup1, text="Show Setup", bg=GRAY, font=BFont, command=show_mailserver_setup) SL1.grid(row=0, column=0, columnspan=2) SL1Info.grid(row=1, column=0, columnspan=2, padx=3, pady=8) SubSL1.grid(row=2, column=0, padx=3, pady=2) Hostname.grid(row=2, column=1, padx=3, pady=2) SubSL2.grid(row=3,column=0, padx=3, pady=2) Username.grid(row=3, column=1, padx=3, pady=2) SubSL3.grid(row=4,column=0, padx=3, pady=2) Password.grid(row=4, column=1, padx=3, pady=2) ShowButton.grid(row=5, column=0, padx=3, pady=15) S1Button.grid(row=5, column=1, padx=3, pady=15) InfoPanel.grid(row=6, column=0, columnspan=2) QuitButton = Button(master=RightFrame, text="Exit!", bg=GRAY, font=BFont, command=terminate_GUI, width=14) QuitButton.place(x=70, y=580) if not os.path.islink("/etc/systemd/system/multi-user.target.wants/cryptoboned.service"): AdminFrame = Frame(Window) AdminFill = Label(AdminFrame, text="", height=6) AdminLabel = Label(AdminFrame, text="You want to activate your Crypto Bone?", width=60, height=1, font=Bold, bg="#eeffee") Text1 = Label(AdminFrame, text="Please input the login name of the user that\n will be using the Crypto Bone:") Text2 = Label(AdminFrame,text="This user will be listed in the sudoers file.") ExecButton = Button(master=AdminFrame, text="setup", command=readuser) InputField = Entry(master=AdminFrame, width=15) AdminFill.pack() AdminLabel.pack(pady=10) Text1.pack(pady=5) Text2.pack(pady=5) InputField.pack(pady=10) ExecButton.pack() AdminFrame.pack() Window.mainloop() # pack frames StatusFrame.pack() ModeFrame.pack() TopFrame.pack() TextFrame.pack() LeftFrame.pack(side=LEFT, padx=10) RightFrame.pack(side=LEFT, fill=Y) MainFrame.pack(fill=X) Name = "none" set_read() RESULT = unix("pidof /usr/lib/cryptobone/cryptoboned") if "x"+RESULT == "x" : # crypto bone daemon is not running import sys showerror('Crypto Bone Daemon failed', "You need to reboot your computer because the Crypto Bone Daemon is not running.") sys.exit(2) Window.mainloop() ##############################################################