there are quite a few apps to help with what you need, to varying degrees of effectiveness. the best results always start with getting the image captured as square as possible, if the situation allows. of course, if other people took the photo, nothing you can do about it.
i realise this is not what you're after, but perhaps a benchmark of what can be achieved with editing tools.
here's what 2 sliders in lightroom can do...