예제 #1
0
파일: packet.py 프로젝트: tailsjoin/morphis
    def parse(self):
        super().parse()

        i = 1
        l, self.host_key = sshtype.parseBinary(self.buf[i:])
        i += l
        l, self.f = sshtype.parseMpint(self.buf[i:])
        i += l
        l, self.signature = sshtype.parseBinary(self.buf[i:])
예제 #2
0
    def parse(self):
        super().parse()

        i = 1
        l, self.host_key = sshtype.parseBinary(self.buf[i:])
        i += l
        l, self.f = sshtype.parseMpint(self.buf[i:])
        i += l
        l, self.signature = sshtype.parseBinary(self.buf[i:])
예제 #3
0
    def parse(self):
        super().parse()

        i = 1
        l, self.algorithm_name = sshtype.parseString(self.buf[i:])
        i += l
        l, self.public_key = sshtype.parseBinary(self.buf[i:])
예제 #4
0
파일: packet.py 프로젝트: tailsjoin/morphis
    def parse(self):
        super().parse()

        i = 1
        l, self.algorithm_name = sshtype.parseString(self.buf[i:])
        i += l
        l, self.public_key = sshtype.parseBinary(self.buf[i:])
예제 #5
0
    def parse(self):
        super().parse()
        i = 1

        if i + 1 == len(self.buf):
            self.data_present = struct.unpack("?", self.buf[i : i + 1])[0]
        else:
            l, self.first_id = sshtype.parseBinary(self.buf[i:])
예제 #6
0
    def parse(self):
        super().parse()
        i = 1

        if i + 1 == len(self.buf):
            self.data_present = struct.unpack("?", self.buf[i:i + 1])[0]
        else:
            l, self.first_id = sshtype.parseBinary(self.buf[i:])
예제 #7
0
    def parse(self):
        super().parse()
        i = 1
        l, self.data = sshtype.parseBinary(self.buf[i:])
        i += l
        self.targeted = struct.unpack_from("?", self.buf, i)[0]
        i += 1

        if i == len(self.buf):
            return

        l, self.pubkey = sshtype.parseBinary(self.buf[i:])
        i += l
        l, self.path_hash = sshtype.parseBinary(self.buf[i:])
        i += l
        l, self.version = sshtype.parseMpint(self.buf[i:])
        i += l
        l, self.signature = sshtype.parseBinary(self.buf[i:])
예제 #8
0
    def parse(self):
        super().parse()
        i = 1
        pcnt = struct.unpack(">L", self.buf[i:i + 4])[0]
        i += 4
        self.peers = []
        for n in range(pcnt):
            if log.isEnabledFor(logging.DEBUG):
                log.debug("Reading record {}.".format(n))
            peer = Peer()  # db.Peer.
            l, peer.address = sshtype.parseString(self.buf[i:])
            i += l
            l, peer.node_id = sshtype.parseBinary(self.buf[i:])
            i += l
            l, peer.pubkey = sshtype.parseBinary(self.buf[i:])
            i += l

            self.peers.append(peer)
예제 #9
0
    def parse(self):
        super().parse()
        i = 1
        l, self.data = sshtype.parseBinary(self.buf[i:])
        i += l
        self.targeted = struct.unpack_from("?", self.buf, i)[0]
        i += 1

        if i == len(self.buf):
            return

        l, self.pubkey = sshtype.parseBinary(self.buf[i:])
        i += l
        l, self.path_hash = sshtype.parseBinary(self.buf[i:])
        i += l
        l, self.version = sshtype.parseMpint(self.buf[i:])
        i += l
        l, self.signature = sshtype.parseBinary(self.buf[i:])
예제 #10
0
    def parse(self):
        super().parse()
        i = 1
        pcnt = struct.unpack(">L", self.buf[i : i + 4])[0]
        i += 4
        self.peers = []
        for n in range(pcnt):
            if log.isEnabledFor(logging.DEBUG):
                log.debug("Reading record {}.".format(n))
            peer = Peer()  # db.Peer.
            l, peer.address = sshtype.parseString(self.buf[i:])
            i += l
            l, peer.node_id = sshtype.parseBinary(self.buf[i:])
            i += l
            l, peer.pubkey = sshtype.parseBinary(self.buf[i:])
            i += l

            self.peers.append(peer)
