Example #1
0
    def test_login(self):
        """Test (de)compression of a login packet. The result is
        compared with data obtained from SAP GUI."""
        from pysapcompress import compress, decompress, ALG_LZH
        login_compressed = read_data_file('sapgui_730_login_compressed.data')
        login_decompressed = read_data_file(
            'sapgui_730_login_decompressed.data')

        status, out_length, decompressed = decompress(login_compressed,
                                                      len(login_decompressed))

        self.assertTrue(status)
        self.assertEqual(out_length, len(login_decompressed))
        self.assertEqual(decompressed, login_decompressed)

        status, out_length, compressed = compress(decompressed, ALG_LZH)

        self.assertTrue(status)
        self.assertEqual(out_length, len(login_compressed))

        # As we can't compare with the compressed data (LZH randomness),
        # decompress again and check with the plain text

        status, out_length, decompressed = decompress(compressed,
                                                      len(login_decompressed))

        self.assertTrue(status)
        self.assertEqual(out_length, len(login_decompressed))
        self.assertEqual(decompressed, login_decompressed)
Example #2
0
    def test_login_screen(self):
        """Test (de)compression of a login screen packet. The result is
        compared with data obtained from SAP GUI."""
        from pysapcompress import compress, decompress, ALG_LZH
        login_screen_compressed = read_data_file('nw_703_login_screen_compressed.data')
        login_screen_decompressed = read_data_file('nw_703_login_screen_decompressed.data')

        status, out_length, decompressed = decompress(login_screen_compressed, len(login_screen_decompressed))

        self.assertTrue(status)
        self.assertEqual(out_length, len(login_screen_decompressed))
        self.assertEqual(decompressed, login_screen_decompressed)

        status, out_length, compressed = compress(decompressed, ALG_LZH)

        self.assertTrue(status)
        self.assertEqual(out_length, len(login_screen_compressed))

        # As we can't compare with the compressed data (LZH randomness),
        # decompress again and check with the plain text

        status, out_length, decompressed = decompress(compressed, len(login_screen_decompressed))

        self.assertTrue(status)
        self.assertEqual(out_length, len(login_screen_decompressed))
        self.assertEqual(decompressed, login_screen_decompressed)
Example #3
0
    def test_invalid_write(self):
        """Test invalid write vulnerability in LZC code (CVE-2015-2282)"""
        from pysapcompress import decompress, DecompressError

        test_case = read_data_file('invalid_write_testcase.data', False)

        self.assertRaisesRegexp(DecompressError, "stack overflow in decomp", decompress, test_case, 6716)
Example #4
0
    def test_invalid_write(self):
        """Test invalid write vulnerability in LZC code (CVE-2015-2282)"""
        from pysapcompress import decompress, DecompressError

        test_case = read_data_file('invalid_write_testcase.data', False)

        self.assertRaisesRegexp(DecompressError, "stack overflow in decomp", decompress, test_case, 6716)
Example #5
0
    def test_sapdiag_items(self):
        """Test dissection of Diag Items"""
        diag_items = SAPDiagItems(read_data_file('nw_703_login_screen_decompressed.data'))

        self.assertEqual(len(diag_items.message), 131)

        for item in diag_items.message:
            self.assertIsInstance(item, SAPDiagItem)
Example #6
0
    def test_sapdiag_items(self):
        """Test dissection of Diag Items"""
        diag_items = SAPDiagItems(read_data_file('nw_703_login_screen_decompressed.data'))

        self.assertEqual(len(diag_items.message), 131)

        for item in diag_items.message:
            self.assertIsInstance(item, SAPDiagItem)
Example #7
0
    def test_sapdiag_atoms(self):
        """Test dissection of Diag Items and Dynt Atom Items"""
        diag_items = SAPDiagItems(read_data_file('nw_703_login_screen_decompressed.data'))
        diag_packet = SAPDiag(message=diag_items.message)
        diag_atoms = diag_packet.get_item(0x12, 0x09, 0x02)

        for atom in diag_atoms:
            for atom_item in atom.item_value.items:
                self.assertIsInstance(atom_item, SAPDiagDyntAtomItem)
Example #8
0
    def test_sapdiag_atoms(self):
        """Test dissection of Diag Items and Dynt Atom Items"""
        diag_items = SAPDiagItems(read_data_file('nw_703_login_screen_decompressed.data'))
        diag_packet = SAPDiag(message=diag_items.message)
        diag_atoms = diag_packet.get_item(0x12, 0x09, 0x02)

        for atom in diag_atoms:
            for atom_item in atom.item_value.items:
                self.assertIsInstance(atom_item, SAPDiagDyntAtomItem)
Example #9
0
    def test_invalid_write(self):
        """Test invalid write vulnerability in LZC code (CVE-2015-2282)"""
        from pysapcompress import decompress, DecompressError

        test_case = read_data_file('invalid_write_testcase.data', False)

        try:
            decompress(test_case, 6716)
        except Exception as e:
            self.assertIsInstance(e, DecompressError)
Example #10
0
    def test_invalid_read(self):
        "Test invalid read vulnerability in LZH code (CVE-2015-2278)"
        from pysapcompress import decompress, DecompressError

        test_case = read_data_file('invalid_read_testcase.data', False)

        try:
            decompress(test_case, 661)
        except Exception as e:
            self.assertIsInstance(e, DecompressError)
            self.assertEqual(str(e), "Decompression error (bad hufman tree)")
Example #11
0
    def test_invalid_read(self):
        """Test invalid read vulnerability in LZH code (CVE-2015-2278)"""
        from pysapcompress import decompress, DecompressError

        test_case = read_data_file('invalid_read_testcase.data', False)

        try:
            decompress(test_case, 661)
        except Exception as e:
            self.assertIsInstance(e, DecompressError)
            self.assertIn("bad hufman tree", str(e))