示例#1
0
文件: basic.py 项目: hmyit/qiew
    def init(self, dataModel, viewMode):
        super(basic, self).init(dataModel, viewMode)

        root = os.path.dirname(sys.argv[0])
        self.ui = PyQt5.uic.loadUi(
            os.path.join(root, 'plugins', 'unpack', 'basic.ui'))

        self.ui.key.textChanged.connect(self._keychanged)
        self.ui.key.setValidator(UnpackPlugin.MyValidator(self.ui.key))
        self.ui.delta.setValidator(UnpackPlugin.MyValidator(self.ui.delta))

        return True
示例#2
0
    def _getvalue(self, op, key):

        if key == '':
            return key

        if op == 'Hex':
            key = UnpackPlugin._convert(key)

            keysize = (key.bit_length() + (8 - key.bit_length()%8)%8)/8
            i = 0

            out = ''
            if keysize == 0:
                out += '\x00'

            # ugly, but it's ok, string is small
            while i < keysize:
                out += chr(key & 0xFF)
                key = key >> 8
                i += 1

            key = out

        else:
            key = key

        return key
示例#3
0
    def proceed(self):
    	op = self.ui.op.currentText()
    	op = str(op)

    	key = str(self.ui.key.text())
    	if key == '':
    		return False

    	if op == 'Hex':
    		key = UnpackPlugin._convert(key)

    		keysize = (key.bit_length() + (8 - key.bit_length()%8)%8)/8
    		i = 0

    		out = ''
    		if keysize == 0:
    			out += '\x00'

    		# ugly, but it's ok, string is small
    		while i < keysize:
    			out += chr(key & 0xFF)
    			key = key >> 8
    			i += 1

    		key = out


        if self.viewMode.selector.getCurrentSelection():
            u, v = self.viewMode.selector.getCurrentSelection()

            encrypted = self.rc4decrypt(self.dataModel.getStream(u, v), key)
            self.dataModel.setData_s(u, v, encrypted)
        return True
示例#4
0
    def proceed(self):
        op = self.ui.op.currentText()
        op = str(op)

        key = str(self.ui.key.text())
        if key == '':
            return False

        if op == 'Hex':
            key = UnpackPlugin._convert(key)

            keysize = (key.bit_length() + (8 - key.bit_length() % 8) % 8) / 8
            i = 0

            out = ''
            if keysize == 0:
                out += '\x00'

            # ugly, but it's ok, string is small
            while i < keysize:
                out += chr(key & 0xFF)
                key = key >> 8
                i += 1

            key = out

        if self.viewMode.selector.getCurrentSelection():
            u, v = self.viewMode.selector.getCurrentSelection()

            encrypted = self.rc4decrypt(self.dataModel.getStream(u, v), key)
            self.dataModel.setData_s(u, v, encrypted)
        return True
示例#5
0
    def _getvalue(self, op, key):

        if key == '':
            return key

        if op == 'Hex':
            key = UnpackPlugin._convert(key)

            keysize = (key.bit_length() + (8 - key.bit_length() % 8) % 8) / 8
            i = 0

            out = ''
            if keysize == 0:
                out += '\x00'

            # ugly, but it's ok, string is small
            while i < keysize:
                out += chr(key & 0xFF)
                key = key >> 8
                i += 1

            key = out

        else:
            key = key

        return key
示例#6
0
文件: basic.py 项目: gh0std4ncer/qiew
    def _keychanged(self, key):
        key = str(key)
        if key:
            key = UnpackPlugin._convert(key)
        else:
            key = 0

        keysize = (key.bit_length() + (8 - key.bit_length()%8)%8)/8
        self.ui.bytes.setText(str(keysize))
示例#7
0
文件: basic.py 项目: hmyit/qiew
    def _keychanged(self, key):
        key = str(key)
        if key:
            key = UnpackPlugin._convert(key)
        else:
            key = 0

        keysize = (key.bit_length() + (8 - key.bit_length() % 8) % 8) // 8
        self.ui.bytes.setText(str(keysize))
示例#8
0
    def _itemchanged(self, text):
        text = str(text)

        if text == 'Hex':
            # hex validator
            self.ui.key.setText('')
            self.ui.key.setValidator(UnpackPlugin.MyValidator(self.ui.key))
        else:
            # no validator for string
            self.ui.key.setText('')
            self.ui.key.setValidator(None)