예제 #11
0
    def parse(self):
        super().parse()

        i = 1
        l, self.user_name = sshtype.parseString(self.buf[i:])
        i += l
        l, self.service_name = sshtype.parseString(self.buf[i:])
        i += l
        l, self.method_name = sshtype.parseString(self.buf[i:])
        i += l

        if self.method_name == "publickey":
            self.signature_present = struct.unpack("?", self.buf[i:i + 1])[0]
            i += 1
            l, self.algorithm_name = sshtype.parseString(self.buf[i:])
            i += l
            l, self.public_key = sshtype.parseBinary(self.buf[i:])
            if self.signature_present:
                i += l
                l, self.signature = sshtype.parseBinary(self.buf[i:])
                self.signature_length = l
예제 #12
0
파일: packet.py 프로젝트: tailsjoin/morphis
    def parse(self):
        super().parse()

        i = 1
        l, self.user_name = sshtype.parseString(self.buf[i:])
        i += l
        l, self.service_name = sshtype.parseString(self.buf[i:])
        i += l
        l, self.method_name = sshtype.parseString(self.buf[i:])
        i += l

        if self.method_name == "publickey":
            self.signature_present = struct.unpack("?", self.buf[i:i+1])[0]
            i += 1
            l, self.algorithm_name = sshtype.parseString(self.buf[i:])
            i += l
            l, self.public_key = sshtype.parseBinary(self.buf[i:])
            if self.signature_present:
                i += l
                l, self.signature = sshtype.parseBinary(self.buf[i:])
                self.signature_length = l
예제 #13
0
    def parse(self):
        super().parse()
        i = 1
        l, self.data = sshtype.parseBinary(self.buf[i:])
        i += l
        self.original_size = struct.unpack(">L", self.buf[i:i + 4])[0]
        i += 4

        if i == len(self.buf):
            return

        l, self.version = sshtype.parseMpint(self.buf[i:])
        i += l
        l, self.signature = sshtype.parseBinary(self.buf[i:])
        i += l

        if i == len(self.buf):
            return

        l, self.epubkey = sshtype.parseBinary(self.buf[i:])
        i += l
        self.pubkeylen = struct.unpack(">L", self.buf[i:i + 4])[0]
예제 #14
0
    def parse(self):
        super().parse()
        i = 1
        self.index = struct.unpack(">L", self.buf[i:i + 4])[0]
        i += 4

        cnt = struct.unpack(">L", self.buf[i:i + 4])[0]
        i += 4
        self.packets = []
        for n in range(cnt):
            l, packet = sshtype.parseBinary(self.buf[i:])
            i += l
            self.packets.append(packet)
예제 #15
0
    def parse(self):
        super().parse()
        i = 1
        self.index = struct.unpack(">L", self.buf[i : i + 4])[0]
        i += 4

        cnt = struct.unpack(">L", self.buf[i : i + 4])[0]
        i += 4
        self.packets = []
        for n in range(cnt):
            l, packet = sshtype.parseBinary(self.buf[i:])
            i += l
            self.packets.append(packet)
예제 #16
0
    def parse(self):
        super().parse()
        i = 1
        l, self.data = sshtype.parseBinary(self.buf[i:])
        i += l
        self.original_size = struct.unpack(">L", self.buf[i : i + 4])[0]
        i += 4

        if i == len(self.buf):
            return

        l, self.version = sshtype.parseMpint(self.buf[i:])
        i += l
        l, self.signature = sshtype.parseBinary(self.buf[i:])
        i += l

        if i == len(self.buf):
            return

        l, self.epubkey = sshtype.parseBinary(self.buf[i:])
        i += l
        self.pubkeylen = struct.unpack(">L", self.buf[i : i + 4])[0]
