def restart(): print('Sleeping...') sleep(3) tls.reset() usb.open() usb.send_init() tls.parseTlsFlash(read_flash(1, 0, 0x1000)) tls.open()
def open97(): usb.open() usb.send_init() # try to init TLS session from the flash tls.parseTlsFlash(read_flash(1, 0, 0x1000)) tls.open() tls.save()
def open_device(self, init=False): print('Opening device', hex(self.dev_type.value)) vfs_usb.open(product=self.dev_type.value) if init: vfs_usb.send_init() # try to init TLS session from the flash vfs_tls.parseTlsFlash(read_flash(1, 0, 0x1000)) vfs_tls.open()
def load97(): #usb.trace_enabled = True #tls.trace_enabled = True usb.open() tls.load()
if __name__ == "__main__": if os.geteuid() != 0: raise Exception('This script needs to be executed as root') usb_dev = None for d in VFS: dev = usb_core.find(idVendor=0x138a, idProduct=d.value) if dev: usb_dev = dev if not usb_dev: raise Exception('No supported validity device found') vfs_usb.open(product=usb_dev.idProduct) vfs_usb.send_init() try: with open('/sys/class/dmi/id/product_name', 'r') as node: product_name = node.read().strip() with open('/sys/class/dmi/id/product_serial', 'r') as node: product_serial = node.read().strip() except: product_name = 'VirtualBox' product_serial = '0' vfs_tls.set_hwkey(product_name=product_name, serial_number=product_serial) # try to init TLS session from the flash vfs_tls.parseTlsFlash(read_flash(1, 0, 0x1000))
#usb.trace_enabled=True #tls.trace_enabled=True def restart(): print('Sleeping...') sleep(3) tls.reset() usb.open() usb.send_init() tls.parseTlsFlash(read_flash(1, 0, 0x1000)) tls.open() usb.open() print('Initializing flash...') init_flash() restart() print('Uploading firmware...') upload_fwext() restart() print('Calibrating...') calibrate() print('Init database...') init_db() print('That\'s it, pairing\'s finished')