There are many different ways of acquiring prohibited wealth and the action that needs to be taken can vary a great deal, depending on the specific circumstances. One should study the Fiqh of trade in order to get a more complete understanding of the subject matter.
However, if the wealth is such that it legally belongs to another then one must return it to the true owner or his inheritors. It is not permitted to consume it.
لاَ تَأْكُلُوَاْ أَمْوَالَكُمْ بَيْنَكُمْ بِالْبَاطِلِ
Do not consume one another’s wealth unjustly (Surah al-Baqarah, 188).
If that is not possible then one must give it to charity without the intention of receiving reward, but rather with the intention of removing Haram wealth from his possession.
كَسْبُ الْمُغَنِّيَةِ كَالْمَغْصُوبِ لَمْ يَحِلَّ أَخْذُهُ، وَعَلَى هَذَا قَالُوا لَوْ مَاتَ الرَّجُلُ وَكَسْبُهُ مِنْ بَيْعِ الْبَاذَقِ أَوْ الظُّلْمِ أَوْ أَخْذِ الرِّشْوَةِ يَتَوَرَّعُ الْوَرَثَةُ، وَلَا يَأْخُذُونَ مِنْهُ شَيْئًا وَهُوَ أَوْلَى بِهِمْ وَيَرُدُّونَهَا عَلَى أَرْبَابِهَا إنْ عَرَفُوهُمْ، وَإِلَّا تَصَدَّقُوا بِهَا لِأَنَّ سَبِيلَ الْكَسْبِ الْخَبِيثِ التَّصَدُّقُ إذَا تَعَذَّرَ الرَّدُّ عَلَى صَاحِبِهِ
The earnings of a singer are liked usurped wealth. It is not permitted to take the payment. Based on this they said if a man dies and his earnings were from selling intoxicants, oppression or taking bribes then the inheritors should be scrupulous and not take any of it, this is most correct for them. They should return it to the people it truly belongs to, if they know who they are. Otherwise, they should give it to the poor, because impure earnings should be given to the poor (as charity) if it is not possible to return the wealth to the true owners. (Radd al-Muhtaar).
– Answered by Shaykh Noorud-deen (04.01.2021)