예제 #1
0
 def load_config(self):
     try:
         config, _ = self.keystore.load_aead(
             self.path + "/settings", self.keystore.enc_secret
         )
         config = json.loads(config.decode())
     except Exception as e:
         print(e)
         config = {"dev": self.dev, "usb": self.usb}
         self.keystore.save_aead(
             self.path + "/settings",
             adata=json.dumps(config).encode(),
             key=self.keystore.enc_secret,
         )
     self.dev = config["dev"]
     self.usb = config["usb"]
     # add apps in dev mode
     if self.dev:
         try:
             qspi = fpath("/qspi/extensions")
             maybe_mkdir(qspi)
             maybe_mkdir(qspi + "/extra_apps")
             if qspi not in sys.path:
                 sys.path.append(qspi)
                 self.apps += load_apps("extra_apps")
         except Exception as e:
             print(e)
예제 #2
0
def main(apps=None, network='test', keystore_cls=None):
    # create virtual file system /sdram
    # for temp untrusted data storage
    rampath = platform.mount_sdram()
    # define hosts - USB, QR, SDCard
    # each hosts gets it's own RAM folder for data
    hosts = [
        QRHost(rampath + "/qr"),
        USBHost(rampath + "/usb"),
        # SDHost(rampath+"/sd"), # not implemented yet
    ]
    # define GUI
    gui = SpecterGUI()

    # folder where keystore will store it's data
    keystore_path = platform.fpath("/flash/keystore")
    # define KeyStore
    if keystore_cls is None:
        keystore = FlashKeyStore(keystore_path)
    else:
        keystore = keystore_cls(keystore_path)

    # loading apps
    if apps is None:
        apps = load_apps()

    # make Specter instance
    settings_path = platform.fpath("/flash")
    specter = Specter(gui=gui,
                      keystore=keystore,
                      hosts=hosts,
                      apps=apps,
                      settings_path=settings_path,
                      network=network)
    specter.start()
예제 #3
0
def main(apps=None, network="main", keystore_cls=None):
    """
    apps: list of apps to load
    network: default network to operate
    keystores: list of KeyStore classes that can be used
    """
    # create virtual file system /sdram
    # for temp untrusted data storage
    rampath = platform.mount_sdram()
    # define hosts - USB, QR, SDCard
    # each hosts gets it's own RAM folder for data
    Host.SETTINGS_DIR = platform.fpath("/qspi/hosts")
    hosts = [
        USBHost(rampath + "/usb"),
        QRHost(rampath + "/qr"),
        SDHost(rampath + "/sd"),
    ]
    # temp storage in RAM for host commands processing
    BaseApp.TEMPDIR = rampath + "/tmp"

    # define GUI
    if not platform.simulator:
        gui = SpecterGUI()
    else:
        # this GUI can simulate user actions for automated testing
        from gui.tcp_gui import TCPGUI
        gui = TCPGUI()

    # inject the folder where keystore stores it's data
    KeyStore.path = platform.fpath("/flash/keystore")
    # detect keystore to use
    if keystore_cls is not None:
        keystores = [keystore_cls]
    else:
        keystores = [
            MemoryCard,
            SDKeyStore,
        ]

    # loading apps
    if apps is None:
        apps = load_apps()

    # make Specter instance
    settings_path = platform.fpath("/flash")
    specter = Specter(
        gui=gui,
        keystores=keystores,
        hosts=hosts,
        apps=apps,
        settings_path=settings_path,
        network=network,
    )
    specter.start()
예제 #4
0
파일: main.py 프로젝트: holgern/specter-diy
def main(apps=None, network="test", keystore_cls=None):
    """
    apps: list of apps to load
    network: default network to operate
    keystores: list of KeyStore classes that can be used
    """
    # create virtual file system /sdram
    # for temp untrusted data storage
    rampath = platform.mount_sdram()
    # define hosts - USB, QR, SDCard
    # each hosts gets it's own RAM folder for data
    hosts = [
        QRHost(rampath + "/qr"),
        USBHost(rampath + "/usb"),
        # SDHost(rampath+"/sd"), # not implemented yet
    ]
    # define GUI
    gui = SpecterGUI()

    # inject the folder where keystore stores it's data
    KeyStore.path = platform.fpath("/flash/keystore")
    # detect keystore to use
    if keystore_cls is not None:
        keystores = [keystore_cls]
    else:
        keystores = [
            SDKeyStore,
            # uncomment this if you want to
            # enable smartcard support:
            # MemoryCard,
        ]

    # loading apps
    if apps is None:
        apps = load_apps()

    # make Specter instance
    settings_path = platform.fpath("/flash")
    specter = Specter(
        gui=gui,
        keystores=keystores,
        hosts=hosts,
        apps=apps,
        settings_path=settings_path,
        network=network,
    )
    specter.start()