Masturbation is haram, and the aforementioned situation would not exempt a man from conducting such an act.
He can either request assistance from his wife, if he is married, and if not, to find alternative halal methods, which he certainly will be able to find.
With prayers for your success.
Thank you for your question. Frapping is unfortunately a common practice among males due to the highly sexualised world that we live in. It is a habit that needs to be dealt with in a number of ways so what follows is not an exhaustive list but some suggestions on what to do.
1) It is very important to be clear about the harms of frapping both for your current mental state and for your future life with a partner. That is aside from the effects on your spirituality and faith as well as the punishment it induces in the next world. It is impotant to think about these so that you have a clear motivation to stop.
2) Ridding your environment of all aids and prerequisites that cause frapping. Turn on the parental locks on all your devices and make a consequences on yourself for breaking this rule in any way.
3) Realizing that breaking any habit is a process but that this specific habit should never be consciously repeated. Make this a rule for yourself. If you break it don't get so down that you stop the journey.
5) Some people have recommended having a cold shower when making the ghusl after ejaculation, so as to build up an additional barrier to the act itself.
6) Although there are no specific duas i know of continual prayer is something that is absolutely necessary to reach any important goal in life.
May you always be successful
The root of these sinful acts is weakness in front of the sinful desires. This weakness can be tackled by:
1. Remembering the fact the Allah is seeing us always. Will we ignore His presence and commit the sinful act in front of Allah?
2. Remembering the harm and damage caused to your heart, mind and body by these sinful acts. How can a sensible person harm himself deliberately for the sake of few moments of sinful lust?
3. Remembering the fate of those who committed such sinful acts and how they gained nothing, but the loss and damage to themselves.
4. Remembering the great reward of pious people who keep themselves away from the sinful desires for the sake of Allah. The reward in Paradise is much greater than any lust.
5. Remembering the painful results and sever misery of those who committed sinful acts. Can you tolerate such dangerous results? Is this sinful desire worth putting you in such fatal results?
6. Repeating Estighfaar and Salawaat is very useful in cleaning the inner and enlightening the mind and heart.
7. Seeking the help from Allah with the Waseela of His most beloved servants, Muhammad and his Holy Progeny Ahlul Bayt (AS).
Wrong act committed in ignorance is not a deliberate sin if the person was unable to know the real rule of it and thought it permissible. ( JAAHIL MUQASSIR).
Masturbation is undoubtedly a sin in Islam and it is not permitted in any circumstances.
As this verse of the Holy Qur’an states:
"And those who guard their chastity (i.e. private parts, from illegal sexual acts). Except from their wives or (the captives and slaves) that their right hands possess, - for them, they are free from blame. But whoever seeks beyond that, then those are the transgressors." (23:5-7)
To research further the Islamic view about masturbation and its consequences, please refer to the following texts:
- Philosophy of Islamic Laws by Ayatullah Naser Makarem Shirazi & Ayatullah Jafar Subhani, in particular question 27:
- Marriage and Morals in Islam by Sayyid Muhammad Rizvi, Chapter 3: Islamic Sexual Morality 2
- Youth and Spouse Selection, by Ali Akbar Mazaheri: