コード例 #1
0
    def initiate_session(self, data, address, session):
        if len(data) < 22:
            self.close_server_session(session)
            return
        payload_offset = 14
        if not (data[0] == '\x06' and data[2:4] == '\xff\x07'):
            # check rmcp version, sequencenumber and class;
            self.close_server_session(session)
            return
        if data[4] == '\x06':
            # ipmi v2
            session.ipmiversion = 2.0
            session.authtype = 6
            payload_type = data[5]
            if payload_type not in ('\x00', '\x10'):
                self.close_server_session(session)
                return
            if payload_type == '\x10':
                # new session to handle conversation
                serversession.ServerSession(self.authdata,
                                            self.kg,
                                            session.sockaddr,
                                            self.sock,
                                            data[16:],
                                            self.uuid,
                                            bmc=self)
                return
            payload_offset = 16

        myaddr, netfnlun = struct.unpack(
            '2B', data[payload_offset:payload_offset + 2])
        netfn = (netfnlun & 0b11111100) >> 2
        mylun = netfnlun & 0b11
        clientaddr, clientseqlun = struct.unpack(
            'BB', data[payload_offset + 3:payload_offset + 5])
        clientlun = (clientseqlun & 0xb11)
        clientseq = (clientseqlun & 0b11111100) >> 2
        if netfn == 6:
            # application request
            if data[payload_offset + 5] == '\x38':
                # cmd = get channel auth capabilities
                verchannel, level = struct.unpack(
                    '2B', data[payload_offset + 6:payload_offset + 8])
                version = verchannel & 0b10000000
                if version != 0b10000000:
                    self.close_server_session(session)
                    return
                channel = verchannel & 0b1111
                if channel != 0xe:
                    self.close_server_session(session)
                    return
                (clientaddr, clientlun) = struct.unpack('BB', data[17:19])
                level &= 0b1111
                if session.authtype == 6:
                    self.send_auth_cap_v2(session, myaddr, mylun, clientaddr,
                                          clientlun, clientseq,
                                          session.sockaddr)
                else:
                    self.send_auth_cap(session, myaddr, mylun, clientaddr,
                                       clientlun, session.sockaddr)
コード例 #2
0
 def initiate_session(self, data, address, session):
     if len(data) < 22:
         self.close_server_session()
         return
     if not (chr_py3(data[0]) == b"\x06" and data[2:4] == b"\xff\x07"):
         # check rmcp version, sequencenumber and class;
         self.close_server_session()
         return
     if chr_py3(data[4]) == b"\x06":
         # ipmi v2
         session.ipmiversion = 2.0
         session.authtype = 6
         payload_type = chr_py3(data[5])
         if payload_type not in (b"\x00", b"\x10"):
             self.close_server_session()
             return
         if payload_type == b"\x10":
             # new session to handle conversation
             serversession.ServerSession(
                 self.authdata,
                 self.kg,
                 session.sockaddr,
                 self.sock,
                 data[16:],
                 self.uuid,
                 bmc=self,
             )
             serversession.ServerSession.logged = logger
             return
         # data = data[13:]
     if len(data[14:16]) < 2:
         self.close_server_session()
     else:
         myaddr, netfnlun = struct.unpack("2B", data[14:16])
         netfn = (netfnlun & 0b11111100) >> 2
         mylun = netfnlun & 0b11
         if netfn == 6:
             # application request
             if chr_py3(data[19]) == b"\x38":
                 # cmd = get channel auth capabilities
                 verchannel, level = struct.unpack("2B", data[20:22])
                 version = verchannel & 0b10000000
                 if version != 0b10000000:
                     self.close_server_session()
                     return
                 channel = verchannel & 0b1111
                 if channel != 0xE:
                     self.close_server_session()
                     return
                 (clientaddr, clientlun) = struct.unpack("BB", data[17:19])
                 level &= 0b1111
                 self.send_auth_cap(
                     myaddr, mylun, clientaddr, clientlun, session.sockaddr
                 )
コード例 #3
0
 def initiate_session(self, data, address, session):
     if len(data) < 22:
         self.close_server_session()
         return
     if not (data[0:1] == b'\x06' and data[2:4] == b'\xff\x07'):
         # check rmcp version, sequencenumber and class;
         self.close_server_session()
         return
     if data[4:5] == b'\x06':
         # ipmi v2
         session.ipmiversion = 2.0
         session.authtype = 6
         payload_type = data[5:6]
         if payload_type not in (b'\x00', b'\x10'):
             self.close_server_session()
             return
         if payload_type == b'\x10':
             # new session to handle conversation
             serversession.ServerSession(self.authdata,
                                         self.kg,
                                         session.sockaddr,
                                         self.sock,
                                         data[16:],
                                         self.uuid,
                                         bmc=self)
             return
         data = data[13:]
     myaddr, netfnlun = struct.unpack('2B', data[14:16])
     netfn = (netfnlun & 0b11111100) >> 2
     mylun = netfnlun & 0b11
     if netfn == 6:
         # application request
         if data[19:20] == b'\x38':
             # cmd = get channel auth capabilities
             verchannel, level = struct.unpack('2B', data[20:22])
             version = verchannel & 0b10000000
             if version != 0b10000000:
                 self.close_server_session()
                 return
             channel = verchannel & 0b1111
             if channel != 0xe:
                 self.close_server_session()
                 return
             (clientaddr, clientlun) = struct.unpack('BB', data[17:19])
             level &= 0b1111
             self.send_auth_cap(myaddr, mylun, clientaddr, clientlun,
                                session.sockaddr)