示例#9
0
文件: enc_aes.py 项目: mtivadar/qiew
    def _getvalue(self, op, key):

        if key == '':
            return bytes(key)

        if op == 'Hex':
            key = UnpackPlugin._convert(key)
            key = key.to_bytes((key.bit_length() + 7) // 8, byteorder='little')
        else:
            key = bytes(key, 'utf-8')

        return key
示例#10
0
    def _getvalue(self, op, key):

        if key == '':
            return bytes(key)

        if op == 'Hex':
            key = UnpackPlugin._convert(key)
            key = key.to_bytes((key.bit_length() + 7) // 8, byteorder='little')
        else:
            key = bytes(key, 'utf-8')

        return key
示例#11
0
    def _itemchanged(self, text):
        self.ui.label_key.setStyleSheet("QLabel {color : red; }")
        text = str(text)

        if text == 'Hex':
            # hex validator
            self.ui.key.setText('')
            self.ui.key.setValidator(UnpackPlugin.MyValidator(self.ui.key))
        else:
            # no validator for string
            self.ui.key.setText('')
            self.ui.key.setValidator(None)
示例#12
0
文件: enc_rc4.py 项目: mtivadar/qiew
    def proceed(self):
        op = self.ui.op.currentText()
        op = str(op)

        key = str(self.ui.key.text())

        if key == '':
            return False

        if op == 'Hex':
            key = UnpackPlugin._convert(key)
            key = key.to_bytes((key.bit_length() + 7) // 8, byteorder='little')
            print(key)
        else:
            key = bytearray(key, 'utf-8')

        if self.viewMode.selector.getCurrentSelection():
            u, v = self.viewMode.selector.getCurrentSelection()

            encrypted = self.rc4decrypt(self.dataModel.getStream(u, v), key)
            self.dataModel.setData_s(u, v, encrypted)

        return True
示例#13
0
    def proceed(self):
        op = self.ui.op.currentText()
        op = str(op)

        key = str(self.ui.key.text())

        if key == '':
            return False

        if op == 'Hex':
            key = UnpackPlugin._convert(key)
            key = key.to_bytes((key.bit_length() + 7) // 8, byteorder='little')
            print(key)
        else:
            key = bytearray(key, 'utf-8')

        if self.viewMode.selector.getCurrentSelection():
            u, v = self.viewMode.selector.getCurrentSelection()

            encrypted = self.rc4decrypt(self.dataModel.getStream(u, v), key)
            self.dataModel.setData_s(u, v, encrypted)

        return True
示例#14
0
文件: basic.py 项目: gh0std4ncer/qiew
    def proceed(self):
        if self.viewMode.selector.getCurrentSelection():
            u, v = self.viewMode.selector.getCurrentSelection()

            # prepare values vrom text boxes            
            op = str(self.ui.op.currentText())
            key = str(self.ui.key.text())
            
            if key:
                key = UnpackPlugin._convert(str(self.ui.key.text()))
            else:
                key = 0

            keyop = str(self.ui.keyop.currentText())

            # get delta
            delta = str(self.ui.delta.text())
            if delta:
                delta = UnpackPlugin._convert(str(self.ui.delta.text()))
            else:
                delta = 0

            size = str(self.ui.bytes.text())
            if size:
                size = int(size)
            else:
                size = 0

            if size < 1:
                return

            skip = str(self.ui.skip.text())
            if skip:
                skip = int(skip, 0)
            else:
                skip = 0

            OP = {}
            
            OP['ROL'] = self._rol
            OP['ROR'] = self._ror
            OP['ADD'] = self._add
            OP['SUB'] = self._sub
            OP['XOR'] = self._xor
            OP['---'] = lambda key, delta, keysize: key

            i = 0
            while i < v-u:
                
                offset = u+i

                b = 0
                j = 0

                # ugly
                while j < size:
                    B = self.dataModel.getBYTE(offset + j)
                    if B:
                        b = b | (B << (8*j))
                    j += 1

                b = OP[op](b, key, size)

                # compute key size in bytes
                keysize = (key.bit_length() + (8 - key.bit_length()%8)%8)/8
                key = OP[keyop](key, delta, keysize)

                j = 0
                # ugly again
                while j < size:
                    c = b & 0xFF
                    #self.dataModel.setData_b(offset + size - 1 - j, chr(c))
                    self.dataModel.setData_b(offset +  j, chr(c))
                    b = b >> 8
                    j += 1

                i += (size + skip)
示例#15
0
文件: basic.py 项目: hmyit/qiew
    def proceed(self):
        if self.viewMode.selector.getCurrentSelection():
            u, v = self.viewMode.selector.getCurrentSelection()

            # prepare values vrom text boxes
            op = str(self.ui.op.currentText())
            key = str(self.ui.key.text())

            if key:
                key = UnpackPlugin._convert(str(self.ui.key.text()))
            else:
                key = 0

            keyop = str(self.ui.keyop.currentText())

            # get delta
            delta = str(self.ui.delta.text())
            if delta:
                delta = UnpackPlugin._convert(str(self.ui.delta.text()))
            else:
                delta = 0

            size = str(self.ui.bytes.text())
            if size:
                size = int(size)
            else:
                size = 0

            if size < 1:
                return

            skip = str(self.ui.skip.text())
            if skip:
                skip = int(skip, 0)
            else:
                skip = 0

            OP = {}

            OP['ROL'] = self._rol
            OP['ROR'] = self._ror
            OP['ADD'] = self._add
            OP['SUB'] = self._sub
            OP['XOR'] = self._xor
            OP['---'] = lambda key, delta, keysize: key

            i = 0
            while i < v - u:

                offset = u + i

                b = 0
                j = 0

                # ugly
                while j < size:
                    B = self.dataModel.getBYTE(offset + j)
                    if B:
                        b = b | (B << (8 * j))
                    j += 1

                b = OP[op](b, key, size)

                # compute key size in bytes
                keysize = (key.bit_length() +
                           (8 - key.bit_length() % 8) % 8) // 8
                key = OP[keyop](key, delta, keysize)

                j = 0
                # ugly again
                while j < size:
                    c = b & 0xFF
                    #self.dataModel.setData_b(offset + size - 1 - j, chr(c))
                    self.dataModel.setData_b(offset + j, c)
                    b = b >> 8
                    j += 1

                i += (size + skip)