예제 #17
0
 def verify_ssh_sig(self, key_data, sig_msg):
     i, v = sshtype.parseString(sig_msg)
     if v != "ssh-rsa":
         log.warning("Not an ssh-rsa signature!")
         return False
     if log.isEnabledFor(logging.DEBUG):
         log.debug("l[{}][{}]".format(i, len(sig_msg)))
     sig = util.inflate_long(sshtype.parseBinary(sig_msg[i:])[1], True)
     # verify the signature by SHA'ing the key_data and encrypting it using the
     # public key.  some wackiness ensues where we "pkcs1imify" the 20-byte
     # hash into a string as long as the RSA key.
     if log.isEnabledFor(logging.DEBUG):
         log.debug("sig=[{}].".format(sig))
     hash_obj = util.inflate_long(self._pkcs1imify(sha1(key_data).digest()), True)
     rsa = self._public_key()
     return rsa.verify(hash_obj, (sig,))
예제 #18
0
 def verify_ssh_sig(self, key_data, sig_msg):
     i, v = sshtype.parseString(sig_msg)
     if v != 'ssh-rsa':
         log.warning("Not an ssh-rsa signature!")
         return False
     if log.isEnabledFor(logging.DEBUG):
         log.debug("l[{}][{}]".format(i, len(sig_msg)))
     sig = util.inflate_long(sshtype.parseBinary(sig_msg[i:])[1], True)
     # verify the signature by SHA'ing the key_data and encrypting it using the
     # public key.  some wackiness ensues where we "pkcs1imify" the 20-byte
     # hash into a string as long as the RSA key.
     if log.isEnabledFor(logging.DEBUG):
         log.debug("sig=[{}].".format(sig))
     hash_obj = util.inflate_long(self._pkcs1imify(sha1(key_data).digest()), True)
     rsa = self._public_key()
     return rsa.verify(hash_obj, (sig, ))
예제 #19
0
    def parse(self):
        super().parse()
        i = 1
        l, self.node_id = sshtype.parseBinary(self.buf[i:])
        i += l
        self.data_mode = DataMode(struct.unpack("B", self.buf[i:i + 1])[0])
        i += 1

        has_version = struct.unpack_from("?", self.buf, i)[0]
        i += 1
        if has_version:
            i, self.version = sshtype.parse_mpint_from(self.buf, i)

        if i == len(self.buf):
            return

        self.significant_bits = struct.unpack(">H", self.buf[i:i + 2])[0]
        i += 2

        if i == len(self.buf):
            return

        i, self.target_key = sshtype.parse_binary_from(self.buf, i)
예제 #20
0
    def parse(self):
        super().parse()
        i = 1
        l, self.node_id = sshtype.parseBinary(self.buf[i:])
        i += l
        self.data_mode = DataMode(struct.unpack("B", self.buf[i : i + 1])[0])
        i += 1

        has_version = struct.unpack_from("?", self.buf, i)[0]
        i += 1
        if has_version:
            i, self.version = sshtype.parse_mpint_from(self.buf, i)

        if i == len(self.buf):
            return

        self.significant_bits = struct.unpack(">H", self.buf[i : i + 2])[0]
        i += 2

        if i == len(self.buf):
            return

        i, self.target_key = sshtype.parse_binary_from(self.buf, i)
예제 #21
0
 def parse(self):
     super().parse()
     i = 1
     l, self.data = sshtype.parseBinary(self.buf[i:])
     i += l
     self.targeted = struct.unpack_from("?", self.buf, i)[0]
예제 #22
0
파일: shell.py 프로젝트: tailsjoin/morphis
 def parse(self):
     i = 1
     l, self.value = sshtype.parseBinary(self.buf)
예제 #23
0
파일: shell.py 프로젝트: tailsjoin/morphis
 def parse(self):
     i = 1
     l, self.value = sshtype.parseBinary(self.buf)
예제 #24
0
 def parse(self):
     super().parse()
     i = 1
     l, self.data = sshtype.parseBinary(self.buf[i:])
     i += l
     self.targeted = struct.unpack_from("?", self.buf, i)[0]