def test_login(self): """Test decompression of a login packet. The result is compared with data obtained from SAP GUI.""" login_compressed = read_data_file('sapgui_730_login_compressed.data') login_decompressed = read_data_file('sapgui_730_login_decompressed.data') pkt = Ether()/IP()/TCP(dport=3200)/SAPNI()/Raw(str(SAPDiag(compress=1))[:-8])/login_compressed packet = self.get_capture(pkt)[0] self.assertIn('sapdiag', packet) self.assertEqual(1, int(packet['sapdiag'].header_compression_returncode)) self.assertEqual(len(login_decompressed), int(packet['sapdiag'].header_compression_uncomplength))
def test_invalid_write(self): """Test invalid write vulnerability in LZC code (CVE-2015-2282)""" test_case = read_data_file('invalid_write_testcase.data', False) pkt = Ether()/IP()/TCP(dport=3200)/SAPNI()/Raw(str(SAPDiag(compress=1))[:-8])/test_case packet = self.get_capture(pkt)[0] self.assertIn('sapdiag', packet)
def test_invalid_write(self): """Test invalid write vulnerability in LZC code (CVE-2015-2282)""" test_case = read_data_file('invalid_write_testcase.data', False) pkt = Ether()/IP()/TCP(dport=3200)/SAPNI()/Raw(str(SAPDiag(compress=1))[:-8])/test_case packet = self.get_capture(pkt)[0] self.assertIn('sapdiag', packet) self.assertEqual(-60, int(packet['sapdiag'].header_compression_returncode))
def test_invalid_read(self): "Test invalid read vulnerability in LZH code (CVE-2015-2278)" test_case = read_data_file('invalid_read_testcase.data', False) pkt = Ether()/IP()/TCP(dport=3200)/SAPNI()/Raw(str(SAPDiag(compress=1))[:-8])/test_case packet = self.get_capture(pkt)[0] self.assertIn('sapdiag', packet) self.assertEqual(1, int(packet['sapdiag'].header_compression_returncode)) self.assertEqual("The uncompressed payload length (0) differs with the reported length (661)", packet['sapdiag'].header_compression_uncomplength_invalid)