Nine South African and three Malawian peacekeeping soldiers have been killed by M23 rebels, authorities say.