def do_init(self, params): self._status2 = params self.frames = [] self.commands['set_key'] = Command("Set new key (17 hex bytes)", 1, "<key>", self.set_key, True) self.commands['set_vin'] = Command("Set VIN", 1, "<VIN>", self.set_vin, True) self.commands['exploit'] = Command("Exploit", 0, "", self.exploit, True)
def do_init(self, params): self._status2 = params self.frames = [] self._doors = {} self.commands['status'] = Command("Get doors status", 0, "", self.control_get_status, True) self.commands['central_lock'] = Command("Lock doors", 0, "", self.control_lock, True) self.commands['central_unlock'] = Command("Unlock doors", 0, "", self.control_unlock, True)
def do_init(self, params): self.can_buffer_read = [] self.can_buffer_write = [] self.commands['c'] = Command("Clean buffers", 0, "", self.do_start, True) self.commands['r'] = Command("Read message", 0, "", self.cmd_read, True) self.commands['w'] = Command("Write message", 1, "[0x]ID[:len]:HEX_DATA", self.cmd_write, True)
def do_init(self, params): self._status2 = params self.frames = [] self._doors = {} self.commands['status'] = Command("Get lights status", 0, "", self.control_get_status, True) self.commands['off'] = Command("Lights OFF", 0, "", self.lights_off, True) self.commands['on'] = Command("Lights ON", 0, "", self.lights_on, True) self.commands['distance'] = Command("Disatnace lights on", 0, "", self.dlights_on, True)
def do_init(self, params): self._statuses = params.get('statuses', []) self._commands = params.get('commands', []) self._frames = [] cmd_list = [ chr(i) for i in (list(range(0x41, 0x41 + 26)) + list(range(0x61, 0x61 + 26))) if i not in self.commands.keys() ] index = 0 for command in self._commands: if 'cmd' in command and command['cmd'] not in self.commands.keys(): cmd = command['cmd'] if cmd in cmd_list: cmd_list.remove(cmd) else: cmd = cmd_list.pop() self.commands[cmd] = Command( 'Action: ' + list([x for x in list(command.keys()) if x not in ['cmd']])[0], 0, '', self.send_command, True, index) index += 1 index = 0 for status in self._statuses: if 'cmd' in status and status['cmd'] not in self.commands.keys(): cmd = status['cmd'] if cmd in cmd_list: cmd_list.remove(cmd) else: cmd = cmd_list.pop() self.commands[cmd] = Command( "Status: " + list([ x for x in list(status.keys()) if x not in ["id_list_can_toolz_system", "cmd", "current_status"] ])[0], 0, '', self.get_statuses, True, index) index += 1 fid_list = [] for name, data in status.items(): if name not in [ 'cmd', 'id_list_can_toolz_system', 'current_status' ]: for act, frame in data.items(): fid = frame.split("#")[0].strip() fid = int(fid, 0) if fid not in fid_list: fid_list.append(fid) status['id_list_can_toolz_system'] = fid_list
def do_init(self, params): self._status2 = params self.frames = [] self.init_sess2 = None self._seed = [] self.auth_resp_byte = 0 self.record_status = False self.wait_for_auth = False self.commands['auth'] = Command("UDS Auth", 0, "", self.control_auth, True) self.commands['set_key'] = Command("Set UDS access key", 1, "<key>", self.set_key, True) self.commands['write_id'] = Command("Write parameter (HEX)", 1, "<ident>, <data>", self.write_param, True)
def do_init(self, params): # Get device and open serial port self.DEBUG = int(params.get('debug', 0)) self.dprint(1, "Init phase started...") self._bus = (params.get('bus', "USBTin")) self._lost_frames = 0 self._dev_write_try = 0 if 'port' in params: self._COMPort = params['port'] if params['port'] == 'auto': for port in list(serial.tools.list_ports.comports()): self._COMPort = port[0] if self.init_port() == 1: break if not self._serialPort: self.dprint(0, 'Can\'t init device!') exit() elif params['port'] == 'loop': self._serialPort = serial.serial_for_url('loop://', timeout=0.5) else: if self.init_port() != 1: self.dprint(0, 'Can\'t init device!') exit() else: self.dprint(0, 'No port in config!') return 0 self._usbtin_loop = bool(params.get('usbtin_loop', False)) self._restart = bool(params.get('auto_activate', False)) self.act_time = float(params.get('auto_activate', 5.0)) self.last = time.clock() self.wait_for = False self._run = True self.do_stop({}) self.set_speed( str(params.get('speed', '500')) + ", " + str(params.get('sjw', '3'))) # print str(self._serialPort) self.dprint(1, "PORT: " + self._COMPort) self.dprint(1, "Speed: " + str(self._currentSpeed)) self.dprint(1, "USBtin device found!") self.commands['speed'] = Command( "Set device speed (kBaud) and SJW level(optional)", 1, " <speed>,<SJW> ", self.set_speed, True) self.commands['t'] = Command( "Send direct command to the device, like t001411223344", 1, " <cmd> ", self.dev_write, True)
def do_init(self, init_params): # Get device and open serial port self.device = init_params.get('iface', None) self._bus = init_params.get('bus', 'CANSocket') self.commands['t'] = Command( "Send CAN frame directly, like 01A#11223344", 1, " <frame> ", self.dev_write, True) self._active = True self._run = False
def do_init(self, params): self._status2 = params self._vin = self._status2.get("vin", "NLXXX6666CW006666") self._auth = self._status2.get("start_uniq_key", "tGh&ujKnf5$rFgvc%") self._status_engine = 0xfe # fe - unknown, ff - wrong key, 01 - turned on, 02 - dead self._status_rpm = 0 self.rpm_up = 0 self.rpm_down = 0 self.frames = [] self.commands['status'] = Command("Get engine status", 0, "", self.control_get_status, True) self.commands['rpmup'] = Command("Increase RMP", 0, "", self.control_rpm_up, True) self.commands['rpmdw'] = Command("Decrease RMP", 0, "", self.control_rpm_down, True) self.commands['start'] = Command("Start engine", 0, "", self.control_start_engine, True) self.commands['stop'] = Command("Stop engine", 0, "", self.control_stop_engine, True)
def do_init(self, params): self.CANList = Replay() self.last = time.process_time() self._last = 0 self._full = 1 self._num1 = 0 self._num2 = 0 if 'save_to' in params: self._fname = params['save_to'] else: self._fname = "mod_replay.save" if 'load_from' in params: self.cmd_load(params['load_from']) self.commands['g'] = Command( "Enable/Disable sniff mode to collect packets", 0, "", self.sniff_mode, True) self.commands['p'] = Command("Print count of loaded packets", 0, "", self.cnt_print, True) self.commands['l'] = Command("Load packets from file", 1, " <file> ", self.cmd_load, True) self.commands['r'] = Command( "Replay range from loaded, from number X to number Y", 1, " <X>-<Y> ", self.replay_mode, True) self.commands['d'] = Command( "Save range of loaded packets, from X to Y", 1, " <X>-<Y>, <filename>", self.save_dump, True) self.commands['c'] = Command("Clean loaded table", 0, "", self.clean_table, True)
def do_init(self, params): # Get device and open serial port # Interactive mode self.DEBUG = int(params.get('debug', 0)) self.dprint(1, "Init phase started...") self._queue = [[], [], []] if 'port' in params: self._COMPort = params['port'] if params['port'] == 'auto': for port in list(serial.tools.list_ports.comports()): self._COMPort = port[0] if self.init_port() == 1: break if not self._serialPort: self.dprint(0, 'Can\'t init device!') exit() else: if self.init_port() != 1: self.dprint(0, 'Can\'t init device!') exit() else: self.dprint(0, 'No port in config!') exit() self.do_stop(params) self.read_all() self.dprint(1, "Port : " + self._COMPort) if str(params.get('speed')) != 'auto': self._serialPort.write(b"\x01\x09\x01" + struct.pack("!H", int(params['speed']))) time.sleep(1) self._serialPort.write(b"\x01\x09\x02" + struct.pack("!H", int(params['speed']))) time.sleep(1) self._serialPort.write(b"\x01\x09\x03" + struct.pack("!H", int(params['speed']))) self.dprint(1, "Speed: " + str(params.get('speed'))) else: self.do_auto_rate() time.sleep(4) self.read_all() self.dprint( 1, "CANBus Triple device detected, version: " + self.read_json(self.get_info())['version']) self.commands['t'] = Command( "Send direct command to the device, like 02010011112233440000000008", 1, " <cmd> ", self.dev_write, True)
def do_init(self, params): # Get device and open serial port self.commands['t'] = Command("Send direct command to the device, like 13:8:1122334455667788", 1, " <cmd> ", self.dev_write, True) self.mode = params.get('mode', None) self.server = None if not self.mode or self.mode not in ['server', 'client']: self.dprint(0, 'Can\'t get mode!') exit() self.HOST = params.get('address', 'localhost') self.PORT = int(params.get('port', 6550)) self._bus = "TCP_" + self.mode + "_" + str(self.PORT) self.do_start_x() return 1
def do_init(self, params): """Initialize the serial communication with the CAN hardware. :raise: IOError when an error occured during CAN232 intialization. """ self.DEBUG = int(params.get('debug', 0)) self.dprint(1, 'Initializating hardware starting...') self._COM_port_name = params.get('port', None) if not self._COM_port_name: raise ValueError('No port specified (e.g. COM3, /dev/ttyACM0)') self._COM_speed = params.get('serial_speed', 115200) self._CAN_speed = params.get('speed', '500KBPS') self.init_port() self.dprint( 1, 'C232 version: {0}'.format(self._C232.version(max_tries=100))) self.commands['V'] = Command( 'Get version number of the CANBUS hardware', 0, '', self.cmd_version, True) self.commands['N'] = Command( 'Get serial number of the CANBUS hardware', 0, '', self.cmd_serial, True) self.commands['O'] = Command( 'Open communication channel with the CANBUS hardware', 0, '', self.cmd_open, True) self.commands['L'] = Command( 'Open communication channel in read only with the CANBUS hardware', 0, '', self.cmd_ropen, True) self.commands['C'] = Command( 'Close communication channel with the CANBUS hardware', 0, '', self.cmd_close, True) self.commands['Speed'] = Command('Set speed of CAN bus (e.g. 500KBPS)', 1, '<speed>', self.cmd_speed, True) self.commands['F'] = Command( 'Get status flag from the CANBUS hardware', 0, '', self.cmd_status, True) self.commands['Z'] = Command( 'Switch on/off the timestamp on the CAN frames', 1, '<True/False>', self.cmd_timestamp, True) self.commands['t'] = Command( 'Transmit a standard (11bit) frame (format iiiLDD..DD; e.g. 10021133)', 1, '<cmd>', self.cmd_transmit_std, True) self.commands['T'] = Command( 'Transmit an extended (29bit) frame (format iiiiiiiiLDD..DD; e.g. 0000010021133)', 1, '<cmd>', self.cmd_transmit_ext, True) self.commands['r'] = Command( 'Transmit a remote standard (11bit) frame (format iiiL; e.g. 1002)', 1, '<cmd>', self.cmd_transmit_rtr_std, True) self.commands['R'] = Command( 'Transmit a remote extended (29bit) frame (format iiiiiiiiL; e.g. 000001002)', 1, '<cmd>', self.cmd_transmit_rtr_ext, True) return 0