def split_device_password(arg): "arg: device [password], password can contain spaces" cnt = 1 last_len = 0 while True: lst = arg.rsplit(None, cnt) dev = eveusb.Device(lst[0], False) if dev: auth = dev.authorization() dev.setPassword('') # will reset auth dev.setAuthorization(auth) password = arg[len(str(dev)):] if password: password = password.lstrip() return dev, password lst_len = len(lst) if lst_len != last_len: last_len = lst_len ++cnt else: break return eveusb.Device(arg, False), None
def do_share(self, arg): if not arg: self.help_share() return self.stop_on_error dev = eveusb.Device(arg, True) if dev: return self.ctl.localShare(dev) lst = arg.split(None, 5) if len(lst) < 2: self.help_share() return self.stop_on_error reverse_host, sep, port = lst.pop(0).rpartition(':') try: tcp_port = int(port) except ValueError as e: print(e) return self.stop_on_error kernel_devname = lst.pop(0) dev = eveusb.Device(reverse_host, tcp_port, kernel_devname) if not dev: print("cannot create device " + kernel_devname) return self.stop_on_error if lst: dev.setDeviceNick(lst.pop(0)) if lst: encrypt = get_bool_option(lst.pop(0), 'ENCRYPT') dev.setEncryption(encrypt) if lst: compress = get_bool_option(lst.pop(0), 'COMPRESS') dev.setCompression(compress) if lst: dev.setPassword(lst.pop(0)) assert not lst return self.ctl.localShare(dev)
def do_disconnect(self, arg): if not arg: self.help_disconnect() return self.stop_on_error dev = eveusb.Device(arg, False) if dev: return self.ctl.remoteDisconnect(dev) else: print("invalid device: {0}".format(arg)) return self.stop_on_error
def do_break(self, arg): if not arg: self.help_break() return self.stop_on_error dev = eveusb.Device(arg, True) if dev: return self.ctl.localDisconnectClient(dev) else: print("invalid device: {0}".format(arg)) return self.stop_on_error
def do_unshare(self, arg): if not arg: self.help_unshare() return self.stop_on_error elif arg == 'all': return self.ctl.localUnshareAll() dev = eveusb.Device(arg, True) if dev: return self.ctl.localUnshare(dev) else: print("invalid device: {0}".format(arg)) return self.stop_on_error
def do_add(self, arg): if not arg: self.help_add() return self.stop_on_error dev = eveusb.Device(arg, False) if not dev: # try as local dev = eveusb.Device(arg, True) if dev: assert dev.host() == '' usbhub, usbport = split_hub_port(dev.kernel_devname()) d = eveusb.Device('localhost', dev.reverse_host(), dev.port(), usbhub, usbport) assert d and d.isRemote() d.update(dev) dev = d if dev: return self.ctl.remoteAdd(dev) else: print("invalid device: {0}".format(arg)) return self.stop_on_error
def do_unshareto(self,localip,localport,localdevname): dev = eveusb.Device(localip,localport,localdevname) return self.ctl.localUnshare(dev)
def do_share2(self,_ipstr,_portstr,_devnamestr): dev = eveusb.Device(_ipstr,_portstr,_devnamestr) return self.ctl.localShare(dev)