"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
Many believe that masturbation is completely forbidden no matter what the case
“O young men, whoever among you can afford to marry, let him get married, and whoever cannot do that, then he should fast, for it will be a protection for him.” (Narrated by al-Bukhaari, al-Nikaah, 4677)
The hadeeth indicates that masturbation is haraam, because if it were prescribed the Prophet (peace and blessings of Allaah be upon him) would have indicated that.
If a person is patient in abstaining from that which Allaah has forbidden and gives it up because he is seeking the pleasure of Allaah, then Allaah will reward him abundantly on the Day of Resurrection, because whoever gives up something for the sake of Allaah, Allaah will compensate him with something better.
Some may declare it as completely forbidden while others may declare it as permissible unded a circumstance such as if masturbation is not done it would lead to zina.
If it helps try lowering your gaze, stop spending time around bad company, try not to waste time, try not surfing the internet, avoid TV, avoid foods that may have an impact after and try to stay away from public places such as malls that may catch your attention to wrongful things.
By Quran (16:90) "Surely God enjoins justice, kindness and the doing of good, to kith and kin; and He forbids all that is shameful, indecent, evil, rebellious and oppressive."
Pornography according to this is forbidden. It is shameful, indecent etc.